babylon.module.d.ts 5.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676
  1. declare module "babylonjs/types" {
  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 "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * 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.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * 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).
  163. * 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.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @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.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/deepCopier" {
  378. /**
  379. * Class containing a set of static utilities functions for deep copy.
  380. */
  381. export class DeepCopier {
  382. /**
  383. * Tries to copy an object by duplicating every property
  384. * @param source defines the source object
  385. * @param destination defines the target object
  386. * @param doNotCopyList defines a list of properties to avoid
  387. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  388. */
  389. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  390. }
  391. }
  392. declare module "babylonjs/Misc/precisionDate" {
  393. /**
  394. * Class containing a set of static utilities functions for precision date
  395. */
  396. export class PrecisionDate {
  397. /**
  398. * Gets either window.performance.now() if supported or Date.now() else
  399. */
  400. static readonly Now: number;
  401. }
  402. }
  403. declare module "babylonjs/Misc/devTools" {
  404. /** @hidden */
  405. export class _DevTools {
  406. static WarnImport(name: string): string;
  407. }
  408. }
  409. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  410. /**
  411. * Interface used to define the mechanism to get data from the network
  412. */
  413. export interface IWebRequest {
  414. /**
  415. * Returns client's response url
  416. */
  417. responseURL: string;
  418. /**
  419. * Returns client's status
  420. */
  421. status: number;
  422. /**
  423. * Returns client's status as a text
  424. */
  425. statusText: string;
  426. }
  427. }
  428. declare module "babylonjs/Misc/webRequest" {
  429. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  430. /**
  431. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  432. */
  433. export class WebRequest implements IWebRequest {
  434. private _xhr;
  435. /**
  436. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  437. * i.e. when loading files, where the server/service expects an Authorization header
  438. */
  439. static CustomRequestHeaders: {
  440. [key: string]: string;
  441. };
  442. /**
  443. * Add callback functions in this array to update all the requests before they get sent to the network
  444. */
  445. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  446. private _injectCustomRequestHeaders;
  447. /**
  448. * Gets or sets a function to be called when loading progress changes
  449. */
  450. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  451. /**
  452. * Returns client's state
  453. */
  454. readonly readyState: number;
  455. /**
  456. * Returns client's status
  457. */
  458. readonly status: number;
  459. /**
  460. * Returns client's status as a text
  461. */
  462. readonly statusText: string;
  463. /**
  464. * Returns client's response
  465. */
  466. readonly response: any;
  467. /**
  468. * Returns client's response url
  469. */
  470. readonly responseURL: string;
  471. /**
  472. * Returns client's response as text
  473. */
  474. readonly responseText: string;
  475. /**
  476. * Gets or sets the expected response type
  477. */
  478. responseType: XMLHttpRequestResponseType;
  479. /** @hidden */
  480. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  481. /** @hidden */
  482. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  483. /**
  484. * Cancels any network activity
  485. */
  486. abort(): void;
  487. /**
  488. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  489. * @param body defines an optional request body
  490. */
  491. send(body?: Document | BodyInit | null): void;
  492. /**
  493. * Sets the request method, request URL
  494. * @param method defines the method to use (GET, POST, etc..)
  495. * @param url defines the url to connect with
  496. */
  497. open(method: string, url: string): void;
  498. }
  499. }
  500. declare module "babylonjs/Misc/fileRequest" {
  501. import { Observable } from "babylonjs/Misc/observable";
  502. /**
  503. * File request interface
  504. */
  505. export interface IFileRequest {
  506. /**
  507. * Raised when the request is complete (success or error).
  508. */
  509. onCompleteObservable: Observable<IFileRequest>;
  510. /**
  511. * Aborts the request for a file.
  512. */
  513. abort: () => void;
  514. }
  515. }
  516. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  517. /**
  518. * Define options used to create a render target texture
  519. */
  520. export class RenderTargetCreationOptions {
  521. /**
  522. * Specifies is mipmaps must be generated
  523. */
  524. generateMipMaps?: boolean;
  525. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  526. generateDepthBuffer?: boolean;
  527. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  528. generateStencilBuffer?: boolean;
  529. /** Defines texture type (int by default) */
  530. type?: number;
  531. /** Defines sampling mode (trilinear by default) */
  532. samplingMode?: number;
  533. /** Defines format (RGBA by default) */
  534. format?: number;
  535. }
  536. }
  537. declare module "babylonjs/Instrumentation/timeToken" {
  538. import { Nullable } from "babylonjs/types";
  539. /**
  540. * @hidden
  541. **/
  542. export class _TimeToken {
  543. _startTimeQuery: Nullable<WebGLQuery>;
  544. _endTimeQuery: Nullable<WebGLQuery>;
  545. _timeElapsedQuery: Nullable<WebGLQuery>;
  546. _timeElapsedQueryEnded: boolean;
  547. }
  548. }
  549. declare module "babylonjs/Engines/constants" {
  550. /** Defines the cross module used constants to avoid circular dependncies */
  551. export class Constants {
  552. /** Defines that alpha blending is disabled */
  553. static readonly ALPHA_DISABLE: number;
  554. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  555. static readonly ALPHA_ADD: number;
  556. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  557. static readonly ALPHA_COMBINE: number;
  558. /** Defines that alpha blending to DEST - SRC * DEST */
  559. static readonly ALPHA_SUBTRACT: number;
  560. /** Defines that alpha blending to SRC * DEST */
  561. static readonly ALPHA_MULTIPLY: number;
  562. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  563. static readonly ALPHA_MAXIMIZED: number;
  564. /** Defines that alpha blending to SRC + DEST */
  565. static readonly ALPHA_ONEONE: number;
  566. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  567. static readonly ALPHA_PREMULTIPLIED: number;
  568. /**
  569. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  570. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  571. */
  572. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  573. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  574. static readonly ALPHA_INTERPOLATE: number;
  575. /**
  576. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  577. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  578. */
  579. static readonly ALPHA_SCREENMODE: number;
  580. /**
  581. * Defines that alpha blending to SRC + DST
  582. * Alpha will be set to SRC ALPHA + DST ALPHA
  583. */
  584. static readonly ALPHA_ONEONE_ONEONE: number;
  585. /**
  586. * Defines that alpha blending to SRC * DST ALPHA + DST
  587. * Alpha will be set to 0
  588. */
  589. static readonly ALPHA_ALPHATOCOLOR: number;
  590. /**
  591. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  592. */
  593. static readonly ALPHA_REVERSEONEMINUS: number;
  594. /**
  595. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  596. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  597. */
  598. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  599. /**
  600. * Defines that alpha blending to SRC + DST
  601. * Alpha will be set to SRC ALPHA
  602. */
  603. static readonly ALPHA_ONEONE_ONEZERO: number;
  604. /** Defines that alpha blending equation a SUM */
  605. static readonly ALPHA_EQUATION_ADD: number;
  606. /** Defines that alpha blending equation a SUBSTRACTION */
  607. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  608. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  609. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  610. /** Defines that alpha blending equation a MAX operation */
  611. static readonly ALPHA_EQUATION_MAX: number;
  612. /** Defines that alpha blending equation a MIN operation */
  613. static readonly ALPHA_EQUATION_MIN: number;
  614. /**
  615. * Defines that alpha blending equation a DARKEN operation:
  616. * It takes the min of the src and sums the alpha channels.
  617. */
  618. static readonly ALPHA_EQUATION_DARKEN: number;
  619. /** Defines that the ressource is not delayed*/
  620. static readonly DELAYLOADSTATE_NONE: number;
  621. /** Defines that the ressource was successfully delay loaded */
  622. static readonly DELAYLOADSTATE_LOADED: number;
  623. /** Defines that the ressource is currently delay loading */
  624. static readonly DELAYLOADSTATE_LOADING: number;
  625. /** Defines that the ressource is delayed and has not started loading */
  626. static readonly DELAYLOADSTATE_NOTLOADED: number;
  627. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  628. static readonly NEVER: number;
  629. /** 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 */
  630. static readonly ALWAYS: number;
  631. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  632. static readonly LESS: number;
  633. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  634. static readonly EQUAL: number;
  635. /** 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 */
  636. static readonly LEQUAL: number;
  637. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  638. static readonly GREATER: number;
  639. /** 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 */
  640. static readonly GEQUAL: number;
  641. /** 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 */
  642. static readonly NOTEQUAL: number;
  643. /** Passed to stencilOperation to specify that stencil value must be kept */
  644. static readonly KEEP: number;
  645. /** Passed to stencilOperation to specify that stencil value must be replaced */
  646. static readonly REPLACE: number;
  647. /** Passed to stencilOperation to specify that stencil value must be incremented */
  648. static readonly INCR: number;
  649. /** Passed to stencilOperation to specify that stencil value must be decremented */
  650. static readonly DECR: number;
  651. /** Passed to stencilOperation to specify that stencil value must be inverted */
  652. static readonly INVERT: number;
  653. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  654. static readonly INCR_WRAP: number;
  655. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  656. static readonly DECR_WRAP: number;
  657. /** Texture is not repeating outside of 0..1 UVs */
  658. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  659. /** Texture is repeating outside of 0..1 UVs */
  660. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  661. /** Texture is repeating and mirrored */
  662. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  663. /** ALPHA */
  664. static readonly TEXTUREFORMAT_ALPHA: number;
  665. /** LUMINANCE */
  666. static readonly TEXTUREFORMAT_LUMINANCE: number;
  667. /** LUMINANCE_ALPHA */
  668. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  669. /** RGB */
  670. static readonly TEXTUREFORMAT_RGB: number;
  671. /** RGBA */
  672. static readonly TEXTUREFORMAT_RGBA: number;
  673. /** RED */
  674. static readonly TEXTUREFORMAT_RED: number;
  675. /** RED (2nd reference) */
  676. static readonly TEXTUREFORMAT_R: number;
  677. /** RG */
  678. static readonly TEXTUREFORMAT_RG: number;
  679. /** RED_INTEGER */
  680. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  681. /** RED_INTEGER (2nd reference) */
  682. static readonly TEXTUREFORMAT_R_INTEGER: number;
  683. /** RG_INTEGER */
  684. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  685. /** RGB_INTEGER */
  686. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  687. /** RGBA_INTEGER */
  688. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  689. /** UNSIGNED_BYTE */
  690. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  691. /** UNSIGNED_BYTE (2nd reference) */
  692. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  693. /** FLOAT */
  694. static readonly TEXTURETYPE_FLOAT: number;
  695. /** HALF_FLOAT */
  696. static readonly TEXTURETYPE_HALF_FLOAT: number;
  697. /** BYTE */
  698. static readonly TEXTURETYPE_BYTE: number;
  699. /** SHORT */
  700. static readonly TEXTURETYPE_SHORT: number;
  701. /** UNSIGNED_SHORT */
  702. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  703. /** INT */
  704. static readonly TEXTURETYPE_INT: number;
  705. /** UNSIGNED_INT */
  706. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  707. /** UNSIGNED_SHORT_4_4_4_4 */
  708. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  709. /** UNSIGNED_SHORT_5_5_5_1 */
  710. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  711. /** UNSIGNED_SHORT_5_6_5 */
  712. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  713. /** UNSIGNED_INT_2_10_10_10_REV */
  714. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  715. /** UNSIGNED_INT_24_8 */
  716. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  717. /** UNSIGNED_INT_10F_11F_11F_REV */
  718. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  719. /** UNSIGNED_INT_5_9_9_9_REV */
  720. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  721. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  722. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  723. /** nearest is mag = nearest and min = nearest and mip = linear */
  724. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  725. /** Bilinear is mag = linear and min = linear and mip = nearest */
  726. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  727. /** Trilinear is mag = linear and min = linear and mip = linear */
  728. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  729. /** nearest is mag = nearest and min = nearest and mip = linear */
  730. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  731. /** Bilinear is mag = linear and min = linear and mip = nearest */
  732. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  733. /** Trilinear is mag = linear and min = linear and mip = linear */
  734. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  735. /** mag = nearest and min = nearest and mip = nearest */
  736. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  737. /** mag = nearest and min = linear and mip = nearest */
  738. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  739. /** mag = nearest and min = linear and mip = linear */
  740. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  741. /** mag = nearest and min = linear and mip = none */
  742. static readonly TEXTURE_NEAREST_LINEAR: number;
  743. /** mag = nearest and min = nearest and mip = none */
  744. static readonly TEXTURE_NEAREST_NEAREST: number;
  745. /** mag = linear and min = nearest and mip = nearest */
  746. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  747. /** mag = linear and min = nearest and mip = linear */
  748. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  749. /** mag = linear and min = linear and mip = none */
  750. static readonly TEXTURE_LINEAR_LINEAR: number;
  751. /** mag = linear and min = nearest and mip = none */
  752. static readonly TEXTURE_LINEAR_NEAREST: number;
  753. /** Explicit coordinates mode */
  754. static readonly TEXTURE_EXPLICIT_MODE: number;
  755. /** Spherical coordinates mode */
  756. static readonly TEXTURE_SPHERICAL_MODE: number;
  757. /** Planar coordinates mode */
  758. static readonly TEXTURE_PLANAR_MODE: number;
  759. /** Cubic coordinates mode */
  760. static readonly TEXTURE_CUBIC_MODE: number;
  761. /** Projection coordinates mode */
  762. static readonly TEXTURE_PROJECTION_MODE: number;
  763. /** Skybox coordinates mode */
  764. static readonly TEXTURE_SKYBOX_MODE: number;
  765. /** Inverse Cubic coordinates mode */
  766. static readonly TEXTURE_INVCUBIC_MODE: number;
  767. /** Equirectangular coordinates mode */
  768. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  769. /** Equirectangular Fixed coordinates mode */
  770. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  771. /** Equirectangular Fixed Mirrored coordinates mode */
  772. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  773. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  774. static readonly SCALEMODE_FLOOR: number;
  775. /** Defines that texture rescaling will look for the nearest power of 2 size */
  776. static readonly SCALEMODE_NEAREST: number;
  777. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  778. static readonly SCALEMODE_CEILING: number;
  779. /**
  780. * The dirty texture flag value
  781. */
  782. static readonly MATERIAL_TextureDirtyFlag: number;
  783. /**
  784. * The dirty light flag value
  785. */
  786. static readonly MATERIAL_LightDirtyFlag: number;
  787. /**
  788. * The dirty fresnel flag value
  789. */
  790. static readonly MATERIAL_FresnelDirtyFlag: number;
  791. /**
  792. * The dirty attribute flag value
  793. */
  794. static readonly MATERIAL_AttributesDirtyFlag: number;
  795. /**
  796. * The dirty misc flag value
  797. */
  798. static readonly MATERIAL_MiscDirtyFlag: number;
  799. /**
  800. * The all dirty flag value
  801. */
  802. static readonly MATERIAL_AllDirtyFlag: number;
  803. /**
  804. * Returns the triangle fill mode
  805. */
  806. static readonly MATERIAL_TriangleFillMode: number;
  807. /**
  808. * Returns the wireframe mode
  809. */
  810. static readonly MATERIAL_WireFrameFillMode: number;
  811. /**
  812. * Returns the point fill mode
  813. */
  814. static readonly MATERIAL_PointFillMode: number;
  815. /**
  816. * Returns the point list draw mode
  817. */
  818. static readonly MATERIAL_PointListDrawMode: number;
  819. /**
  820. * Returns the line list draw mode
  821. */
  822. static readonly MATERIAL_LineListDrawMode: number;
  823. /**
  824. * Returns the line loop draw mode
  825. */
  826. static readonly MATERIAL_LineLoopDrawMode: number;
  827. /**
  828. * Returns the line strip draw mode
  829. */
  830. static readonly MATERIAL_LineStripDrawMode: number;
  831. /**
  832. * Returns the triangle strip draw mode
  833. */
  834. static readonly MATERIAL_TriangleStripDrawMode: number;
  835. /**
  836. * Returns the triangle fan draw mode
  837. */
  838. static readonly MATERIAL_TriangleFanDrawMode: number;
  839. /**
  840. * Stores the clock-wise side orientation
  841. */
  842. static readonly MATERIAL_ClockWiseSideOrientation: number;
  843. /**
  844. * Stores the counter clock-wise side orientation
  845. */
  846. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  847. /**
  848. * Nothing
  849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  850. */
  851. static readonly ACTION_NothingTrigger: number;
  852. /**
  853. * On pick
  854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  855. */
  856. static readonly ACTION_OnPickTrigger: number;
  857. /**
  858. * On left pick
  859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  860. */
  861. static readonly ACTION_OnLeftPickTrigger: number;
  862. /**
  863. * On right pick
  864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  865. */
  866. static readonly ACTION_OnRightPickTrigger: number;
  867. /**
  868. * On center pick
  869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  870. */
  871. static readonly ACTION_OnCenterPickTrigger: number;
  872. /**
  873. * On pick down
  874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  875. */
  876. static readonly ACTION_OnPickDownTrigger: number;
  877. /**
  878. * On double pick
  879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  880. */
  881. static readonly ACTION_OnDoublePickTrigger: number;
  882. /**
  883. * On pick up
  884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  885. */
  886. static readonly ACTION_OnPickUpTrigger: number;
  887. /**
  888. * On pick out.
  889. * This trigger will only be raised if you also declared a OnPickDown
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_OnPickOutTrigger: number;
  893. /**
  894. * On long press
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnLongPressTrigger: number;
  898. /**
  899. * On pointer over
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPointerOverTrigger: number;
  903. /**
  904. * On pointer out
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnPointerOutTrigger: number;
  908. /**
  909. * On every frame
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnEveryFrameTrigger: number;
  913. /**
  914. * On intersection enter
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnIntersectionEnterTrigger: number;
  918. /**
  919. * On intersection exit
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnIntersectionExitTrigger: number;
  923. /**
  924. * On key down
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnKeyDownTrigger: number;
  928. /**
  929. * On key up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnKeyUpTrigger: number;
  933. /**
  934. * Billboard mode will only apply to Y axis
  935. */
  936. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  937. /**
  938. * Billboard mode will apply to all axes
  939. */
  940. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  941. /**
  942. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  943. */
  944. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  945. /**
  946. * Gets or sets base Assets URL
  947. */
  948. static PARTICLES_BaseAssetsUrl: string;
  949. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  950. * Test order :
  951. * Is the bounding sphere outside the frustum ?
  952. * If not, are the bounding box vertices outside the frustum ?
  953. * It not, then the cullable object is in the frustum.
  954. */
  955. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  956. /** Culling strategy : Bounding Sphere Only.
  957. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  958. * It's also less accurate than the standard because some not visible objects can still be selected.
  959. * Test : is the bounding sphere outside the frustum ?
  960. * If not, then the cullable object is in the frustum.
  961. */
  962. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  963. /** Culling strategy : Optimistic Inclusion.
  964. * This in an inclusion test first, then the standard exclusion test.
  965. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  966. * 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.
  967. * Anyway, it's as accurate as the standard strategy.
  968. * Test :
  969. * Is the cullable object bounding sphere center in the frustum ?
  970. * If not, apply the default culling strategy.
  971. */
  972. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  973. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  974. * This in an inclusion test first, then the bounding sphere only exclusion test.
  975. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  976. * 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.
  977. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  978. * Test :
  979. * Is the cullable object bounding sphere center in the frustum ?
  980. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  981. */
  982. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  983. /**
  984. * No logging while loading
  985. */
  986. static readonly SCENELOADER_NO_LOGGING: number;
  987. /**
  988. * Minimal logging while loading
  989. */
  990. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  991. /**
  992. * Summary logging while loading
  993. */
  994. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  995. /**
  996. * Detailled logging while loading
  997. */
  998. static readonly SCENELOADER_DETAILED_LOGGING: number;
  999. }
  1000. }
  1001. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1002. import { Nullable } from "babylonjs/types";
  1003. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1004. /**
  1005. * This represents the required contract to create a new type of texture loader.
  1006. */
  1007. export interface IInternalTextureLoader {
  1008. /**
  1009. * Defines wether the loader supports cascade loading the different faces.
  1010. */
  1011. supportCascades: boolean;
  1012. /**
  1013. * This returns if the loader support the current file information.
  1014. * @param extension defines the file extension of the file being loaded
  1015. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1016. * @param fallback defines the fallback internal texture if any
  1017. * @param isBase64 defines whether the texture is encoded as a base64
  1018. * @param isBuffer defines whether the texture data are stored as a buffer
  1019. * @returns true if the loader can load the specified file
  1020. */
  1021. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1022. /**
  1023. * Transform the url before loading if required.
  1024. * @param rootUrl the url of the texture
  1025. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1026. * @returns the transformed texture
  1027. */
  1028. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1029. /**
  1030. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1031. * @param rootUrl the url of the texture
  1032. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1033. * @returns the fallback texture
  1034. */
  1035. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1036. /**
  1037. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1038. * @param data contains the texture data
  1039. * @param texture defines the BabylonJS internal texture
  1040. * @param createPolynomials will be true if polynomials have been requested
  1041. * @param onLoad defines the callback to trigger once the texture is ready
  1042. * @param onError defines the callback to trigger in case of error
  1043. */
  1044. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1045. /**
  1046. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1047. * @param data contains the texture data
  1048. * @param texture defines the BabylonJS internal texture
  1049. * @param callback defines the method to call once ready to upload
  1050. */
  1051. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1052. }
  1053. }
  1054. declare module "babylonjs/Engines/IPipelineContext" {
  1055. /**
  1056. * Class used to store and describe the pipeline context associated with an effect
  1057. */
  1058. export interface IPipelineContext {
  1059. /**
  1060. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1061. */
  1062. isAsync: boolean;
  1063. /**
  1064. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1065. */
  1066. isReady: boolean;
  1067. /** @hidden */
  1068. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1069. }
  1070. }
  1071. declare module "babylonjs/Meshes/dataBuffer" {
  1072. /**
  1073. * Class used to store gfx data (like WebGLBuffer)
  1074. */
  1075. export class DataBuffer {
  1076. /**
  1077. * Gets or sets the number of objects referencing this buffer
  1078. */
  1079. references: number;
  1080. /** Gets or sets the size of the underlying buffer */
  1081. capacity: number;
  1082. /**
  1083. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1084. */
  1085. is32Bits: boolean;
  1086. /**
  1087. * Gets the underlying buffer
  1088. */
  1089. readonly underlyingResource: any;
  1090. }
  1091. }
  1092. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1093. /** @hidden */
  1094. export interface IShaderProcessor {
  1095. attributeProcessor?: (attribute: string) => string;
  1096. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1097. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1098. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1099. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1100. lineProcessor?: (line: string, isFragment: boolean) => string;
  1101. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1102. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1103. }
  1104. }
  1105. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1106. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1107. /** @hidden */
  1108. export interface ProcessingOptions {
  1109. defines: string[];
  1110. indexParameters: any;
  1111. isFragment: boolean;
  1112. shouldUseHighPrecisionShader: boolean;
  1113. supportsUniformBuffers: boolean;
  1114. shadersRepository: string;
  1115. includesShadersStore: {
  1116. [key: string]: string;
  1117. };
  1118. processor?: IShaderProcessor;
  1119. version: string;
  1120. platformName: string;
  1121. lookForClosingBracketForUniformBuffer?: boolean;
  1122. }
  1123. }
  1124. declare module "babylonjs/Misc/stringTools" {
  1125. /**
  1126. * Helper to manipulate strings
  1127. */
  1128. export class StringTools {
  1129. /**
  1130. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  1131. * @param str Source string
  1132. * @param suffix Suffix to search for in the source string
  1133. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1134. */
  1135. static EndsWith(str: string, suffix: string): boolean;
  1136. /**
  1137. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  1138. * @param str Source string
  1139. * @param suffix Suffix to search for in the source string
  1140. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1141. */
  1142. static StartsWith(str: string, suffix: string): boolean;
  1143. }
  1144. }
  1145. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1146. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1147. /** @hidden */
  1148. export class ShaderCodeNode {
  1149. line: string;
  1150. children: ShaderCodeNode[];
  1151. additionalDefineKey?: string;
  1152. additionalDefineValue?: string;
  1153. isValid(preprocessors: {
  1154. [key: string]: string;
  1155. }): boolean;
  1156. process(preprocessors: {
  1157. [key: string]: string;
  1158. }, options: ProcessingOptions): string;
  1159. }
  1160. }
  1161. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1162. /** @hidden */
  1163. export class ShaderCodeCursor {
  1164. private _lines;
  1165. lineIndex: number;
  1166. readonly currentLine: string;
  1167. readonly canRead: boolean;
  1168. lines: string[];
  1169. }
  1170. }
  1171. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1172. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1173. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1174. /** @hidden */
  1175. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1176. process(preprocessors: {
  1177. [key: string]: string;
  1178. }, options: ProcessingOptions): string;
  1179. }
  1180. }
  1181. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1182. /** @hidden */
  1183. export class ShaderDefineExpression {
  1184. isTrue(preprocessors: {
  1185. [key: string]: string;
  1186. }): boolean;
  1187. }
  1188. }
  1189. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1190. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1191. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1192. /** @hidden */
  1193. export class ShaderCodeTestNode extends ShaderCodeNode {
  1194. testExpression: ShaderDefineExpression;
  1195. isValid(preprocessors: {
  1196. [key: string]: string;
  1197. }): boolean;
  1198. }
  1199. }
  1200. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1201. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1202. /** @hidden */
  1203. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1204. define: string;
  1205. not: boolean;
  1206. constructor(define: string, not?: boolean);
  1207. isTrue(preprocessors: {
  1208. [key: string]: string;
  1209. }): boolean;
  1210. }
  1211. }
  1212. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1213. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1214. /** @hidden */
  1215. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1216. leftOperand: ShaderDefineExpression;
  1217. rightOperand: ShaderDefineExpression;
  1218. isTrue(preprocessors: {
  1219. [key: string]: string;
  1220. }): boolean;
  1221. }
  1222. }
  1223. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1224. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1225. /** @hidden */
  1226. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1227. leftOperand: ShaderDefineExpression;
  1228. rightOperand: ShaderDefineExpression;
  1229. isTrue(preprocessors: {
  1230. [key: string]: string;
  1231. }): boolean;
  1232. }
  1233. }
  1234. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1235. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1236. /** @hidden */
  1237. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1238. define: string;
  1239. operand: string;
  1240. testValue: string;
  1241. constructor(define: string, operand: string, testValue: string);
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. }
  1246. }
  1247. declare module "babylonjs/Misc/loadFileError" {
  1248. import { WebRequest } from "babylonjs/Misc/webRequest";
  1249. /**
  1250. * @ignore
  1251. * Application error to support additional information when loading a file
  1252. */
  1253. export class LoadFileError extends Error {
  1254. /** defines the optional web request */
  1255. request?: WebRequest | undefined;
  1256. private static _setPrototypeOf;
  1257. /**
  1258. * Creates a new LoadFileError
  1259. * @param message defines the message of the error
  1260. * @param request defines the optional web request
  1261. */
  1262. constructor(message: string,
  1263. /** defines the optional web request */
  1264. request?: WebRequest | undefined);
  1265. }
  1266. }
  1267. declare module "babylonjs/Offline/IOfflineProvider" {
  1268. /**
  1269. * Class used to enable access to offline support
  1270. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1271. */
  1272. export interface IOfflineProvider {
  1273. /**
  1274. * Gets a boolean indicating if scene must be saved in the database
  1275. */
  1276. enableSceneOffline: boolean;
  1277. /**
  1278. * Gets a boolean indicating if textures must be saved in the database
  1279. */
  1280. enableTexturesOffline: boolean;
  1281. /**
  1282. * Open the offline support and make it available
  1283. * @param successCallback defines the callback to call on success
  1284. * @param errorCallback defines the callback to call on error
  1285. */
  1286. open(successCallback: () => void, errorCallback: () => void): void;
  1287. /**
  1288. * Loads an image from the offline support
  1289. * @param url defines the url to load from
  1290. * @param image defines the target DOM image
  1291. */
  1292. loadImage(url: string, image: HTMLImageElement): void;
  1293. /**
  1294. * Loads a file from offline support
  1295. * @param url defines the URL to load from
  1296. * @param sceneLoaded defines a callback to call on success
  1297. * @param progressCallBack defines a callback to call when progress changed
  1298. * @param errorCallback defines a callback to call on error
  1299. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1300. */
  1301. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1302. }
  1303. }
  1304. declare module "babylonjs/Misc/filesInputStore" {
  1305. /**
  1306. * Class used to help managing file picking and drag'n'drop
  1307. * File Storage
  1308. */
  1309. export class FilesInputStore {
  1310. /**
  1311. * List of files ready to be loaded
  1312. */
  1313. static FilesToLoad: {
  1314. [key: string]: File;
  1315. };
  1316. }
  1317. }
  1318. declare module "babylonjs/Misc/retryStrategy" {
  1319. import { WebRequest } from "babylonjs/Misc/webRequest";
  1320. /**
  1321. * Class used to define a retry strategy when error happens while loading assets
  1322. */
  1323. export class RetryStrategy {
  1324. /**
  1325. * Function used to defines an exponential back off strategy
  1326. * @param maxRetries defines the maximum number of retries (3 by default)
  1327. * @param baseInterval defines the interval between retries
  1328. * @returns the strategy function to use
  1329. */
  1330. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1331. }
  1332. }
  1333. declare module "babylonjs/Misc/fileTools" {
  1334. import { WebRequest } from "babylonjs/Misc/webRequest";
  1335. import { Nullable } from "babylonjs/types";
  1336. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1337. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1338. /**
  1339. * @hidden
  1340. */
  1341. export class FileTools {
  1342. /**
  1343. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1344. */
  1345. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1346. /**
  1347. * Gets or sets the base URL to use to load assets
  1348. */
  1349. static BaseUrl: string;
  1350. /**
  1351. * Default behaviour for cors in the application.
  1352. * It can be a string if the expected behavior is identical in the entire app.
  1353. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1354. */
  1355. static CorsBehavior: string | ((url: string | string[]) => string);
  1356. /**
  1357. * Gets or sets a function used to pre-process url before using them to load assets
  1358. */
  1359. static PreprocessUrl: (url: string) => string;
  1360. /**
  1361. * Removes unwanted characters from an url
  1362. * @param url defines the url to clean
  1363. * @returns the cleaned url
  1364. */
  1365. private static _CleanUrl;
  1366. /**
  1367. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1368. * @param url define the url we are trying
  1369. * @param element define the dom element where to configure the cors policy
  1370. */
  1371. static SetCorsBehavior(url: string | string[], element: {
  1372. crossOrigin: string | null;
  1373. }): void;
  1374. /**
  1375. * Loads an image as an HTMLImageElement.
  1376. * @param input url string, ArrayBuffer, or Blob to load
  1377. * @param onLoad callback called when the image successfully loads
  1378. * @param onError callback called when the image fails to load
  1379. * @param offlineProvider offline provider for caching
  1380. * @returns the HTMLImageElement of the loaded image
  1381. */
  1382. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  1383. /**
  1384. * Loads a file
  1385. * @param fileToLoad defines the file to load
  1386. * @param callback defines the callback to call when data is loaded
  1387. * @param progressCallBack defines the callback to call during loading process
  1388. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1389. * @returns a file request object
  1390. */
  1391. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  1392. /**
  1393. * Loads a file
  1394. * @param url url string, ArrayBuffer, or Blob to load
  1395. * @param onSuccess callback called when the file successfully loads
  1396. * @param onProgress callback called while file is loading (if the server supports this mode)
  1397. * @param offlineProvider defines the offline provider for caching
  1398. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1399. * @param onError callback called when the file fails to load
  1400. * @returns a file request object
  1401. */
  1402. 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;
  1403. /**
  1404. * Checks if the loaded document was accessed via `file:`-Protocol.
  1405. * @returns boolean
  1406. */
  1407. static IsFileURL(): boolean;
  1408. }
  1409. }
  1410. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1411. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1412. /** @hidden */
  1413. export class ShaderProcessor {
  1414. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1415. private static _ProcessPrecision;
  1416. private static _ExtractOperation;
  1417. private static _BuildSubExpression;
  1418. private static _BuildExpression;
  1419. private static _MoveCursorWithinIf;
  1420. private static _MoveCursor;
  1421. private static _EvaluatePreProcessors;
  1422. private static _PreparePreProcessors;
  1423. private static _ProcessShaderConversion;
  1424. private static _ProcessIncludes;
  1425. }
  1426. }
  1427. declare module "babylonjs/Maths/math.like" {
  1428. import { float, int, DeepImmutable } from "babylonjs/types";
  1429. /**
  1430. * @hidden
  1431. */
  1432. export interface IColor4Like {
  1433. r: float;
  1434. g: float;
  1435. b: float;
  1436. a: float;
  1437. }
  1438. /**
  1439. * @hidden
  1440. */
  1441. export interface IColor3Like {
  1442. r: float;
  1443. g: float;
  1444. b: float;
  1445. }
  1446. /**
  1447. * @hidden
  1448. */
  1449. export interface IVector4Like {
  1450. x: float;
  1451. y: float;
  1452. z: float;
  1453. w: float;
  1454. }
  1455. /**
  1456. * @hidden
  1457. */
  1458. export interface IVector3Like {
  1459. x: float;
  1460. y: float;
  1461. z: float;
  1462. }
  1463. /**
  1464. * @hidden
  1465. */
  1466. export interface IVector2Like {
  1467. x: float;
  1468. y: float;
  1469. }
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IMatrixLike {
  1474. toArray(): DeepImmutable<Float32Array>;
  1475. updateFlag: int;
  1476. }
  1477. /**
  1478. * @hidden
  1479. */
  1480. export interface IViewportLike {
  1481. x: float;
  1482. y: float;
  1483. width: float;
  1484. height: float;
  1485. }
  1486. /**
  1487. * @hidden
  1488. */
  1489. export interface IPlaneLike {
  1490. normal: IVector3Like;
  1491. d: float;
  1492. normalize(): void;
  1493. }
  1494. }
  1495. declare module "babylonjs/Materials/iEffectFallbacks" {
  1496. import { Effect } from "babylonjs/Materials/effect";
  1497. /**
  1498. * Interface used to define common properties for effect fallbacks
  1499. */
  1500. export interface IEffectFallbacks {
  1501. /**
  1502. * Removes the defines that should be removed when falling back.
  1503. * @param currentDefines defines the current define statements for the shader.
  1504. * @param effect defines the current effect we try to compile
  1505. * @returns The resulting defines with defines of the current rank removed.
  1506. */
  1507. reduce(currentDefines: string, effect: Effect): string;
  1508. /**
  1509. * Removes the fallback from the bound mesh.
  1510. */
  1511. unBindMesh(): void;
  1512. /**
  1513. * Checks to see if more fallbacks are still availible.
  1514. */
  1515. hasMoreFallbacks: boolean;
  1516. }
  1517. }
  1518. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1519. /**
  1520. * Class used to evalaute queries containing `and` and `or` operators
  1521. */
  1522. export class AndOrNotEvaluator {
  1523. /**
  1524. * Evaluate a query
  1525. * @param query defines the query to evaluate
  1526. * @param evaluateCallback defines the callback used to filter result
  1527. * @returns true if the query matches
  1528. */
  1529. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1530. private static _HandleParenthesisContent;
  1531. private static _SimplifyNegation;
  1532. }
  1533. }
  1534. declare module "babylonjs/Misc/tags" {
  1535. /**
  1536. * Class used to store custom tags
  1537. */
  1538. export class Tags {
  1539. /**
  1540. * Adds support for tags on the given object
  1541. * @param obj defines the object to use
  1542. */
  1543. static EnableFor(obj: any): void;
  1544. /**
  1545. * Removes tags support
  1546. * @param obj defines the object to use
  1547. */
  1548. static DisableFor(obj: any): void;
  1549. /**
  1550. * Gets a boolean indicating if the given object has tags
  1551. * @param obj defines the object to use
  1552. * @returns a boolean
  1553. */
  1554. static HasTags(obj: any): boolean;
  1555. /**
  1556. * Gets the tags available on a given object
  1557. * @param obj defines the object to use
  1558. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1559. * @returns the tags
  1560. */
  1561. static GetTags(obj: any, asString?: boolean): any;
  1562. /**
  1563. * Adds tags to an object
  1564. * @param obj defines the object to use
  1565. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1566. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1567. */
  1568. static AddTagsTo(obj: any, tagsString: string): void;
  1569. /**
  1570. * @hidden
  1571. */
  1572. static _AddTagTo(obj: any, tag: string): void;
  1573. /**
  1574. * Removes specific tags from a specific object
  1575. * @param obj defines the object to use
  1576. * @param tagsString defines the tags to remove
  1577. */
  1578. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1579. /**
  1580. * @hidden
  1581. */
  1582. static _RemoveTagFrom(obj: any, tag: string): void;
  1583. /**
  1584. * Defines if tags hosted on an object match a given query
  1585. * @param obj defines the object to use
  1586. * @param tagsQuery defines the tag query
  1587. * @returns a boolean
  1588. */
  1589. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1590. }
  1591. }
  1592. declare module "babylonjs/Maths/math.scalar" {
  1593. /**
  1594. * Scalar computation library
  1595. */
  1596. export class Scalar {
  1597. /**
  1598. * Two pi constants convenient for computation.
  1599. */
  1600. static TwoPi: number;
  1601. /**
  1602. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1603. * @param a number
  1604. * @param b number
  1605. * @param epsilon (default = 1.401298E-45)
  1606. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1607. */
  1608. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1609. /**
  1610. * Returns a string : the upper case translation of the number i to hexadecimal.
  1611. * @param i number
  1612. * @returns the upper case translation of the number i to hexadecimal.
  1613. */
  1614. static ToHex(i: number): string;
  1615. /**
  1616. * Returns -1 if value is negative and +1 is value is positive.
  1617. * @param value the value
  1618. * @returns the value itself if it's equal to zero.
  1619. */
  1620. static Sign(value: number): number;
  1621. /**
  1622. * Returns the value itself if it's between min and max.
  1623. * Returns min if the value is lower than min.
  1624. * Returns max if the value is greater than max.
  1625. * @param value the value to clmap
  1626. * @param min the min value to clamp to (default: 0)
  1627. * @param max the max value to clamp to (default: 1)
  1628. * @returns the clamped value
  1629. */
  1630. static Clamp(value: number, min?: number, max?: number): number;
  1631. /**
  1632. * the log2 of value.
  1633. * @param value the value to compute log2 of
  1634. * @returns the log2 of value.
  1635. */
  1636. static Log2(value: number): number;
  1637. /**
  1638. * Loops the value, so that it is never larger than length and never smaller than 0.
  1639. *
  1640. * This is similar to the modulo operator but it works with floating point numbers.
  1641. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1642. * With t = 5 and length = 2.5, the result would be 0.0.
  1643. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1644. * @param value the value
  1645. * @param length the length
  1646. * @returns the looped value
  1647. */
  1648. static Repeat(value: number, length: number): number;
  1649. /**
  1650. * Normalize the value between 0.0 and 1.0 using min and max values
  1651. * @param value value to normalize
  1652. * @param min max to normalize between
  1653. * @param max min to normalize between
  1654. * @returns the normalized value
  1655. */
  1656. static Normalize(value: number, min: number, max: number): number;
  1657. /**
  1658. * Denormalize the value from 0.0 and 1.0 using min and max values
  1659. * @param normalized value to denormalize
  1660. * @param min max to denormalize between
  1661. * @param max min to denormalize between
  1662. * @returns the denormalized value
  1663. */
  1664. static Denormalize(normalized: number, min: number, max: number): number;
  1665. /**
  1666. * Calculates the shortest difference between two given angles given in degrees.
  1667. * @param current current angle in degrees
  1668. * @param target target angle in degrees
  1669. * @returns the delta
  1670. */
  1671. static DeltaAngle(current: number, target: number): number;
  1672. /**
  1673. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1674. * @param tx value
  1675. * @param length length
  1676. * @returns The returned value will move back and forth between 0 and length
  1677. */
  1678. static PingPong(tx: number, length: number): number;
  1679. /**
  1680. * Interpolates between min and max with smoothing at the limits.
  1681. *
  1682. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1683. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1684. * @param from from
  1685. * @param to to
  1686. * @param tx value
  1687. * @returns the smooth stepped value
  1688. */
  1689. static SmoothStep(from: number, to: number, tx: number): number;
  1690. /**
  1691. * Moves a value current towards target.
  1692. *
  1693. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1694. * Negative values of maxDelta pushes the value away from target.
  1695. * @param current current value
  1696. * @param target target value
  1697. * @param maxDelta max distance to move
  1698. * @returns resulting value
  1699. */
  1700. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1701. /**
  1702. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1703. *
  1704. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1705. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1706. * @param current current value
  1707. * @param target target value
  1708. * @param maxDelta max distance to move
  1709. * @returns resulting angle
  1710. */
  1711. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1712. /**
  1713. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1714. * @param start start value
  1715. * @param end target value
  1716. * @param amount amount to lerp between
  1717. * @returns the lerped value
  1718. */
  1719. static Lerp(start: number, end: number, amount: number): number;
  1720. /**
  1721. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1722. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1723. * @param start start value
  1724. * @param end target value
  1725. * @param amount amount to lerp between
  1726. * @returns the lerped value
  1727. */
  1728. static LerpAngle(start: number, end: number, amount: number): number;
  1729. /**
  1730. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1731. * @param a start value
  1732. * @param b target value
  1733. * @param value value between a and b
  1734. * @returns the inverseLerp value
  1735. */
  1736. static InverseLerp(a: number, b: number, value: number): number;
  1737. /**
  1738. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1739. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1740. * @param value1 spline value
  1741. * @param tangent1 spline value
  1742. * @param value2 spline value
  1743. * @param tangent2 spline value
  1744. * @param amount input value
  1745. * @returns hermite result
  1746. */
  1747. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1748. /**
  1749. * Returns a random float number between and min and max values
  1750. * @param min min value of random
  1751. * @param max max value of random
  1752. * @returns random value
  1753. */
  1754. static RandomRange(min: number, max: number): number;
  1755. /**
  1756. * This function returns percentage of a number in a given range.
  1757. *
  1758. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1759. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1760. * @param number to convert to percentage
  1761. * @param min min range
  1762. * @param max max range
  1763. * @returns the percentage
  1764. */
  1765. static RangeToPercent(number: number, min: number, max: number): number;
  1766. /**
  1767. * This function returns number that corresponds to the percentage in a given range.
  1768. *
  1769. * PercentToRange(0.34,0,100) will return 34.
  1770. * @param percent to convert to number
  1771. * @param min min range
  1772. * @param max max range
  1773. * @returns the number
  1774. */
  1775. static PercentToRange(percent: number, min: number, max: number): number;
  1776. /**
  1777. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1778. * @param angle The angle to normalize in radian.
  1779. * @return The converted angle.
  1780. */
  1781. static NormalizeRadians(angle: number): number;
  1782. }
  1783. }
  1784. declare module "babylonjs/Maths/math.constants" {
  1785. /**
  1786. * Constant used to convert a value to gamma space
  1787. * @ignorenaming
  1788. */
  1789. export const ToGammaSpace: number;
  1790. /**
  1791. * Constant used to convert a value to linear space
  1792. * @ignorenaming
  1793. */
  1794. export const ToLinearSpace = 2.2;
  1795. /**
  1796. * Constant used to define the minimal number value in Babylon.js
  1797. * @ignorenaming
  1798. */
  1799. let Epsilon: number;
  1800. export { Epsilon };
  1801. }
  1802. declare module "babylonjs/Maths/math.viewport" {
  1803. /**
  1804. * Class used to represent a viewport on screen
  1805. */
  1806. export class Viewport {
  1807. /** viewport left coordinate */
  1808. x: number;
  1809. /** viewport top coordinate */
  1810. y: number;
  1811. /**viewport width */
  1812. width: number;
  1813. /** viewport height */
  1814. height: number;
  1815. /**
  1816. * Creates a Viewport object located at (x, y) and sized (width, height)
  1817. * @param x defines viewport left coordinate
  1818. * @param y defines viewport top coordinate
  1819. * @param width defines the viewport width
  1820. * @param height defines the viewport height
  1821. */
  1822. constructor(
  1823. /** viewport left coordinate */
  1824. x: number,
  1825. /** viewport top coordinate */
  1826. y: number,
  1827. /**viewport width */
  1828. width: number,
  1829. /** viewport height */
  1830. height: number);
  1831. /**
  1832. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1833. * @param renderWidth defines the rendering width
  1834. * @param renderHeight defines the rendering height
  1835. * @returns a new Viewport
  1836. */
  1837. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1838. /**
  1839. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1840. * @param renderWidth defines the rendering width
  1841. * @param renderHeight defines the rendering height
  1842. * @param ref defines the target viewport
  1843. * @returns the current viewport
  1844. */
  1845. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1846. /**
  1847. * Returns a new Viewport copied from the current one
  1848. * @returns a new Viewport
  1849. */
  1850. clone(): Viewport;
  1851. }
  1852. }
  1853. declare module "babylonjs/Misc/arrayTools" {
  1854. /**
  1855. * Class containing a set of static utilities functions for arrays.
  1856. */
  1857. export class ArrayTools {
  1858. /**
  1859. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1860. * @param size the number of element to construct and put in the array
  1861. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1862. * @returns a new array filled with new objects
  1863. */
  1864. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1865. }
  1866. }
  1867. declare module "babylonjs/Maths/math.vector" {
  1868. import { Viewport } from "babylonjs/Maths/math.viewport";
  1869. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1870. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1871. /**
  1872. * Class representing a vector containing 2 coordinates
  1873. */
  1874. export class Vector2 {
  1875. /** defines the first coordinate */
  1876. x: number;
  1877. /** defines the second coordinate */
  1878. y: number;
  1879. /**
  1880. * Creates a new Vector2 from the given x and y coordinates
  1881. * @param x defines the first coordinate
  1882. * @param y defines the second coordinate
  1883. */
  1884. constructor(
  1885. /** defines the first coordinate */
  1886. x?: number,
  1887. /** defines the second coordinate */
  1888. y?: number);
  1889. /**
  1890. * Gets a string with the Vector2 coordinates
  1891. * @returns a string with the Vector2 coordinates
  1892. */
  1893. toString(): string;
  1894. /**
  1895. * Gets class name
  1896. * @returns the string "Vector2"
  1897. */
  1898. getClassName(): string;
  1899. /**
  1900. * Gets current vector hash code
  1901. * @returns the Vector2 hash code as a number
  1902. */
  1903. getHashCode(): number;
  1904. /**
  1905. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1906. * @param array defines the source array
  1907. * @param index defines the offset in source array
  1908. * @returns the current Vector2
  1909. */
  1910. toArray(array: FloatArray, index?: number): Vector2;
  1911. /**
  1912. * Copy the current vector to an array
  1913. * @returns a new array with 2 elements: the Vector2 coordinates.
  1914. */
  1915. asArray(): number[];
  1916. /**
  1917. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1918. * @param source defines the source Vector2
  1919. * @returns the current updated Vector2
  1920. */
  1921. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1922. /**
  1923. * Sets the Vector2 coordinates with the given floats
  1924. * @param x defines the first coordinate
  1925. * @param y defines the second coordinate
  1926. * @returns the current updated Vector2
  1927. */
  1928. copyFromFloats(x: number, y: number): Vector2;
  1929. /**
  1930. * Sets the Vector2 coordinates with the given floats
  1931. * @param x defines the first coordinate
  1932. * @param y defines the second coordinate
  1933. * @returns the current updated Vector2
  1934. */
  1935. set(x: number, y: number): Vector2;
  1936. /**
  1937. * Add another vector with the current one
  1938. * @param otherVector defines the other vector
  1939. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1940. */
  1941. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1942. /**
  1943. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1944. * @param otherVector defines the other vector
  1945. * @param result defines the target vector
  1946. * @returns the unmodified current Vector2
  1947. */
  1948. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1949. /**
  1950. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1951. * @param otherVector defines the other vector
  1952. * @returns the current updated Vector2
  1953. */
  1954. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1955. /**
  1956. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1957. * @param otherVector defines the other vector
  1958. * @returns a new Vector2
  1959. */
  1960. addVector3(otherVector: Vector3): Vector2;
  1961. /**
  1962. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1963. * @param otherVector defines the other vector
  1964. * @returns a new Vector2
  1965. */
  1966. subtract(otherVector: Vector2): Vector2;
  1967. /**
  1968. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1969. * @param otherVector defines the other vector
  1970. * @param result defines the target vector
  1971. * @returns the unmodified current Vector2
  1972. */
  1973. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1974. /**
  1975. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1976. * @param otherVector defines the other vector
  1977. * @returns the current updated Vector2
  1978. */
  1979. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1980. /**
  1981. * Multiplies in place the current Vector2 coordinates by the given ones
  1982. * @param otherVector defines the other vector
  1983. * @returns the current updated Vector2
  1984. */
  1985. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1986. /**
  1987. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1988. * @param otherVector defines the other vector
  1989. * @returns a new Vector2
  1990. */
  1991. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1992. /**
  1993. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1994. * @param otherVector defines the other vector
  1995. * @param result defines the target vector
  1996. * @returns the unmodified current Vector2
  1997. */
  1998. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1999. /**
  2000. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2001. * @param x defines the first coordinate
  2002. * @param y defines the second coordinate
  2003. * @returns a new Vector2
  2004. */
  2005. multiplyByFloats(x: number, y: number): Vector2;
  2006. /**
  2007. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2008. * @param otherVector defines the other vector
  2009. * @returns a new Vector2
  2010. */
  2011. divide(otherVector: Vector2): Vector2;
  2012. /**
  2013. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2014. * @param otherVector defines the other vector
  2015. * @param result defines the target vector
  2016. * @returns the unmodified current Vector2
  2017. */
  2018. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2019. /**
  2020. * Divides the current Vector2 coordinates by the given ones
  2021. * @param otherVector defines the other vector
  2022. * @returns the current updated Vector2
  2023. */
  2024. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2025. /**
  2026. * Gets a new Vector2 with current Vector2 negated coordinates
  2027. * @returns a new Vector2
  2028. */
  2029. negate(): Vector2;
  2030. /**
  2031. * Multiply the Vector2 coordinates by scale
  2032. * @param scale defines the scaling factor
  2033. * @returns the current updated Vector2
  2034. */
  2035. scaleInPlace(scale: number): Vector2;
  2036. /**
  2037. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2038. * @param scale defines the scaling factor
  2039. * @returns a new Vector2
  2040. */
  2041. scale(scale: number): Vector2;
  2042. /**
  2043. * Scale the current Vector2 values by a factor to a given Vector2
  2044. * @param scale defines the scale factor
  2045. * @param result defines the Vector2 object where to store the result
  2046. * @returns the unmodified current Vector2
  2047. */
  2048. scaleToRef(scale: number, result: Vector2): Vector2;
  2049. /**
  2050. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2051. * @param scale defines the scale factor
  2052. * @param result defines the Vector2 object where to store the result
  2053. * @returns the unmodified current Vector2
  2054. */
  2055. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2056. /**
  2057. * Gets a boolean if two vectors are equals
  2058. * @param otherVector defines the other vector
  2059. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2060. */
  2061. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2062. /**
  2063. * Gets a boolean if two vectors are equals (using an epsilon value)
  2064. * @param otherVector defines the other vector
  2065. * @param epsilon defines the minimal distance to consider equality
  2066. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2067. */
  2068. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2069. /**
  2070. * Gets a new Vector2 from current Vector2 floored values
  2071. * @returns a new Vector2
  2072. */
  2073. floor(): Vector2;
  2074. /**
  2075. * Gets a new Vector2 from current Vector2 floored values
  2076. * @returns a new Vector2
  2077. */
  2078. fract(): Vector2;
  2079. /**
  2080. * Gets the length of the vector
  2081. * @returns the vector length (float)
  2082. */
  2083. length(): number;
  2084. /**
  2085. * Gets the vector squared length
  2086. * @returns the vector squared length (float)
  2087. */
  2088. lengthSquared(): number;
  2089. /**
  2090. * Normalize the vector
  2091. * @returns the current updated Vector2
  2092. */
  2093. normalize(): Vector2;
  2094. /**
  2095. * Gets a new Vector2 copied from the Vector2
  2096. * @returns a new Vector2
  2097. */
  2098. clone(): Vector2;
  2099. /**
  2100. * Gets a new Vector2(0, 0)
  2101. * @returns a new Vector2
  2102. */
  2103. static Zero(): Vector2;
  2104. /**
  2105. * Gets a new Vector2(1, 1)
  2106. * @returns a new Vector2
  2107. */
  2108. static One(): Vector2;
  2109. /**
  2110. * Gets a new Vector2 set from the given index element of the given array
  2111. * @param array defines the data source
  2112. * @param offset defines the offset in the data source
  2113. * @returns a new Vector2
  2114. */
  2115. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2116. /**
  2117. * Sets "result" from the given index element of the given array
  2118. * @param array defines the data source
  2119. * @param offset defines the offset in the data source
  2120. * @param result defines the target vector
  2121. */
  2122. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2123. /**
  2124. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2125. * @param value1 defines 1st point of control
  2126. * @param value2 defines 2nd point of control
  2127. * @param value3 defines 3rd point of control
  2128. * @param value4 defines 4th point of control
  2129. * @param amount defines the interpolation factor
  2130. * @returns a new Vector2
  2131. */
  2132. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2133. /**
  2134. * 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".
  2135. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2136. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2137. * @param value defines the value to clamp
  2138. * @param min defines the lower limit
  2139. * @param max defines the upper limit
  2140. * @returns a new Vector2
  2141. */
  2142. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2143. /**
  2144. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2145. * @param value1 defines the 1st control point
  2146. * @param tangent1 defines the outgoing tangent
  2147. * @param value2 defines the 2nd control point
  2148. * @param tangent2 defines the incoming tangent
  2149. * @param amount defines the interpolation factor
  2150. * @returns a new Vector2
  2151. */
  2152. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2153. /**
  2154. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2155. * @param start defines the start vector
  2156. * @param end defines the end vector
  2157. * @param amount defines the interpolation factor
  2158. * @returns a new Vector2
  2159. */
  2160. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2161. /**
  2162. * Gets the dot product of the vector "left" and the vector "right"
  2163. * @param left defines first vector
  2164. * @param right defines second vector
  2165. * @returns the dot product (float)
  2166. */
  2167. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2168. /**
  2169. * Returns a new Vector2 equal to the normalized given vector
  2170. * @param vector defines the vector to normalize
  2171. * @returns a new Vector2
  2172. */
  2173. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2174. /**
  2175. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2176. * @param left defines 1st vector
  2177. * @param right defines 2nd vector
  2178. * @returns a new Vector2
  2179. */
  2180. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2181. /**
  2182. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2183. * @param left defines 1st vector
  2184. * @param right defines 2nd vector
  2185. * @returns a new Vector2
  2186. */
  2187. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2190. * @param vector defines the vector to transform
  2191. * @param transformation defines the matrix to apply
  2192. * @returns a new Vector2
  2193. */
  2194. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2195. /**
  2196. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2197. * @param vector defines the vector to transform
  2198. * @param transformation defines the matrix to apply
  2199. * @param result defines the target vector
  2200. */
  2201. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2202. /**
  2203. * Determines if a given vector is included in a triangle
  2204. * @param p defines the vector to test
  2205. * @param p0 defines 1st triangle point
  2206. * @param p1 defines 2nd triangle point
  2207. * @param p2 defines 3rd triangle point
  2208. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2209. */
  2210. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2211. /**
  2212. * Gets the distance between the vectors "value1" and "value2"
  2213. * @param value1 defines first vector
  2214. * @param value2 defines second vector
  2215. * @returns the distance between vectors
  2216. */
  2217. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2218. /**
  2219. * Returns the squared distance between the vectors "value1" and "value2"
  2220. * @param value1 defines first vector
  2221. * @param value2 defines second vector
  2222. * @returns the squared distance between vectors
  2223. */
  2224. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2225. /**
  2226. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2227. * @param value1 defines first vector
  2228. * @param value2 defines second vector
  2229. * @returns a new Vector2
  2230. */
  2231. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2232. /**
  2233. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2234. * @param p defines the middle point
  2235. * @param segA defines one point of the segment
  2236. * @param segB defines the other point of the segment
  2237. * @returns the shortest distance
  2238. */
  2239. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2240. }
  2241. /**
  2242. * Classed used to store (x,y,z) vector representation
  2243. * A Vector3 is the main object used in 3D geometry
  2244. * It can represent etiher the coordinates of a point the space, either a direction
  2245. * Reminder: js uses a left handed forward facing system
  2246. */
  2247. export class Vector3 {
  2248. /**
  2249. * Defines the first coordinates (on X axis)
  2250. */
  2251. x: number;
  2252. /**
  2253. * Defines the second coordinates (on Y axis)
  2254. */
  2255. y: number;
  2256. /**
  2257. * Defines the third coordinates (on Z axis)
  2258. */
  2259. z: number;
  2260. private static _UpReadOnly;
  2261. private static _ZeroReadOnly;
  2262. /**
  2263. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2264. * @param x defines the first coordinates (on X axis)
  2265. * @param y defines the second coordinates (on Y axis)
  2266. * @param z defines the third coordinates (on Z axis)
  2267. */
  2268. constructor(
  2269. /**
  2270. * Defines the first coordinates (on X axis)
  2271. */
  2272. x?: number,
  2273. /**
  2274. * Defines the second coordinates (on Y axis)
  2275. */
  2276. y?: number,
  2277. /**
  2278. * Defines the third coordinates (on Z axis)
  2279. */
  2280. z?: number);
  2281. /**
  2282. * Creates a string representation of the Vector3
  2283. * @returns a string with the Vector3 coordinates.
  2284. */
  2285. toString(): string;
  2286. /**
  2287. * Gets the class name
  2288. * @returns the string "Vector3"
  2289. */
  2290. getClassName(): string;
  2291. /**
  2292. * Creates the Vector3 hash code
  2293. * @returns a number which tends to be unique between Vector3 instances
  2294. */
  2295. getHashCode(): number;
  2296. /**
  2297. * Creates an array containing three elements : the coordinates of the Vector3
  2298. * @returns a new array of numbers
  2299. */
  2300. asArray(): number[];
  2301. /**
  2302. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2303. * @param array defines the destination array
  2304. * @param index defines the offset in the destination array
  2305. * @returns the current Vector3
  2306. */
  2307. toArray(array: FloatArray, index?: number): Vector3;
  2308. /**
  2309. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2310. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2311. */
  2312. toQuaternion(): Quaternion;
  2313. /**
  2314. * Adds the given vector to the current Vector3
  2315. * @param otherVector defines the second operand
  2316. * @returns the current updated Vector3
  2317. */
  2318. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2319. /**
  2320. * Adds the given coordinates to the current Vector3
  2321. * @param x defines the x coordinate of the operand
  2322. * @param y defines the y coordinate of the operand
  2323. * @param z defines the z coordinate of the operand
  2324. * @returns the current updated Vector3
  2325. */
  2326. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2327. /**
  2328. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2329. * @param otherVector defines the second operand
  2330. * @returns the resulting Vector3
  2331. */
  2332. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2333. /**
  2334. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2335. * @param otherVector defines the second operand
  2336. * @param result defines the Vector3 object where to store the result
  2337. * @returns the current Vector3
  2338. */
  2339. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2340. /**
  2341. * Subtract the given vector from the current Vector3
  2342. * @param otherVector defines the second operand
  2343. * @returns the current updated Vector3
  2344. */
  2345. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2346. /**
  2347. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2348. * @param otherVector defines the second operand
  2349. * @returns the resulting Vector3
  2350. */
  2351. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2352. /**
  2353. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2354. * @param otherVector defines the second operand
  2355. * @param result defines the Vector3 object where to store the result
  2356. * @returns the current Vector3
  2357. */
  2358. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2359. /**
  2360. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2361. * @param x defines the x coordinate of the operand
  2362. * @param y defines the y coordinate of the operand
  2363. * @param z defines the z coordinate of the operand
  2364. * @returns the resulting Vector3
  2365. */
  2366. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2367. /**
  2368. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2369. * @param x defines the x coordinate of the operand
  2370. * @param y defines the y coordinate of the operand
  2371. * @param z defines the z coordinate of the operand
  2372. * @param result defines the Vector3 object where to store the result
  2373. * @returns the current Vector3
  2374. */
  2375. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2376. /**
  2377. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2378. * @returns a new Vector3
  2379. */
  2380. negate(): Vector3;
  2381. /**
  2382. * Multiplies the Vector3 coordinates by the float "scale"
  2383. * @param scale defines the multiplier factor
  2384. * @returns the current updated Vector3
  2385. */
  2386. scaleInPlace(scale: number): Vector3;
  2387. /**
  2388. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2389. * @param scale defines the multiplier factor
  2390. * @returns a new Vector3
  2391. */
  2392. scale(scale: number): Vector3;
  2393. /**
  2394. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2395. * @param scale defines the multiplier factor
  2396. * @param result defines the Vector3 object where to store the result
  2397. * @returns the current Vector3
  2398. */
  2399. scaleToRef(scale: number, result: Vector3): Vector3;
  2400. /**
  2401. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2402. * @param scale defines the scale factor
  2403. * @param result defines the Vector3 object where to store the result
  2404. * @returns the unmodified current Vector3
  2405. */
  2406. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2407. /**
  2408. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2409. * @param otherVector defines the second operand
  2410. * @returns true if both vectors are equals
  2411. */
  2412. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2413. /**
  2414. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2415. * @param otherVector defines the second operand
  2416. * @param epsilon defines the minimal distance to define values as equals
  2417. * @returns true if both vectors are distant less than epsilon
  2418. */
  2419. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2420. /**
  2421. * Returns true if the current Vector3 coordinates equals the given floats
  2422. * @param x defines the x coordinate of the operand
  2423. * @param y defines the y coordinate of the operand
  2424. * @param z defines the z coordinate of the operand
  2425. * @returns true if both vectors are equals
  2426. */
  2427. equalsToFloats(x: number, y: number, z: number): boolean;
  2428. /**
  2429. * Multiplies the current Vector3 coordinates by the given ones
  2430. * @param otherVector defines the second operand
  2431. * @returns the current updated Vector3
  2432. */
  2433. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2434. /**
  2435. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2436. * @param otherVector defines the second operand
  2437. * @returns the new Vector3
  2438. */
  2439. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2440. /**
  2441. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2442. * @param otherVector defines the second operand
  2443. * @param result defines the Vector3 object where to store the result
  2444. * @returns the current Vector3
  2445. */
  2446. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2447. /**
  2448. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2449. * @param x defines the x coordinate of the operand
  2450. * @param y defines the y coordinate of the operand
  2451. * @param z defines the z coordinate of the operand
  2452. * @returns the new Vector3
  2453. */
  2454. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2455. /**
  2456. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2457. * @param otherVector defines the second operand
  2458. * @returns the new Vector3
  2459. */
  2460. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2461. /**
  2462. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2463. * @param otherVector defines the second operand
  2464. * @param result defines the Vector3 object where to store the result
  2465. * @returns the current Vector3
  2466. */
  2467. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2468. /**
  2469. * Divides the current Vector3 coordinates by the given ones.
  2470. * @param otherVector defines the second operand
  2471. * @returns the current updated Vector3
  2472. */
  2473. divideInPlace(otherVector: Vector3): Vector3;
  2474. /**
  2475. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2476. * @param other defines the second operand
  2477. * @returns the current updated Vector3
  2478. */
  2479. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2480. /**
  2481. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2482. * @param other defines the second operand
  2483. * @returns the current updated Vector3
  2484. */
  2485. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2486. /**
  2487. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2488. * @param x defines the x coordinate of the operand
  2489. * @param y defines the y coordinate of the operand
  2490. * @param z defines the z coordinate of the operand
  2491. * @returns the current updated Vector3
  2492. */
  2493. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2494. /**
  2495. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2496. * @param x defines the x coordinate of the operand
  2497. * @param y defines the y coordinate of the operand
  2498. * @param z defines the z coordinate of the operand
  2499. * @returns the current updated Vector3
  2500. */
  2501. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2502. /**
  2503. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2504. * Check if is non uniform within a certain amount of decimal places to account for this
  2505. * @param epsilon the amount the values can differ
  2506. * @returns if the the vector is non uniform to a certain number of decimal places
  2507. */
  2508. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2509. /**
  2510. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2511. */
  2512. readonly isNonUniform: boolean;
  2513. /**
  2514. * Gets a new Vector3 from current Vector3 floored values
  2515. * @returns a new Vector3
  2516. */
  2517. floor(): Vector3;
  2518. /**
  2519. * Gets a new Vector3 from current Vector3 floored values
  2520. * @returns a new Vector3
  2521. */
  2522. fract(): Vector3;
  2523. /**
  2524. * Gets the length of the Vector3
  2525. * @returns the length of the Vector3
  2526. */
  2527. length(): number;
  2528. /**
  2529. * Gets the squared length of the Vector3
  2530. * @returns squared length of the Vector3
  2531. */
  2532. lengthSquared(): number;
  2533. /**
  2534. * Normalize the current Vector3.
  2535. * Please note that this is an in place operation.
  2536. * @returns the current updated Vector3
  2537. */
  2538. normalize(): Vector3;
  2539. /**
  2540. * Reorders the x y z properties of the vector in place
  2541. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2542. * @returns the current updated vector
  2543. */
  2544. reorderInPlace(order: string): this;
  2545. /**
  2546. * Rotates the vector around 0,0,0 by a quaternion
  2547. * @param quaternion the rotation quaternion
  2548. * @param result vector to store the result
  2549. * @returns the resulting vector
  2550. */
  2551. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2552. /**
  2553. * Rotates a vector around a given point
  2554. * @param quaternion the rotation quaternion
  2555. * @param point the point to rotate around
  2556. * @param result vector to store the result
  2557. * @returns the resulting vector
  2558. */
  2559. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2560. /**
  2561. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2562. * The cross product is then orthogonal to both current and "other"
  2563. * @param other defines the right operand
  2564. * @returns the cross product
  2565. */
  2566. cross(other: Vector3): Vector3;
  2567. /**
  2568. * Normalize the current Vector3 with the given input length.
  2569. * Please note that this is an in place operation.
  2570. * @param len the length of the vector
  2571. * @returns the current updated Vector3
  2572. */
  2573. normalizeFromLength(len: number): Vector3;
  2574. /**
  2575. * Normalize the current Vector3 to a new vector
  2576. * @returns the new Vector3
  2577. */
  2578. normalizeToNew(): Vector3;
  2579. /**
  2580. * Normalize the current Vector3 to the reference
  2581. * @param reference define the Vector3 to update
  2582. * @returns the updated Vector3
  2583. */
  2584. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2585. /**
  2586. * Creates a new Vector3 copied from the current Vector3
  2587. * @returns the new Vector3
  2588. */
  2589. clone(): Vector3;
  2590. /**
  2591. * Copies the given vector coordinates to the current Vector3 ones
  2592. * @param source defines the source Vector3
  2593. * @returns the current updated Vector3
  2594. */
  2595. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2596. /**
  2597. * Copies the given floats to the current Vector3 coordinates
  2598. * @param x defines the x coordinate of the operand
  2599. * @param y defines the y coordinate of the operand
  2600. * @param z defines the z coordinate of the operand
  2601. * @returns the current updated Vector3
  2602. */
  2603. copyFromFloats(x: number, y: number, z: number): Vector3;
  2604. /**
  2605. * Copies the given floats to the current Vector3 coordinates
  2606. * @param x defines the x coordinate of the operand
  2607. * @param y defines the y coordinate of the operand
  2608. * @param z defines the z coordinate of the operand
  2609. * @returns the current updated Vector3
  2610. */
  2611. set(x: number, y: number, z: number): Vector3;
  2612. /**
  2613. * Copies the given float to the current Vector3 coordinates
  2614. * @param v defines the x, y and z coordinates of the operand
  2615. * @returns the current updated Vector3
  2616. */
  2617. setAll(v: number): Vector3;
  2618. /**
  2619. * Get the clip factor between two vectors
  2620. * @param vector0 defines the first operand
  2621. * @param vector1 defines the second operand
  2622. * @param axis defines the axis to use
  2623. * @param size defines the size along the axis
  2624. * @returns the clip factor
  2625. */
  2626. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2627. /**
  2628. * Get angle between two vectors
  2629. * @param vector0 angle between vector0 and vector1
  2630. * @param vector1 angle between vector0 and vector1
  2631. * @param normal direction of the normal
  2632. * @return the angle between vector0 and vector1
  2633. */
  2634. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2635. /**
  2636. * Returns a new Vector3 set from the index "offset" of the given array
  2637. * @param array defines the source array
  2638. * @param offset defines the offset in the source array
  2639. * @returns the new Vector3
  2640. */
  2641. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2642. /**
  2643. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2644. * This function is deprecated. Use FromArray instead
  2645. * @param array defines the source array
  2646. * @param offset defines the offset in the source array
  2647. * @returns the new Vector3
  2648. */
  2649. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2650. /**
  2651. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2652. * @param array defines the source array
  2653. * @param offset defines the offset in the source array
  2654. * @param result defines the Vector3 where to store the result
  2655. */
  2656. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2657. /**
  2658. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2659. * This function is deprecated. Use FromArrayToRef instead.
  2660. * @param array defines the source array
  2661. * @param offset defines the offset in the source array
  2662. * @param result defines the Vector3 where to store the result
  2663. */
  2664. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2665. /**
  2666. * Sets the given vector "result" with the given floats.
  2667. * @param x defines the x coordinate of the source
  2668. * @param y defines the y coordinate of the source
  2669. * @param z defines the z coordinate of the source
  2670. * @param result defines the Vector3 where to store the result
  2671. */
  2672. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2673. /**
  2674. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2675. * @returns a new empty Vector3
  2676. */
  2677. static Zero(): Vector3;
  2678. /**
  2679. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2680. * @returns a new unit Vector3
  2681. */
  2682. static One(): Vector3;
  2683. /**
  2684. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2685. * @returns a new up Vector3
  2686. */
  2687. static Up(): Vector3;
  2688. /**
  2689. * Gets a up Vector3 that must not be updated
  2690. */
  2691. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2692. /**
  2693. * Gets a zero Vector3 that must not be updated
  2694. */
  2695. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2696. /**
  2697. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2698. * @returns a new down Vector3
  2699. */
  2700. static Down(): Vector3;
  2701. /**
  2702. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2703. * @returns a new forward Vector3
  2704. */
  2705. static Forward(): Vector3;
  2706. /**
  2707. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2708. * @returns a new forward Vector3
  2709. */
  2710. static Backward(): Vector3;
  2711. /**
  2712. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2713. * @returns a new right Vector3
  2714. */
  2715. static Right(): Vector3;
  2716. /**
  2717. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2718. * @returns a new left Vector3
  2719. */
  2720. static Left(): Vector3;
  2721. /**
  2722. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2723. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2724. * @param vector defines the Vector3 to transform
  2725. * @param transformation defines the transformation matrix
  2726. * @returns the transformed Vector3
  2727. */
  2728. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2729. /**
  2730. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2731. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2732. * @param vector defines the Vector3 to transform
  2733. * @param transformation defines the transformation matrix
  2734. * @param result defines the Vector3 where to store the result
  2735. */
  2736. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2737. /**
  2738. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2739. * This method computes tranformed coordinates only, not transformed direction vectors
  2740. * @param x define the x coordinate of the source vector
  2741. * @param y define the y coordinate of the source vector
  2742. * @param z define the z coordinate of the source vector
  2743. * @param transformation defines the transformation matrix
  2744. * @param result defines the Vector3 where to store the result
  2745. */
  2746. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2747. /**
  2748. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2749. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2750. * @param vector defines the Vector3 to transform
  2751. * @param transformation defines the transformation matrix
  2752. * @returns the new Vector3
  2753. */
  2754. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2755. /**
  2756. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2757. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2758. * @param vector defines the Vector3 to transform
  2759. * @param transformation defines the transformation matrix
  2760. * @param result defines the Vector3 where to store the result
  2761. */
  2762. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2763. /**
  2764. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2765. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2766. * @param x define the x coordinate of the source vector
  2767. * @param y define the y coordinate of the source vector
  2768. * @param z define the z coordinate of the source vector
  2769. * @param transformation defines the transformation matrix
  2770. * @param result defines the Vector3 where to store the result
  2771. */
  2772. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2773. /**
  2774. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2775. * @param value1 defines the first control point
  2776. * @param value2 defines the second control point
  2777. * @param value3 defines the third control point
  2778. * @param value4 defines the fourth control point
  2779. * @param amount defines the amount on the spline to use
  2780. * @returns the new Vector3
  2781. */
  2782. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2783. /**
  2784. * 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"
  2785. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2786. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2787. * @param value defines the current value
  2788. * @param min defines the lower range value
  2789. * @param max defines the upper range value
  2790. * @returns the new Vector3
  2791. */
  2792. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2793. /**
  2794. * 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"
  2795. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2796. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2797. * @param value defines the current value
  2798. * @param min defines the lower range value
  2799. * @param max defines the upper range value
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2803. /**
  2804. * Checks if a given vector is inside a specific range
  2805. * @param v defines the vector to test
  2806. * @param min defines the minimum range
  2807. * @param max defines the maximum range
  2808. */
  2809. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2810. /**
  2811. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2812. * @param value1 defines the first control point
  2813. * @param tangent1 defines the first tangent vector
  2814. * @param value2 defines the second control point
  2815. * @param tangent2 defines the second tangent vector
  2816. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2817. * @returns the new Vector3
  2818. */
  2819. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2820. /**
  2821. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2822. * @param start defines the start value
  2823. * @param end defines the end value
  2824. * @param amount max defines amount between both (between 0 and 1)
  2825. * @returns the new Vector3
  2826. */
  2827. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2828. /**
  2829. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2830. * @param start defines the start value
  2831. * @param end defines the end value
  2832. * @param amount max defines amount between both (between 0 and 1)
  2833. * @param result defines the Vector3 where to store the result
  2834. */
  2835. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2836. /**
  2837. * Returns the dot product (float) between the vectors "left" and "right"
  2838. * @param left defines the left operand
  2839. * @param right defines the right operand
  2840. * @returns the dot product
  2841. */
  2842. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2843. /**
  2844. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2845. * The cross product is then orthogonal to both "left" and "right"
  2846. * @param left defines the left operand
  2847. * @param right defines the right operand
  2848. * @returns the cross product
  2849. */
  2850. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2851. /**
  2852. * Sets the given vector "result" with the cross product of "left" and "right"
  2853. * The cross product is then orthogonal to both "left" and "right"
  2854. * @param left defines the left operand
  2855. * @param right defines the right operand
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2859. /**
  2860. * Returns a new Vector3 as the normalization of the given vector
  2861. * @param vector defines the Vector3 to normalize
  2862. * @returns the new Vector3
  2863. */
  2864. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2865. /**
  2866. * Sets the given vector "result" with the normalization of the given first vector
  2867. * @param vector defines the Vector3 to normalize
  2868. * @param result defines the Vector3 where to store the result
  2869. */
  2870. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2871. /**
  2872. * Project a Vector3 onto screen space
  2873. * @param vector defines the Vector3 to project
  2874. * @param world defines the world matrix to use
  2875. * @param transform defines the transform (view x projection) matrix to use
  2876. * @param viewport defines the screen viewport to use
  2877. * @returns the new Vector3
  2878. */
  2879. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2880. /** @hidden */
  2881. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2882. /**
  2883. * Unproject from screen space to object space
  2884. * @param source defines the screen space Vector3 to use
  2885. * @param viewportWidth defines the current width of the viewport
  2886. * @param viewportHeight defines the current height of the viewport
  2887. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2888. * @param transform defines the transform (view x projection) matrix to use
  2889. * @returns the new Vector3
  2890. */
  2891. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2892. /**
  2893. * Unproject from screen space to object space
  2894. * @param source defines the screen space Vector3 to use
  2895. * @param viewportWidth defines the current width of the viewport
  2896. * @param viewportHeight defines the current height of the viewport
  2897. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2898. * @param view defines the view matrix to use
  2899. * @param projection defines the projection matrix to use
  2900. * @returns the new Vector3
  2901. */
  2902. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2903. /**
  2904. * Unproject from screen space to object space
  2905. * @param source defines the screen space Vector3 to use
  2906. * @param viewportWidth defines the current width of the viewport
  2907. * @param viewportHeight defines the current height of the viewport
  2908. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2909. * @param view defines the view matrix to use
  2910. * @param projection defines the projection matrix to use
  2911. * @param result defines the Vector3 where to store the result
  2912. */
  2913. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2914. /**
  2915. * Unproject from screen space to object space
  2916. * @param sourceX defines the screen space x coordinate to use
  2917. * @param sourceY defines the screen space y coordinate to use
  2918. * @param sourceZ defines the screen space z coordinate to use
  2919. * @param viewportWidth defines the current width of the viewport
  2920. * @param viewportHeight defines the current height of the viewport
  2921. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2922. * @param view defines the view matrix to use
  2923. * @param projection defines the projection matrix to use
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2927. /**
  2928. * Gets the minimal coordinate values between two Vector3
  2929. * @param left defines the first operand
  2930. * @param right defines the second operand
  2931. * @returns the new Vector3
  2932. */
  2933. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2934. /**
  2935. * Gets the maximal coordinate values between two Vector3
  2936. * @param left defines the first operand
  2937. * @param right defines the second operand
  2938. * @returns the new Vector3
  2939. */
  2940. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2941. /**
  2942. * Returns the distance between the vectors "value1" and "value2"
  2943. * @param value1 defines the first operand
  2944. * @param value2 defines the second operand
  2945. * @returns the distance
  2946. */
  2947. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2948. /**
  2949. * Returns the squared distance between the vectors "value1" and "value2"
  2950. * @param value1 defines the first operand
  2951. * @param value2 defines the second operand
  2952. * @returns the squared distance
  2953. */
  2954. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2955. /**
  2956. * Returns a new Vector3 located at the center between "value1" and "value2"
  2957. * @param value1 defines the first operand
  2958. * @param value2 defines the second operand
  2959. * @returns the new Vector3
  2960. */
  2961. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2962. /**
  2963. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2964. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2965. * to something in order to rotate it from its local system to the given target system
  2966. * Note: axis1, axis2 and axis3 are normalized during this operation
  2967. * @param axis1 defines the first axis
  2968. * @param axis2 defines the second axis
  2969. * @param axis3 defines the third axis
  2970. * @returns a new Vector3
  2971. */
  2972. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2973. /**
  2974. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2975. * @param axis1 defines the first axis
  2976. * @param axis2 defines the second axis
  2977. * @param axis3 defines the third axis
  2978. * @param ref defines the Vector3 where to store the result
  2979. */
  2980. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2981. }
  2982. /**
  2983. * Vector4 class created for EulerAngle class conversion to Quaternion
  2984. */
  2985. export class Vector4 {
  2986. /** x value of the vector */
  2987. x: number;
  2988. /** y value of the vector */
  2989. y: number;
  2990. /** z value of the vector */
  2991. z: number;
  2992. /** w value of the vector */
  2993. w: number;
  2994. /**
  2995. * Creates a Vector4 object from the given floats.
  2996. * @param x x value of the vector
  2997. * @param y y value of the vector
  2998. * @param z z value of the vector
  2999. * @param w w value of the vector
  3000. */
  3001. constructor(
  3002. /** x value of the vector */
  3003. x: number,
  3004. /** y value of the vector */
  3005. y: number,
  3006. /** z value of the vector */
  3007. z: number,
  3008. /** w value of the vector */
  3009. w: number);
  3010. /**
  3011. * Returns the string with the Vector4 coordinates.
  3012. * @returns a string containing all the vector values
  3013. */
  3014. toString(): string;
  3015. /**
  3016. * Returns the string "Vector4".
  3017. * @returns "Vector4"
  3018. */
  3019. getClassName(): string;
  3020. /**
  3021. * Returns the Vector4 hash code.
  3022. * @returns a unique hash code
  3023. */
  3024. getHashCode(): number;
  3025. /**
  3026. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3027. * @returns the resulting array
  3028. */
  3029. asArray(): number[];
  3030. /**
  3031. * Populates the given array from the given index with the Vector4 coordinates.
  3032. * @param array array to populate
  3033. * @param index index of the array to start at (default: 0)
  3034. * @returns the Vector4.
  3035. */
  3036. toArray(array: FloatArray, index?: number): Vector4;
  3037. /**
  3038. * Adds the given vector to the current Vector4.
  3039. * @param otherVector the vector to add
  3040. * @returns the updated Vector4.
  3041. */
  3042. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3043. /**
  3044. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3045. * @param otherVector the vector to add
  3046. * @returns the resulting vector
  3047. */
  3048. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3049. /**
  3050. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3051. * @param otherVector the vector to add
  3052. * @param result the vector to store the result
  3053. * @returns the current Vector4.
  3054. */
  3055. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3056. /**
  3057. * Subtract in place the given vector from the current Vector4.
  3058. * @param otherVector the vector to subtract
  3059. * @returns the updated Vector4.
  3060. */
  3061. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3062. /**
  3063. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3064. * @param otherVector the vector to add
  3065. * @returns the new vector with the result
  3066. */
  3067. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3068. /**
  3069. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3070. * @param otherVector the vector to subtract
  3071. * @param result the vector to store the result
  3072. * @returns the current Vector4.
  3073. */
  3074. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3075. /**
  3076. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3077. */
  3078. /**
  3079. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3080. * @param x value to subtract
  3081. * @param y value to subtract
  3082. * @param z value to subtract
  3083. * @param w value to subtract
  3084. * @returns new vector containing the result
  3085. */
  3086. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3087. /**
  3088. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3089. * @param x value to subtract
  3090. * @param y value to subtract
  3091. * @param z value to subtract
  3092. * @param w value to subtract
  3093. * @param result the vector to store the result in
  3094. * @returns the current Vector4.
  3095. */
  3096. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3097. /**
  3098. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3099. * @returns a new vector with the negated values
  3100. */
  3101. negate(): Vector4;
  3102. /**
  3103. * Multiplies the current Vector4 coordinates by scale (float).
  3104. * @param scale the number to scale with
  3105. * @returns the updated Vector4.
  3106. */
  3107. scaleInPlace(scale: number): Vector4;
  3108. /**
  3109. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3110. * @param scale the number to scale with
  3111. * @returns a new vector with the result
  3112. */
  3113. scale(scale: number): Vector4;
  3114. /**
  3115. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3116. * @param scale the number to scale with
  3117. * @param result a vector to store the result in
  3118. * @returns the current Vector4.
  3119. */
  3120. scaleToRef(scale: number, result: Vector4): Vector4;
  3121. /**
  3122. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3123. * @param scale defines the scale factor
  3124. * @param result defines the Vector4 object where to store the result
  3125. * @returns the unmodified current Vector4
  3126. */
  3127. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3128. /**
  3129. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3130. * @param otherVector the vector to compare against
  3131. * @returns true if they are equal
  3132. */
  3133. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3134. /**
  3135. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3136. * @param otherVector vector to compare against
  3137. * @param epsilon (Default: very small number)
  3138. * @returns true if they are equal
  3139. */
  3140. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3141. /**
  3142. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3143. * @param x x value to compare against
  3144. * @param y y value to compare against
  3145. * @param z z value to compare against
  3146. * @param w w value to compare against
  3147. * @returns true if equal
  3148. */
  3149. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3150. /**
  3151. * Multiplies in place the current Vector4 by the given one.
  3152. * @param otherVector vector to multiple with
  3153. * @returns the updated Vector4.
  3154. */
  3155. multiplyInPlace(otherVector: Vector4): Vector4;
  3156. /**
  3157. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3158. * @param otherVector vector to multiple with
  3159. * @returns resulting new vector
  3160. */
  3161. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3162. /**
  3163. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3164. * @param otherVector vector to multiple with
  3165. * @param result vector to store the result
  3166. * @returns the current Vector4.
  3167. */
  3168. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3169. /**
  3170. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3171. * @param x x value multiply with
  3172. * @param y y value multiply with
  3173. * @param z z value multiply with
  3174. * @param w w value multiply with
  3175. * @returns resulting new vector
  3176. */
  3177. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3178. /**
  3179. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3180. * @param otherVector vector to devide with
  3181. * @returns resulting new vector
  3182. */
  3183. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3184. /**
  3185. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3186. * @param otherVector vector to devide with
  3187. * @param result vector to store the result
  3188. * @returns the current Vector4.
  3189. */
  3190. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3191. /**
  3192. * Divides the current Vector3 coordinates by the given ones.
  3193. * @param otherVector vector to devide with
  3194. * @returns the updated Vector3.
  3195. */
  3196. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3197. /**
  3198. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3199. * @param other defines the second operand
  3200. * @returns the current updated Vector4
  3201. */
  3202. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3203. /**
  3204. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3205. * @param other defines the second operand
  3206. * @returns the current updated Vector4
  3207. */
  3208. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3209. /**
  3210. * Gets a new Vector4 from current Vector4 floored values
  3211. * @returns a new Vector4
  3212. */
  3213. floor(): Vector4;
  3214. /**
  3215. * Gets a new Vector4 from current Vector3 floored values
  3216. * @returns a new Vector4
  3217. */
  3218. fract(): Vector4;
  3219. /**
  3220. * Returns the Vector4 length (float).
  3221. * @returns the length
  3222. */
  3223. length(): number;
  3224. /**
  3225. * Returns the Vector4 squared length (float).
  3226. * @returns the length squared
  3227. */
  3228. lengthSquared(): number;
  3229. /**
  3230. * Normalizes in place the Vector4.
  3231. * @returns the updated Vector4.
  3232. */
  3233. normalize(): Vector4;
  3234. /**
  3235. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3236. * @returns this converted to a new vector3
  3237. */
  3238. toVector3(): Vector3;
  3239. /**
  3240. * Returns a new Vector4 copied from the current one.
  3241. * @returns the new cloned vector
  3242. */
  3243. clone(): Vector4;
  3244. /**
  3245. * Updates the current Vector4 with the given one coordinates.
  3246. * @param source the source vector to copy from
  3247. * @returns the updated Vector4.
  3248. */
  3249. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3250. /**
  3251. * Updates the current Vector4 coordinates with the given floats.
  3252. * @param x float to copy from
  3253. * @param y float to copy from
  3254. * @param z float to copy from
  3255. * @param w float to copy from
  3256. * @returns the updated Vector4.
  3257. */
  3258. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3259. /**
  3260. * Updates the current Vector4 coordinates with the given floats.
  3261. * @param x float to set from
  3262. * @param y float to set from
  3263. * @param z float to set from
  3264. * @param w float to set from
  3265. * @returns the updated Vector4.
  3266. */
  3267. set(x: number, y: number, z: number, w: number): Vector4;
  3268. /**
  3269. * Copies the given float to the current Vector3 coordinates
  3270. * @param v defines the x, y, z and w coordinates of the operand
  3271. * @returns the current updated Vector3
  3272. */
  3273. setAll(v: number): Vector4;
  3274. /**
  3275. * Returns a new Vector4 set from the starting index of the given array.
  3276. * @param array the array to pull values from
  3277. * @param offset the offset into the array to start at
  3278. * @returns the new vector
  3279. */
  3280. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3281. /**
  3282. * Updates the given vector "result" from the starting index of the given array.
  3283. * @param array the array to pull values from
  3284. * @param offset the offset into the array to start at
  3285. * @param result the vector to store the result in
  3286. */
  3287. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3288. /**
  3289. * Updates the given vector "result" from the starting index of the given Float32Array.
  3290. * @param array the array to pull values from
  3291. * @param offset the offset into the array to start at
  3292. * @param result the vector to store the result in
  3293. */
  3294. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3295. /**
  3296. * Updates the given vector "result" coordinates from the given floats.
  3297. * @param x float to set from
  3298. * @param y float to set from
  3299. * @param z float to set from
  3300. * @param w float to set from
  3301. * @param result the vector to the floats in
  3302. */
  3303. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3304. /**
  3305. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3306. * @returns the new vector
  3307. */
  3308. static Zero(): Vector4;
  3309. /**
  3310. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3311. * @returns the new vector
  3312. */
  3313. static One(): Vector4;
  3314. /**
  3315. * Returns a new normalized Vector4 from the given one.
  3316. * @param vector the vector to normalize
  3317. * @returns the vector
  3318. */
  3319. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3320. /**
  3321. * Updates the given vector "result" from the normalization of the given one.
  3322. * @param vector the vector to normalize
  3323. * @param result the vector to store the result in
  3324. */
  3325. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3326. /**
  3327. * Returns a vector with the minimum values from the left and right vectors
  3328. * @param left left vector to minimize
  3329. * @param right right vector to minimize
  3330. * @returns a new vector with the minimum of the left and right vector values
  3331. */
  3332. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3333. /**
  3334. * Returns a vector with the maximum values from the left and right vectors
  3335. * @param left left vector to maximize
  3336. * @param right right vector to maximize
  3337. * @returns a new vector with the maximum of the left and right vector values
  3338. */
  3339. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3340. /**
  3341. * Returns the distance (float) between the vectors "value1" and "value2".
  3342. * @param value1 value to calulate the distance between
  3343. * @param value2 value to calulate the distance between
  3344. * @return the distance between the two vectors
  3345. */
  3346. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3347. /**
  3348. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3349. * @param value1 value to calulate the distance between
  3350. * @param value2 value to calulate the distance between
  3351. * @return the distance between the two vectors squared
  3352. */
  3353. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3354. /**
  3355. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3356. * @param value1 value to calulate the center between
  3357. * @param value2 value to calulate the center between
  3358. * @return the center between the two vectors
  3359. */
  3360. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3361. /**
  3362. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3363. * This methods computes transformed normalized direction vectors only.
  3364. * @param vector the vector to transform
  3365. * @param transformation the transformation matrix to apply
  3366. * @returns the new vector
  3367. */
  3368. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3369. /**
  3370. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3371. * This methods computes transformed normalized direction vectors only.
  3372. * @param vector the vector to transform
  3373. * @param transformation the transformation matrix to apply
  3374. * @param result the vector to store the result in
  3375. */
  3376. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3377. /**
  3378. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3379. * This methods computes transformed normalized direction vectors only.
  3380. * @param x value to transform
  3381. * @param y value to transform
  3382. * @param z value to transform
  3383. * @param w value to transform
  3384. * @param transformation the transformation matrix to apply
  3385. * @param result the vector to store the results in
  3386. */
  3387. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3388. /**
  3389. * Creates a new Vector4 from a Vector3
  3390. * @param source defines the source data
  3391. * @param w defines the 4th component (default is 0)
  3392. * @returns a new Vector4
  3393. */
  3394. static FromVector3(source: Vector3, w?: number): Vector4;
  3395. }
  3396. /**
  3397. * Class used to store quaternion data
  3398. * @see https://en.wikipedia.org/wiki/Quaternion
  3399. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3400. */
  3401. export class Quaternion {
  3402. /** defines the first component (0 by default) */
  3403. x: number;
  3404. /** defines the second component (0 by default) */
  3405. y: number;
  3406. /** defines the third component (0 by default) */
  3407. z: number;
  3408. /** defines the fourth component (1.0 by default) */
  3409. w: number;
  3410. /**
  3411. * Creates a new Quaternion from the given floats
  3412. * @param x defines the first component (0 by default)
  3413. * @param y defines the second component (0 by default)
  3414. * @param z defines the third component (0 by default)
  3415. * @param w defines the fourth component (1.0 by default)
  3416. */
  3417. constructor(
  3418. /** defines the first component (0 by default) */
  3419. x?: number,
  3420. /** defines the second component (0 by default) */
  3421. y?: number,
  3422. /** defines the third component (0 by default) */
  3423. z?: number,
  3424. /** defines the fourth component (1.0 by default) */
  3425. w?: number);
  3426. /**
  3427. * Gets a string representation for the current quaternion
  3428. * @returns a string with the Quaternion coordinates
  3429. */
  3430. toString(): string;
  3431. /**
  3432. * Gets the class name of the quaternion
  3433. * @returns the string "Quaternion"
  3434. */
  3435. getClassName(): string;
  3436. /**
  3437. * Gets a hash code for this quaternion
  3438. * @returns the quaternion hash code
  3439. */
  3440. getHashCode(): number;
  3441. /**
  3442. * Copy the quaternion to an array
  3443. * @returns a new array populated with 4 elements from the quaternion coordinates
  3444. */
  3445. asArray(): number[];
  3446. /**
  3447. * Check if two quaternions are equals
  3448. * @param otherQuaternion defines the second operand
  3449. * @return true if the current quaternion and the given one coordinates are strictly equals
  3450. */
  3451. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3452. /**
  3453. * Clone the current quaternion
  3454. * @returns a new quaternion copied from the current one
  3455. */
  3456. clone(): Quaternion;
  3457. /**
  3458. * Copy a quaternion to the current one
  3459. * @param other defines the other quaternion
  3460. * @returns the updated current quaternion
  3461. */
  3462. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3463. /**
  3464. * Updates the current quaternion with the given float coordinates
  3465. * @param x defines the x coordinate
  3466. * @param y defines the y coordinate
  3467. * @param z defines the z coordinate
  3468. * @param w defines the w coordinate
  3469. * @returns the updated current quaternion
  3470. */
  3471. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3472. /**
  3473. * Updates the current quaternion from the given float coordinates
  3474. * @param x defines the x coordinate
  3475. * @param y defines the y coordinate
  3476. * @param z defines the z coordinate
  3477. * @param w defines the w coordinate
  3478. * @returns the updated current quaternion
  3479. */
  3480. set(x: number, y: number, z: number, w: number): Quaternion;
  3481. /**
  3482. * Adds two quaternions
  3483. * @param other defines the second operand
  3484. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3485. */
  3486. add(other: DeepImmutable<Quaternion>): Quaternion;
  3487. /**
  3488. * Add a quaternion to the current one
  3489. * @param other defines the quaternion to add
  3490. * @returns the current quaternion
  3491. */
  3492. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3493. /**
  3494. * Subtract two quaternions
  3495. * @param other defines the second operand
  3496. * @returns a new quaternion as the subtraction result of the given one from the current one
  3497. */
  3498. subtract(other: Quaternion): Quaternion;
  3499. /**
  3500. * Multiplies the current quaternion by a scale factor
  3501. * @param value defines the scale factor
  3502. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3503. */
  3504. scale(value: number): Quaternion;
  3505. /**
  3506. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3507. * @param scale defines the scale factor
  3508. * @param result defines the Quaternion object where to store the result
  3509. * @returns the unmodified current quaternion
  3510. */
  3511. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3512. /**
  3513. * Multiplies in place the current quaternion by a scale factor
  3514. * @param value defines the scale factor
  3515. * @returns the current modified quaternion
  3516. */
  3517. scaleInPlace(value: number): Quaternion;
  3518. /**
  3519. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3520. * @param scale defines the scale factor
  3521. * @param result defines the Quaternion object where to store the result
  3522. * @returns the unmodified current quaternion
  3523. */
  3524. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3525. /**
  3526. * Multiplies two quaternions
  3527. * @param q1 defines the second operand
  3528. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3529. */
  3530. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3531. /**
  3532. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3533. * @param q1 defines the second operand
  3534. * @param result defines the target quaternion
  3535. * @returns the current quaternion
  3536. */
  3537. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3538. /**
  3539. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3540. * @param q1 defines the second operand
  3541. * @returns the currentupdated quaternion
  3542. */
  3543. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3544. /**
  3545. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3546. * @param ref defines the target quaternion
  3547. * @returns the current quaternion
  3548. */
  3549. conjugateToRef(ref: Quaternion): Quaternion;
  3550. /**
  3551. * Conjugates in place (1-q) the current quaternion
  3552. * @returns the current updated quaternion
  3553. */
  3554. conjugateInPlace(): Quaternion;
  3555. /**
  3556. * Conjugates in place (1-q) the current quaternion
  3557. * @returns a new quaternion
  3558. */
  3559. conjugate(): Quaternion;
  3560. /**
  3561. * Gets length of current quaternion
  3562. * @returns the quaternion length (float)
  3563. */
  3564. length(): number;
  3565. /**
  3566. * Normalize in place the current quaternion
  3567. * @returns the current updated quaternion
  3568. */
  3569. normalize(): Quaternion;
  3570. /**
  3571. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3572. * @param order is a reserved parameter and is ignore for now
  3573. * @returns a new Vector3 containing the Euler angles
  3574. */
  3575. toEulerAngles(order?: string): Vector3;
  3576. /**
  3577. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3578. * @param result defines the vector which will be filled with the Euler angles
  3579. * @param order is a reserved parameter and is ignore for now
  3580. * @returns the current unchanged quaternion
  3581. */
  3582. toEulerAnglesToRef(result: Vector3): Quaternion;
  3583. /**
  3584. * Updates the given rotation matrix with the current quaternion values
  3585. * @param result defines the target matrix
  3586. * @returns the current unchanged quaternion
  3587. */
  3588. toRotationMatrix(result: Matrix): Quaternion;
  3589. /**
  3590. * Updates the current quaternion from the given rotation matrix values
  3591. * @param matrix defines the source matrix
  3592. * @returns the current updated quaternion
  3593. */
  3594. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3595. /**
  3596. * Creates a new quaternion from a rotation matrix
  3597. * @param matrix defines the source matrix
  3598. * @returns a new quaternion created from the given rotation matrix values
  3599. */
  3600. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3601. /**
  3602. * Updates the given quaternion with the given rotation matrix values
  3603. * @param matrix defines the source matrix
  3604. * @param result defines the target quaternion
  3605. */
  3606. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3607. /**
  3608. * Returns the dot product (float) between the quaternions "left" and "right"
  3609. * @param left defines the left operand
  3610. * @param right defines the right operand
  3611. * @returns the dot product
  3612. */
  3613. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3614. /**
  3615. * Checks if the two quaternions are close to each other
  3616. * @param quat0 defines the first quaternion to check
  3617. * @param quat1 defines the second quaternion to check
  3618. * @returns true if the two quaternions are close to each other
  3619. */
  3620. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3621. /**
  3622. * Creates an empty quaternion
  3623. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3624. */
  3625. static Zero(): Quaternion;
  3626. /**
  3627. * Inverse a given quaternion
  3628. * @param q defines the source quaternion
  3629. * @returns a new quaternion as the inverted current quaternion
  3630. */
  3631. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3632. /**
  3633. * Inverse a given quaternion
  3634. * @param q defines the source quaternion
  3635. * @param result the quaternion the result will be stored in
  3636. * @returns the result quaternion
  3637. */
  3638. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3639. /**
  3640. * Creates an identity quaternion
  3641. * @returns the identity quaternion
  3642. */
  3643. static Identity(): Quaternion;
  3644. /**
  3645. * Gets a boolean indicating if the given quaternion is identity
  3646. * @param quaternion defines the quaternion to check
  3647. * @returns true if the quaternion is identity
  3648. */
  3649. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3650. /**
  3651. * Creates a quaternion from a rotation around an axis
  3652. * @param axis defines the axis to use
  3653. * @param angle defines the angle to use
  3654. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3655. */
  3656. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3657. /**
  3658. * Creates a rotation around an axis and stores it into the given quaternion
  3659. * @param axis defines the axis to use
  3660. * @param angle defines the angle to use
  3661. * @param result defines the target quaternion
  3662. * @returns the target quaternion
  3663. */
  3664. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3665. /**
  3666. * Creates a new quaternion from data stored into an array
  3667. * @param array defines the data source
  3668. * @param offset defines the offset in the source array where the data starts
  3669. * @returns a new quaternion
  3670. */
  3671. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3672. /**
  3673. * Create a quaternion from Euler rotation angles
  3674. * @param x Pitch
  3675. * @param y Yaw
  3676. * @param z Roll
  3677. * @returns the new Quaternion
  3678. */
  3679. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3680. /**
  3681. * Updates a quaternion from Euler rotation angles
  3682. * @param x Pitch
  3683. * @param y Yaw
  3684. * @param z Roll
  3685. * @param result the quaternion to store the result
  3686. * @returns the updated quaternion
  3687. */
  3688. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3689. /**
  3690. * Create a quaternion from Euler rotation vector
  3691. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3692. * @returns the new Quaternion
  3693. */
  3694. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3695. /**
  3696. * Updates a quaternion from Euler rotation vector
  3697. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3698. * @param result the quaternion to store the result
  3699. * @returns the updated quaternion
  3700. */
  3701. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3702. /**
  3703. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3704. * @param yaw defines the rotation around Y axis
  3705. * @param pitch defines the rotation around X axis
  3706. * @param roll defines the rotation around Z axis
  3707. * @returns the new quaternion
  3708. */
  3709. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3710. /**
  3711. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3712. * @param yaw defines the rotation around Y axis
  3713. * @param pitch defines the rotation around X axis
  3714. * @param roll defines the rotation around Z axis
  3715. * @param result defines the target quaternion
  3716. */
  3717. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3718. /**
  3719. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3720. * @param alpha defines the rotation around first axis
  3721. * @param beta defines the rotation around second axis
  3722. * @param gamma defines the rotation around third axis
  3723. * @returns the new quaternion
  3724. */
  3725. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3726. /**
  3727. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3728. * @param alpha defines the rotation around first axis
  3729. * @param beta defines the rotation around second axis
  3730. * @param gamma defines the rotation around third axis
  3731. * @param result defines the target quaternion
  3732. */
  3733. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3734. /**
  3735. * 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)
  3736. * @param axis1 defines the first axis
  3737. * @param axis2 defines the second axis
  3738. * @param axis3 defines the third axis
  3739. * @returns the new quaternion
  3740. */
  3741. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3742. /**
  3743. * 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
  3744. * @param axis1 defines the first axis
  3745. * @param axis2 defines the second axis
  3746. * @param axis3 defines the third axis
  3747. * @param ref defines the target quaternion
  3748. */
  3749. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3750. /**
  3751. * Interpolates between two quaternions
  3752. * @param left defines first quaternion
  3753. * @param right defines second quaternion
  3754. * @param amount defines the gradient to use
  3755. * @returns the new interpolated quaternion
  3756. */
  3757. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3758. /**
  3759. * Interpolates between two quaternions and stores it into a target quaternion
  3760. * @param left defines first quaternion
  3761. * @param right defines second quaternion
  3762. * @param amount defines the gradient to use
  3763. * @param result defines the target quaternion
  3764. */
  3765. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3766. /**
  3767. * Interpolate between two quaternions using Hermite interpolation
  3768. * @param value1 defines first quaternion
  3769. * @param tangent1 defines the incoming tangent
  3770. * @param value2 defines second quaternion
  3771. * @param tangent2 defines the outgoing tangent
  3772. * @param amount defines the target quaternion
  3773. * @returns the new interpolated quaternion
  3774. */
  3775. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3776. }
  3777. /**
  3778. * Class used to store matrix data (4x4)
  3779. */
  3780. export class Matrix {
  3781. private static _updateFlagSeed;
  3782. private static _identityReadOnly;
  3783. private _isIdentity;
  3784. private _isIdentityDirty;
  3785. private _isIdentity3x2;
  3786. private _isIdentity3x2Dirty;
  3787. /**
  3788. * Gets the update flag of the matrix which is an unique number for the matrix.
  3789. * It will be incremented every time the matrix data change.
  3790. * You can use it to speed the comparison between two versions of the same matrix.
  3791. */
  3792. updateFlag: number;
  3793. private readonly _m;
  3794. /**
  3795. * Gets the internal data of the matrix
  3796. */
  3797. readonly m: DeepImmutable<Float32Array>;
  3798. /** @hidden */
  3799. _markAsUpdated(): void;
  3800. /** @hidden */
  3801. private _updateIdentityStatus;
  3802. /**
  3803. * Creates an empty matrix (filled with zeros)
  3804. */
  3805. constructor();
  3806. /**
  3807. * Check if the current matrix is identity
  3808. * @returns true is the matrix is the identity matrix
  3809. */
  3810. isIdentity(): boolean;
  3811. /**
  3812. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3813. * @returns true is the matrix is the identity matrix
  3814. */
  3815. isIdentityAs3x2(): boolean;
  3816. /**
  3817. * Gets the determinant of the matrix
  3818. * @returns the matrix determinant
  3819. */
  3820. determinant(): number;
  3821. /**
  3822. * Returns the matrix as a Float32Array
  3823. * @returns the matrix underlying array
  3824. */
  3825. toArray(): DeepImmutable<Float32Array>;
  3826. /**
  3827. * Returns the matrix as a Float32Array
  3828. * @returns the matrix underlying array.
  3829. */
  3830. asArray(): DeepImmutable<Float32Array>;
  3831. /**
  3832. * Inverts the current matrix in place
  3833. * @returns the current inverted matrix
  3834. */
  3835. invert(): Matrix;
  3836. /**
  3837. * Sets all the matrix elements to zero
  3838. * @returns the current matrix
  3839. */
  3840. reset(): Matrix;
  3841. /**
  3842. * Adds the current matrix with a second one
  3843. * @param other defines the matrix to add
  3844. * @returns a new matrix as the addition of the current matrix and the given one
  3845. */
  3846. add(other: DeepImmutable<Matrix>): Matrix;
  3847. /**
  3848. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3849. * @param other defines the matrix to add
  3850. * @param result defines the target matrix
  3851. * @returns the current matrix
  3852. */
  3853. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3854. /**
  3855. * Adds in place the given matrix to the current matrix
  3856. * @param other defines the second operand
  3857. * @returns the current updated matrix
  3858. */
  3859. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3860. /**
  3861. * Sets the given matrix to the current inverted Matrix
  3862. * @param other defines the target matrix
  3863. * @returns the unmodified current matrix
  3864. */
  3865. invertToRef(other: Matrix): Matrix;
  3866. /**
  3867. * add a value at the specified position in the current Matrix
  3868. * @param index the index of the value within the matrix. between 0 and 15.
  3869. * @param value the value to be added
  3870. * @returns the current updated matrix
  3871. */
  3872. addAtIndex(index: number, value: number): Matrix;
  3873. /**
  3874. * mutiply the specified position in the current Matrix by a value
  3875. * @param index the index of the value within the matrix. between 0 and 15.
  3876. * @param value the value to be added
  3877. * @returns the current updated matrix
  3878. */
  3879. multiplyAtIndex(index: number, value: number): Matrix;
  3880. /**
  3881. * Inserts the translation vector (using 3 floats) in the current matrix
  3882. * @param x defines the 1st component of the translation
  3883. * @param y defines the 2nd component of the translation
  3884. * @param z defines the 3rd component of the translation
  3885. * @returns the current updated matrix
  3886. */
  3887. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3888. /**
  3889. * Adds the translation vector (using 3 floats) in the current matrix
  3890. * @param x defines the 1st component of the translation
  3891. * @param y defines the 2nd component of the translation
  3892. * @param z defines the 3rd component of the translation
  3893. * @returns the current updated matrix
  3894. */
  3895. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3896. /**
  3897. * Inserts the translation vector in the current matrix
  3898. * @param vector3 defines the translation to insert
  3899. * @returns the current updated matrix
  3900. */
  3901. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3902. /**
  3903. * Gets the translation value of the current matrix
  3904. * @returns a new Vector3 as the extracted translation from the matrix
  3905. */
  3906. getTranslation(): Vector3;
  3907. /**
  3908. * Fill a Vector3 with the extracted translation from the matrix
  3909. * @param result defines the Vector3 where to store the translation
  3910. * @returns the current matrix
  3911. */
  3912. getTranslationToRef(result: Vector3): Matrix;
  3913. /**
  3914. * Remove rotation and scaling part from the matrix
  3915. * @returns the updated matrix
  3916. */
  3917. removeRotationAndScaling(): Matrix;
  3918. /**
  3919. * Multiply two matrices
  3920. * @param other defines the second operand
  3921. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3922. */
  3923. multiply(other: DeepImmutable<Matrix>): Matrix;
  3924. /**
  3925. * Copy the current matrix from the given one
  3926. * @param other defines the source matrix
  3927. * @returns the current updated matrix
  3928. */
  3929. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3930. /**
  3931. * Populates the given array from the starting index with the current matrix values
  3932. * @param array defines the target array
  3933. * @param offset defines the offset in the target array where to start storing values
  3934. * @returns the current matrix
  3935. */
  3936. copyToArray(array: Float32Array, offset?: number): Matrix;
  3937. /**
  3938. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3939. * @param other defines the second operand
  3940. * @param result defines the matrix where to store the multiplication
  3941. * @returns the current matrix
  3942. */
  3943. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3944. /**
  3945. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3946. * @param other defines the second operand
  3947. * @param result defines the array where to store the multiplication
  3948. * @param offset defines the offset in the target array where to start storing values
  3949. * @returns the current matrix
  3950. */
  3951. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3952. /**
  3953. * Check equality between this matrix and a second one
  3954. * @param value defines the second matrix to compare
  3955. * @returns true is the current matrix and the given one values are strictly equal
  3956. */
  3957. equals(value: DeepImmutable<Matrix>): boolean;
  3958. /**
  3959. * Clone the current matrix
  3960. * @returns a new matrix from the current matrix
  3961. */
  3962. clone(): Matrix;
  3963. /**
  3964. * Returns the name of the current matrix class
  3965. * @returns the string "Matrix"
  3966. */
  3967. getClassName(): string;
  3968. /**
  3969. * Gets the hash code of the current matrix
  3970. * @returns the hash code
  3971. */
  3972. getHashCode(): number;
  3973. /**
  3974. * Decomposes the current Matrix into a translation, rotation and scaling components
  3975. * @param scale defines the scale vector3 given as a reference to update
  3976. * @param rotation defines the rotation quaternion given as a reference to update
  3977. * @param translation defines the translation vector3 given as a reference to update
  3978. * @returns true if operation was successful
  3979. */
  3980. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3981. /**
  3982. * Gets specific row of the matrix
  3983. * @param index defines the number of the row to get
  3984. * @returns the index-th row of the current matrix as a new Vector4
  3985. */
  3986. getRow(index: number): Nullable<Vector4>;
  3987. /**
  3988. * Sets the index-th row of the current matrix to the vector4 values
  3989. * @param index defines the number of the row to set
  3990. * @param row defines the target vector4
  3991. * @returns the updated current matrix
  3992. */
  3993. setRow(index: number, row: Vector4): Matrix;
  3994. /**
  3995. * Compute the transpose of the matrix
  3996. * @returns the new transposed matrix
  3997. */
  3998. transpose(): Matrix;
  3999. /**
  4000. * Compute the transpose of the matrix and store it in a given matrix
  4001. * @param result defines the target matrix
  4002. * @returns the current matrix
  4003. */
  4004. transposeToRef(result: Matrix): Matrix;
  4005. /**
  4006. * Sets the index-th row of the current matrix with the given 4 x float values
  4007. * @param index defines the row index
  4008. * @param x defines the x component to set
  4009. * @param y defines the y component to set
  4010. * @param z defines the z component to set
  4011. * @param w defines the w component to set
  4012. * @returns the updated current matrix
  4013. */
  4014. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4015. /**
  4016. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4017. * @param scale defines the scale factor
  4018. * @returns a new matrix
  4019. */
  4020. scale(scale: number): Matrix;
  4021. /**
  4022. * Scale the current matrix values by a factor to a given result matrix
  4023. * @param scale defines the scale factor
  4024. * @param result defines the matrix to store the result
  4025. * @returns the current matrix
  4026. */
  4027. scaleToRef(scale: number, result: Matrix): Matrix;
  4028. /**
  4029. * Scale the current matrix values by a factor and add the result to a given matrix
  4030. * @param scale defines the scale factor
  4031. * @param result defines the Matrix to store the result
  4032. * @returns the current matrix
  4033. */
  4034. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4035. /**
  4036. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4037. * @param ref matrix to store the result
  4038. */
  4039. toNormalMatrix(ref: Matrix): void;
  4040. /**
  4041. * Gets only rotation part of the current matrix
  4042. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4043. */
  4044. getRotationMatrix(): Matrix;
  4045. /**
  4046. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4047. * @param result defines the target matrix to store data to
  4048. * @returns the current matrix
  4049. */
  4050. getRotationMatrixToRef(result: Matrix): Matrix;
  4051. /**
  4052. * Toggles model matrix from being right handed to left handed in place and vice versa
  4053. */
  4054. toggleModelMatrixHandInPlace(): void;
  4055. /**
  4056. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4057. */
  4058. toggleProjectionMatrixHandInPlace(): void;
  4059. /**
  4060. * Creates a matrix from an array
  4061. * @param array defines the source array
  4062. * @param offset defines an offset in the source array
  4063. * @returns a new Matrix set from the starting index of the given array
  4064. */
  4065. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4066. /**
  4067. * Copy the content of an array into a given matrix
  4068. * @param array defines the source array
  4069. * @param offset defines an offset in the source array
  4070. * @param result defines the target matrix
  4071. */
  4072. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4073. /**
  4074. * Stores an array into a matrix after having multiplied each component by a given factor
  4075. * @param array defines the source array
  4076. * @param offset defines the offset in the source array
  4077. * @param scale defines the scaling factor
  4078. * @param result defines the target matrix
  4079. */
  4080. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4081. /**
  4082. * Gets an identity matrix that must not be updated
  4083. */
  4084. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4085. /**
  4086. * Stores a list of values (16) inside a given matrix
  4087. * @param initialM11 defines 1st value of 1st row
  4088. * @param initialM12 defines 2nd value of 1st row
  4089. * @param initialM13 defines 3rd value of 1st row
  4090. * @param initialM14 defines 4th value of 1st row
  4091. * @param initialM21 defines 1st value of 2nd row
  4092. * @param initialM22 defines 2nd value of 2nd row
  4093. * @param initialM23 defines 3rd value of 2nd row
  4094. * @param initialM24 defines 4th value of 2nd row
  4095. * @param initialM31 defines 1st value of 3rd row
  4096. * @param initialM32 defines 2nd value of 3rd row
  4097. * @param initialM33 defines 3rd value of 3rd row
  4098. * @param initialM34 defines 4th value of 3rd row
  4099. * @param initialM41 defines 1st value of 4th row
  4100. * @param initialM42 defines 2nd value of 4th row
  4101. * @param initialM43 defines 3rd value of 4th row
  4102. * @param initialM44 defines 4th value of 4th row
  4103. * @param result defines the target matrix
  4104. */
  4105. 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;
  4106. /**
  4107. * Creates new matrix from a list of values (16)
  4108. * @param initialM11 defines 1st value of 1st row
  4109. * @param initialM12 defines 2nd value of 1st row
  4110. * @param initialM13 defines 3rd value of 1st row
  4111. * @param initialM14 defines 4th value of 1st row
  4112. * @param initialM21 defines 1st value of 2nd row
  4113. * @param initialM22 defines 2nd value of 2nd row
  4114. * @param initialM23 defines 3rd value of 2nd row
  4115. * @param initialM24 defines 4th value of 2nd row
  4116. * @param initialM31 defines 1st value of 3rd row
  4117. * @param initialM32 defines 2nd value of 3rd row
  4118. * @param initialM33 defines 3rd value of 3rd row
  4119. * @param initialM34 defines 4th value of 3rd row
  4120. * @param initialM41 defines 1st value of 4th row
  4121. * @param initialM42 defines 2nd value of 4th row
  4122. * @param initialM43 defines 3rd value of 4th row
  4123. * @param initialM44 defines 4th value of 4th row
  4124. * @returns the new matrix
  4125. */
  4126. 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;
  4127. /**
  4128. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4129. * @param scale defines the scale vector3
  4130. * @param rotation defines the rotation quaternion
  4131. * @param translation defines the translation vector3
  4132. * @returns a new matrix
  4133. */
  4134. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4135. /**
  4136. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4137. * @param scale defines the scale vector3
  4138. * @param rotation defines the rotation quaternion
  4139. * @param translation defines the translation vector3
  4140. * @param result defines the target matrix
  4141. */
  4142. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4143. /**
  4144. * Creates a new identity matrix
  4145. * @returns a new identity matrix
  4146. */
  4147. static Identity(): Matrix;
  4148. /**
  4149. * Creates a new identity matrix and stores the result in a given matrix
  4150. * @param result defines the target matrix
  4151. */
  4152. static IdentityToRef(result: Matrix): void;
  4153. /**
  4154. * Creates a new zero matrix
  4155. * @returns a new zero matrix
  4156. */
  4157. static Zero(): Matrix;
  4158. /**
  4159. * Creates a new rotation matrix for "angle" radians around the X axis
  4160. * @param angle defines the angle (in radians) to use
  4161. * @return the new matrix
  4162. */
  4163. static RotationX(angle: number): Matrix;
  4164. /**
  4165. * Creates a new matrix as the invert of a given matrix
  4166. * @param source defines the source matrix
  4167. * @returns the new matrix
  4168. */
  4169. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4170. /**
  4171. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4172. * @param angle defines the angle (in radians) to use
  4173. * @param result defines the target matrix
  4174. */
  4175. static RotationXToRef(angle: number, result: Matrix): void;
  4176. /**
  4177. * Creates a new rotation matrix for "angle" radians around the Y axis
  4178. * @param angle defines the angle (in radians) to use
  4179. * @return the new matrix
  4180. */
  4181. static RotationY(angle: number): Matrix;
  4182. /**
  4183. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4184. * @param angle defines the angle (in radians) to use
  4185. * @param result defines the target matrix
  4186. */
  4187. static RotationYToRef(angle: number, result: Matrix): void;
  4188. /**
  4189. * Creates a new rotation matrix for "angle" radians around the Z axis
  4190. * @param angle defines the angle (in radians) to use
  4191. * @return the new matrix
  4192. */
  4193. static RotationZ(angle: number): Matrix;
  4194. /**
  4195. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4196. * @param angle defines the angle (in radians) to use
  4197. * @param result defines the target matrix
  4198. */
  4199. static RotationZToRef(angle: number, result: Matrix): void;
  4200. /**
  4201. * Creates a new rotation matrix for "angle" radians around the given axis
  4202. * @param axis defines the axis to use
  4203. * @param angle defines the angle (in radians) to use
  4204. * @return the new matrix
  4205. */
  4206. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4207. /**
  4208. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4209. * @param axis defines the axis to use
  4210. * @param angle defines the angle (in radians) to use
  4211. * @param result defines the target matrix
  4212. */
  4213. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4214. /**
  4215. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4216. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4217. * @param from defines the vector to align
  4218. * @param to defines the vector to align to
  4219. * @param result defines the target matrix
  4220. */
  4221. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4222. /**
  4223. * Creates a rotation matrix
  4224. * @param yaw defines the yaw angle in radians (Y axis)
  4225. * @param pitch defines the pitch angle in radians (X axis)
  4226. * @param roll defines the roll angle in radians (X axis)
  4227. * @returns the new rotation matrix
  4228. */
  4229. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4230. /**
  4231. * Creates a rotation matrix and stores it in a given matrix
  4232. * @param yaw defines the yaw angle in radians (Y axis)
  4233. * @param pitch defines the pitch angle in radians (X axis)
  4234. * @param roll defines the roll angle in radians (X axis)
  4235. * @param result defines the target matrix
  4236. */
  4237. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4238. /**
  4239. * Creates a scaling matrix
  4240. * @param x defines the scale factor on X axis
  4241. * @param y defines the scale factor on Y axis
  4242. * @param z defines the scale factor on Z axis
  4243. * @returns the new matrix
  4244. */
  4245. static Scaling(x: number, y: number, z: number): Matrix;
  4246. /**
  4247. * Creates a scaling matrix and stores it in a given matrix
  4248. * @param x defines the scale factor on X axis
  4249. * @param y defines the scale factor on Y axis
  4250. * @param z defines the scale factor on Z axis
  4251. * @param result defines the target matrix
  4252. */
  4253. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4254. /**
  4255. * Creates a translation matrix
  4256. * @param x defines the translation on X axis
  4257. * @param y defines the translation on Y axis
  4258. * @param z defines the translationon Z axis
  4259. * @returns the new matrix
  4260. */
  4261. static Translation(x: number, y: number, z: number): Matrix;
  4262. /**
  4263. * Creates a translation matrix and stores it in a given matrix
  4264. * @param x defines the translation on X axis
  4265. * @param y defines the translation on Y axis
  4266. * @param z defines the translationon Z axis
  4267. * @param result defines the target matrix
  4268. */
  4269. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4270. /**
  4271. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4272. * @param startValue defines the start value
  4273. * @param endValue defines the end value
  4274. * @param gradient defines the gradient factor
  4275. * @returns the new matrix
  4276. */
  4277. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4278. /**
  4279. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4280. * @param startValue defines the start value
  4281. * @param endValue defines the end value
  4282. * @param gradient defines the gradient factor
  4283. * @param result defines the Matrix object where to store data
  4284. */
  4285. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4286. /**
  4287. * Builds a new matrix whose values are computed by:
  4288. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4289. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4290. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4291. * @param startValue defines the first matrix
  4292. * @param endValue defines the second matrix
  4293. * @param gradient defines the gradient between the two matrices
  4294. * @returns the new matrix
  4295. */
  4296. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4297. /**
  4298. * Update a matrix to values which are computed by:
  4299. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4300. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4301. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4302. * @param startValue defines the first matrix
  4303. * @param endValue defines the second matrix
  4304. * @param gradient defines the gradient between the two matrices
  4305. * @param result defines the target matrix
  4306. */
  4307. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4308. /**
  4309. * 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"
  4310. * This function works in left handed mode
  4311. * @param eye defines the final position of the entity
  4312. * @param target defines where the entity should look at
  4313. * @param up defines the up vector for the entity
  4314. * @returns the new matrix
  4315. */
  4316. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4317. /**
  4318. * 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".
  4319. * This function works in left handed mode
  4320. * @param eye defines the final position of the entity
  4321. * @param target defines where the entity should look at
  4322. * @param up defines the up vector for the entity
  4323. * @param result defines the target matrix
  4324. */
  4325. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4326. /**
  4327. * 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"
  4328. * This function works in right handed mode
  4329. * @param eye defines the final position of the entity
  4330. * @param target defines where the entity should look at
  4331. * @param up defines the up vector for the entity
  4332. * @returns the new matrix
  4333. */
  4334. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4335. /**
  4336. * 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".
  4337. * This function works in right handed mode
  4338. * @param eye defines the final position of the entity
  4339. * @param target defines where the entity should look at
  4340. * @param up defines the up vector for the entity
  4341. * @param result defines the target matrix
  4342. */
  4343. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4344. /**
  4345. * Create a left-handed orthographic projection matrix
  4346. * @param width defines the viewport width
  4347. * @param height defines the viewport height
  4348. * @param znear defines the near clip plane
  4349. * @param zfar defines the far clip plane
  4350. * @returns a new matrix as a left-handed orthographic projection matrix
  4351. */
  4352. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4353. /**
  4354. * Store a left-handed orthographic projection to a given matrix
  4355. * @param width defines the viewport width
  4356. * @param height defines the viewport height
  4357. * @param znear defines the near clip plane
  4358. * @param zfar defines the far clip plane
  4359. * @param result defines the target matrix
  4360. */
  4361. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4362. /**
  4363. * Create a left-handed orthographic projection matrix
  4364. * @param left defines the viewport left coordinate
  4365. * @param right defines the viewport right coordinate
  4366. * @param bottom defines the viewport bottom coordinate
  4367. * @param top defines the viewport top coordinate
  4368. * @param znear defines the near clip plane
  4369. * @param zfar defines the far clip plane
  4370. * @returns a new matrix as a left-handed orthographic projection matrix
  4371. */
  4372. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4373. /**
  4374. * Stores a left-handed orthographic projection into a given matrix
  4375. * @param left defines the viewport left coordinate
  4376. * @param right defines the viewport right coordinate
  4377. * @param bottom defines the viewport bottom coordinate
  4378. * @param top defines the viewport top coordinate
  4379. * @param znear defines the near clip plane
  4380. * @param zfar defines the far clip plane
  4381. * @param result defines the target matrix
  4382. */
  4383. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4384. /**
  4385. * Creates a right-handed orthographic projection matrix
  4386. * @param left defines the viewport left coordinate
  4387. * @param right defines the viewport right coordinate
  4388. * @param bottom defines the viewport bottom coordinate
  4389. * @param top defines the viewport top coordinate
  4390. * @param znear defines the near clip plane
  4391. * @param zfar defines the far clip plane
  4392. * @returns a new matrix as a right-handed orthographic projection matrix
  4393. */
  4394. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4395. /**
  4396. * Stores a right-handed orthographic projection into a given matrix
  4397. * @param left defines the viewport left coordinate
  4398. * @param right defines the viewport right coordinate
  4399. * @param bottom defines the viewport bottom coordinate
  4400. * @param top defines the viewport top coordinate
  4401. * @param znear defines the near clip plane
  4402. * @param zfar defines the far clip plane
  4403. * @param result defines the target matrix
  4404. */
  4405. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4406. /**
  4407. * Creates a left-handed perspective projection matrix
  4408. * @param width defines the viewport width
  4409. * @param height defines the viewport height
  4410. * @param znear defines the near clip plane
  4411. * @param zfar defines the far clip plane
  4412. * @returns a new matrix as a left-handed perspective projection matrix
  4413. */
  4414. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4415. /**
  4416. * Creates a left-handed perspective projection matrix
  4417. * @param fov defines the horizontal field of view
  4418. * @param aspect defines the aspect ratio
  4419. * @param znear defines the near clip plane
  4420. * @param zfar defines the far clip plane
  4421. * @returns a new matrix as a left-handed perspective projection matrix
  4422. */
  4423. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4424. /**
  4425. * Stores a left-handed perspective projection into a given matrix
  4426. * @param fov defines the horizontal field of view
  4427. * @param aspect defines the aspect ratio
  4428. * @param znear defines the near clip plane
  4429. * @param zfar defines the far clip plane
  4430. * @param result defines the target matrix
  4431. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4432. */
  4433. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4434. /**
  4435. * Creates a right-handed perspective projection matrix
  4436. * @param fov defines the horizontal field of view
  4437. * @param aspect defines the aspect ratio
  4438. * @param znear defines the near clip plane
  4439. * @param zfar defines the far clip plane
  4440. * @returns a new matrix as a right-handed perspective projection matrix
  4441. */
  4442. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4443. /**
  4444. * Stores a right-handed perspective projection into a given matrix
  4445. * @param fov defines the horizontal field of view
  4446. * @param aspect defines the aspect ratio
  4447. * @param znear defines the near clip plane
  4448. * @param zfar defines the far clip plane
  4449. * @param result defines the target matrix
  4450. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4451. */
  4452. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4453. /**
  4454. * Stores a perspective projection for WebVR info a given matrix
  4455. * @param fov defines the field of view
  4456. * @param znear defines the near clip plane
  4457. * @param zfar defines the far clip plane
  4458. * @param result defines the target matrix
  4459. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4460. */
  4461. static PerspectiveFovWebVRToRef(fov: {
  4462. upDegrees: number;
  4463. downDegrees: number;
  4464. leftDegrees: number;
  4465. rightDegrees: number;
  4466. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4467. /**
  4468. * Computes a complete transformation matrix
  4469. * @param viewport defines the viewport to use
  4470. * @param world defines the world matrix
  4471. * @param view defines the view matrix
  4472. * @param projection defines the projection matrix
  4473. * @param zmin defines the near clip plane
  4474. * @param zmax defines the far clip plane
  4475. * @returns the transformation matrix
  4476. */
  4477. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4478. /**
  4479. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4480. * @param matrix defines the matrix to use
  4481. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4482. */
  4483. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4484. /**
  4485. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4486. * @param matrix defines the matrix to use
  4487. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4488. */
  4489. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4490. /**
  4491. * Compute the transpose of a given matrix
  4492. * @param matrix defines the matrix to transpose
  4493. * @returns the new matrix
  4494. */
  4495. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4496. /**
  4497. * Compute the transpose of a matrix and store it in a target matrix
  4498. * @param matrix defines the matrix to transpose
  4499. * @param result defines the target matrix
  4500. */
  4501. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4502. /**
  4503. * Computes a reflection matrix from a plane
  4504. * @param plane defines the reflection plane
  4505. * @returns a new matrix
  4506. */
  4507. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4508. /**
  4509. * Computes a reflection matrix from a plane
  4510. * @param plane defines the reflection plane
  4511. * @param result defines the target matrix
  4512. */
  4513. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4514. /**
  4515. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4516. * @param xaxis defines the value of the 1st axis
  4517. * @param yaxis defines the value of the 2nd axis
  4518. * @param zaxis defines the value of the 3rd axis
  4519. * @param result defines the target matrix
  4520. */
  4521. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4522. /**
  4523. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4524. * @param quat defines the quaternion to use
  4525. * @param result defines the target matrix
  4526. */
  4527. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4528. }
  4529. /**
  4530. * @hidden
  4531. */
  4532. export class TmpVectors {
  4533. static Vector2: Vector2[];
  4534. static Vector3: Vector3[];
  4535. static Vector4: Vector4[];
  4536. static Quaternion: Quaternion[];
  4537. static Matrix: Matrix[];
  4538. }
  4539. }
  4540. declare module "babylonjs/Maths/math.path" {
  4541. import { DeepImmutable, Nullable } from "babylonjs/types";
  4542. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4543. /**
  4544. * Defines potential orientation for back face culling
  4545. */
  4546. export enum Orientation {
  4547. /**
  4548. * Clockwise
  4549. */
  4550. CW = 0,
  4551. /** Counter clockwise */
  4552. CCW = 1
  4553. }
  4554. /** Class used to represent a Bezier curve */
  4555. export class BezierCurve {
  4556. /**
  4557. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4558. * @param t defines the time
  4559. * @param x1 defines the left coordinate on X axis
  4560. * @param y1 defines the left coordinate on Y axis
  4561. * @param x2 defines the right coordinate on X axis
  4562. * @param y2 defines the right coordinate on Y axis
  4563. * @returns the interpolated value
  4564. */
  4565. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4566. }
  4567. /**
  4568. * Defines angle representation
  4569. */
  4570. export class Angle {
  4571. private _radians;
  4572. /**
  4573. * Creates an Angle object of "radians" radians (float).
  4574. * @param radians the angle in radians
  4575. */
  4576. constructor(radians: number);
  4577. /**
  4578. * Get value in degrees
  4579. * @returns the Angle value in degrees (float)
  4580. */
  4581. degrees(): number;
  4582. /**
  4583. * Get value in radians
  4584. * @returns the Angle value in radians (float)
  4585. */
  4586. radians(): number;
  4587. /**
  4588. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4589. * @param a defines first vector
  4590. * @param b defines second vector
  4591. * @returns a new Angle
  4592. */
  4593. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4594. /**
  4595. * Gets a new Angle object from the given float in radians
  4596. * @param radians defines the angle value in radians
  4597. * @returns a new Angle
  4598. */
  4599. static FromRadians(radians: number): Angle;
  4600. /**
  4601. * Gets a new Angle object from the given float in degrees
  4602. * @param degrees defines the angle value in degrees
  4603. * @returns a new Angle
  4604. */
  4605. static FromDegrees(degrees: number): Angle;
  4606. }
  4607. /**
  4608. * This represents an arc in a 2d space.
  4609. */
  4610. export class Arc2 {
  4611. /** Defines the start point of the arc */
  4612. startPoint: Vector2;
  4613. /** Defines the mid point of the arc */
  4614. midPoint: Vector2;
  4615. /** Defines the end point of the arc */
  4616. endPoint: Vector2;
  4617. /**
  4618. * Defines the center point of the arc.
  4619. */
  4620. centerPoint: Vector2;
  4621. /**
  4622. * Defines the radius of the arc.
  4623. */
  4624. radius: number;
  4625. /**
  4626. * Defines the angle of the arc (from mid point to end point).
  4627. */
  4628. angle: Angle;
  4629. /**
  4630. * Defines the start angle of the arc (from start point to middle point).
  4631. */
  4632. startAngle: Angle;
  4633. /**
  4634. * Defines the orientation of the arc (clock wise/counter clock wise).
  4635. */
  4636. orientation: Orientation;
  4637. /**
  4638. * Creates an Arc object from the three given points : start, middle and end.
  4639. * @param startPoint Defines the start point of the arc
  4640. * @param midPoint Defines the midlle point of the arc
  4641. * @param endPoint Defines the end point of the arc
  4642. */
  4643. constructor(
  4644. /** Defines the start point of the arc */
  4645. startPoint: Vector2,
  4646. /** Defines the mid point of the arc */
  4647. midPoint: Vector2,
  4648. /** Defines the end point of the arc */
  4649. endPoint: Vector2);
  4650. }
  4651. /**
  4652. * Represents a 2D path made up of multiple 2D points
  4653. */
  4654. export class Path2 {
  4655. private _points;
  4656. private _length;
  4657. /**
  4658. * If the path start and end point are the same
  4659. */
  4660. closed: boolean;
  4661. /**
  4662. * Creates a Path2 object from the starting 2D coordinates x and y.
  4663. * @param x the starting points x value
  4664. * @param y the starting points y value
  4665. */
  4666. constructor(x: number, y: number);
  4667. /**
  4668. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4669. * @param x the added points x value
  4670. * @param y the added points y value
  4671. * @returns the updated Path2.
  4672. */
  4673. addLineTo(x: number, y: number): Path2;
  4674. /**
  4675. * 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.
  4676. * @param midX middle point x value
  4677. * @param midY middle point y value
  4678. * @param endX end point x value
  4679. * @param endY end point y value
  4680. * @param numberOfSegments (default: 36)
  4681. * @returns the updated Path2.
  4682. */
  4683. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4684. /**
  4685. * Closes the Path2.
  4686. * @returns the Path2.
  4687. */
  4688. close(): Path2;
  4689. /**
  4690. * Gets the sum of the distance between each sequential point in the path
  4691. * @returns the Path2 total length (float).
  4692. */
  4693. length(): number;
  4694. /**
  4695. * Gets the points which construct the path
  4696. * @returns the Path2 internal array of points.
  4697. */
  4698. getPoints(): Vector2[];
  4699. /**
  4700. * Retreives the point at the distance aways from the starting point
  4701. * @param normalizedLengthPosition the length along the path to retreive the point from
  4702. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4703. */
  4704. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4705. /**
  4706. * Creates a new path starting from an x and y position
  4707. * @param x starting x value
  4708. * @param y starting y value
  4709. * @returns a new Path2 starting at the coordinates (x, y).
  4710. */
  4711. static StartingAt(x: number, y: number): Path2;
  4712. }
  4713. /**
  4714. * Represents a 3D path made up of multiple 3D points
  4715. */
  4716. export class Path3D {
  4717. /**
  4718. * an array of Vector3, the curve axis of the Path3D
  4719. */
  4720. path: Vector3[];
  4721. private _curve;
  4722. private _distances;
  4723. private _tangents;
  4724. private _normals;
  4725. private _binormals;
  4726. private _raw;
  4727. /**
  4728. * new Path3D(path, normal, raw)
  4729. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4730. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4731. * @param path an array of Vector3, the curve axis of the Path3D
  4732. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4733. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4734. */
  4735. constructor(
  4736. /**
  4737. * an array of Vector3, the curve axis of the Path3D
  4738. */
  4739. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4740. /**
  4741. * Returns the Path3D array of successive Vector3 designing its curve.
  4742. * @returns the Path3D array of successive Vector3 designing its curve.
  4743. */
  4744. getCurve(): Vector3[];
  4745. /**
  4746. * Returns an array populated with tangent vectors on each Path3D curve point.
  4747. * @returns an array populated with tangent vectors on each Path3D curve point.
  4748. */
  4749. getTangents(): Vector3[];
  4750. /**
  4751. * Returns an array populated with normal vectors on each Path3D curve point.
  4752. * @returns an array populated with normal vectors on each Path3D curve point.
  4753. */
  4754. getNormals(): Vector3[];
  4755. /**
  4756. * Returns an array populated with binormal vectors on each Path3D curve point.
  4757. * @returns an array populated with binormal vectors on each Path3D curve point.
  4758. */
  4759. getBinormals(): Vector3[];
  4760. /**
  4761. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4762. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4763. */
  4764. getDistances(): number[];
  4765. /**
  4766. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4767. * @param path path which all values are copied into the curves points
  4768. * @param firstNormal which should be projected onto the curve
  4769. * @returns the same object updated.
  4770. */
  4771. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4772. private _compute;
  4773. private _getFirstNonNullVector;
  4774. private _getLastNonNullVector;
  4775. private _normalVector;
  4776. }
  4777. /**
  4778. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4779. * A Curve3 is designed from a series of successive Vector3.
  4780. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4781. */
  4782. export class Curve3 {
  4783. private _points;
  4784. private _length;
  4785. /**
  4786. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4787. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4788. * @param v1 (Vector3) the control point
  4789. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4790. * @param nbPoints (integer) the wanted number of points in the curve
  4791. * @returns the created Curve3
  4792. */
  4793. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4794. /**
  4795. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4796. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4797. * @param v1 (Vector3) the first control point
  4798. * @param v2 (Vector3) the second control point
  4799. * @param v3 (Vector3) the end point of the Cubic Bezier
  4800. * @param nbPoints (integer) the wanted number of points in the curve
  4801. * @returns the created Curve3
  4802. */
  4803. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4804. /**
  4805. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4806. * @param p1 (Vector3) the origin point of the Hermite Spline
  4807. * @param t1 (Vector3) the tangent vector at the origin point
  4808. * @param p2 (Vector3) the end point of the Hermite Spline
  4809. * @param t2 (Vector3) the tangent vector at the end point
  4810. * @param nbPoints (integer) the wanted number of points in the curve
  4811. * @returns the created Curve3
  4812. */
  4813. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4814. /**
  4815. * Returns a Curve3 object along a CatmullRom Spline curve :
  4816. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4817. * @param nbPoints (integer) the wanted number of points between each curve control points
  4818. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4819. * @returns the created Curve3
  4820. */
  4821. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4822. /**
  4823. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4824. * A Curve3 is designed from a series of successive Vector3.
  4825. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4826. * @param points points which make up the curve
  4827. */
  4828. constructor(points: Vector3[]);
  4829. /**
  4830. * @returns the Curve3 stored array of successive Vector3
  4831. */
  4832. getPoints(): Vector3[];
  4833. /**
  4834. * @returns the computed length (float) of the curve.
  4835. */
  4836. length(): number;
  4837. /**
  4838. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4839. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4840. * curveA and curveB keep unchanged.
  4841. * @param curve the curve to continue from this curve
  4842. * @returns the newly constructed curve
  4843. */
  4844. continue(curve: DeepImmutable<Curve3>): Curve3;
  4845. private _computeLength;
  4846. }
  4847. }
  4848. declare module "babylonjs/Animations/easing" {
  4849. /**
  4850. * This represents the main contract an easing function should follow.
  4851. * Easing functions are used throughout the animation system.
  4852. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4853. */
  4854. export interface IEasingFunction {
  4855. /**
  4856. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4857. * of the easing function.
  4858. * The link below provides some of the most common examples of easing functions.
  4859. * @see https://easings.net/
  4860. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4861. * @returns the corresponding value on the curve defined by the easing function
  4862. */
  4863. ease(gradient: number): number;
  4864. }
  4865. /**
  4866. * Base class used for every default easing function.
  4867. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4868. */
  4869. export class EasingFunction implements IEasingFunction {
  4870. /**
  4871. * Interpolation follows the mathematical formula associated with the easing function.
  4872. */
  4873. static readonly EASINGMODE_EASEIN: number;
  4874. /**
  4875. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4876. */
  4877. static readonly EASINGMODE_EASEOUT: number;
  4878. /**
  4879. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4880. */
  4881. static readonly EASINGMODE_EASEINOUT: number;
  4882. private _easingMode;
  4883. /**
  4884. * Sets the easing mode of the current function.
  4885. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4886. */
  4887. setEasingMode(easingMode: number): void;
  4888. /**
  4889. * Gets the current easing mode.
  4890. * @returns the easing mode
  4891. */
  4892. getEasingMode(): number;
  4893. /**
  4894. * @hidden
  4895. */
  4896. easeInCore(gradient: number): number;
  4897. /**
  4898. * Given an input gradient between 0 and 1, this returns the corresponding value
  4899. * of the easing function.
  4900. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4901. * @returns the corresponding value on the curve defined by the easing function
  4902. */
  4903. ease(gradient: number): number;
  4904. }
  4905. /**
  4906. * Easing function with a circle shape (see link below).
  4907. * @see https://easings.net/#easeInCirc
  4908. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4909. */
  4910. export class CircleEase extends EasingFunction implements IEasingFunction {
  4911. /** @hidden */
  4912. easeInCore(gradient: number): number;
  4913. }
  4914. /**
  4915. * Easing function with a ease back shape (see link below).
  4916. * @see https://easings.net/#easeInBack
  4917. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4918. */
  4919. export class BackEase extends EasingFunction implements IEasingFunction {
  4920. /** Defines the amplitude of the function */
  4921. amplitude: number;
  4922. /**
  4923. * Instantiates a back ease easing
  4924. * @see https://easings.net/#easeInBack
  4925. * @param amplitude Defines the amplitude of the function
  4926. */
  4927. constructor(
  4928. /** Defines the amplitude of the function */
  4929. amplitude?: number);
  4930. /** @hidden */
  4931. easeInCore(gradient: number): number;
  4932. }
  4933. /**
  4934. * Easing function with a bouncing shape (see link below).
  4935. * @see https://easings.net/#easeInBounce
  4936. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4937. */
  4938. export class BounceEase extends EasingFunction implements IEasingFunction {
  4939. /** Defines the number of bounces */
  4940. bounces: number;
  4941. /** Defines the amplitude of the bounce */
  4942. bounciness: number;
  4943. /**
  4944. * Instantiates a bounce easing
  4945. * @see https://easings.net/#easeInBounce
  4946. * @param bounces Defines the number of bounces
  4947. * @param bounciness Defines the amplitude of the bounce
  4948. */
  4949. constructor(
  4950. /** Defines the number of bounces */
  4951. bounces?: number,
  4952. /** Defines the amplitude of the bounce */
  4953. bounciness?: number);
  4954. /** @hidden */
  4955. easeInCore(gradient: number): number;
  4956. }
  4957. /**
  4958. * Easing function with a power of 3 shape (see link below).
  4959. * @see https://easings.net/#easeInCubic
  4960. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4961. */
  4962. export class CubicEase extends EasingFunction implements IEasingFunction {
  4963. /** @hidden */
  4964. easeInCore(gradient: number): number;
  4965. }
  4966. /**
  4967. * Easing function with an elastic shape (see link below).
  4968. * @see https://easings.net/#easeInElastic
  4969. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4970. */
  4971. export class ElasticEase extends EasingFunction implements IEasingFunction {
  4972. /** Defines the number of oscillations*/
  4973. oscillations: number;
  4974. /** Defines the amplitude of the oscillations*/
  4975. springiness: number;
  4976. /**
  4977. * Instantiates an elastic easing function
  4978. * @see https://easings.net/#easeInElastic
  4979. * @param oscillations Defines the number of oscillations
  4980. * @param springiness Defines the amplitude of the oscillations
  4981. */
  4982. constructor(
  4983. /** Defines the number of oscillations*/
  4984. oscillations?: number,
  4985. /** Defines the amplitude of the oscillations*/
  4986. springiness?: number);
  4987. /** @hidden */
  4988. easeInCore(gradient: number): number;
  4989. }
  4990. /**
  4991. * Easing function with an exponential shape (see link below).
  4992. * @see https://easings.net/#easeInExpo
  4993. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4994. */
  4995. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  4996. /** Defines the exponent of the function */
  4997. exponent: number;
  4998. /**
  4999. * Instantiates an exponential easing function
  5000. * @see https://easings.net/#easeInExpo
  5001. * @param exponent Defines the exponent of the function
  5002. */
  5003. constructor(
  5004. /** Defines the exponent of the function */
  5005. exponent?: number);
  5006. /** @hidden */
  5007. easeInCore(gradient: number): number;
  5008. }
  5009. /**
  5010. * Easing function with a power shape (see link below).
  5011. * @see https://easings.net/#easeInQuad
  5012. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5013. */
  5014. export class PowerEase extends EasingFunction implements IEasingFunction {
  5015. /** Defines the power of the function */
  5016. power: number;
  5017. /**
  5018. * Instantiates an power base easing function
  5019. * @see https://easings.net/#easeInQuad
  5020. * @param power Defines the power of the function
  5021. */
  5022. constructor(
  5023. /** Defines the power of the function */
  5024. power?: number);
  5025. /** @hidden */
  5026. easeInCore(gradient: number): number;
  5027. }
  5028. /**
  5029. * Easing function with a power of 2 shape (see link below).
  5030. * @see https://easings.net/#easeInQuad
  5031. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5032. */
  5033. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5034. /** @hidden */
  5035. easeInCore(gradient: number): number;
  5036. }
  5037. /**
  5038. * Easing function with a power of 4 shape (see link below).
  5039. * @see https://easings.net/#easeInQuart
  5040. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5041. */
  5042. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5043. /** @hidden */
  5044. easeInCore(gradient: number): number;
  5045. }
  5046. /**
  5047. * Easing function with a power of 5 shape (see link below).
  5048. * @see https://easings.net/#easeInQuint
  5049. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5050. */
  5051. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5052. /** @hidden */
  5053. easeInCore(gradient: number): number;
  5054. }
  5055. /**
  5056. * Easing function with a sin shape (see link below).
  5057. * @see https://easings.net/#easeInSine
  5058. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5059. */
  5060. export class SineEase extends EasingFunction implements IEasingFunction {
  5061. /** @hidden */
  5062. easeInCore(gradient: number): number;
  5063. }
  5064. /**
  5065. * Easing function with a bezier shape (see link below).
  5066. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5067. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5068. */
  5069. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5070. /** Defines the x component of the start tangent in the bezier curve */
  5071. x1: number;
  5072. /** Defines the y component of the start tangent in the bezier curve */
  5073. y1: number;
  5074. /** Defines the x component of the end tangent in the bezier curve */
  5075. x2: number;
  5076. /** Defines the y component of the end tangent in the bezier curve */
  5077. y2: number;
  5078. /**
  5079. * Instantiates a bezier function
  5080. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5081. * @param x1 Defines the x component of the start tangent in the bezier curve
  5082. * @param y1 Defines the y component of the start tangent in the bezier curve
  5083. * @param x2 Defines the x component of the end tangent in the bezier curve
  5084. * @param y2 Defines the y component of the end tangent in the bezier curve
  5085. */
  5086. constructor(
  5087. /** Defines the x component of the start tangent in the bezier curve */
  5088. x1?: number,
  5089. /** Defines the y component of the start tangent in the bezier curve */
  5090. y1?: number,
  5091. /** Defines the x component of the end tangent in the bezier curve */
  5092. x2?: number,
  5093. /** Defines the y component of the end tangent in the bezier curve */
  5094. y2?: number);
  5095. /** @hidden */
  5096. easeInCore(gradient: number): number;
  5097. }
  5098. }
  5099. declare module "babylonjs/Maths/math.color" {
  5100. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5101. /**
  5102. * Class used to hold a RBG color
  5103. */
  5104. export class Color3 {
  5105. /**
  5106. * Defines the red component (between 0 and 1, default is 0)
  5107. */
  5108. r: number;
  5109. /**
  5110. * Defines the green component (between 0 and 1, default is 0)
  5111. */
  5112. g: number;
  5113. /**
  5114. * Defines the blue component (between 0 and 1, default is 0)
  5115. */
  5116. b: number;
  5117. /**
  5118. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5119. * @param r defines the red component (between 0 and 1, default is 0)
  5120. * @param g defines the green component (between 0 and 1, default is 0)
  5121. * @param b defines the blue component (between 0 and 1, default is 0)
  5122. */
  5123. constructor(
  5124. /**
  5125. * Defines the red component (between 0 and 1, default is 0)
  5126. */
  5127. r?: number,
  5128. /**
  5129. * Defines the green component (between 0 and 1, default is 0)
  5130. */
  5131. g?: number,
  5132. /**
  5133. * Defines the blue component (between 0 and 1, default is 0)
  5134. */
  5135. b?: number);
  5136. /**
  5137. * Creates a string with the Color3 current values
  5138. * @returns the string representation of the Color3 object
  5139. */
  5140. toString(): string;
  5141. /**
  5142. * Returns the string "Color3"
  5143. * @returns "Color3"
  5144. */
  5145. getClassName(): string;
  5146. /**
  5147. * Compute the Color3 hash code
  5148. * @returns an unique number that can be used to hash Color3 objects
  5149. */
  5150. getHashCode(): number;
  5151. /**
  5152. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5153. * @param array defines the array where to store the r,g,b components
  5154. * @param index defines an optional index in the target array to define where to start storing values
  5155. * @returns the current Color3 object
  5156. */
  5157. toArray(array: FloatArray, index?: number): Color3;
  5158. /**
  5159. * Returns a new Color4 object from the current Color3 and the given alpha
  5160. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5161. * @returns a new Color4 object
  5162. */
  5163. toColor4(alpha?: number): Color4;
  5164. /**
  5165. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5166. * @returns the new array
  5167. */
  5168. asArray(): number[];
  5169. /**
  5170. * Returns the luminance value
  5171. * @returns a float value
  5172. */
  5173. toLuminance(): number;
  5174. /**
  5175. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5176. * @param otherColor defines the second operand
  5177. * @returns the new Color3 object
  5178. */
  5179. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5180. /**
  5181. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5182. * @param otherColor defines the second operand
  5183. * @param result defines the Color3 object where to store the result
  5184. * @returns the current Color3
  5185. */
  5186. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5187. /**
  5188. * Determines equality between Color3 objects
  5189. * @param otherColor defines the second operand
  5190. * @returns true if the rgb values are equal to the given ones
  5191. */
  5192. equals(otherColor: DeepImmutable<Color3>): boolean;
  5193. /**
  5194. * Determines equality between the current Color3 object and a set of r,b,g values
  5195. * @param r defines the red component to check
  5196. * @param g defines the green component to check
  5197. * @param b defines the blue component to check
  5198. * @returns true if the rgb values are equal to the given ones
  5199. */
  5200. equalsFloats(r: number, g: number, b: number): boolean;
  5201. /**
  5202. * Multiplies in place each rgb value by scale
  5203. * @param scale defines the scaling factor
  5204. * @returns the updated Color3
  5205. */
  5206. scale(scale: number): Color3;
  5207. /**
  5208. * Multiplies the rgb values by scale and stores the result into "result"
  5209. * @param scale defines the scaling factor
  5210. * @param result defines the Color3 object where to store the result
  5211. * @returns the unmodified current Color3
  5212. */
  5213. scaleToRef(scale: number, result: Color3): Color3;
  5214. /**
  5215. * Scale the current Color3 values by a factor and add the result to a given Color3
  5216. * @param scale defines the scale factor
  5217. * @param result defines color to store the result into
  5218. * @returns the unmodified current Color3
  5219. */
  5220. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5221. /**
  5222. * Clamps the rgb values by the min and max values and stores the result into "result"
  5223. * @param min defines minimum clamping value (default is 0)
  5224. * @param max defines maximum clamping value (default is 1)
  5225. * @param result defines color to store the result into
  5226. * @returns the original Color3
  5227. */
  5228. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5229. /**
  5230. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5231. * @param otherColor defines the second operand
  5232. * @returns the new Color3
  5233. */
  5234. add(otherColor: DeepImmutable<Color3>): Color3;
  5235. /**
  5236. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5237. * @param otherColor defines the second operand
  5238. * @param result defines Color3 object to store the result into
  5239. * @returns the unmodified current Color3
  5240. */
  5241. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5242. /**
  5243. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5244. * @param otherColor defines the second operand
  5245. * @returns the new Color3
  5246. */
  5247. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5248. /**
  5249. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5250. * @param otherColor defines the second operand
  5251. * @param result defines Color3 object to store the result into
  5252. * @returns the unmodified current Color3
  5253. */
  5254. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5255. /**
  5256. * Copy the current object
  5257. * @returns a new Color3 copied the current one
  5258. */
  5259. clone(): Color3;
  5260. /**
  5261. * Copies the rgb values from the source in the current Color3
  5262. * @param source defines the source Color3 object
  5263. * @returns the updated Color3 object
  5264. */
  5265. copyFrom(source: DeepImmutable<Color3>): Color3;
  5266. /**
  5267. * Updates the Color3 rgb values from the given floats
  5268. * @param r defines the red component to read from
  5269. * @param g defines the green component to read from
  5270. * @param b defines the blue component to read from
  5271. * @returns the current Color3 object
  5272. */
  5273. copyFromFloats(r: number, g: number, b: number): Color3;
  5274. /**
  5275. * Updates the Color3 rgb values from the given floats
  5276. * @param r defines the red component to read from
  5277. * @param g defines the green component to read from
  5278. * @param b defines the blue component to read from
  5279. * @returns the current Color3 object
  5280. */
  5281. set(r: number, g: number, b: number): Color3;
  5282. /**
  5283. * Compute the Color3 hexadecimal code as a string
  5284. * @returns a string containing the hexadecimal representation of the Color3 object
  5285. */
  5286. toHexString(): string;
  5287. /**
  5288. * Computes a new Color3 converted from the current one to linear space
  5289. * @returns a new Color3 object
  5290. */
  5291. toLinearSpace(): Color3;
  5292. /**
  5293. * Converts current color in rgb space to HSV values
  5294. * @returns a new color3 representing the HSV values
  5295. */
  5296. toHSV(): Color3;
  5297. /**
  5298. * Converts current color in rgb space to HSV values
  5299. * @param result defines the Color3 where to store the HSV values
  5300. */
  5301. toHSVToRef(result: Color3): void;
  5302. /**
  5303. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5304. * @param convertedColor defines the Color3 object where to store the linear space version
  5305. * @returns the unmodified Color3
  5306. */
  5307. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5308. /**
  5309. * Computes a new Color3 converted from the current one to gamma space
  5310. * @returns a new Color3 object
  5311. */
  5312. toGammaSpace(): Color3;
  5313. /**
  5314. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5315. * @param convertedColor defines the Color3 object where to store the gamma space version
  5316. * @returns the unmodified Color3
  5317. */
  5318. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5319. private static _BlackReadOnly;
  5320. /**
  5321. * Convert Hue, saturation and value to a Color3 (RGB)
  5322. * @param hue defines the hue
  5323. * @param saturation defines the saturation
  5324. * @param value defines the value
  5325. * @param result defines the Color3 where to store the RGB values
  5326. */
  5327. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5328. /**
  5329. * Creates a new Color3 from the string containing valid hexadecimal values
  5330. * @param hex defines a string containing valid hexadecimal values
  5331. * @returns a new Color3 object
  5332. */
  5333. static FromHexString(hex: string): Color3;
  5334. /**
  5335. * Creates a new Color3 from the starting index of the given array
  5336. * @param array defines the source array
  5337. * @param offset defines an offset in the source array
  5338. * @returns a new Color3 object
  5339. */
  5340. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5341. /**
  5342. * Creates a new Color3 from integer values (< 256)
  5343. * @param r defines the red component to read from (value between 0 and 255)
  5344. * @param g defines the green component to read from (value between 0 and 255)
  5345. * @param b defines the blue component to read from (value between 0 and 255)
  5346. * @returns a new Color3 object
  5347. */
  5348. static FromInts(r: number, g: number, b: number): Color3;
  5349. /**
  5350. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5351. * @param start defines the start Color3 value
  5352. * @param end defines the end Color3 value
  5353. * @param amount defines the gradient value between start and end
  5354. * @returns a new Color3 object
  5355. */
  5356. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5357. /**
  5358. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5359. * @param left defines the start value
  5360. * @param right defines the end value
  5361. * @param amount defines the gradient factor
  5362. * @param result defines the Color3 object where to store the result
  5363. */
  5364. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5365. /**
  5366. * Returns a Color3 value containing a red color
  5367. * @returns a new Color3 object
  5368. */
  5369. static Red(): Color3;
  5370. /**
  5371. * Returns a Color3 value containing a green color
  5372. * @returns a new Color3 object
  5373. */
  5374. static Green(): Color3;
  5375. /**
  5376. * Returns a Color3 value containing a blue color
  5377. * @returns a new Color3 object
  5378. */
  5379. static Blue(): Color3;
  5380. /**
  5381. * Returns a Color3 value containing a black color
  5382. * @returns a new Color3 object
  5383. */
  5384. static Black(): Color3;
  5385. /**
  5386. * Gets a Color3 value containing a black color that must not be updated
  5387. */
  5388. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5389. /**
  5390. * Returns a Color3 value containing a white color
  5391. * @returns a new Color3 object
  5392. */
  5393. static White(): Color3;
  5394. /**
  5395. * Returns a Color3 value containing a purple color
  5396. * @returns a new Color3 object
  5397. */
  5398. static Purple(): Color3;
  5399. /**
  5400. * Returns a Color3 value containing a magenta color
  5401. * @returns a new Color3 object
  5402. */
  5403. static Magenta(): Color3;
  5404. /**
  5405. * Returns a Color3 value containing a yellow color
  5406. * @returns a new Color3 object
  5407. */
  5408. static Yellow(): Color3;
  5409. /**
  5410. * Returns a Color3 value containing a gray color
  5411. * @returns a new Color3 object
  5412. */
  5413. static Gray(): Color3;
  5414. /**
  5415. * Returns a Color3 value containing a teal color
  5416. * @returns a new Color3 object
  5417. */
  5418. static Teal(): Color3;
  5419. /**
  5420. * Returns a Color3 value containing a random color
  5421. * @returns a new Color3 object
  5422. */
  5423. static Random(): Color3;
  5424. }
  5425. /**
  5426. * Class used to hold a RBGA color
  5427. */
  5428. export class Color4 {
  5429. /**
  5430. * Defines the red component (between 0 and 1, default is 0)
  5431. */
  5432. r: number;
  5433. /**
  5434. * Defines the green component (between 0 and 1, default is 0)
  5435. */
  5436. g: number;
  5437. /**
  5438. * Defines the blue component (between 0 and 1, default is 0)
  5439. */
  5440. b: number;
  5441. /**
  5442. * Defines the alpha component (between 0 and 1, default is 1)
  5443. */
  5444. a: number;
  5445. /**
  5446. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5447. * @param r defines the red component (between 0 and 1, default is 0)
  5448. * @param g defines the green component (between 0 and 1, default is 0)
  5449. * @param b defines the blue component (between 0 and 1, default is 0)
  5450. * @param a defines the alpha component (between 0 and 1, default is 1)
  5451. */
  5452. constructor(
  5453. /**
  5454. * Defines the red component (between 0 and 1, default is 0)
  5455. */
  5456. r?: number,
  5457. /**
  5458. * Defines the green component (between 0 and 1, default is 0)
  5459. */
  5460. g?: number,
  5461. /**
  5462. * Defines the blue component (between 0 and 1, default is 0)
  5463. */
  5464. b?: number,
  5465. /**
  5466. * Defines the alpha component (between 0 and 1, default is 1)
  5467. */
  5468. a?: number);
  5469. /**
  5470. * Adds in place the given Color4 values to the current Color4 object
  5471. * @param right defines the second operand
  5472. * @returns the current updated Color4 object
  5473. */
  5474. addInPlace(right: DeepImmutable<Color4>): Color4;
  5475. /**
  5476. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5477. * @returns the new array
  5478. */
  5479. asArray(): number[];
  5480. /**
  5481. * Stores from the starting index in the given array the Color4 successive values
  5482. * @param array defines the array where to store the r,g,b components
  5483. * @param index defines an optional index in the target array to define where to start storing values
  5484. * @returns the current Color4 object
  5485. */
  5486. toArray(array: number[], index?: number): Color4;
  5487. /**
  5488. * Determines equality between Color4 objects
  5489. * @param otherColor defines the second operand
  5490. * @returns true if the rgba values are equal to the given ones
  5491. */
  5492. equals(otherColor: DeepImmutable<Color4>): boolean;
  5493. /**
  5494. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5495. * @param right defines the second operand
  5496. * @returns a new Color4 object
  5497. */
  5498. add(right: DeepImmutable<Color4>): Color4;
  5499. /**
  5500. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5501. * @param right defines the second operand
  5502. * @returns a new Color4 object
  5503. */
  5504. subtract(right: DeepImmutable<Color4>): Color4;
  5505. /**
  5506. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5507. * @param right defines the second operand
  5508. * @param result defines the Color4 object where to store the result
  5509. * @returns the current Color4 object
  5510. */
  5511. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5512. /**
  5513. * Creates a new Color4 with the current Color4 values multiplied by scale
  5514. * @param scale defines the scaling factor to apply
  5515. * @returns a new Color4 object
  5516. */
  5517. scale(scale: number): Color4;
  5518. /**
  5519. * Multiplies the current Color4 values by scale and stores the result in "result"
  5520. * @param scale defines the scaling factor to apply
  5521. * @param result defines the Color4 object where to store the result
  5522. * @returns the current unmodified Color4
  5523. */
  5524. scaleToRef(scale: number, result: Color4): Color4;
  5525. /**
  5526. * Scale the current Color4 values by a factor and add the result to a given Color4
  5527. * @param scale defines the scale factor
  5528. * @param result defines the Color4 object where to store the result
  5529. * @returns the unmodified current Color4
  5530. */
  5531. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5532. /**
  5533. * Clamps the rgb values by the min and max values and stores the result into "result"
  5534. * @param min defines minimum clamping value (default is 0)
  5535. * @param max defines maximum clamping value (default is 1)
  5536. * @param result defines color to store the result into.
  5537. * @returns the cuurent Color4
  5538. */
  5539. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5540. /**
  5541. * Multipy an Color4 value by another and return a new Color4 object
  5542. * @param color defines the Color4 value to multiply by
  5543. * @returns a new Color4 object
  5544. */
  5545. multiply(color: Color4): Color4;
  5546. /**
  5547. * Multipy a Color4 value by another and push the result in a reference value
  5548. * @param color defines the Color4 value to multiply by
  5549. * @param result defines the Color4 to fill the result in
  5550. * @returns the result Color4
  5551. */
  5552. multiplyToRef(color: Color4, result: Color4): Color4;
  5553. /**
  5554. * Creates a string with the Color4 current values
  5555. * @returns the string representation of the Color4 object
  5556. */
  5557. toString(): string;
  5558. /**
  5559. * Returns the string "Color4"
  5560. * @returns "Color4"
  5561. */
  5562. getClassName(): string;
  5563. /**
  5564. * Compute the Color4 hash code
  5565. * @returns an unique number that can be used to hash Color4 objects
  5566. */
  5567. getHashCode(): number;
  5568. /**
  5569. * Creates a new Color4 copied from the current one
  5570. * @returns a new Color4 object
  5571. */
  5572. clone(): Color4;
  5573. /**
  5574. * Copies the given Color4 values into the current one
  5575. * @param source defines the source Color4 object
  5576. * @returns the current updated Color4 object
  5577. */
  5578. copyFrom(source: Color4): Color4;
  5579. /**
  5580. * Copies the given float values into the current one
  5581. * @param r defines the red component to read from
  5582. * @param g defines the green component to read from
  5583. * @param b defines the blue component to read from
  5584. * @param a defines the alpha component to read from
  5585. * @returns the current updated Color4 object
  5586. */
  5587. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5588. /**
  5589. * Copies the given float values into the current one
  5590. * @param r defines the red component to read from
  5591. * @param g defines the green component to read from
  5592. * @param b defines the blue component to read from
  5593. * @param a defines the alpha component to read from
  5594. * @returns the current updated Color4 object
  5595. */
  5596. set(r: number, g: number, b: number, a: number): Color4;
  5597. /**
  5598. * Compute the Color4 hexadecimal code as a string
  5599. * @returns a string containing the hexadecimal representation of the Color4 object
  5600. */
  5601. toHexString(): string;
  5602. /**
  5603. * Computes a new Color4 converted from the current one to linear space
  5604. * @returns a new Color4 object
  5605. */
  5606. toLinearSpace(): Color4;
  5607. /**
  5608. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5609. * @param convertedColor defines the Color4 object where to store the linear space version
  5610. * @returns the unmodified Color4
  5611. */
  5612. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5613. /**
  5614. * Computes a new Color4 converted from the current one to gamma space
  5615. * @returns a new Color4 object
  5616. */
  5617. toGammaSpace(): Color4;
  5618. /**
  5619. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5620. * @param convertedColor defines the Color4 object where to store the gamma space version
  5621. * @returns the unmodified Color4
  5622. */
  5623. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5624. /**
  5625. * Creates a new Color4 from the string containing valid hexadecimal values
  5626. * @param hex defines a string containing valid hexadecimal values
  5627. * @returns a new Color4 object
  5628. */
  5629. static FromHexString(hex: string): Color4;
  5630. /**
  5631. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5632. * @param left defines the start value
  5633. * @param right defines the end value
  5634. * @param amount defines the gradient factor
  5635. * @returns a new Color4 object
  5636. */
  5637. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5638. /**
  5639. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5640. * @param left defines the start value
  5641. * @param right defines the end value
  5642. * @param amount defines the gradient factor
  5643. * @param result defines the Color4 object where to store data
  5644. */
  5645. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5646. /**
  5647. * Creates a new Color4 from a Color3 and an alpha value
  5648. * @param color3 defines the source Color3 to read from
  5649. * @param alpha defines the alpha component (1.0 by default)
  5650. * @returns a new Color4 object
  5651. */
  5652. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5653. /**
  5654. * Creates a new Color4 from the starting index element of the given array
  5655. * @param array defines the source array to read from
  5656. * @param offset defines the offset in the source array
  5657. * @returns a new Color4 object
  5658. */
  5659. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5660. /**
  5661. * Creates a new Color3 from integer values (< 256)
  5662. * @param r defines the red component to read from (value between 0 and 255)
  5663. * @param g defines the green component to read from (value between 0 and 255)
  5664. * @param b defines the blue component to read from (value between 0 and 255)
  5665. * @param a defines the alpha component to read from (value between 0 and 255)
  5666. * @returns a new Color3 object
  5667. */
  5668. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5669. /**
  5670. * Check the content of a given array and convert it to an array containing RGBA data
  5671. * If the original array was already containing count * 4 values then it is returned directly
  5672. * @param colors defines the array to check
  5673. * @param count defines the number of RGBA data to expect
  5674. * @returns an array containing count * 4 values (RGBA)
  5675. */
  5676. static CheckColors4(colors: number[], count: number): number[];
  5677. }
  5678. /**
  5679. * @hidden
  5680. */
  5681. export class TmpColors {
  5682. static Color3: Color3[];
  5683. static Color4: Color4[];
  5684. }
  5685. }
  5686. declare module "babylonjs/Animations/animationKey" {
  5687. /**
  5688. * Defines an interface which represents an animation key frame
  5689. */
  5690. export interface IAnimationKey {
  5691. /**
  5692. * Frame of the key frame
  5693. */
  5694. frame: number;
  5695. /**
  5696. * Value at the specifies key frame
  5697. */
  5698. value: any;
  5699. /**
  5700. * The input tangent for the cubic hermite spline
  5701. */
  5702. inTangent?: any;
  5703. /**
  5704. * The output tangent for the cubic hermite spline
  5705. */
  5706. outTangent?: any;
  5707. /**
  5708. * The animation interpolation type
  5709. */
  5710. interpolation?: AnimationKeyInterpolation;
  5711. }
  5712. /**
  5713. * Enum for the animation key frame interpolation type
  5714. */
  5715. export enum AnimationKeyInterpolation {
  5716. /**
  5717. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5718. */
  5719. STEP = 1
  5720. }
  5721. }
  5722. declare module "babylonjs/Animations/animationRange" {
  5723. /**
  5724. * Represents the range of an animation
  5725. */
  5726. export class AnimationRange {
  5727. /**The name of the animation range**/
  5728. name: string;
  5729. /**The starting frame of the animation */
  5730. from: number;
  5731. /**The ending frame of the animation*/
  5732. to: number;
  5733. /**
  5734. * Initializes the range of an animation
  5735. * @param name The name of the animation range
  5736. * @param from The starting frame of the animation
  5737. * @param to The ending frame of the animation
  5738. */
  5739. constructor(
  5740. /**The name of the animation range**/
  5741. name: string,
  5742. /**The starting frame of the animation */
  5743. from: number,
  5744. /**The ending frame of the animation*/
  5745. to: number);
  5746. /**
  5747. * Makes a copy of the animation range
  5748. * @returns A copy of the animation range
  5749. */
  5750. clone(): AnimationRange;
  5751. }
  5752. }
  5753. declare module "babylonjs/Animations/animationEvent" {
  5754. /**
  5755. * Composed of a frame, and an action function
  5756. */
  5757. export class AnimationEvent {
  5758. /** The frame for which the event is triggered **/
  5759. frame: number;
  5760. /** The event to perform when triggered **/
  5761. action: (currentFrame: number) => void;
  5762. /** Specifies if the event should be triggered only once**/
  5763. onlyOnce?: boolean | undefined;
  5764. /**
  5765. * Specifies if the animation event is done
  5766. */
  5767. isDone: boolean;
  5768. /**
  5769. * Initializes the animation event
  5770. * @param frame The frame for which the event is triggered
  5771. * @param action The event to perform when triggered
  5772. * @param onlyOnce Specifies if the event should be triggered only once
  5773. */
  5774. constructor(
  5775. /** The frame for which the event is triggered **/
  5776. frame: number,
  5777. /** The event to perform when triggered **/
  5778. action: (currentFrame: number) => void,
  5779. /** Specifies if the event should be triggered only once**/
  5780. onlyOnce?: boolean | undefined);
  5781. /** @hidden */
  5782. _clone(): AnimationEvent;
  5783. }
  5784. }
  5785. declare module "babylonjs/Behaviors/behavior" {
  5786. import { Nullable } from "babylonjs/types";
  5787. /**
  5788. * Interface used to define a behavior
  5789. */
  5790. export interface Behavior<T> {
  5791. /** gets or sets behavior's name */
  5792. name: string;
  5793. /**
  5794. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5795. */
  5796. init(): void;
  5797. /**
  5798. * Called when the behavior is attached to a target
  5799. * @param target defines the target where the behavior is attached to
  5800. */
  5801. attach(target: T): void;
  5802. /**
  5803. * Called when the behavior is detached from its target
  5804. */
  5805. detach(): void;
  5806. }
  5807. /**
  5808. * Interface implemented by classes supporting behaviors
  5809. */
  5810. export interface IBehaviorAware<T> {
  5811. /**
  5812. * Attach a behavior
  5813. * @param behavior defines the behavior to attach
  5814. * @returns the current host
  5815. */
  5816. addBehavior(behavior: Behavior<T>): T;
  5817. /**
  5818. * Remove a behavior from the current object
  5819. * @param behavior defines the behavior to detach
  5820. * @returns the current host
  5821. */
  5822. removeBehavior(behavior: Behavior<T>): T;
  5823. /**
  5824. * Gets a behavior using its name to search
  5825. * @param name defines the name to search
  5826. * @returns the behavior or null if not found
  5827. */
  5828. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5829. }
  5830. }
  5831. declare module "babylonjs/Misc/smartArray" {
  5832. /**
  5833. * Defines an array and its length.
  5834. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5835. */
  5836. export interface ISmartArrayLike<T> {
  5837. /**
  5838. * The data of the array.
  5839. */
  5840. data: Array<T>;
  5841. /**
  5842. * The active length of the array.
  5843. */
  5844. length: number;
  5845. }
  5846. /**
  5847. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5848. */
  5849. export class SmartArray<T> implements ISmartArrayLike<T> {
  5850. /**
  5851. * The full set of data from the array.
  5852. */
  5853. data: Array<T>;
  5854. /**
  5855. * The active length of the array.
  5856. */
  5857. length: number;
  5858. protected _id: number;
  5859. /**
  5860. * Instantiates a Smart Array.
  5861. * @param capacity defines the default capacity of the array.
  5862. */
  5863. constructor(capacity: number);
  5864. /**
  5865. * Pushes a value at the end of the active data.
  5866. * @param value defines the object to push in the array.
  5867. */
  5868. push(value: T): void;
  5869. /**
  5870. * Iterates over the active data and apply the lambda to them.
  5871. * @param func defines the action to apply on each value.
  5872. */
  5873. forEach(func: (content: T) => void): void;
  5874. /**
  5875. * Sorts the full sets of data.
  5876. * @param compareFn defines the comparison function to apply.
  5877. */
  5878. sort(compareFn: (a: T, b: T) => number): void;
  5879. /**
  5880. * Resets the active data to an empty array.
  5881. */
  5882. reset(): void;
  5883. /**
  5884. * Releases all the data from the array as well as the array.
  5885. */
  5886. dispose(): void;
  5887. /**
  5888. * Concats the active data with a given array.
  5889. * @param array defines the data to concatenate with.
  5890. */
  5891. concat(array: any): void;
  5892. /**
  5893. * Returns the position of a value in the active data.
  5894. * @param value defines the value to find the index for
  5895. * @returns the index if found in the active data otherwise -1
  5896. */
  5897. indexOf(value: T): number;
  5898. /**
  5899. * Returns whether an element is part of the active data.
  5900. * @param value defines the value to look for
  5901. * @returns true if found in the active data otherwise false
  5902. */
  5903. contains(value: T): boolean;
  5904. private static _GlobalId;
  5905. }
  5906. /**
  5907. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5908. * The data in this array can only be present once
  5909. */
  5910. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5911. private _duplicateId;
  5912. /**
  5913. * Pushes a value at the end of the active data.
  5914. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5915. * @param value defines the object to push in the array.
  5916. */
  5917. push(value: T): void;
  5918. /**
  5919. * Pushes a value at the end of the active data.
  5920. * If the data is already present, it won t be added again
  5921. * @param value defines the object to push in the array.
  5922. * @returns true if added false if it was already present
  5923. */
  5924. pushNoDuplicate(value: T): boolean;
  5925. /**
  5926. * Resets the active data to an empty array.
  5927. */
  5928. reset(): void;
  5929. /**
  5930. * Concats the active data with a given array.
  5931. * This ensures no dupplicate will be present in the result.
  5932. * @param array defines the data to concatenate with.
  5933. */
  5934. concatWithNoDuplicate(array: any): void;
  5935. }
  5936. }
  5937. declare module "babylonjs/Cameras/cameraInputsManager" {
  5938. import { Nullable } from "babylonjs/types";
  5939. import { Camera } from "babylonjs/Cameras/camera";
  5940. /**
  5941. * @ignore
  5942. * This is a list of all the different input types that are available in the application.
  5943. * Fo instance: ArcRotateCameraGamepadInput...
  5944. */
  5945. export var CameraInputTypes: {};
  5946. /**
  5947. * This is the contract to implement in order to create a new input class.
  5948. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  5949. */
  5950. export interface ICameraInput<TCamera extends Camera> {
  5951. /**
  5952. * Defines the camera the input is attached to.
  5953. */
  5954. camera: Nullable<TCamera>;
  5955. /**
  5956. * Gets the class name of the current intput.
  5957. * @returns the class name
  5958. */
  5959. getClassName(): string;
  5960. /**
  5961. * Get the friendly name associated with the input class.
  5962. * @returns the input friendly name
  5963. */
  5964. getSimpleName(): string;
  5965. /**
  5966. * Attach the input controls to a specific dom element to get the input from.
  5967. * @param element Defines the element the controls should be listened from
  5968. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5969. */
  5970. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5971. /**
  5972. * Detach the current controls from the specified dom element.
  5973. * @param element Defines the element to stop listening the inputs from
  5974. */
  5975. detachControl(element: Nullable<HTMLElement>): void;
  5976. /**
  5977. * Update the current camera state depending on the inputs that have been used this frame.
  5978. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5979. */
  5980. checkInputs?: () => void;
  5981. }
  5982. /**
  5983. * Represents a map of input types to input instance or input index to input instance.
  5984. */
  5985. export interface CameraInputsMap<TCamera extends Camera> {
  5986. /**
  5987. * Accessor to the input by input type.
  5988. */
  5989. [name: string]: ICameraInput<TCamera>;
  5990. /**
  5991. * Accessor to the input by input index.
  5992. */
  5993. [idx: number]: ICameraInput<TCamera>;
  5994. }
  5995. /**
  5996. * This represents the input manager used within a camera.
  5997. * It helps dealing with all the different kind of input attached to a camera.
  5998. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  5999. */
  6000. export class CameraInputsManager<TCamera extends Camera> {
  6001. /**
  6002. * Defines the list of inputs attahed to the camera.
  6003. */
  6004. attached: CameraInputsMap<TCamera>;
  6005. /**
  6006. * Defines the dom element the camera is collecting inputs from.
  6007. * This is null if the controls have not been attached.
  6008. */
  6009. attachedElement: Nullable<HTMLElement>;
  6010. /**
  6011. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6012. */
  6013. noPreventDefault: boolean;
  6014. /**
  6015. * Defined the camera the input manager belongs to.
  6016. */
  6017. camera: TCamera;
  6018. /**
  6019. * Update the current camera state depending on the inputs that have been used this frame.
  6020. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6021. */
  6022. checkInputs: () => void;
  6023. /**
  6024. * Instantiate a new Camera Input Manager.
  6025. * @param camera Defines the camera the input manager blongs to
  6026. */
  6027. constructor(camera: TCamera);
  6028. /**
  6029. * Add an input method to a camera
  6030. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6031. * @param input camera input method
  6032. */
  6033. add(input: ICameraInput<TCamera>): void;
  6034. /**
  6035. * Remove a specific input method from a camera
  6036. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6037. * @param inputToRemove camera input method
  6038. */
  6039. remove(inputToRemove: ICameraInput<TCamera>): void;
  6040. /**
  6041. * Remove a specific input type from a camera
  6042. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6043. * @param inputType the type of the input to remove
  6044. */
  6045. removeByType(inputType: string): void;
  6046. private _addCheckInputs;
  6047. /**
  6048. * Attach the input controls to the currently attached dom element to listen the events from.
  6049. * @param input Defines the input to attach
  6050. */
  6051. attachInput(input: ICameraInput<TCamera>): void;
  6052. /**
  6053. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6054. * @param element Defines the dom element to collect the events from
  6055. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6056. */
  6057. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6058. /**
  6059. * Detach the current manager inputs controls from a specific dom element.
  6060. * @param element Defines the dom element to collect the events from
  6061. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6062. */
  6063. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6064. /**
  6065. * Rebuild the dynamic inputCheck function from the current list of
  6066. * defined inputs in the manager.
  6067. */
  6068. rebuildInputCheck(): void;
  6069. /**
  6070. * Remove all attached input methods from a camera
  6071. */
  6072. clear(): void;
  6073. /**
  6074. * Serialize the current input manager attached to a camera.
  6075. * This ensures than once parsed,
  6076. * the input associated to the camera will be identical to the current ones
  6077. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6078. */
  6079. serialize(serializedCamera: any): void;
  6080. /**
  6081. * Parses an input manager serialized JSON to restore the previous list of inputs
  6082. * and states associated to a camera.
  6083. * @param parsedCamera Defines the JSON to parse
  6084. */
  6085. parse(parsedCamera: any): void;
  6086. }
  6087. }
  6088. declare module "babylonjs/Meshes/buffer" {
  6089. import { Nullable, DataArray } from "babylonjs/types";
  6090. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6091. /**
  6092. * Class used to store data that will be store in GPU memory
  6093. */
  6094. export class Buffer {
  6095. private _engine;
  6096. private _buffer;
  6097. /** @hidden */
  6098. _data: Nullable<DataArray>;
  6099. private _updatable;
  6100. private _instanced;
  6101. /**
  6102. * Gets the byte stride.
  6103. */
  6104. readonly byteStride: number;
  6105. /**
  6106. * Constructor
  6107. * @param engine the engine
  6108. * @param data the data to use for this buffer
  6109. * @param updatable whether the data is updatable
  6110. * @param stride the stride (optional)
  6111. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6112. * @param instanced whether the buffer is instanced (optional)
  6113. * @param useBytes set to true if the stride in in bytes (optional)
  6114. */
  6115. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6116. /**
  6117. * Create a new VertexBuffer based on the current buffer
  6118. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6119. * @param offset defines offset in the buffer (0 by default)
  6120. * @param size defines the size in floats of attributes (position is 3 for instance)
  6121. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6122. * @param instanced defines if the vertex buffer contains indexed data
  6123. * @param useBytes defines if the offset and stride are in bytes
  6124. * @returns the new vertex buffer
  6125. */
  6126. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6127. /**
  6128. * Gets a boolean indicating if the Buffer is updatable?
  6129. * @returns true if the buffer is updatable
  6130. */
  6131. isUpdatable(): boolean;
  6132. /**
  6133. * Gets current buffer's data
  6134. * @returns a DataArray or null
  6135. */
  6136. getData(): Nullable<DataArray>;
  6137. /**
  6138. * Gets underlying native buffer
  6139. * @returns underlying native buffer
  6140. */
  6141. getBuffer(): Nullable<DataBuffer>;
  6142. /**
  6143. * Gets the stride in float32 units (i.e. byte stride / 4).
  6144. * May not be an integer if the byte stride is not divisible by 4.
  6145. * DEPRECATED. Use byteStride instead.
  6146. * @returns the stride in float32 units
  6147. */
  6148. getStrideSize(): number;
  6149. /**
  6150. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6151. * @param data defines the data to store
  6152. */
  6153. create(data?: Nullable<DataArray>): void;
  6154. /** @hidden */
  6155. _rebuild(): void;
  6156. /**
  6157. * Update current buffer data
  6158. * @param data defines the data to store
  6159. */
  6160. update(data: DataArray): void;
  6161. /**
  6162. * Updates the data directly.
  6163. * @param data the new data
  6164. * @param offset the new offset
  6165. * @param vertexCount the vertex count (optional)
  6166. * @param useBytes set to true if the offset is in bytes
  6167. */
  6168. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6169. /**
  6170. * Release all resources
  6171. */
  6172. dispose(): void;
  6173. }
  6174. /**
  6175. * Specialized buffer used to store vertex data
  6176. */
  6177. export class VertexBuffer {
  6178. /** @hidden */
  6179. _buffer: Buffer;
  6180. private _kind;
  6181. private _size;
  6182. private _ownsBuffer;
  6183. private _instanced;
  6184. private _instanceDivisor;
  6185. /**
  6186. * The byte type.
  6187. */
  6188. static readonly BYTE: number;
  6189. /**
  6190. * The unsigned byte type.
  6191. */
  6192. static readonly UNSIGNED_BYTE: number;
  6193. /**
  6194. * The short type.
  6195. */
  6196. static readonly SHORT: number;
  6197. /**
  6198. * The unsigned short type.
  6199. */
  6200. static readonly UNSIGNED_SHORT: number;
  6201. /**
  6202. * The integer type.
  6203. */
  6204. static readonly INT: number;
  6205. /**
  6206. * The unsigned integer type.
  6207. */
  6208. static readonly UNSIGNED_INT: number;
  6209. /**
  6210. * The float type.
  6211. */
  6212. static readonly FLOAT: number;
  6213. /**
  6214. * Gets or sets the instance divisor when in instanced mode
  6215. */
  6216. instanceDivisor: number;
  6217. /**
  6218. * Gets the byte stride.
  6219. */
  6220. readonly byteStride: number;
  6221. /**
  6222. * Gets the byte offset.
  6223. */
  6224. readonly byteOffset: number;
  6225. /**
  6226. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6227. */
  6228. readonly normalized: boolean;
  6229. /**
  6230. * Gets the data type of each component in the array.
  6231. */
  6232. readonly type: number;
  6233. /**
  6234. * Constructor
  6235. * @param engine the engine
  6236. * @param data the data to use for this vertex buffer
  6237. * @param kind the vertex buffer kind
  6238. * @param updatable whether the data is updatable
  6239. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6240. * @param stride the stride (optional)
  6241. * @param instanced whether the buffer is instanced (optional)
  6242. * @param offset the offset of the data (optional)
  6243. * @param size the number of components (optional)
  6244. * @param type the type of the component (optional)
  6245. * @param normalized whether the data contains normalized data (optional)
  6246. * @param useBytes set to true if stride and offset are in bytes (optional)
  6247. */
  6248. 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);
  6249. /** @hidden */
  6250. _rebuild(): void;
  6251. /**
  6252. * Returns the kind of the VertexBuffer (string)
  6253. * @returns a string
  6254. */
  6255. getKind(): string;
  6256. /**
  6257. * Gets a boolean indicating if the VertexBuffer is updatable?
  6258. * @returns true if the buffer is updatable
  6259. */
  6260. isUpdatable(): boolean;
  6261. /**
  6262. * Gets current buffer's data
  6263. * @returns a DataArray or null
  6264. */
  6265. getData(): Nullable<DataArray>;
  6266. /**
  6267. * Gets underlying native buffer
  6268. * @returns underlying native buffer
  6269. */
  6270. getBuffer(): Nullable<DataBuffer>;
  6271. /**
  6272. * Gets the stride in float32 units (i.e. byte stride / 4).
  6273. * May not be an integer if the byte stride is not divisible by 4.
  6274. * DEPRECATED. Use byteStride instead.
  6275. * @returns the stride in float32 units
  6276. */
  6277. getStrideSize(): number;
  6278. /**
  6279. * Returns the offset as a multiple of the type byte length.
  6280. * DEPRECATED. Use byteOffset instead.
  6281. * @returns the offset in bytes
  6282. */
  6283. getOffset(): number;
  6284. /**
  6285. * Returns the number of components per vertex attribute (integer)
  6286. * @returns the size in float
  6287. */
  6288. getSize(): number;
  6289. /**
  6290. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6291. * @returns true if this buffer is instanced
  6292. */
  6293. getIsInstanced(): boolean;
  6294. /**
  6295. * Returns the instancing divisor, zero for non-instanced (integer).
  6296. * @returns a number
  6297. */
  6298. getInstanceDivisor(): number;
  6299. /**
  6300. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6301. * @param data defines the data to store
  6302. */
  6303. create(data?: DataArray): void;
  6304. /**
  6305. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6306. * This function will create a new buffer if the current one is not updatable
  6307. * @param data defines the data to store
  6308. */
  6309. update(data: DataArray): void;
  6310. /**
  6311. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6312. * Returns the directly updated WebGLBuffer.
  6313. * @param data the new data
  6314. * @param offset the new offset
  6315. * @param useBytes set to true if the offset is in bytes
  6316. */
  6317. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6318. /**
  6319. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6320. */
  6321. dispose(): void;
  6322. /**
  6323. * Enumerates each value of this vertex buffer as numbers.
  6324. * @param count the number of values to enumerate
  6325. * @param callback the callback function called for each value
  6326. */
  6327. forEach(count: number, callback: (value: number, index: number) => void): void;
  6328. /**
  6329. * Positions
  6330. */
  6331. static readonly PositionKind: string;
  6332. /**
  6333. * Normals
  6334. */
  6335. static readonly NormalKind: string;
  6336. /**
  6337. * Tangents
  6338. */
  6339. static readonly TangentKind: string;
  6340. /**
  6341. * Texture coordinates
  6342. */
  6343. static readonly UVKind: string;
  6344. /**
  6345. * Texture coordinates 2
  6346. */
  6347. static readonly UV2Kind: string;
  6348. /**
  6349. * Texture coordinates 3
  6350. */
  6351. static readonly UV3Kind: string;
  6352. /**
  6353. * Texture coordinates 4
  6354. */
  6355. static readonly UV4Kind: string;
  6356. /**
  6357. * Texture coordinates 5
  6358. */
  6359. static readonly UV5Kind: string;
  6360. /**
  6361. * Texture coordinates 6
  6362. */
  6363. static readonly UV6Kind: string;
  6364. /**
  6365. * Colors
  6366. */
  6367. static readonly ColorKind: string;
  6368. /**
  6369. * Matrix indices (for bones)
  6370. */
  6371. static readonly MatricesIndicesKind: string;
  6372. /**
  6373. * Matrix weights (for bones)
  6374. */
  6375. static readonly MatricesWeightsKind: string;
  6376. /**
  6377. * Additional matrix indices (for bones)
  6378. */
  6379. static readonly MatricesIndicesExtraKind: string;
  6380. /**
  6381. * Additional matrix weights (for bones)
  6382. */
  6383. static readonly MatricesWeightsExtraKind: string;
  6384. /**
  6385. * Deduces the stride given a kind.
  6386. * @param kind The kind string to deduce
  6387. * @returns The deduced stride
  6388. */
  6389. static DeduceStride(kind: string): number;
  6390. /**
  6391. * Gets the byte length of the given type.
  6392. * @param type the type
  6393. * @returns the number of bytes
  6394. */
  6395. static GetTypeByteLength(type: number): number;
  6396. /**
  6397. * Enumerates each value of the given parameters as numbers.
  6398. * @param data the data to enumerate
  6399. * @param byteOffset the byte offset of the data
  6400. * @param byteStride the byte stride of the data
  6401. * @param componentCount the number of components per element
  6402. * @param componentType the type of the component
  6403. * @param count the number of values to enumerate
  6404. * @param normalized whether the data is normalized
  6405. * @param callback the callback function called for each value
  6406. */
  6407. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6408. private static _GetFloatValue;
  6409. }
  6410. }
  6411. declare module "babylonjs/Collisions/intersectionInfo" {
  6412. import { Nullable } from "babylonjs/types";
  6413. /**
  6414. * @hidden
  6415. */
  6416. export class IntersectionInfo {
  6417. bu: Nullable<number>;
  6418. bv: Nullable<number>;
  6419. distance: number;
  6420. faceId: number;
  6421. subMeshId: number;
  6422. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6423. }
  6424. }
  6425. declare module "babylonjs/Maths/math.plane" {
  6426. import { DeepImmutable } from "babylonjs/types";
  6427. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6428. /**
  6429. * Represens a plane by the equation ax + by + cz + d = 0
  6430. */
  6431. export class Plane {
  6432. private static _TmpMatrix;
  6433. /**
  6434. * Normal of the plane (a,b,c)
  6435. */
  6436. normal: Vector3;
  6437. /**
  6438. * d component of the plane
  6439. */
  6440. d: number;
  6441. /**
  6442. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6443. * @param a a component of the plane
  6444. * @param b b component of the plane
  6445. * @param c c component of the plane
  6446. * @param d d component of the plane
  6447. */
  6448. constructor(a: number, b: number, c: number, d: number);
  6449. /**
  6450. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6451. */
  6452. asArray(): number[];
  6453. /**
  6454. * @returns a new plane copied from the current Plane.
  6455. */
  6456. clone(): Plane;
  6457. /**
  6458. * @returns the string "Plane".
  6459. */
  6460. getClassName(): string;
  6461. /**
  6462. * @returns the Plane hash code.
  6463. */
  6464. getHashCode(): number;
  6465. /**
  6466. * Normalize the current Plane in place.
  6467. * @returns the updated Plane.
  6468. */
  6469. normalize(): Plane;
  6470. /**
  6471. * Applies a transformation the plane and returns the result
  6472. * @param transformation the transformation matrix to be applied to the plane
  6473. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6474. */
  6475. transform(transformation: DeepImmutable<Matrix>): Plane;
  6476. /**
  6477. * Calcualtte the dot product between the point and the plane normal
  6478. * @param point point to calculate the dot product with
  6479. * @returns the dot product (float) of the point coordinates and the plane normal.
  6480. */
  6481. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6482. /**
  6483. * Updates the current Plane from the plane defined by the three given points.
  6484. * @param point1 one of the points used to contruct the plane
  6485. * @param point2 one of the points used to contruct the plane
  6486. * @param point3 one of the points used to contruct the plane
  6487. * @returns the updated Plane.
  6488. */
  6489. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6490. /**
  6491. * Checks if the plane is facing a given direction
  6492. * @param direction the direction to check if the plane is facing
  6493. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6494. * @returns True is the vector "direction" is the same side than the plane normal.
  6495. */
  6496. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6497. /**
  6498. * Calculates the distance to a point
  6499. * @param point point to calculate distance to
  6500. * @returns the signed distance (float) from the given point to the Plane.
  6501. */
  6502. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6503. /**
  6504. * Creates a plane from an array
  6505. * @param array the array to create a plane from
  6506. * @returns a new Plane from the given array.
  6507. */
  6508. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6509. /**
  6510. * Creates a plane from three points
  6511. * @param point1 point used to create the plane
  6512. * @param point2 point used to create the plane
  6513. * @param point3 point used to create the plane
  6514. * @returns a new Plane defined by the three given points.
  6515. */
  6516. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6517. /**
  6518. * Creates a plane from an origin point and a normal
  6519. * @param origin origin of the plane to be constructed
  6520. * @param normal normal of the plane to be constructed
  6521. * @returns a new Plane the normal vector to this plane at the given origin point.
  6522. * Note : the vector "normal" is updated because normalized.
  6523. */
  6524. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6525. /**
  6526. * Calculates the distance from a plane and a point
  6527. * @param origin origin of the plane to be constructed
  6528. * @param normal normal of the plane to be constructed
  6529. * @param point point to calculate distance to
  6530. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6531. */
  6532. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6533. }
  6534. }
  6535. declare module "babylonjs/Culling/boundingSphere" {
  6536. import { DeepImmutable } from "babylonjs/types";
  6537. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6538. import { Plane } from "babylonjs/Maths/math.plane";
  6539. /**
  6540. * Class used to store bounding sphere information
  6541. */
  6542. export class BoundingSphere {
  6543. /**
  6544. * Gets the center of the bounding sphere in local space
  6545. */
  6546. readonly center: Vector3;
  6547. /**
  6548. * Radius of the bounding sphere in local space
  6549. */
  6550. radius: number;
  6551. /**
  6552. * Gets the center of the bounding sphere in world space
  6553. */
  6554. readonly centerWorld: Vector3;
  6555. /**
  6556. * Radius of the bounding sphere in world space
  6557. */
  6558. radiusWorld: number;
  6559. /**
  6560. * Gets the minimum vector in local space
  6561. */
  6562. readonly minimum: Vector3;
  6563. /**
  6564. * Gets the maximum vector in local space
  6565. */
  6566. readonly maximum: Vector3;
  6567. private _worldMatrix;
  6568. private static readonly TmpVector3;
  6569. /**
  6570. * Creates a new bounding sphere
  6571. * @param min defines the minimum vector (in local space)
  6572. * @param max defines the maximum vector (in local space)
  6573. * @param worldMatrix defines the new world matrix
  6574. */
  6575. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6576. /**
  6577. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6578. * @param min defines the new minimum vector (in local space)
  6579. * @param max defines the new maximum vector (in local space)
  6580. * @param worldMatrix defines the new world matrix
  6581. */
  6582. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6583. /**
  6584. * Scale the current bounding sphere by applying a scale factor
  6585. * @param factor defines the scale factor to apply
  6586. * @returns the current bounding box
  6587. */
  6588. scale(factor: number): BoundingSphere;
  6589. /**
  6590. * Gets the world matrix of the bounding box
  6591. * @returns a matrix
  6592. */
  6593. getWorldMatrix(): DeepImmutable<Matrix>;
  6594. /** @hidden */
  6595. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6596. /**
  6597. * Tests if the bounding sphere is intersecting the frustum planes
  6598. * @param frustumPlanes defines the frustum planes to test
  6599. * @returns true if there is an intersection
  6600. */
  6601. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6602. /**
  6603. * Tests if the bounding sphere center is in between the frustum planes.
  6604. * Used for optimistic fast inclusion.
  6605. * @param frustumPlanes defines the frustum planes to test
  6606. * @returns true if the sphere center is in between the frustum planes
  6607. */
  6608. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6609. /**
  6610. * Tests if a point is inside the bounding sphere
  6611. * @param point defines the point to test
  6612. * @returns true if the point is inside the bounding sphere
  6613. */
  6614. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6615. /**
  6616. * Checks if two sphere intersct
  6617. * @param sphere0 sphere 0
  6618. * @param sphere1 sphere 1
  6619. * @returns true if the speres intersect
  6620. */
  6621. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6622. }
  6623. }
  6624. declare module "babylonjs/Culling/boundingBox" {
  6625. import { DeepImmutable } from "babylonjs/types";
  6626. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6627. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6628. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6629. import { Plane } from "babylonjs/Maths/math.plane";
  6630. /**
  6631. * Class used to store bounding box information
  6632. */
  6633. export class BoundingBox implements ICullable {
  6634. /**
  6635. * Gets the 8 vectors representing the bounding box in local space
  6636. */
  6637. readonly vectors: Vector3[];
  6638. /**
  6639. * Gets the center of the bounding box in local space
  6640. */
  6641. readonly center: Vector3;
  6642. /**
  6643. * Gets the center of the bounding box in world space
  6644. */
  6645. readonly centerWorld: Vector3;
  6646. /**
  6647. * Gets the extend size in local space
  6648. */
  6649. readonly extendSize: Vector3;
  6650. /**
  6651. * Gets the extend size in world space
  6652. */
  6653. readonly extendSizeWorld: Vector3;
  6654. /**
  6655. * Gets the OBB (object bounding box) directions
  6656. */
  6657. readonly directions: Vector3[];
  6658. /**
  6659. * Gets the 8 vectors representing the bounding box in world space
  6660. */
  6661. readonly vectorsWorld: Vector3[];
  6662. /**
  6663. * Gets the minimum vector in world space
  6664. */
  6665. readonly minimumWorld: Vector3;
  6666. /**
  6667. * Gets the maximum vector in world space
  6668. */
  6669. readonly maximumWorld: Vector3;
  6670. /**
  6671. * Gets the minimum vector in local space
  6672. */
  6673. readonly minimum: Vector3;
  6674. /**
  6675. * Gets the maximum vector in local space
  6676. */
  6677. readonly maximum: Vector3;
  6678. private _worldMatrix;
  6679. private static readonly TmpVector3;
  6680. /**
  6681. * @hidden
  6682. */
  6683. _tag: number;
  6684. /**
  6685. * Creates a new bounding box
  6686. * @param min defines the minimum vector (in local space)
  6687. * @param max defines the maximum vector (in local space)
  6688. * @param worldMatrix defines the new world matrix
  6689. */
  6690. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6691. /**
  6692. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6693. * @param min defines the new minimum vector (in local space)
  6694. * @param max defines the new maximum vector (in local space)
  6695. * @param worldMatrix defines the new world matrix
  6696. */
  6697. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6698. /**
  6699. * Scale the current bounding box by applying a scale factor
  6700. * @param factor defines the scale factor to apply
  6701. * @returns the current bounding box
  6702. */
  6703. scale(factor: number): BoundingBox;
  6704. /**
  6705. * Gets the world matrix of the bounding box
  6706. * @returns a matrix
  6707. */
  6708. getWorldMatrix(): DeepImmutable<Matrix>;
  6709. /** @hidden */
  6710. _update(world: DeepImmutable<Matrix>): void;
  6711. /**
  6712. * Tests if the bounding box is intersecting the frustum planes
  6713. * @param frustumPlanes defines the frustum planes to test
  6714. * @returns true if there is an intersection
  6715. */
  6716. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6717. /**
  6718. * Tests if the bounding box is entirely inside the frustum planes
  6719. * @param frustumPlanes defines the frustum planes to test
  6720. * @returns true if there is an inclusion
  6721. */
  6722. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6723. /**
  6724. * Tests if a point is inside the bounding box
  6725. * @param point defines the point to test
  6726. * @returns true if the point is inside the bounding box
  6727. */
  6728. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6729. /**
  6730. * Tests if the bounding box intersects with a bounding sphere
  6731. * @param sphere defines the sphere to test
  6732. * @returns true if there is an intersection
  6733. */
  6734. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6735. /**
  6736. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6737. * @param min defines the min vector to use
  6738. * @param max defines the max vector to use
  6739. * @returns true if there is an intersection
  6740. */
  6741. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6742. /**
  6743. * Tests if two bounding boxes are intersections
  6744. * @param box0 defines the first box to test
  6745. * @param box1 defines the second box to test
  6746. * @returns true if there is an intersection
  6747. */
  6748. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6749. /**
  6750. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6751. * @param minPoint defines the minimum vector of the bounding box
  6752. * @param maxPoint defines the maximum vector of the bounding box
  6753. * @param sphereCenter defines the sphere center
  6754. * @param sphereRadius defines the sphere radius
  6755. * @returns true if there is an intersection
  6756. */
  6757. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6758. /**
  6759. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6760. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6761. * @param frustumPlanes defines the frustum planes to test
  6762. * @return true if there is an inclusion
  6763. */
  6764. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6765. /**
  6766. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6767. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6768. * @param frustumPlanes defines the frustum planes to test
  6769. * @return true if there is an intersection
  6770. */
  6771. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6772. }
  6773. }
  6774. declare module "babylonjs/Collisions/collider" {
  6775. import { Nullable, IndicesArray } from "babylonjs/types";
  6776. import { Vector3 } from "babylonjs/Maths/math.vector";
  6777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6778. import { Plane } from "babylonjs/Maths/math.plane";
  6779. /** @hidden */
  6780. export class Collider {
  6781. /** Define if a collision was found */
  6782. collisionFound: boolean;
  6783. /**
  6784. * Define last intersection point in local space
  6785. */
  6786. intersectionPoint: Vector3;
  6787. /**
  6788. * Define last collided mesh
  6789. */
  6790. collidedMesh: Nullable<AbstractMesh>;
  6791. private _collisionPoint;
  6792. private _planeIntersectionPoint;
  6793. private _tempVector;
  6794. private _tempVector2;
  6795. private _tempVector3;
  6796. private _tempVector4;
  6797. private _edge;
  6798. private _baseToVertex;
  6799. private _destinationPoint;
  6800. private _slidePlaneNormal;
  6801. private _displacementVector;
  6802. /** @hidden */
  6803. _radius: Vector3;
  6804. /** @hidden */
  6805. _retry: number;
  6806. private _velocity;
  6807. private _basePoint;
  6808. private _epsilon;
  6809. /** @hidden */
  6810. _velocityWorldLength: number;
  6811. /** @hidden */
  6812. _basePointWorld: Vector3;
  6813. private _velocityWorld;
  6814. private _normalizedVelocity;
  6815. /** @hidden */
  6816. _initialVelocity: Vector3;
  6817. /** @hidden */
  6818. _initialPosition: Vector3;
  6819. private _nearestDistance;
  6820. private _collisionMask;
  6821. collisionMask: number;
  6822. /**
  6823. * Gets the plane normal used to compute the sliding response (in local space)
  6824. */
  6825. readonly slidePlaneNormal: Vector3;
  6826. /** @hidden */
  6827. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6828. /** @hidden */
  6829. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6830. /** @hidden */
  6831. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6832. /** @hidden */
  6833. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6834. /** @hidden */
  6835. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6836. /** @hidden */
  6837. _getResponse(pos: Vector3, vel: Vector3): void;
  6838. }
  6839. }
  6840. declare module "babylonjs/Culling/boundingInfo" {
  6841. import { DeepImmutable } from "babylonjs/types";
  6842. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6843. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6844. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6845. import { Plane } from "babylonjs/Maths/math.plane";
  6846. import { Collider } from "babylonjs/Collisions/collider";
  6847. /**
  6848. * Interface for cullable objects
  6849. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6850. */
  6851. export interface ICullable {
  6852. /**
  6853. * Checks if the object or part of the object is in the frustum
  6854. * @param frustumPlanes Camera near/planes
  6855. * @returns true if the object is in frustum otherwise false
  6856. */
  6857. isInFrustum(frustumPlanes: Plane[]): boolean;
  6858. /**
  6859. * Checks if a cullable object (mesh...) is in the camera frustum
  6860. * Unlike isInFrustum this cheks the full bounding box
  6861. * @param frustumPlanes Camera near/planes
  6862. * @returns true if the object is in frustum otherwise false
  6863. */
  6864. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6865. }
  6866. /**
  6867. * Info for a bounding data of a mesh
  6868. */
  6869. export class BoundingInfo implements ICullable {
  6870. /**
  6871. * Bounding box for the mesh
  6872. */
  6873. readonly boundingBox: BoundingBox;
  6874. /**
  6875. * Bounding sphere for the mesh
  6876. */
  6877. readonly boundingSphere: BoundingSphere;
  6878. private _isLocked;
  6879. private static readonly TmpVector3;
  6880. /**
  6881. * Constructs bounding info
  6882. * @param minimum min vector of the bounding box/sphere
  6883. * @param maximum max vector of the bounding box/sphere
  6884. * @param worldMatrix defines the new world matrix
  6885. */
  6886. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6887. /**
  6888. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6889. * @param min defines the new minimum vector (in local space)
  6890. * @param max defines the new maximum vector (in local space)
  6891. * @param worldMatrix defines the new world matrix
  6892. */
  6893. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6894. /**
  6895. * min vector of the bounding box/sphere
  6896. */
  6897. readonly minimum: Vector3;
  6898. /**
  6899. * max vector of the bounding box/sphere
  6900. */
  6901. readonly maximum: Vector3;
  6902. /**
  6903. * If the info is locked and won't be updated to avoid perf overhead
  6904. */
  6905. isLocked: boolean;
  6906. /**
  6907. * Updates the bounding sphere and box
  6908. * @param world world matrix to be used to update
  6909. */
  6910. update(world: DeepImmutable<Matrix>): void;
  6911. /**
  6912. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6913. * @param center New center of the bounding info
  6914. * @param extend New extend of the bounding info
  6915. * @returns the current bounding info
  6916. */
  6917. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6918. /**
  6919. * Scale the current bounding info by applying a scale factor
  6920. * @param factor defines the scale factor to apply
  6921. * @returns the current bounding info
  6922. */
  6923. scale(factor: number): BoundingInfo;
  6924. /**
  6925. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6926. * @param frustumPlanes defines the frustum to test
  6927. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6928. * @returns true if the bounding info is in the frustum planes
  6929. */
  6930. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6931. /**
  6932. * Gets the world distance between the min and max points of the bounding box
  6933. */
  6934. readonly diagonalLength: number;
  6935. /**
  6936. * Checks if a cullable object (mesh...) is in the camera frustum
  6937. * Unlike isInFrustum this cheks the full bounding box
  6938. * @param frustumPlanes Camera near/planes
  6939. * @returns true if the object is in frustum otherwise false
  6940. */
  6941. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. /** @hidden */
  6943. _checkCollision(collider: Collider): boolean;
  6944. /**
  6945. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  6946. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6947. * @param point the point to check intersection with
  6948. * @returns if the point intersects
  6949. */
  6950. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6951. /**
  6952. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  6953. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6954. * @param boundingInfo the bounding info to check intersection with
  6955. * @param precise if the intersection should be done using OBB
  6956. * @returns if the bounding info intersects
  6957. */
  6958. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  6959. }
  6960. }
  6961. declare module "babylonjs/Maths/math.functions" {
  6962. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  6963. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  6964. /**
  6965. * Extracts minimum and maximum values from a list of indexed positions
  6966. * @param positions defines the positions to use
  6967. * @param indices defines the indices to the positions
  6968. * @param indexStart defines the start index
  6969. * @param indexCount defines the end index
  6970. * @param bias defines bias value to add to the result
  6971. * @return minimum and maximum values
  6972. */
  6973. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  6974. minimum: Vector3;
  6975. maximum: Vector3;
  6976. };
  6977. /**
  6978. * Extracts minimum and maximum values from a list of positions
  6979. * @param positions defines the positions to use
  6980. * @param start defines the start index in the positions array
  6981. * @param count defines the number of positions to handle
  6982. * @param bias defines bias value to add to the result
  6983. * @param stride defines the stride size to use (distance between two positions in the positions array)
  6984. * @return minimum and maximum values
  6985. */
  6986. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  6987. minimum: Vector3;
  6988. maximum: Vector3;
  6989. };
  6990. }
  6991. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  6992. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6993. /** @hidden */
  6994. export class WebGLDataBuffer extends DataBuffer {
  6995. private _buffer;
  6996. constructor(resource: WebGLBuffer);
  6997. readonly underlyingResource: any;
  6998. }
  6999. }
  7000. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7001. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7002. import { Nullable } from "babylonjs/types";
  7003. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7004. /** @hidden */
  7005. export class WebGLPipelineContext implements IPipelineContext {
  7006. engine: ThinEngine;
  7007. program: Nullable<WebGLProgram>;
  7008. context?: WebGLRenderingContext;
  7009. vertexShader?: WebGLShader;
  7010. fragmentShader?: WebGLShader;
  7011. isParallelCompiled: boolean;
  7012. onCompiled?: () => void;
  7013. transformFeedback?: WebGLTransformFeedback | null;
  7014. readonly isAsync: boolean;
  7015. readonly isReady: boolean;
  7016. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7017. }
  7018. }
  7019. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7020. import { FloatArray, Nullable } from "babylonjs/types";
  7021. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7022. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7023. module "babylonjs/Engines/thinEngine" {
  7024. interface ThinEngine {
  7025. /**
  7026. * Create an uniform buffer
  7027. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7028. * @param elements defines the content of the uniform buffer
  7029. * @returns the webGL uniform buffer
  7030. */
  7031. createUniformBuffer(elements: FloatArray): DataBuffer;
  7032. /**
  7033. * Create a dynamic uniform buffer
  7034. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7035. * @param elements defines the content of the uniform buffer
  7036. * @returns the webGL uniform buffer
  7037. */
  7038. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7039. /**
  7040. * Update an existing uniform buffer
  7041. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7042. * @param uniformBuffer defines the target uniform buffer
  7043. * @param elements defines the content to update
  7044. * @param offset defines the offset in the uniform buffer where update should start
  7045. * @param count defines the size of the data to update
  7046. */
  7047. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7048. /**
  7049. * Bind an uniform buffer to the current webGL context
  7050. * @param buffer defines the buffer to bind
  7051. */
  7052. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7053. /**
  7054. * Bind a buffer to the current webGL context at a given location
  7055. * @param buffer defines the buffer to bind
  7056. * @param location defines the index where to bind the buffer
  7057. */
  7058. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7059. /**
  7060. * Bind a specific block at a given index in a specific shader program
  7061. * @param pipelineContext defines the pipeline context to use
  7062. * @param blockName defines the block name
  7063. * @param index defines the index where to bind the block
  7064. */
  7065. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7066. }
  7067. }
  7068. }
  7069. declare module "babylonjs/Materials/uniformBuffer" {
  7070. import { Nullable, FloatArray } from "babylonjs/types";
  7071. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7072. import { Engine } from "babylonjs/Engines/engine";
  7073. import { Effect } from "babylonjs/Materials/effect";
  7074. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7075. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7076. import { Color3 } from "babylonjs/Maths/math.color";
  7077. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7078. /**
  7079. * Uniform buffer objects.
  7080. *
  7081. * Handles blocks of uniform on the GPU.
  7082. *
  7083. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7084. *
  7085. * For more information, please refer to :
  7086. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7087. */
  7088. export class UniformBuffer {
  7089. private _engine;
  7090. private _buffer;
  7091. private _data;
  7092. private _bufferData;
  7093. private _dynamic?;
  7094. private _uniformLocations;
  7095. private _uniformSizes;
  7096. private _uniformLocationPointer;
  7097. private _needSync;
  7098. private _noUBO;
  7099. private _currentEffect;
  7100. private static _MAX_UNIFORM_SIZE;
  7101. private static _tempBuffer;
  7102. /**
  7103. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7104. * This is dynamic to allow compat with webgl 1 and 2.
  7105. * You will need to pass the name of the uniform as well as the value.
  7106. */
  7107. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7108. /**
  7109. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7110. * This is dynamic to allow compat with webgl 1 and 2.
  7111. * You will need to pass the name of the uniform as well as the value.
  7112. */
  7113. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7114. /**
  7115. * Lambda to Update a single float in a uniform buffer.
  7116. * This is dynamic to allow compat with webgl 1 and 2.
  7117. * You will need to pass the name of the uniform as well as the value.
  7118. */
  7119. updateFloat: (name: string, x: number) => void;
  7120. /**
  7121. * Lambda to Update a vec2 of float in a uniform buffer.
  7122. * This is dynamic to allow compat with webgl 1 and 2.
  7123. * You will need to pass the name of the uniform as well as the value.
  7124. */
  7125. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7126. /**
  7127. * Lambda to Update a vec3 of float in a uniform buffer.
  7128. * This is dynamic to allow compat with webgl 1 and 2.
  7129. * You will need to pass the name of the uniform as well as the value.
  7130. */
  7131. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7132. /**
  7133. * Lambda to Update a vec4 of float in a uniform buffer.
  7134. * This is dynamic to allow compat with webgl 1 and 2.
  7135. * You will need to pass the name of the uniform as well as the value.
  7136. */
  7137. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7138. /**
  7139. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7140. * This is dynamic to allow compat with webgl 1 and 2.
  7141. * You will need to pass the name of the uniform as well as the value.
  7142. */
  7143. updateMatrix: (name: string, mat: Matrix) => void;
  7144. /**
  7145. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7146. * This is dynamic to allow compat with webgl 1 and 2.
  7147. * You will need to pass the name of the uniform as well as the value.
  7148. */
  7149. updateVector3: (name: string, vector: Vector3) => void;
  7150. /**
  7151. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7152. * This is dynamic to allow compat with webgl 1 and 2.
  7153. * You will need to pass the name of the uniform as well as the value.
  7154. */
  7155. updateVector4: (name: string, vector: Vector4) => void;
  7156. /**
  7157. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7158. * This is dynamic to allow compat with webgl 1 and 2.
  7159. * You will need to pass the name of the uniform as well as the value.
  7160. */
  7161. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7162. /**
  7163. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7164. * This is dynamic to allow compat with webgl 1 and 2.
  7165. * You will need to pass the name of the uniform as well as the value.
  7166. */
  7167. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7168. /**
  7169. * Instantiates a new Uniform buffer objects.
  7170. *
  7171. * Handles blocks of uniform on the GPU.
  7172. *
  7173. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7174. *
  7175. * For more information, please refer to :
  7176. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7177. * @param engine Define the engine the buffer is associated with
  7178. * @param data Define the data contained in the buffer
  7179. * @param dynamic Define if the buffer is updatable
  7180. */
  7181. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7182. /**
  7183. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7184. * or just falling back on setUniformXXX calls.
  7185. */
  7186. readonly useUbo: boolean;
  7187. /**
  7188. * Indicates if the WebGL underlying uniform buffer is in sync
  7189. * with the javascript cache data.
  7190. */
  7191. readonly isSync: boolean;
  7192. /**
  7193. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7194. * Also, a dynamic UniformBuffer will disable cache verification and always
  7195. * update the underlying WebGL uniform buffer to the GPU.
  7196. * @returns if Dynamic, otherwise false
  7197. */
  7198. isDynamic(): boolean;
  7199. /**
  7200. * The data cache on JS side.
  7201. * @returns the underlying data as a float array
  7202. */
  7203. getData(): Float32Array;
  7204. /**
  7205. * The underlying WebGL Uniform buffer.
  7206. * @returns the webgl buffer
  7207. */
  7208. getBuffer(): Nullable<DataBuffer>;
  7209. /**
  7210. * std140 layout specifies how to align data within an UBO structure.
  7211. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7212. * for specs.
  7213. */
  7214. private _fillAlignment;
  7215. /**
  7216. * Adds an uniform in the buffer.
  7217. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7218. * for the layout to be correct !
  7219. * @param name Name of the uniform, as used in the uniform block in the shader.
  7220. * @param size Data size, or data directly.
  7221. */
  7222. addUniform(name: string, size: number | number[]): void;
  7223. /**
  7224. * Adds a Matrix 4x4 to the uniform buffer.
  7225. * @param name Name of the uniform, as used in the uniform block in the shader.
  7226. * @param mat A 4x4 matrix.
  7227. */
  7228. addMatrix(name: string, mat: Matrix): void;
  7229. /**
  7230. * Adds a vec2 to the uniform buffer.
  7231. * @param name Name of the uniform, as used in the uniform block in the shader.
  7232. * @param x Define the x component value of the vec2
  7233. * @param y Define the y component value of the vec2
  7234. */
  7235. addFloat2(name: string, x: number, y: number): void;
  7236. /**
  7237. * Adds a vec3 to the uniform buffer.
  7238. * @param name Name of the uniform, as used in the uniform block in the shader.
  7239. * @param x Define the x component value of the vec3
  7240. * @param y Define the y component value of the vec3
  7241. * @param z Define the z component value of the vec3
  7242. */
  7243. addFloat3(name: string, x: number, y: number, z: number): void;
  7244. /**
  7245. * Adds a vec3 to the uniform buffer.
  7246. * @param name Name of the uniform, as used in the uniform block in the shader.
  7247. * @param color Define the vec3 from a Color
  7248. */
  7249. addColor3(name: string, color: Color3): void;
  7250. /**
  7251. * Adds a vec4 to the uniform buffer.
  7252. * @param name Name of the uniform, as used in the uniform block in the shader.
  7253. * @param color Define the rgb components from a Color
  7254. * @param alpha Define the a component of the vec4
  7255. */
  7256. addColor4(name: string, color: Color3, alpha: number): void;
  7257. /**
  7258. * Adds a vec3 to the uniform buffer.
  7259. * @param name Name of the uniform, as used in the uniform block in the shader.
  7260. * @param vector Define the vec3 components from a Vector
  7261. */
  7262. addVector3(name: string, vector: Vector3): void;
  7263. /**
  7264. * Adds a Matrix 3x3 to the uniform buffer.
  7265. * @param name Name of the uniform, as used in the uniform block in the shader.
  7266. */
  7267. addMatrix3x3(name: string): void;
  7268. /**
  7269. * Adds a Matrix 2x2 to the uniform buffer.
  7270. * @param name Name of the uniform, as used in the uniform block in the shader.
  7271. */
  7272. addMatrix2x2(name: string): void;
  7273. /**
  7274. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7275. */
  7276. create(): void;
  7277. /** @hidden */
  7278. _rebuild(): void;
  7279. /**
  7280. * Updates the WebGL Uniform Buffer on the GPU.
  7281. * If the `dynamic` flag is set to true, no cache comparison is done.
  7282. * Otherwise, the buffer will be updated only if the cache differs.
  7283. */
  7284. update(): void;
  7285. /**
  7286. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7287. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7288. * @param data Define the flattened data
  7289. * @param size Define the size of the data.
  7290. */
  7291. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7292. private _valueCache;
  7293. private _cacheMatrix;
  7294. private _updateMatrix3x3ForUniform;
  7295. private _updateMatrix3x3ForEffect;
  7296. private _updateMatrix2x2ForEffect;
  7297. private _updateMatrix2x2ForUniform;
  7298. private _updateFloatForEffect;
  7299. private _updateFloatForUniform;
  7300. private _updateFloat2ForEffect;
  7301. private _updateFloat2ForUniform;
  7302. private _updateFloat3ForEffect;
  7303. private _updateFloat3ForUniform;
  7304. private _updateFloat4ForEffect;
  7305. private _updateFloat4ForUniform;
  7306. private _updateMatrixForEffect;
  7307. private _updateMatrixForUniform;
  7308. private _updateVector3ForEffect;
  7309. private _updateVector3ForUniform;
  7310. private _updateVector4ForEffect;
  7311. private _updateVector4ForUniform;
  7312. private _updateColor3ForEffect;
  7313. private _updateColor3ForUniform;
  7314. private _updateColor4ForEffect;
  7315. private _updateColor4ForUniform;
  7316. /**
  7317. * Sets a sampler uniform on the effect.
  7318. * @param name Define the name of the sampler.
  7319. * @param texture Define the texture to set in the sampler
  7320. */
  7321. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7322. /**
  7323. * Directly updates the value of the uniform in the cache AND on the GPU.
  7324. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7325. * @param data Define the flattened data
  7326. */
  7327. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7328. /**
  7329. * Binds this uniform buffer to an effect.
  7330. * @param effect Define the effect to bind the buffer to
  7331. * @param name Name of the uniform block in the shader.
  7332. */
  7333. bindToEffect(effect: Effect, name: string): void;
  7334. /**
  7335. * Disposes the uniform buffer.
  7336. */
  7337. dispose(): void;
  7338. }
  7339. }
  7340. declare module "babylonjs/Misc/iInspectable" {
  7341. /**
  7342. * Enum that determines the text-wrapping mode to use.
  7343. */
  7344. export enum InspectableType {
  7345. /**
  7346. * Checkbox for booleans
  7347. */
  7348. Checkbox = 0,
  7349. /**
  7350. * Sliders for numbers
  7351. */
  7352. Slider = 1,
  7353. /**
  7354. * Vector3
  7355. */
  7356. Vector3 = 2,
  7357. /**
  7358. * Quaternions
  7359. */
  7360. Quaternion = 3,
  7361. /**
  7362. * Color3
  7363. */
  7364. Color3 = 4,
  7365. /**
  7366. * String
  7367. */
  7368. String = 5
  7369. }
  7370. /**
  7371. * Interface used to define custom inspectable properties.
  7372. * This interface is used by the inspector to display custom property grids
  7373. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7374. */
  7375. export interface IInspectable {
  7376. /**
  7377. * Gets the label to display
  7378. */
  7379. label: string;
  7380. /**
  7381. * Gets the name of the property to edit
  7382. */
  7383. propertyName: string;
  7384. /**
  7385. * Gets the type of the editor to use
  7386. */
  7387. type: InspectableType;
  7388. /**
  7389. * Gets the minimum value of the property when using in "slider" mode
  7390. */
  7391. min?: number;
  7392. /**
  7393. * Gets the maximum value of the property when using in "slider" mode
  7394. */
  7395. max?: number;
  7396. /**
  7397. * Gets the setp to use when using in "slider" mode
  7398. */
  7399. step?: number;
  7400. }
  7401. }
  7402. declare module "babylonjs/Misc/timingTools" {
  7403. /**
  7404. * Class used to provide helper for timing
  7405. */
  7406. export class TimingTools {
  7407. /**
  7408. * Polyfill for setImmediate
  7409. * @param action defines the action to execute after the current execution block
  7410. */
  7411. static SetImmediate(action: () => void): void;
  7412. }
  7413. }
  7414. declare module "babylonjs/Misc/instantiationTools" {
  7415. /**
  7416. * Class used to enable instatition of objects by class name
  7417. */
  7418. export class InstantiationTools {
  7419. /**
  7420. * Use this object to register external classes like custom textures or material
  7421. * to allow the laoders to instantiate them
  7422. */
  7423. static RegisteredExternalClasses: {
  7424. [key: string]: Object;
  7425. };
  7426. /**
  7427. * Tries to instantiate a new object from a given class name
  7428. * @param className defines the class name to instantiate
  7429. * @returns the new object or null if the system was not able to do the instantiation
  7430. */
  7431. static Instantiate(className: string): any;
  7432. }
  7433. }
  7434. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7435. /**
  7436. * Define options used to create a depth texture
  7437. */
  7438. export class DepthTextureCreationOptions {
  7439. /** Specifies whether or not a stencil should be allocated in the texture */
  7440. generateStencil?: boolean;
  7441. /** Specifies whether or not bilinear filtering is enable on the texture */
  7442. bilinearFiltering?: boolean;
  7443. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7444. comparisonFunction?: number;
  7445. /** Specifies if the created texture is a cube texture */
  7446. isCube?: boolean;
  7447. }
  7448. }
  7449. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7450. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7451. import { Nullable } from "babylonjs/types";
  7452. import { Scene } from "babylonjs/scene";
  7453. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7454. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7455. module "babylonjs/Engines/thinEngine" {
  7456. interface ThinEngine {
  7457. /**
  7458. * Creates a depth stencil cube texture.
  7459. * This is only available in WebGL 2.
  7460. * @param size The size of face edge in the cube texture.
  7461. * @param options The options defining the cube texture.
  7462. * @returns The cube texture
  7463. */
  7464. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7465. /**
  7466. * Creates a cube texture
  7467. * @param rootUrl defines the url where the files to load is located
  7468. * @param scene defines the current scene
  7469. * @param files defines the list of files to load (1 per face)
  7470. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7471. * @param onLoad defines an optional callback raised when the texture is loaded
  7472. * @param onError defines an optional callback raised if there is an issue to load the texture
  7473. * @param format defines the format of the data
  7474. * @param forcedExtension defines the extension to use to pick the right loader
  7475. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7476. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7477. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7478. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7479. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7480. * @returns the cube texture as an InternalTexture
  7481. */
  7482. 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;
  7483. /**
  7484. * Creates a cube texture
  7485. * @param rootUrl defines the url where the files to load is located
  7486. * @param scene defines the current scene
  7487. * @param files defines the list of files to load (1 per face)
  7488. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7489. * @param onLoad defines an optional callback raised when the texture is loaded
  7490. * @param onError defines an optional callback raised if there is an issue to load the texture
  7491. * @param format defines the format of the data
  7492. * @param forcedExtension defines the extension to use to pick the right loader
  7493. * @returns the cube texture as an InternalTexture
  7494. */
  7495. 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;
  7496. /**
  7497. * Creates a cube texture
  7498. * @param rootUrl defines the url where the files to load is located
  7499. * @param scene defines the current scene
  7500. * @param files defines the list of files to load (1 per face)
  7501. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7502. * @param onLoad defines an optional callback raised when the texture is loaded
  7503. * @param onError defines an optional callback raised if there is an issue to load the texture
  7504. * @param format defines the format of the data
  7505. * @param forcedExtension defines the extension to use to pick the right loader
  7506. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7507. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7508. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7509. * @returns the cube texture as an InternalTexture
  7510. */
  7511. 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;
  7512. /** @hidden */
  7513. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7514. /** @hidden */
  7515. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7516. /** @hidden */
  7517. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7518. /** @hidden */
  7519. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7520. }
  7521. }
  7522. }
  7523. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7524. import { Nullable } from "babylonjs/types";
  7525. import { Scene } from "babylonjs/scene";
  7526. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7527. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7528. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7529. /**
  7530. * Class for creating a cube texture
  7531. */
  7532. export class CubeTexture extends BaseTexture {
  7533. private _delayedOnLoad;
  7534. /**
  7535. * The url of the texture
  7536. */
  7537. url: string;
  7538. /**
  7539. * Gets or sets the center of the bounding box associated with the cube texture.
  7540. * It must define where the camera used to render the texture was set
  7541. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7542. */
  7543. boundingBoxPosition: Vector3;
  7544. private _boundingBoxSize;
  7545. /**
  7546. * Gets or sets the size of the bounding box associated with the cube texture
  7547. * When defined, the cubemap will switch to local mode
  7548. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7549. * @example https://www.babylonjs-playground.com/#RNASML
  7550. */
  7551. /**
  7552. * Returns the bounding box size
  7553. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7554. */
  7555. boundingBoxSize: Vector3;
  7556. protected _rotationY: number;
  7557. /**
  7558. * Sets texture matrix rotation angle around Y axis in radians.
  7559. */
  7560. /**
  7561. * Gets texture matrix rotation angle around Y axis radians.
  7562. */
  7563. rotationY: number;
  7564. /**
  7565. * Are mip maps generated for this texture or not.
  7566. */
  7567. readonly noMipmap: boolean;
  7568. private _noMipmap;
  7569. private _files;
  7570. protected _forcedExtension: Nullable<string>;
  7571. private _extensions;
  7572. private _textureMatrix;
  7573. private _format;
  7574. private _createPolynomials;
  7575. /** @hidden */
  7576. _prefiltered: boolean;
  7577. /**
  7578. * Creates a cube texture from an array of image urls
  7579. * @param files defines an array of image urls
  7580. * @param scene defines the hosting scene
  7581. * @param noMipmap specifies if mip maps are not used
  7582. * @returns a cube texture
  7583. */
  7584. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7585. /**
  7586. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7587. * @param url defines the url of the prefiltered texture
  7588. * @param scene defines the scene the texture is attached to
  7589. * @param forcedExtension defines the extension of the file if different from the url
  7590. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7591. * @return the prefiltered texture
  7592. */
  7593. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7594. /**
  7595. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7596. * as prefiltered data.
  7597. * @param rootUrl defines the url of the texture or the root name of the six images
  7598. * @param scene defines the scene the texture is attached to
  7599. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7600. * @param noMipmap defines if mipmaps should be created or not
  7601. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7602. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7603. * @param onError defines a callback triggered in case of error during load
  7604. * @param format defines the internal format to use for the texture once loaded
  7605. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7606. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7607. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7608. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7609. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7610. * @return the cube texture
  7611. */
  7612. 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);
  7613. /**
  7614. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7615. */
  7616. readonly isPrefiltered: boolean;
  7617. /**
  7618. * Get the current class name of the texture useful for serialization or dynamic coding.
  7619. * @returns "CubeTexture"
  7620. */
  7621. getClassName(): string;
  7622. /**
  7623. * Update the url (and optional buffer) of this texture if url was null during construction.
  7624. * @param url the url of the texture
  7625. * @param forcedExtension defines the extension to use
  7626. * @param onLoad callback called when the texture is loaded (defaults to null)
  7627. */
  7628. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7629. /**
  7630. * Delays loading of the cube texture
  7631. * @param forcedExtension defines the extension to use
  7632. */
  7633. delayLoad(forcedExtension?: string): void;
  7634. /**
  7635. * Returns the reflection texture matrix
  7636. * @returns the reflection texture matrix
  7637. */
  7638. getReflectionTextureMatrix(): Matrix;
  7639. /**
  7640. * Sets the reflection texture matrix
  7641. * @param value Reflection texture matrix
  7642. */
  7643. setReflectionTextureMatrix(value: Matrix): void;
  7644. /**
  7645. * Parses text to create a cube texture
  7646. * @param parsedTexture define the serialized text to read from
  7647. * @param scene defines the hosting scene
  7648. * @param rootUrl defines the root url of the cube texture
  7649. * @returns a cube texture
  7650. */
  7651. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7652. /**
  7653. * Makes a clone, or deep copy, of the cube texture
  7654. * @returns a new cube texture
  7655. */
  7656. clone(): CubeTexture;
  7657. }
  7658. }
  7659. declare module "babylonjs/Materials/materialDefines" {
  7660. /**
  7661. * Manages the defines for the Material
  7662. */
  7663. export class MaterialDefines {
  7664. /** @hidden */
  7665. protected _keys: string[];
  7666. private _isDirty;
  7667. /** @hidden */
  7668. _renderId: number;
  7669. /** @hidden */
  7670. _areLightsDirty: boolean;
  7671. /** @hidden */
  7672. _areLightsDisposed: boolean;
  7673. /** @hidden */
  7674. _areAttributesDirty: boolean;
  7675. /** @hidden */
  7676. _areTexturesDirty: boolean;
  7677. /** @hidden */
  7678. _areFresnelDirty: boolean;
  7679. /** @hidden */
  7680. _areMiscDirty: boolean;
  7681. /** @hidden */
  7682. _areImageProcessingDirty: boolean;
  7683. /** @hidden */
  7684. _normals: boolean;
  7685. /** @hidden */
  7686. _uvs: boolean;
  7687. /** @hidden */
  7688. _needNormals: boolean;
  7689. /** @hidden */
  7690. _needUVs: boolean;
  7691. [id: string]: any;
  7692. /**
  7693. * Specifies if the material needs to be re-calculated
  7694. */
  7695. readonly isDirty: boolean;
  7696. /**
  7697. * Marks the material to indicate that it has been re-calculated
  7698. */
  7699. markAsProcessed(): void;
  7700. /**
  7701. * Marks the material to indicate that it needs to be re-calculated
  7702. */
  7703. markAsUnprocessed(): void;
  7704. /**
  7705. * Marks the material to indicate all of its defines need to be re-calculated
  7706. */
  7707. markAllAsDirty(): void;
  7708. /**
  7709. * Marks the material to indicate that image processing needs to be re-calculated
  7710. */
  7711. markAsImageProcessingDirty(): void;
  7712. /**
  7713. * Marks the material to indicate the lights need to be re-calculated
  7714. * @param disposed Defines whether the light is dirty due to dispose or not
  7715. */
  7716. markAsLightDirty(disposed?: boolean): void;
  7717. /**
  7718. * Marks the attribute state as changed
  7719. */
  7720. markAsAttributesDirty(): void;
  7721. /**
  7722. * Marks the texture state as changed
  7723. */
  7724. markAsTexturesDirty(): void;
  7725. /**
  7726. * Marks the fresnel state as changed
  7727. */
  7728. markAsFresnelDirty(): void;
  7729. /**
  7730. * Marks the misc state as changed
  7731. */
  7732. markAsMiscDirty(): void;
  7733. /**
  7734. * Rebuilds the material defines
  7735. */
  7736. rebuild(): void;
  7737. /**
  7738. * Specifies if two material defines are equal
  7739. * @param other - A material define instance to compare to
  7740. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7741. */
  7742. isEqual(other: MaterialDefines): boolean;
  7743. /**
  7744. * Clones this instance's defines to another instance
  7745. * @param other - material defines to clone values to
  7746. */
  7747. cloneTo(other: MaterialDefines): void;
  7748. /**
  7749. * Resets the material define values
  7750. */
  7751. reset(): void;
  7752. /**
  7753. * Converts the material define values to a string
  7754. * @returns - String of material define information
  7755. */
  7756. toString(): string;
  7757. }
  7758. }
  7759. declare module "babylonjs/Materials/colorCurves" {
  7760. import { Effect } from "babylonjs/Materials/effect";
  7761. /**
  7762. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7763. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7764. * 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;
  7765. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7766. */
  7767. export class ColorCurves {
  7768. private _dirty;
  7769. private _tempColor;
  7770. private _globalCurve;
  7771. private _highlightsCurve;
  7772. private _midtonesCurve;
  7773. private _shadowsCurve;
  7774. private _positiveCurve;
  7775. private _negativeCurve;
  7776. private _globalHue;
  7777. private _globalDensity;
  7778. private _globalSaturation;
  7779. private _globalExposure;
  7780. /**
  7781. * Gets the global Hue value.
  7782. * 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).
  7783. */
  7784. /**
  7785. * Sets the global Hue value.
  7786. * 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).
  7787. */
  7788. globalHue: number;
  7789. /**
  7790. * Gets the global Density value.
  7791. * 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.
  7792. * Values less than zero provide a filter of opposite hue.
  7793. */
  7794. /**
  7795. * Sets the global Density value.
  7796. * 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.
  7797. * Values less than zero provide a filter of opposite hue.
  7798. */
  7799. globalDensity: number;
  7800. /**
  7801. * Gets the global Saturation value.
  7802. * 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.
  7803. */
  7804. /**
  7805. * Sets the global Saturation value.
  7806. * 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.
  7807. */
  7808. globalSaturation: number;
  7809. /**
  7810. * Gets the global Exposure value.
  7811. * 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.
  7812. */
  7813. /**
  7814. * Sets the global Exposure value.
  7815. * 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.
  7816. */
  7817. globalExposure: number;
  7818. private _highlightsHue;
  7819. private _highlightsDensity;
  7820. private _highlightsSaturation;
  7821. private _highlightsExposure;
  7822. /**
  7823. * Gets the highlights Hue value.
  7824. * 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).
  7825. */
  7826. /**
  7827. * Sets the highlights Hue value.
  7828. * 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).
  7829. */
  7830. highlightsHue: number;
  7831. /**
  7832. * Gets the highlights Density value.
  7833. * 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.
  7834. * Values less than zero provide a filter of opposite hue.
  7835. */
  7836. /**
  7837. * Sets the highlights Density value.
  7838. * 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.
  7839. * Values less than zero provide a filter of opposite hue.
  7840. */
  7841. highlightsDensity: number;
  7842. /**
  7843. * Gets the highlights Saturation value.
  7844. * 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.
  7845. */
  7846. /**
  7847. * Sets the highlights Saturation value.
  7848. * 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.
  7849. */
  7850. highlightsSaturation: number;
  7851. /**
  7852. * Gets the highlights Exposure value.
  7853. * 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.
  7854. */
  7855. /**
  7856. * Sets the highlights Exposure value.
  7857. * 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.
  7858. */
  7859. highlightsExposure: number;
  7860. private _midtonesHue;
  7861. private _midtonesDensity;
  7862. private _midtonesSaturation;
  7863. private _midtonesExposure;
  7864. /**
  7865. * Gets the midtones Hue value.
  7866. * 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).
  7867. */
  7868. /**
  7869. * Sets the midtones Hue value.
  7870. * 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).
  7871. */
  7872. midtonesHue: number;
  7873. /**
  7874. * Gets the midtones Density value.
  7875. * 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.
  7876. * Values less than zero provide a filter of opposite hue.
  7877. */
  7878. /**
  7879. * Sets the midtones Density value.
  7880. * 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.
  7881. * Values less than zero provide a filter of opposite hue.
  7882. */
  7883. midtonesDensity: number;
  7884. /**
  7885. * Gets the midtones Saturation value.
  7886. * 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.
  7887. */
  7888. /**
  7889. * Sets the midtones Saturation value.
  7890. * 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.
  7891. */
  7892. midtonesSaturation: number;
  7893. /**
  7894. * Gets the midtones Exposure value.
  7895. * 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.
  7896. */
  7897. /**
  7898. * Sets the midtones Exposure value.
  7899. * 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.
  7900. */
  7901. midtonesExposure: number;
  7902. private _shadowsHue;
  7903. private _shadowsDensity;
  7904. private _shadowsSaturation;
  7905. private _shadowsExposure;
  7906. /**
  7907. * Gets the shadows Hue value.
  7908. * 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).
  7909. */
  7910. /**
  7911. * Sets the shadows Hue value.
  7912. * 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).
  7913. */
  7914. shadowsHue: number;
  7915. /**
  7916. * Gets the shadows Density value.
  7917. * 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.
  7918. * Values less than zero provide a filter of opposite hue.
  7919. */
  7920. /**
  7921. * Sets the shadows Density value.
  7922. * 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.
  7923. * Values less than zero provide a filter of opposite hue.
  7924. */
  7925. shadowsDensity: number;
  7926. /**
  7927. * Gets the shadows Saturation value.
  7928. * 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.
  7929. */
  7930. /**
  7931. * Sets the shadows Saturation value.
  7932. * 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.
  7933. */
  7934. shadowsSaturation: number;
  7935. /**
  7936. * Gets the shadows Exposure value.
  7937. * 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.
  7938. */
  7939. /**
  7940. * Sets the shadows Exposure value.
  7941. * 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.
  7942. */
  7943. shadowsExposure: number;
  7944. /**
  7945. * Returns the class name
  7946. * @returns The class name
  7947. */
  7948. getClassName(): string;
  7949. /**
  7950. * Binds the color curves to the shader.
  7951. * @param colorCurves The color curve to bind
  7952. * @param effect The effect to bind to
  7953. * @param positiveUniform The positive uniform shader parameter
  7954. * @param neutralUniform The neutral uniform shader parameter
  7955. * @param negativeUniform The negative uniform shader parameter
  7956. */
  7957. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7958. /**
  7959. * Prepare the list of uniforms associated with the ColorCurves effects.
  7960. * @param uniformsList The list of uniforms used in the effect
  7961. */
  7962. static PrepareUniforms(uniformsList: string[]): void;
  7963. /**
  7964. * Returns color grading data based on a hue, density, saturation and exposure value.
  7965. * @param filterHue The hue of the color filter.
  7966. * @param filterDensity The density of the color filter.
  7967. * @param saturation The saturation.
  7968. * @param exposure The exposure.
  7969. * @param result The result data container.
  7970. */
  7971. private getColorGradingDataToRef;
  7972. /**
  7973. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7974. * @param value The input slider value in range [-100,100].
  7975. * @returns Adjusted value.
  7976. */
  7977. private static applyColorGradingSliderNonlinear;
  7978. /**
  7979. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7980. * @param hue The hue (H) input.
  7981. * @param saturation The saturation (S) input.
  7982. * @param brightness The brightness (B) input.
  7983. * @result An RGBA color represented as Vector4.
  7984. */
  7985. private static fromHSBToRef;
  7986. /**
  7987. * Returns a value clamped between min and max
  7988. * @param value The value to clamp
  7989. * @param min The minimum of value
  7990. * @param max The maximum of value
  7991. * @returns The clamped value.
  7992. */
  7993. private static clamp;
  7994. /**
  7995. * Clones the current color curve instance.
  7996. * @return The cloned curves
  7997. */
  7998. clone(): ColorCurves;
  7999. /**
  8000. * Serializes the current color curve instance to a json representation.
  8001. * @return a JSON representation
  8002. */
  8003. serialize(): any;
  8004. /**
  8005. * Parses the color curve from a json representation.
  8006. * @param source the JSON source to parse
  8007. * @return The parsed curves
  8008. */
  8009. static Parse(source: any): ColorCurves;
  8010. }
  8011. }
  8012. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8013. import { Observable } from "babylonjs/Misc/observable";
  8014. import { Nullable } from "babylonjs/types";
  8015. import { Color4 } from "babylonjs/Maths/math.color";
  8016. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8017. import { Effect } from "babylonjs/Materials/effect";
  8018. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8019. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8020. /**
  8021. * Interface to follow in your material defines to integrate easily the
  8022. * Image proccessing functions.
  8023. * @hidden
  8024. */
  8025. export interface IImageProcessingConfigurationDefines {
  8026. IMAGEPROCESSING: boolean;
  8027. VIGNETTE: boolean;
  8028. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8029. VIGNETTEBLENDMODEOPAQUE: boolean;
  8030. TONEMAPPING: boolean;
  8031. TONEMAPPING_ACES: boolean;
  8032. CONTRAST: boolean;
  8033. EXPOSURE: boolean;
  8034. COLORCURVES: boolean;
  8035. COLORGRADING: boolean;
  8036. COLORGRADING3D: boolean;
  8037. SAMPLER3DGREENDEPTH: boolean;
  8038. SAMPLER3DBGRMAP: boolean;
  8039. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8040. }
  8041. /**
  8042. * @hidden
  8043. */
  8044. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8045. IMAGEPROCESSING: boolean;
  8046. VIGNETTE: boolean;
  8047. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8048. VIGNETTEBLENDMODEOPAQUE: boolean;
  8049. TONEMAPPING: boolean;
  8050. TONEMAPPING_ACES: boolean;
  8051. CONTRAST: boolean;
  8052. COLORCURVES: boolean;
  8053. COLORGRADING: boolean;
  8054. COLORGRADING3D: boolean;
  8055. SAMPLER3DGREENDEPTH: boolean;
  8056. SAMPLER3DBGRMAP: boolean;
  8057. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8058. EXPOSURE: boolean;
  8059. constructor();
  8060. }
  8061. /**
  8062. * This groups together the common properties used for image processing either in direct forward pass
  8063. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8064. * or not.
  8065. */
  8066. export class ImageProcessingConfiguration {
  8067. /**
  8068. * Default tone mapping applied in BabylonJS.
  8069. */
  8070. static readonly TONEMAPPING_STANDARD: number;
  8071. /**
  8072. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8073. * to other engines rendering to increase portability.
  8074. */
  8075. static readonly TONEMAPPING_ACES: number;
  8076. /**
  8077. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8078. */
  8079. colorCurves: Nullable<ColorCurves>;
  8080. private _colorCurvesEnabled;
  8081. /**
  8082. * Gets wether the color curves effect is enabled.
  8083. */
  8084. /**
  8085. * Sets wether the color curves effect is enabled.
  8086. */
  8087. colorCurvesEnabled: boolean;
  8088. private _colorGradingTexture;
  8089. /**
  8090. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8091. */
  8092. /**
  8093. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8094. */
  8095. colorGradingTexture: Nullable<BaseTexture>;
  8096. private _colorGradingEnabled;
  8097. /**
  8098. * Gets wether the color grading effect is enabled.
  8099. */
  8100. /**
  8101. * Sets wether the color grading effect is enabled.
  8102. */
  8103. colorGradingEnabled: boolean;
  8104. private _colorGradingWithGreenDepth;
  8105. /**
  8106. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8107. */
  8108. /**
  8109. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8110. */
  8111. colorGradingWithGreenDepth: boolean;
  8112. private _colorGradingBGR;
  8113. /**
  8114. * Gets wether the color grading texture contains BGR values.
  8115. */
  8116. /**
  8117. * Sets wether the color grading texture contains BGR values.
  8118. */
  8119. colorGradingBGR: boolean;
  8120. /** @hidden */
  8121. _exposure: number;
  8122. /**
  8123. * Gets the Exposure used in the effect.
  8124. */
  8125. /**
  8126. * Sets the Exposure used in the effect.
  8127. */
  8128. exposure: number;
  8129. private _toneMappingEnabled;
  8130. /**
  8131. * Gets wether the tone mapping effect is enabled.
  8132. */
  8133. /**
  8134. * Sets wether the tone mapping effect is enabled.
  8135. */
  8136. toneMappingEnabled: boolean;
  8137. private _toneMappingType;
  8138. /**
  8139. * Gets the type of tone mapping effect.
  8140. */
  8141. /**
  8142. * Sets the type of tone mapping effect used in BabylonJS.
  8143. */
  8144. toneMappingType: number;
  8145. protected _contrast: number;
  8146. /**
  8147. * Gets the contrast used in the effect.
  8148. */
  8149. /**
  8150. * Sets the contrast used in the effect.
  8151. */
  8152. contrast: number;
  8153. /**
  8154. * Vignette stretch size.
  8155. */
  8156. vignetteStretch: number;
  8157. /**
  8158. * Vignette centre X Offset.
  8159. */
  8160. vignetteCentreX: number;
  8161. /**
  8162. * Vignette centre Y Offset.
  8163. */
  8164. vignetteCentreY: number;
  8165. /**
  8166. * Vignette weight or intensity of the vignette effect.
  8167. */
  8168. vignetteWeight: number;
  8169. /**
  8170. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8171. * if vignetteEnabled is set to true.
  8172. */
  8173. vignetteColor: Color4;
  8174. /**
  8175. * Camera field of view used by the Vignette effect.
  8176. */
  8177. vignetteCameraFov: number;
  8178. private _vignetteBlendMode;
  8179. /**
  8180. * Gets the vignette blend mode allowing different kind of effect.
  8181. */
  8182. /**
  8183. * Sets the vignette blend mode allowing different kind of effect.
  8184. */
  8185. vignetteBlendMode: number;
  8186. private _vignetteEnabled;
  8187. /**
  8188. * Gets wether the vignette effect is enabled.
  8189. */
  8190. /**
  8191. * Sets wether the vignette effect is enabled.
  8192. */
  8193. vignetteEnabled: boolean;
  8194. private _applyByPostProcess;
  8195. /**
  8196. * Gets wether the image processing is applied through a post process or not.
  8197. */
  8198. /**
  8199. * Sets wether the image processing is applied through a post process or not.
  8200. */
  8201. applyByPostProcess: boolean;
  8202. private _isEnabled;
  8203. /**
  8204. * Gets wether the image processing is enabled or not.
  8205. */
  8206. /**
  8207. * Sets wether the image processing is enabled or not.
  8208. */
  8209. isEnabled: boolean;
  8210. /**
  8211. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8212. */
  8213. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8214. /**
  8215. * Method called each time the image processing information changes requires to recompile the effect.
  8216. */
  8217. protected _updateParameters(): void;
  8218. /**
  8219. * Gets the current class name.
  8220. * @return "ImageProcessingConfiguration"
  8221. */
  8222. getClassName(): string;
  8223. /**
  8224. * Prepare the list of uniforms associated with the Image Processing effects.
  8225. * @param uniforms The list of uniforms used in the effect
  8226. * @param defines the list of defines currently in use
  8227. */
  8228. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8229. /**
  8230. * Prepare the list of samplers associated with the Image Processing effects.
  8231. * @param samplersList The list of uniforms used in the effect
  8232. * @param defines the list of defines currently in use
  8233. */
  8234. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8235. /**
  8236. * Prepare the list of defines associated to the shader.
  8237. * @param defines the list of defines to complete
  8238. * @param forPostProcess Define if we are currently in post process mode or not
  8239. */
  8240. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8241. /**
  8242. * Returns true if all the image processing information are ready.
  8243. * @returns True if ready, otherwise, false
  8244. */
  8245. isReady(): boolean;
  8246. /**
  8247. * Binds the image processing to the shader.
  8248. * @param effect The effect to bind to
  8249. * @param aspectRatio Define the current aspect ratio of the effect
  8250. */
  8251. bind(effect: Effect, aspectRatio?: number): void;
  8252. /**
  8253. * Clones the current image processing instance.
  8254. * @return The cloned image processing
  8255. */
  8256. clone(): ImageProcessingConfiguration;
  8257. /**
  8258. * Serializes the current image processing instance to a json representation.
  8259. * @return a JSON representation
  8260. */
  8261. serialize(): any;
  8262. /**
  8263. * Parses the image processing from a json representation.
  8264. * @param source the JSON source to parse
  8265. * @return The parsed image processing
  8266. */
  8267. static Parse(source: any): ImageProcessingConfiguration;
  8268. private static _VIGNETTEMODE_MULTIPLY;
  8269. private static _VIGNETTEMODE_OPAQUE;
  8270. /**
  8271. * Used to apply the vignette as a mix with the pixel color.
  8272. */
  8273. static readonly VIGNETTEMODE_MULTIPLY: number;
  8274. /**
  8275. * Used to apply the vignette as a replacement of the pixel color.
  8276. */
  8277. static readonly VIGNETTEMODE_OPAQUE: number;
  8278. }
  8279. }
  8280. declare module "babylonjs/Shaders/postprocess.vertex" {
  8281. /** @hidden */
  8282. export var postprocessVertexShader: {
  8283. name: string;
  8284. shader: string;
  8285. };
  8286. }
  8287. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8288. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8289. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8290. module "babylonjs/Engines/thinEngine" {
  8291. interface ThinEngine {
  8292. /**
  8293. * Creates a new render target texture
  8294. * @param size defines the size of the texture
  8295. * @param options defines the options used to create the texture
  8296. * @returns a new render target texture stored in an InternalTexture
  8297. */
  8298. createRenderTargetTexture(size: number | {
  8299. width: number;
  8300. height: number;
  8301. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8302. }
  8303. }
  8304. }
  8305. declare module "babylonjs/Maths/math.axis" {
  8306. import { Vector3 } from "babylonjs/Maths/math.vector";
  8307. /** Defines supported spaces */
  8308. export enum Space {
  8309. /** Local (object) space */
  8310. LOCAL = 0,
  8311. /** World space */
  8312. WORLD = 1,
  8313. /** Bone space */
  8314. BONE = 2
  8315. }
  8316. /** Defines the 3 main axes */
  8317. export class Axis {
  8318. /** X axis */
  8319. static X: Vector3;
  8320. /** Y axis */
  8321. static Y: Vector3;
  8322. /** Z axis */
  8323. static Z: Vector3;
  8324. }
  8325. }
  8326. declare module "babylonjs/Cameras/targetCamera" {
  8327. import { Nullable } from "babylonjs/types";
  8328. import { Camera } from "babylonjs/Cameras/camera";
  8329. import { Scene } from "babylonjs/scene";
  8330. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8331. /**
  8332. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8333. * This is the base of the follow, arc rotate cameras and Free camera
  8334. * @see http://doc.babylonjs.com/features/cameras
  8335. */
  8336. export class TargetCamera extends Camera {
  8337. private static _RigCamTransformMatrix;
  8338. private static _TargetTransformMatrix;
  8339. private static _TargetFocalPoint;
  8340. /**
  8341. * Define the current direction the camera is moving to
  8342. */
  8343. cameraDirection: Vector3;
  8344. /**
  8345. * Define the current rotation the camera is rotating to
  8346. */
  8347. cameraRotation: Vector2;
  8348. /**
  8349. * When set, the up vector of the camera will be updated by the rotation of the camera
  8350. */
  8351. updateUpVectorFromRotation: boolean;
  8352. private _tmpQuaternion;
  8353. /**
  8354. * Define the current rotation of the camera
  8355. */
  8356. rotation: Vector3;
  8357. /**
  8358. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8359. */
  8360. rotationQuaternion: Quaternion;
  8361. /**
  8362. * Define the current speed of the camera
  8363. */
  8364. speed: number;
  8365. /**
  8366. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8367. * around all axis.
  8368. */
  8369. noRotationConstraint: boolean;
  8370. /**
  8371. * Define the current target of the camera as an object or a position.
  8372. */
  8373. lockedTarget: any;
  8374. /** @hidden */
  8375. _currentTarget: Vector3;
  8376. /** @hidden */
  8377. _initialFocalDistance: number;
  8378. /** @hidden */
  8379. _viewMatrix: Matrix;
  8380. /** @hidden */
  8381. _camMatrix: Matrix;
  8382. /** @hidden */
  8383. _cameraTransformMatrix: Matrix;
  8384. /** @hidden */
  8385. _cameraRotationMatrix: Matrix;
  8386. /** @hidden */
  8387. _referencePoint: Vector3;
  8388. /** @hidden */
  8389. _transformedReferencePoint: Vector3;
  8390. protected _globalCurrentTarget: Vector3;
  8391. protected _globalCurrentUpVector: Vector3;
  8392. /** @hidden */
  8393. _reset: () => void;
  8394. private _defaultUp;
  8395. /**
  8396. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8397. * This is the base of the follow, arc rotate cameras and Free camera
  8398. * @see http://doc.babylonjs.com/features/cameras
  8399. * @param name Defines the name of the camera in the scene
  8400. * @param position Defines the start position of the camera in the scene
  8401. * @param scene Defines the scene the camera belongs to
  8402. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8403. */
  8404. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8405. /**
  8406. * Gets the position in front of the camera at a given distance.
  8407. * @param distance The distance from the camera we want the position to be
  8408. * @returns the position
  8409. */
  8410. getFrontPosition(distance: number): Vector3;
  8411. /** @hidden */
  8412. _getLockedTargetPosition(): Nullable<Vector3>;
  8413. private _storedPosition;
  8414. private _storedRotation;
  8415. private _storedRotationQuaternion;
  8416. /**
  8417. * Store current camera state of the camera (fov, position, rotation, etc..)
  8418. * @returns the camera
  8419. */
  8420. storeState(): Camera;
  8421. /**
  8422. * Restored camera state. You must call storeState() first
  8423. * @returns whether it was successful or not
  8424. * @hidden
  8425. */
  8426. _restoreStateValues(): boolean;
  8427. /** @hidden */
  8428. _initCache(): void;
  8429. /** @hidden */
  8430. _updateCache(ignoreParentClass?: boolean): void;
  8431. /** @hidden */
  8432. _isSynchronizedViewMatrix(): boolean;
  8433. /** @hidden */
  8434. _computeLocalCameraSpeed(): number;
  8435. /**
  8436. * Defines the target the camera should look at.
  8437. * @param target Defines the new target as a Vector or a mesh
  8438. */
  8439. setTarget(target: Vector3): void;
  8440. /**
  8441. * Return the current target position of the camera. This value is expressed in local space.
  8442. * @returns the target position
  8443. */
  8444. getTarget(): Vector3;
  8445. /** @hidden */
  8446. _decideIfNeedsToMove(): boolean;
  8447. /** @hidden */
  8448. _updatePosition(): void;
  8449. /** @hidden */
  8450. _checkInputs(): void;
  8451. protected _updateCameraRotationMatrix(): void;
  8452. /**
  8453. * 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)
  8454. * @returns the current camera
  8455. */
  8456. private _rotateUpVectorWithCameraRotationMatrix;
  8457. private _cachedRotationZ;
  8458. private _cachedQuaternionRotationZ;
  8459. /** @hidden */
  8460. _getViewMatrix(): Matrix;
  8461. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8462. /**
  8463. * @hidden
  8464. */
  8465. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8466. /**
  8467. * @hidden
  8468. */
  8469. _updateRigCameras(): void;
  8470. private _getRigCamPositionAndTarget;
  8471. /**
  8472. * Gets the current object class name.
  8473. * @return the class name
  8474. */
  8475. getClassName(): string;
  8476. }
  8477. }
  8478. declare module "babylonjs/Events/keyboardEvents" {
  8479. /**
  8480. * Gather the list of keyboard event types as constants.
  8481. */
  8482. export class KeyboardEventTypes {
  8483. /**
  8484. * The keydown event is fired when a key becomes active (pressed).
  8485. */
  8486. static readonly KEYDOWN: number;
  8487. /**
  8488. * The keyup event is fired when a key has been released.
  8489. */
  8490. static readonly KEYUP: number;
  8491. }
  8492. /**
  8493. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8494. */
  8495. export class KeyboardInfo {
  8496. /**
  8497. * Defines the type of event (KeyboardEventTypes)
  8498. */
  8499. type: number;
  8500. /**
  8501. * Defines the related dom event
  8502. */
  8503. event: KeyboardEvent;
  8504. /**
  8505. * Instantiates a new keyboard info.
  8506. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8507. * @param type Defines the type of event (KeyboardEventTypes)
  8508. * @param event Defines the related dom event
  8509. */
  8510. constructor(
  8511. /**
  8512. * Defines the type of event (KeyboardEventTypes)
  8513. */
  8514. type: number,
  8515. /**
  8516. * Defines the related dom event
  8517. */
  8518. event: KeyboardEvent);
  8519. }
  8520. /**
  8521. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8522. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8523. */
  8524. export class KeyboardInfoPre extends KeyboardInfo {
  8525. /**
  8526. * Defines the type of event (KeyboardEventTypes)
  8527. */
  8528. type: number;
  8529. /**
  8530. * Defines the related dom event
  8531. */
  8532. event: KeyboardEvent;
  8533. /**
  8534. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8535. */
  8536. skipOnPointerObservable: boolean;
  8537. /**
  8538. * Instantiates a new keyboard pre info.
  8539. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8540. * @param type Defines the type of event (KeyboardEventTypes)
  8541. * @param event Defines the related dom event
  8542. */
  8543. constructor(
  8544. /**
  8545. * Defines the type of event (KeyboardEventTypes)
  8546. */
  8547. type: number,
  8548. /**
  8549. * Defines the related dom event
  8550. */
  8551. event: KeyboardEvent);
  8552. }
  8553. }
  8554. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8555. import { Nullable } from "babylonjs/types";
  8556. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8557. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8558. /**
  8559. * Manage the keyboard inputs to control the movement of a free camera.
  8560. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8561. */
  8562. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8563. /**
  8564. * Defines the camera the input is attached to.
  8565. */
  8566. camera: FreeCamera;
  8567. /**
  8568. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8569. */
  8570. keysUp: number[];
  8571. /**
  8572. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8573. */
  8574. keysDown: number[];
  8575. /**
  8576. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8577. */
  8578. keysLeft: number[];
  8579. /**
  8580. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8581. */
  8582. keysRight: number[];
  8583. private _keys;
  8584. private _onCanvasBlurObserver;
  8585. private _onKeyboardObserver;
  8586. private _engine;
  8587. private _scene;
  8588. /**
  8589. * Attach the input controls to a specific dom element to get the input from.
  8590. * @param element Defines the element the controls should be listened from
  8591. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8592. */
  8593. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8594. /**
  8595. * Detach the current controls from the specified dom element.
  8596. * @param element Defines the element to stop listening the inputs from
  8597. */
  8598. detachControl(element: Nullable<HTMLElement>): void;
  8599. /**
  8600. * Update the current camera state depending on the inputs that have been used this frame.
  8601. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8602. */
  8603. checkInputs(): void;
  8604. /**
  8605. * Gets the class name of the current intput.
  8606. * @returns the class name
  8607. */
  8608. getClassName(): string;
  8609. /** @hidden */
  8610. _onLostFocus(): void;
  8611. /**
  8612. * Get the friendly name associated with the input class.
  8613. * @returns the input friendly name
  8614. */
  8615. getSimpleName(): string;
  8616. }
  8617. }
  8618. declare module "babylonjs/Lights/shadowLight" {
  8619. import { Camera } from "babylonjs/Cameras/camera";
  8620. import { Scene } from "babylonjs/scene";
  8621. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8623. import { Light } from "babylonjs/Lights/light";
  8624. /**
  8625. * Interface describing all the common properties and methods a shadow light needs to implement.
  8626. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8627. * as well as binding the different shadow properties to the effects.
  8628. */
  8629. export interface IShadowLight extends Light {
  8630. /**
  8631. * The light id in the scene (used in scene.findLighById for instance)
  8632. */
  8633. id: string;
  8634. /**
  8635. * The position the shdow will be casted from.
  8636. */
  8637. position: Vector3;
  8638. /**
  8639. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8640. */
  8641. direction: Vector3;
  8642. /**
  8643. * The transformed position. Position of the light in world space taking parenting in account.
  8644. */
  8645. transformedPosition: Vector3;
  8646. /**
  8647. * The transformed direction. Direction of the light in world space taking parenting in account.
  8648. */
  8649. transformedDirection: Vector3;
  8650. /**
  8651. * The friendly name of the light in the scene.
  8652. */
  8653. name: string;
  8654. /**
  8655. * Defines the shadow projection clipping minimum z value.
  8656. */
  8657. shadowMinZ: number;
  8658. /**
  8659. * Defines the shadow projection clipping maximum z value.
  8660. */
  8661. shadowMaxZ: number;
  8662. /**
  8663. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8664. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8665. */
  8666. computeTransformedInformation(): boolean;
  8667. /**
  8668. * Gets the scene the light belongs to.
  8669. * @returns The scene
  8670. */
  8671. getScene(): Scene;
  8672. /**
  8673. * Callback defining a custom Projection Matrix Builder.
  8674. * This can be used to override the default projection matrix computation.
  8675. */
  8676. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8677. /**
  8678. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8679. * @param matrix The materix to updated with the projection information
  8680. * @param viewMatrix The transform matrix of the light
  8681. * @param renderList The list of mesh to render in the map
  8682. * @returns The current light
  8683. */
  8684. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8685. /**
  8686. * Gets the current depth scale used in ESM.
  8687. * @returns The scale
  8688. */
  8689. getDepthScale(): number;
  8690. /**
  8691. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8692. * @returns true if a cube texture needs to be use
  8693. */
  8694. needCube(): boolean;
  8695. /**
  8696. * Detects if the projection matrix requires to be recomputed this frame.
  8697. * @returns true if it requires to be recomputed otherwise, false.
  8698. */
  8699. needProjectionMatrixCompute(): boolean;
  8700. /**
  8701. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8702. */
  8703. forceProjectionMatrixCompute(): void;
  8704. /**
  8705. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8706. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8707. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8708. */
  8709. getShadowDirection(faceIndex?: number): Vector3;
  8710. /**
  8711. * Gets the minZ used for shadow according to both the scene and the light.
  8712. * @param activeCamera The camera we are returning the min for
  8713. * @returns the depth min z
  8714. */
  8715. getDepthMinZ(activeCamera: Camera): number;
  8716. /**
  8717. * Gets the maxZ used for shadow according to both the scene and the light.
  8718. * @param activeCamera The camera we are returning the max for
  8719. * @returns the depth max z
  8720. */
  8721. getDepthMaxZ(activeCamera: Camera): number;
  8722. }
  8723. /**
  8724. * Base implementation IShadowLight
  8725. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8726. */
  8727. export abstract class ShadowLight extends Light implements IShadowLight {
  8728. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8729. protected _position: Vector3;
  8730. protected _setPosition(value: Vector3): void;
  8731. /**
  8732. * Sets the position the shadow will be casted from. Also use as the light position for both
  8733. * point and spot lights.
  8734. */
  8735. /**
  8736. * Sets the position the shadow will be casted from. Also use as the light position for both
  8737. * point and spot lights.
  8738. */
  8739. position: Vector3;
  8740. protected _direction: Vector3;
  8741. protected _setDirection(value: Vector3): void;
  8742. /**
  8743. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8744. * Also use as the light direction on spot and directional lights.
  8745. */
  8746. /**
  8747. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8748. * Also use as the light direction on spot and directional lights.
  8749. */
  8750. direction: Vector3;
  8751. private _shadowMinZ;
  8752. /**
  8753. * Gets the shadow projection clipping minimum z value.
  8754. */
  8755. /**
  8756. * Sets the shadow projection clipping minimum z value.
  8757. */
  8758. shadowMinZ: number;
  8759. private _shadowMaxZ;
  8760. /**
  8761. * Sets the shadow projection clipping maximum z value.
  8762. */
  8763. /**
  8764. * Gets the shadow projection clipping maximum z value.
  8765. */
  8766. shadowMaxZ: number;
  8767. /**
  8768. * Callback defining a custom Projection Matrix Builder.
  8769. * This can be used to override the default projection matrix computation.
  8770. */
  8771. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8772. /**
  8773. * The transformed position. Position of the light in world space taking parenting in account.
  8774. */
  8775. transformedPosition: Vector3;
  8776. /**
  8777. * The transformed direction. Direction of the light in world space taking parenting in account.
  8778. */
  8779. transformedDirection: Vector3;
  8780. private _needProjectionMatrixCompute;
  8781. /**
  8782. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8783. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8784. */
  8785. computeTransformedInformation(): boolean;
  8786. /**
  8787. * Return the depth scale used for the shadow map.
  8788. * @returns the depth scale.
  8789. */
  8790. getDepthScale(): number;
  8791. /**
  8792. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8793. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8794. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8795. */
  8796. getShadowDirection(faceIndex?: number): Vector3;
  8797. /**
  8798. * Returns the ShadowLight absolute position in the World.
  8799. * @returns the position vector in world space
  8800. */
  8801. getAbsolutePosition(): Vector3;
  8802. /**
  8803. * Sets the ShadowLight direction toward the passed target.
  8804. * @param target The point to target in local space
  8805. * @returns the updated ShadowLight direction
  8806. */
  8807. setDirectionToTarget(target: Vector3): Vector3;
  8808. /**
  8809. * Returns the light rotation in euler definition.
  8810. * @returns the x y z rotation in local space.
  8811. */
  8812. getRotation(): Vector3;
  8813. /**
  8814. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8815. * @returns true if a cube texture needs to be use
  8816. */
  8817. needCube(): boolean;
  8818. /**
  8819. * Detects if the projection matrix requires to be recomputed this frame.
  8820. * @returns true if it requires to be recomputed otherwise, false.
  8821. */
  8822. needProjectionMatrixCompute(): boolean;
  8823. /**
  8824. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8825. */
  8826. forceProjectionMatrixCompute(): void;
  8827. /** @hidden */
  8828. _initCache(): void;
  8829. /** @hidden */
  8830. _isSynchronized(): boolean;
  8831. /**
  8832. * Computes the world matrix of the node
  8833. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8834. * @returns the world matrix
  8835. */
  8836. computeWorldMatrix(force?: boolean): Matrix;
  8837. /**
  8838. * Gets the minZ used for shadow according to both the scene and the light.
  8839. * @param activeCamera The camera we are returning the min for
  8840. * @returns the depth min z
  8841. */
  8842. getDepthMinZ(activeCamera: Camera): number;
  8843. /**
  8844. * Gets the maxZ used for shadow according to both the scene and the light.
  8845. * @param activeCamera The camera we are returning the max for
  8846. * @returns the depth max z
  8847. */
  8848. getDepthMaxZ(activeCamera: Camera): number;
  8849. /**
  8850. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8851. * @param matrix The materix to updated with the projection information
  8852. * @param viewMatrix The transform matrix of the light
  8853. * @param renderList The list of mesh to render in the map
  8854. * @returns The current light
  8855. */
  8856. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8857. }
  8858. }
  8859. declare module "babylonjs/Materials/effectFallbacks" {
  8860. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8861. import { Effect } from "babylonjs/Materials/effect";
  8862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8863. /**
  8864. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8865. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8866. */
  8867. export class EffectFallbacks implements IEffectFallbacks {
  8868. private _defines;
  8869. private _currentRank;
  8870. private _maxRank;
  8871. private _mesh;
  8872. /**
  8873. * Removes the fallback from the bound mesh.
  8874. */
  8875. unBindMesh(): void;
  8876. /**
  8877. * Adds a fallback on the specified property.
  8878. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8879. * @param define The name of the define in the shader
  8880. */
  8881. addFallback(rank: number, define: string): void;
  8882. /**
  8883. * Sets the mesh to use CPU skinning when needing to fallback.
  8884. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8885. * @param mesh The mesh to use the fallbacks.
  8886. */
  8887. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8888. /**
  8889. * Checks to see if more fallbacks are still availible.
  8890. */
  8891. readonly hasMoreFallbacks: boolean;
  8892. /**
  8893. * Removes the defines that should be removed when falling back.
  8894. * @param currentDefines defines the current define statements for the shader.
  8895. * @param effect defines the current effect we try to compile
  8896. * @returns The resulting defines with defines of the current rank removed.
  8897. */
  8898. reduce(currentDefines: string, effect: Effect): string;
  8899. }
  8900. }
  8901. declare module "babylonjs/Materials/materialHelper" {
  8902. import { Nullable } from "babylonjs/types";
  8903. import { Scene } from "babylonjs/scene";
  8904. import { Engine } from "babylonjs/Engines/engine";
  8905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8906. import { Light } from "babylonjs/Lights/light";
  8907. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8908. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  8909. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8910. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8911. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  8912. /**
  8913. * "Static Class" containing the most commonly used helper while dealing with material for
  8914. * rendering purpose.
  8915. *
  8916. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8917. *
  8918. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8919. */
  8920. export class MaterialHelper {
  8921. /**
  8922. * Bind the current view position to an effect.
  8923. * @param effect The effect to be bound
  8924. * @param scene The scene the eyes position is used from
  8925. */
  8926. static BindEyePosition(effect: Effect, scene: Scene): void;
  8927. /**
  8928. * Helps preparing the defines values about the UVs in used in the effect.
  8929. * UVs are shared as much as we can accross channels in the shaders.
  8930. * @param texture The texture we are preparing the UVs for
  8931. * @param defines The defines to update
  8932. * @param key The channel key "diffuse", "specular"... used in the shader
  8933. */
  8934. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8935. /**
  8936. * Binds a texture matrix value to its corrsponding uniform
  8937. * @param texture The texture to bind the matrix for
  8938. * @param uniformBuffer The uniform buffer receivin the data
  8939. * @param key The channel key "diffuse", "specular"... used in the shader
  8940. */
  8941. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8942. /**
  8943. * Gets the current status of the fog (should it be enabled?)
  8944. * @param mesh defines the mesh to evaluate for fog support
  8945. * @param scene defines the hosting scene
  8946. * @returns true if fog must be enabled
  8947. */
  8948. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8949. /**
  8950. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8951. * @param mesh defines the current mesh
  8952. * @param scene defines the current scene
  8953. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8954. * @param pointsCloud defines if point cloud rendering has to be turned on
  8955. * @param fogEnabled defines if fog has to be turned on
  8956. * @param alphaTest defines if alpha testing has to be turned on
  8957. * @param defines defines the current list of defines
  8958. */
  8959. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8960. /**
  8961. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8962. * @param scene defines the current scene
  8963. * @param engine defines the current engine
  8964. * @param defines specifies the list of active defines
  8965. * @param useInstances defines if instances have to be turned on
  8966. * @param useClipPlane defines if clip plane have to be turned on
  8967. */
  8968. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8969. /**
  8970. * Prepares the defines for bones
  8971. * @param mesh The mesh containing the geometry data we will draw
  8972. * @param defines The defines to update
  8973. */
  8974. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8975. /**
  8976. * Prepares the defines for morph targets
  8977. * @param mesh The mesh containing the geometry data we will draw
  8978. * @param defines The defines to update
  8979. */
  8980. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8981. /**
  8982. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8983. * @param mesh The mesh containing the geometry data we will draw
  8984. * @param defines The defines to update
  8985. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8986. * @param useBones Precise whether bones should be used or not (override mesh info)
  8987. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8988. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8989. * @returns false if defines are considered not dirty and have not been checked
  8990. */
  8991. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8992. /**
  8993. * Prepares the defines related to multiview
  8994. * @param scene The scene we are intending to draw
  8995. * @param defines The defines to update
  8996. */
  8997. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8998. /**
  8999. * Prepares the defines related to the light information passed in parameter
  9000. * @param scene The scene we are intending to draw
  9001. * @param mesh The mesh the effect is compiling for
  9002. * @param light The light the effect is compiling for
  9003. * @param lightIndex The index of the light
  9004. * @param defines The defines to update
  9005. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9006. * @param state Defines the current state regarding what is needed (normals, etc...)
  9007. */
  9008. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9009. needNormals: boolean;
  9010. needRebuild: boolean;
  9011. shadowEnabled: boolean;
  9012. specularEnabled: boolean;
  9013. lightmapMode: boolean;
  9014. }): void;
  9015. /**
  9016. * Prepares the defines related to the light information passed in parameter
  9017. * @param scene The scene we are intending to draw
  9018. * @param mesh The mesh the effect is compiling for
  9019. * @param defines The defines to update
  9020. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9021. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9022. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9023. * @returns true if normals will be required for the rest of the effect
  9024. */
  9025. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9026. /**
  9027. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9028. * @param lightIndex defines the light index
  9029. * @param uniformsList The uniform list
  9030. * @param samplersList The sampler list
  9031. * @param projectedLightTexture defines if projected texture must be used
  9032. * @param uniformBuffersList defines an optional list of uniform buffers
  9033. */
  9034. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9035. /**
  9036. * Prepares the uniforms and samplers list to be used in the effect
  9037. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9038. * @param samplersList The sampler list
  9039. * @param defines The defines helping in the list generation
  9040. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9041. */
  9042. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9043. /**
  9044. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9045. * @param defines The defines to update while falling back
  9046. * @param fallbacks The authorized effect fallbacks
  9047. * @param maxSimultaneousLights The maximum number of lights allowed
  9048. * @param rank the current rank of the Effect
  9049. * @returns The newly affected rank
  9050. */
  9051. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9052. private static _TmpMorphInfluencers;
  9053. /**
  9054. * Prepares the list of attributes required for morph targets according to the effect defines.
  9055. * @param attribs The current list of supported attribs
  9056. * @param mesh The mesh to prepare the morph targets attributes for
  9057. * @param influencers The number of influencers
  9058. */
  9059. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9060. /**
  9061. * Prepares the list of attributes required for morph targets according to the effect defines.
  9062. * @param attribs The current list of supported attribs
  9063. * @param mesh The mesh to prepare the morph targets attributes for
  9064. * @param defines The current Defines of the effect
  9065. */
  9066. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9067. /**
  9068. * Prepares the list of attributes required for bones according to the effect defines.
  9069. * @param attribs The current list of supported attribs
  9070. * @param mesh The mesh to prepare the bones attributes for
  9071. * @param defines The current Defines of the effect
  9072. * @param fallbacks The current efffect fallback strategy
  9073. */
  9074. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9075. /**
  9076. * Check and prepare the list of attributes required for instances according to the effect defines.
  9077. * @param attribs The current list of supported attribs
  9078. * @param defines The current MaterialDefines of the effect
  9079. */
  9080. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9081. /**
  9082. * Add the list of attributes required for instances to the attribs array.
  9083. * @param attribs The current list of supported attribs
  9084. */
  9085. static PushAttributesForInstances(attribs: string[]): void;
  9086. /**
  9087. * Binds the light shadow information to the effect for the given mesh.
  9088. * @param light The light containing the generator
  9089. * @param scene The scene the lights belongs to
  9090. * @param mesh The mesh we are binding the information to render
  9091. * @param lightIndex The light index in the effect used to render the mesh
  9092. * @param effect The effect we are binding the data to
  9093. */
  9094. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9095. /**
  9096. * Binds the light information to the effect.
  9097. * @param light The light containing the generator
  9098. * @param effect The effect we are binding the data to
  9099. * @param lightIndex The light index in the effect used to render
  9100. */
  9101. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9102. /**
  9103. * Binds the lights information from the scene to the effect for the given mesh.
  9104. * @param light Light to bind
  9105. * @param lightIndex Light index
  9106. * @param scene The scene where the light belongs to
  9107. * @param mesh The mesh we are binding the information to render
  9108. * @param effect The effect we are binding the data to
  9109. * @param useSpecular Defines if specular is supported
  9110. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9111. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9112. */
  9113. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9114. /**
  9115. * Binds the lights information from the scene to the effect for the given mesh.
  9116. * @param scene The scene the lights belongs to
  9117. * @param mesh The mesh we are binding the information to render
  9118. * @param effect The effect we are binding the data to
  9119. * @param defines The generated defines for the effect
  9120. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9121. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9122. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9123. */
  9124. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9125. private static _tempFogColor;
  9126. /**
  9127. * Binds the fog information from the scene to the effect for the given mesh.
  9128. * @param scene The scene the lights belongs to
  9129. * @param mesh The mesh we are binding the information to render
  9130. * @param effect The effect we are binding the data to
  9131. * @param linearSpace Defines if the fog effect is applied in linear space
  9132. */
  9133. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9134. /**
  9135. * Binds the bones information from the mesh to the effect.
  9136. * @param mesh The mesh we are binding the information to render
  9137. * @param effect The effect we are binding the data to
  9138. */
  9139. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9140. /**
  9141. * Binds the morph targets information from the mesh to the effect.
  9142. * @param abstractMesh The mesh we are binding the information to render
  9143. * @param effect The effect we are binding the data to
  9144. */
  9145. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9146. /**
  9147. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9148. * @param defines The generated defines used in the effect
  9149. * @param effect The effect we are binding the data to
  9150. * @param scene The scene we are willing to render with logarithmic scale for
  9151. */
  9152. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9153. /**
  9154. * Binds the clip plane information from the scene to the effect.
  9155. * @param scene The scene the clip plane information are extracted from
  9156. * @param effect The effect we are binding the data to
  9157. */
  9158. static BindClipPlane(effect: Effect, scene: Scene): void;
  9159. }
  9160. }
  9161. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9162. /** @hidden */
  9163. export var packingFunctions: {
  9164. name: string;
  9165. shader: string;
  9166. };
  9167. }
  9168. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9169. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9170. /** @hidden */
  9171. export var shadowMapPixelShader: {
  9172. name: string;
  9173. shader: string;
  9174. };
  9175. }
  9176. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9177. /** @hidden */
  9178. export var bonesDeclaration: {
  9179. name: string;
  9180. shader: string;
  9181. };
  9182. }
  9183. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9184. /** @hidden */
  9185. export var morphTargetsVertexGlobalDeclaration: {
  9186. name: string;
  9187. shader: string;
  9188. };
  9189. }
  9190. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9191. /** @hidden */
  9192. export var morphTargetsVertexDeclaration: {
  9193. name: string;
  9194. shader: string;
  9195. };
  9196. }
  9197. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9198. /** @hidden */
  9199. export var instancesDeclaration: {
  9200. name: string;
  9201. shader: string;
  9202. };
  9203. }
  9204. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9205. /** @hidden */
  9206. export var helperFunctions: {
  9207. name: string;
  9208. shader: string;
  9209. };
  9210. }
  9211. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9212. /** @hidden */
  9213. export var morphTargetsVertex: {
  9214. name: string;
  9215. shader: string;
  9216. };
  9217. }
  9218. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9219. /** @hidden */
  9220. export var instancesVertex: {
  9221. name: string;
  9222. shader: string;
  9223. };
  9224. }
  9225. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9226. /** @hidden */
  9227. export var bonesVertex: {
  9228. name: string;
  9229. shader: string;
  9230. };
  9231. }
  9232. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9233. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9234. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9235. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9236. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9237. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9238. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9239. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9240. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9241. /** @hidden */
  9242. export var shadowMapVertexShader: {
  9243. name: string;
  9244. shader: string;
  9245. };
  9246. }
  9247. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9248. /** @hidden */
  9249. export var depthBoxBlurPixelShader: {
  9250. name: string;
  9251. shader: string;
  9252. };
  9253. }
  9254. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9255. import { Nullable } from "babylonjs/types";
  9256. import { Scene } from "babylonjs/scene";
  9257. import { Matrix } from "babylonjs/Maths/math.vector";
  9258. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9260. import { Mesh } from "babylonjs/Meshes/mesh";
  9261. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9262. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9263. import { Effect } from "babylonjs/Materials/effect";
  9264. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9265. import "babylonjs/Shaders/shadowMap.fragment";
  9266. import "babylonjs/Shaders/shadowMap.vertex";
  9267. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9268. import { Observable } from "babylonjs/Misc/observable";
  9269. /**
  9270. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9271. */
  9272. export interface ICustomShaderOptions {
  9273. /**
  9274. * Gets or sets the custom shader name to use
  9275. */
  9276. shaderName: string;
  9277. /**
  9278. * The list of attribute names used in the shader
  9279. */
  9280. attributes?: string[];
  9281. /**
  9282. * The list of unifrom names used in the shader
  9283. */
  9284. uniforms?: string[];
  9285. /**
  9286. * The list of sampler names used in the shader
  9287. */
  9288. samplers?: string[];
  9289. /**
  9290. * The list of defines used in the shader
  9291. */
  9292. defines?: string[];
  9293. }
  9294. /**
  9295. * Interface to implement to create a shadow generator compatible with BJS.
  9296. */
  9297. export interface IShadowGenerator {
  9298. /**
  9299. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9300. * @returns The render target texture if present otherwise, null
  9301. */
  9302. getShadowMap(): Nullable<RenderTargetTexture>;
  9303. /**
  9304. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9305. * @returns The render target texture if the shadow map is present otherwise, null
  9306. */
  9307. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9308. /**
  9309. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9310. * @param subMesh The submesh we want to render in the shadow map
  9311. * @param useInstances Defines wether will draw in the map using instances
  9312. * @returns true if ready otherwise, false
  9313. */
  9314. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9315. /**
  9316. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9317. * @param defines Defines of the material we want to update
  9318. * @param lightIndex Index of the light in the enabled light list of the material
  9319. */
  9320. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9321. /**
  9322. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9323. * defined in the generator but impacting the effect).
  9324. * It implies the unifroms available on the materials are the standard BJS ones.
  9325. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9326. * @param effect The effect we are binfing the information for
  9327. */
  9328. bindShadowLight(lightIndex: string, effect: Effect): void;
  9329. /**
  9330. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9331. * (eq to shadow prjection matrix * light transform matrix)
  9332. * @returns The transform matrix used to create the shadow map
  9333. */
  9334. getTransformMatrix(): Matrix;
  9335. /**
  9336. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9337. * Cube and 2D textures for instance.
  9338. */
  9339. recreateShadowMap(): void;
  9340. /**
  9341. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9342. * @param onCompiled Callback triggered at the and of the effects compilation
  9343. * @param options Sets of optional options forcing the compilation with different modes
  9344. */
  9345. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9346. useInstances: boolean;
  9347. }>): void;
  9348. /**
  9349. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9350. * @param options Sets of optional options forcing the compilation with different modes
  9351. * @returns A promise that resolves when the compilation completes
  9352. */
  9353. forceCompilationAsync(options?: Partial<{
  9354. useInstances: boolean;
  9355. }>): Promise<void>;
  9356. /**
  9357. * Serializes the shadow generator setup to a json object.
  9358. * @returns The serialized JSON object
  9359. */
  9360. serialize(): any;
  9361. /**
  9362. * Disposes the Shadow map and related Textures and effects.
  9363. */
  9364. dispose(): void;
  9365. }
  9366. /**
  9367. * Default implementation IShadowGenerator.
  9368. * This is the main object responsible of generating shadows in the framework.
  9369. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9370. */
  9371. export class ShadowGenerator implements IShadowGenerator {
  9372. /**
  9373. * Shadow generator mode None: no filtering applied.
  9374. */
  9375. static readonly FILTER_NONE: number;
  9376. /**
  9377. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9378. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9379. */
  9380. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9381. /**
  9382. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9383. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9384. */
  9385. static readonly FILTER_POISSONSAMPLING: number;
  9386. /**
  9387. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9388. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9389. */
  9390. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9391. /**
  9392. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9393. * edge artifacts on steep falloff.
  9394. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9395. */
  9396. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9397. /**
  9398. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9399. * edge artifacts on steep falloff.
  9400. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9401. */
  9402. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9403. /**
  9404. * Shadow generator mode PCF: Percentage Closer Filtering
  9405. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9406. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9407. */
  9408. static readonly FILTER_PCF: number;
  9409. /**
  9410. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9411. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9412. * Contact Hardening
  9413. */
  9414. static readonly FILTER_PCSS: number;
  9415. /**
  9416. * Reserved for PCF and PCSS
  9417. * Highest Quality.
  9418. *
  9419. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9420. *
  9421. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9422. */
  9423. static readonly QUALITY_HIGH: number;
  9424. /**
  9425. * Reserved for PCF and PCSS
  9426. * Good tradeoff for quality/perf cross devices
  9427. *
  9428. * Execute PCF on a 3*3 kernel.
  9429. *
  9430. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9431. */
  9432. static readonly QUALITY_MEDIUM: number;
  9433. /**
  9434. * Reserved for PCF and PCSS
  9435. * The lowest quality but the fastest.
  9436. *
  9437. * Execute PCF on a 1*1 kernel.
  9438. *
  9439. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9440. */
  9441. static readonly QUALITY_LOW: number;
  9442. /** Gets or sets the custom shader name to use */
  9443. customShaderOptions: ICustomShaderOptions;
  9444. /**
  9445. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9446. */
  9447. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9448. /**
  9449. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9450. */
  9451. onAfterShadowMapRenderObservable: Observable<Effect>;
  9452. /**
  9453. * Observable triggered before a mesh is rendered in the shadow map.
  9454. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9455. */
  9456. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9457. /**
  9458. * Observable triggered after a mesh is rendered in the shadow map.
  9459. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9460. */
  9461. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9462. private _bias;
  9463. /**
  9464. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9465. */
  9466. /**
  9467. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9468. */
  9469. bias: number;
  9470. private _normalBias;
  9471. /**
  9472. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9473. */
  9474. /**
  9475. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9476. */
  9477. normalBias: number;
  9478. private _blurBoxOffset;
  9479. /**
  9480. * Gets the blur box offset: offset applied during the blur pass.
  9481. * Only useful if useKernelBlur = false
  9482. */
  9483. /**
  9484. * Sets the blur box offset: offset applied during the blur pass.
  9485. * Only useful if useKernelBlur = false
  9486. */
  9487. blurBoxOffset: number;
  9488. private _blurScale;
  9489. /**
  9490. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9491. * 2 means half of the size.
  9492. */
  9493. /**
  9494. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9495. * 2 means half of the size.
  9496. */
  9497. blurScale: number;
  9498. private _blurKernel;
  9499. /**
  9500. * Gets the blur kernel: kernel size of the blur pass.
  9501. * Only useful if useKernelBlur = true
  9502. */
  9503. /**
  9504. * Sets the blur kernel: kernel size of the blur pass.
  9505. * Only useful if useKernelBlur = true
  9506. */
  9507. blurKernel: number;
  9508. private _useKernelBlur;
  9509. /**
  9510. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9511. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9512. */
  9513. /**
  9514. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9515. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9516. */
  9517. useKernelBlur: boolean;
  9518. private _depthScale;
  9519. /**
  9520. * Gets the depth scale used in ESM mode.
  9521. */
  9522. /**
  9523. * Sets the depth scale used in ESM mode.
  9524. * This can override the scale stored on the light.
  9525. */
  9526. depthScale: number;
  9527. private _filter;
  9528. /**
  9529. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9530. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9531. */
  9532. /**
  9533. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9534. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9535. */
  9536. filter: number;
  9537. /**
  9538. * Gets if the current filter is set to Poisson Sampling.
  9539. */
  9540. /**
  9541. * Sets the current filter to Poisson Sampling.
  9542. */
  9543. usePoissonSampling: boolean;
  9544. /**
  9545. * Gets if the current filter is set to ESM.
  9546. */
  9547. /**
  9548. * Sets the current filter is to ESM.
  9549. */
  9550. useExponentialShadowMap: boolean;
  9551. /**
  9552. * Gets if the current filter is set to filtered ESM.
  9553. */
  9554. /**
  9555. * Gets if the current filter is set to filtered ESM.
  9556. */
  9557. useBlurExponentialShadowMap: boolean;
  9558. /**
  9559. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9560. * exponential to prevent steep falloff artifacts).
  9561. */
  9562. /**
  9563. * Sets the current filter to "close ESM" (using the inverse of the
  9564. * exponential to prevent steep falloff artifacts).
  9565. */
  9566. useCloseExponentialShadowMap: boolean;
  9567. /**
  9568. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9569. * exponential to prevent steep falloff artifacts).
  9570. */
  9571. /**
  9572. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9573. * exponential to prevent steep falloff artifacts).
  9574. */
  9575. useBlurCloseExponentialShadowMap: boolean;
  9576. /**
  9577. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9578. */
  9579. /**
  9580. * Sets the current filter to "PCF" (percentage closer filtering).
  9581. */
  9582. usePercentageCloserFiltering: boolean;
  9583. private _filteringQuality;
  9584. /**
  9585. * Gets the PCF or PCSS Quality.
  9586. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9587. */
  9588. /**
  9589. * Sets the PCF or PCSS Quality.
  9590. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9591. */
  9592. filteringQuality: number;
  9593. /**
  9594. * Gets if the current filter is set to "PCSS" (contact hardening).
  9595. */
  9596. /**
  9597. * Sets the current filter to "PCSS" (contact hardening).
  9598. */
  9599. useContactHardeningShadow: boolean;
  9600. private _contactHardeningLightSizeUVRatio;
  9601. /**
  9602. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9603. * Using a ratio helps keeping shape stability independently of the map size.
  9604. *
  9605. * It does not account for the light projection as it was having too much
  9606. * instability during the light setup or during light position changes.
  9607. *
  9608. * Only valid if useContactHardeningShadow is true.
  9609. */
  9610. /**
  9611. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9612. * Using a ratio helps keeping shape stability independently of the map size.
  9613. *
  9614. * It does not account for the light projection as it was having too much
  9615. * instability during the light setup or during light position changes.
  9616. *
  9617. * Only valid if useContactHardeningShadow is true.
  9618. */
  9619. contactHardeningLightSizeUVRatio: number;
  9620. private _darkness;
  9621. /** Gets or sets the actual darkness of a shadow */
  9622. darkness: number;
  9623. /**
  9624. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9625. * 0 means strongest and 1 would means no shadow.
  9626. * @returns the darkness.
  9627. */
  9628. getDarkness(): number;
  9629. /**
  9630. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9631. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9632. * @returns the shadow generator allowing fluent coding.
  9633. */
  9634. setDarkness(darkness: number): ShadowGenerator;
  9635. private _transparencyShadow;
  9636. /** Gets or sets the ability to have transparent shadow */
  9637. transparencyShadow: boolean;
  9638. /**
  9639. * Sets the ability to have transparent shadow (boolean).
  9640. * @param transparent True if transparent else False
  9641. * @returns the shadow generator allowing fluent coding
  9642. */
  9643. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9644. private _shadowMap;
  9645. private _shadowMap2;
  9646. /**
  9647. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9648. * @returns The render target texture if present otherwise, null
  9649. */
  9650. getShadowMap(): Nullable<RenderTargetTexture>;
  9651. /**
  9652. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9653. * @returns The render target texture if the shadow map is present otherwise, null
  9654. */
  9655. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9656. /**
  9657. * Gets the class name of that object
  9658. * @returns "ShadowGenerator"
  9659. */
  9660. getClassName(): string;
  9661. /**
  9662. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9663. * @param mesh Mesh to add
  9664. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9665. * @returns the Shadow Generator itself
  9666. */
  9667. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9668. /**
  9669. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9670. * @param mesh Mesh to remove
  9671. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9672. * @returns the Shadow Generator itself
  9673. */
  9674. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9675. /**
  9676. * Controls the extent to which the shadows fade out at the edge of the frustum
  9677. * Used only by directionals and spots
  9678. */
  9679. frustumEdgeFalloff: number;
  9680. private _light;
  9681. /**
  9682. * Returns the associated light object.
  9683. * @returns the light generating the shadow
  9684. */
  9685. getLight(): IShadowLight;
  9686. /**
  9687. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9688. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9689. * It might on the other hand introduce peter panning.
  9690. */
  9691. forceBackFacesOnly: boolean;
  9692. private _scene;
  9693. private _lightDirection;
  9694. private _effect;
  9695. private _viewMatrix;
  9696. private _projectionMatrix;
  9697. private _transformMatrix;
  9698. private _cachedPosition;
  9699. private _cachedDirection;
  9700. private _cachedDefines;
  9701. private _currentRenderID;
  9702. private _boxBlurPostprocess;
  9703. private _kernelBlurXPostprocess;
  9704. private _kernelBlurYPostprocess;
  9705. private _blurPostProcesses;
  9706. private _mapSize;
  9707. private _currentFaceIndex;
  9708. private _currentFaceIndexCache;
  9709. private _textureType;
  9710. private _defaultTextureMatrix;
  9711. private _storedUniqueId;
  9712. /** @hidden */
  9713. static _SceneComponentInitialization: (scene: Scene) => void;
  9714. /**
  9715. * Creates a ShadowGenerator object.
  9716. * A ShadowGenerator is the required tool to use the shadows.
  9717. * Each light casting shadows needs to use its own ShadowGenerator.
  9718. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9719. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9720. * @param light The light object generating the shadows.
  9721. * @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.
  9722. */
  9723. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9724. private _initializeGenerator;
  9725. private _initializeShadowMap;
  9726. private _initializeBlurRTTAndPostProcesses;
  9727. private _renderForShadowMap;
  9728. private _renderSubMeshForShadowMap;
  9729. private _applyFilterValues;
  9730. /**
  9731. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9732. * @param onCompiled Callback triggered at the and of the effects compilation
  9733. * @param options Sets of optional options forcing the compilation with different modes
  9734. */
  9735. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9736. useInstances: boolean;
  9737. }>): void;
  9738. /**
  9739. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9740. * @param options Sets of optional options forcing the compilation with different modes
  9741. * @returns A promise that resolves when the compilation completes
  9742. */
  9743. forceCompilationAsync(options?: Partial<{
  9744. useInstances: boolean;
  9745. }>): Promise<void>;
  9746. /**
  9747. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9748. * @param subMesh The submesh we want to render in the shadow map
  9749. * @param useInstances Defines wether will draw in the map using instances
  9750. * @returns true if ready otherwise, false
  9751. */
  9752. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9753. /**
  9754. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9755. * @param defines Defines of the material we want to update
  9756. * @param lightIndex Index of the light in the enabled light list of the material
  9757. */
  9758. prepareDefines(defines: any, lightIndex: number): void;
  9759. /**
  9760. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9761. * defined in the generator but impacting the effect).
  9762. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9763. * @param effect The effect we are binfing the information for
  9764. */
  9765. bindShadowLight(lightIndex: string, effect: Effect): void;
  9766. /**
  9767. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9768. * (eq to shadow prjection matrix * light transform matrix)
  9769. * @returns The transform matrix used to create the shadow map
  9770. */
  9771. getTransformMatrix(): Matrix;
  9772. /**
  9773. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9774. * Cube and 2D textures for instance.
  9775. */
  9776. recreateShadowMap(): void;
  9777. private _disposeBlurPostProcesses;
  9778. private _disposeRTTandPostProcesses;
  9779. /**
  9780. * Disposes the ShadowGenerator.
  9781. * Returns nothing.
  9782. */
  9783. dispose(): void;
  9784. /**
  9785. * Serializes the shadow generator setup to a json object.
  9786. * @returns The serialized JSON object
  9787. */
  9788. serialize(): any;
  9789. /**
  9790. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9791. * @param parsedShadowGenerator The JSON object to parse
  9792. * @param scene The scene to create the shadow map for
  9793. * @returns The parsed shadow generator
  9794. */
  9795. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9796. }
  9797. }
  9798. declare module "babylonjs/Lights/light" {
  9799. import { Nullable } from "babylonjs/types";
  9800. import { Scene } from "babylonjs/scene";
  9801. import { Vector3 } from "babylonjs/Maths/math.vector";
  9802. import { Color3 } from "babylonjs/Maths/math.color";
  9803. import { Node } from "babylonjs/node";
  9804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9805. import { Effect } from "babylonjs/Materials/effect";
  9806. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9807. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9808. /**
  9809. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9810. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9811. * 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.
  9812. */
  9813. export abstract class Light extends Node {
  9814. /**
  9815. * Falloff Default: light is falling off following the material specification:
  9816. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9817. */
  9818. static readonly FALLOFF_DEFAULT: number;
  9819. /**
  9820. * Falloff Physical: light is falling off following the inverse squared distance law.
  9821. */
  9822. static readonly FALLOFF_PHYSICAL: number;
  9823. /**
  9824. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9825. * to enhance interoperability with other engines.
  9826. */
  9827. static readonly FALLOFF_GLTF: number;
  9828. /**
  9829. * Falloff Standard: light is falling off like in the standard material
  9830. * to enhance interoperability with other materials.
  9831. */
  9832. static readonly FALLOFF_STANDARD: number;
  9833. /**
  9834. * If every light affecting the material is in this lightmapMode,
  9835. * material.lightmapTexture adds or multiplies
  9836. * (depends on material.useLightmapAsShadowmap)
  9837. * after every other light calculations.
  9838. */
  9839. static readonly LIGHTMAP_DEFAULT: number;
  9840. /**
  9841. * material.lightmapTexture as only diffuse lighting from this light
  9842. * adds only specular lighting from this light
  9843. * adds dynamic shadows
  9844. */
  9845. static readonly LIGHTMAP_SPECULAR: number;
  9846. /**
  9847. * material.lightmapTexture as only lighting
  9848. * no light calculation from this light
  9849. * only adds dynamic shadows from this light
  9850. */
  9851. static readonly LIGHTMAP_SHADOWSONLY: number;
  9852. /**
  9853. * Each light type uses the default quantity according to its type:
  9854. * point/spot lights use luminous intensity
  9855. * directional lights use illuminance
  9856. */
  9857. static readonly INTENSITYMODE_AUTOMATIC: number;
  9858. /**
  9859. * lumen (lm)
  9860. */
  9861. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9862. /**
  9863. * candela (lm/sr)
  9864. */
  9865. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9866. /**
  9867. * lux (lm/m^2)
  9868. */
  9869. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9870. /**
  9871. * nit (cd/m^2)
  9872. */
  9873. static readonly INTENSITYMODE_LUMINANCE: number;
  9874. /**
  9875. * Light type const id of the point light.
  9876. */
  9877. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9878. /**
  9879. * Light type const id of the directional light.
  9880. */
  9881. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9882. /**
  9883. * Light type const id of the spot light.
  9884. */
  9885. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9886. /**
  9887. * Light type const id of the hemispheric light.
  9888. */
  9889. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9890. /**
  9891. * Diffuse gives the basic color to an object.
  9892. */
  9893. diffuse: Color3;
  9894. /**
  9895. * Specular produces a highlight color on an object.
  9896. * Note: This is note affecting PBR materials.
  9897. */
  9898. specular: Color3;
  9899. /**
  9900. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9901. * falling off base on range or angle.
  9902. * This can be set to any values in Light.FALLOFF_x.
  9903. *
  9904. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9905. * other types of materials.
  9906. */
  9907. falloffType: number;
  9908. /**
  9909. * Strength of the light.
  9910. * Note: By default it is define in the framework own unit.
  9911. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9912. */
  9913. intensity: number;
  9914. private _range;
  9915. protected _inverseSquaredRange: number;
  9916. /**
  9917. * Defines how far from the source the light is impacting in scene units.
  9918. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9919. */
  9920. /**
  9921. * Defines how far from the source the light is impacting in scene units.
  9922. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9923. */
  9924. range: number;
  9925. /**
  9926. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9927. * of light.
  9928. */
  9929. private _photometricScale;
  9930. private _intensityMode;
  9931. /**
  9932. * Gets the photometric scale used to interpret the intensity.
  9933. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9934. */
  9935. /**
  9936. * Sets the photometric scale used to interpret the intensity.
  9937. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9938. */
  9939. intensityMode: number;
  9940. private _radius;
  9941. /**
  9942. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9943. */
  9944. /**
  9945. * sets the light radius used by PBR Materials to simulate soft area lights.
  9946. */
  9947. radius: number;
  9948. private _renderPriority;
  9949. /**
  9950. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9951. * exceeding the number allowed of the materials.
  9952. */
  9953. renderPriority: number;
  9954. private _shadowEnabled;
  9955. /**
  9956. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9957. * the current shadow generator.
  9958. */
  9959. /**
  9960. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9961. * the current shadow generator.
  9962. */
  9963. shadowEnabled: boolean;
  9964. private _includedOnlyMeshes;
  9965. /**
  9966. * Gets the only meshes impacted by this light.
  9967. */
  9968. /**
  9969. * Sets the only meshes impacted by this light.
  9970. */
  9971. includedOnlyMeshes: AbstractMesh[];
  9972. private _excludedMeshes;
  9973. /**
  9974. * Gets the meshes not impacted by this light.
  9975. */
  9976. /**
  9977. * Sets the meshes not impacted by this light.
  9978. */
  9979. excludedMeshes: AbstractMesh[];
  9980. private _excludeWithLayerMask;
  9981. /**
  9982. * Gets the layer id use to find what meshes are not impacted by the light.
  9983. * Inactive if 0
  9984. */
  9985. /**
  9986. * Sets the layer id use to find what meshes are not impacted by the light.
  9987. * Inactive if 0
  9988. */
  9989. excludeWithLayerMask: number;
  9990. private _includeOnlyWithLayerMask;
  9991. /**
  9992. * Gets the layer id use to find what meshes are impacted by the light.
  9993. * Inactive if 0
  9994. */
  9995. /**
  9996. * Sets the layer id use to find what meshes are impacted by the light.
  9997. * Inactive if 0
  9998. */
  9999. includeOnlyWithLayerMask: number;
  10000. private _lightmapMode;
  10001. /**
  10002. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10003. */
  10004. /**
  10005. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10006. */
  10007. lightmapMode: number;
  10008. /**
  10009. * Shadow generator associted to the light.
  10010. * @hidden Internal use only.
  10011. */
  10012. _shadowGenerator: Nullable<IShadowGenerator>;
  10013. /**
  10014. * @hidden Internal use only.
  10015. */
  10016. _excludedMeshesIds: string[];
  10017. /**
  10018. * @hidden Internal use only.
  10019. */
  10020. _includedOnlyMeshesIds: string[];
  10021. /**
  10022. * The current light unifom buffer.
  10023. * @hidden Internal use only.
  10024. */
  10025. _uniformBuffer: UniformBuffer;
  10026. /**
  10027. * Creates a Light object in the scene.
  10028. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10029. * @param name The firendly name of the light
  10030. * @param scene The scene the light belongs too
  10031. */
  10032. constructor(name: string, scene: Scene);
  10033. protected abstract _buildUniformLayout(): void;
  10034. /**
  10035. * Sets the passed Effect "effect" with the Light information.
  10036. * @param effect The effect to update
  10037. * @param lightIndex The index of the light in the effect to update
  10038. * @returns The light
  10039. */
  10040. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10041. /**
  10042. * Sets the passed Effect "effect" with the Light information.
  10043. * @param effect The effect to update
  10044. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10045. * @returns The light
  10046. */
  10047. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10048. /**
  10049. * Returns the string "Light".
  10050. * @returns the class name
  10051. */
  10052. getClassName(): string;
  10053. /** @hidden */
  10054. readonly _isLight: boolean;
  10055. /**
  10056. * Converts the light information to a readable string for debug purpose.
  10057. * @param fullDetails Supports for multiple levels of logging within scene loading
  10058. * @returns the human readable light info
  10059. */
  10060. toString(fullDetails?: boolean): string;
  10061. /** @hidden */
  10062. protected _syncParentEnabledState(): void;
  10063. /**
  10064. * Set the enabled state of this node.
  10065. * @param value - the new enabled state
  10066. */
  10067. setEnabled(value: boolean): void;
  10068. /**
  10069. * Returns the Light associated shadow generator if any.
  10070. * @return the associated shadow generator.
  10071. */
  10072. getShadowGenerator(): Nullable<IShadowGenerator>;
  10073. /**
  10074. * Returns a Vector3, the absolute light position in the World.
  10075. * @returns the world space position of the light
  10076. */
  10077. getAbsolutePosition(): Vector3;
  10078. /**
  10079. * Specifies if the light will affect the passed mesh.
  10080. * @param mesh The mesh to test against the light
  10081. * @return true the mesh is affected otherwise, false.
  10082. */
  10083. canAffectMesh(mesh: AbstractMesh): boolean;
  10084. /**
  10085. * Sort function to order lights for rendering.
  10086. * @param a First Light object to compare to second.
  10087. * @param b Second Light object to compare first.
  10088. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10089. */
  10090. static CompareLightsPriority(a: Light, b: Light): number;
  10091. /**
  10092. * Releases resources associated with this node.
  10093. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10094. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10095. */
  10096. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10097. /**
  10098. * Returns the light type ID (integer).
  10099. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10100. */
  10101. getTypeID(): number;
  10102. /**
  10103. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10104. * @returns the scaled intensity in intensity mode unit
  10105. */
  10106. getScaledIntensity(): number;
  10107. /**
  10108. * Returns a new Light object, named "name", from the current one.
  10109. * @param name The name of the cloned light
  10110. * @returns the new created light
  10111. */
  10112. clone(name: string): Nullable<Light>;
  10113. /**
  10114. * Serializes the current light into a Serialization object.
  10115. * @returns the serialized object.
  10116. */
  10117. serialize(): any;
  10118. /**
  10119. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10120. * This new light is named "name" and added to the passed scene.
  10121. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10122. * @param name The friendly name of the light
  10123. * @param scene The scene the new light will belong to
  10124. * @returns the constructor function
  10125. */
  10126. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10127. /**
  10128. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10129. * @param parsedLight The JSON representation of the light
  10130. * @param scene The scene to create the parsed light in
  10131. * @returns the created light after parsing
  10132. */
  10133. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10134. private _hookArrayForExcluded;
  10135. private _hookArrayForIncludedOnly;
  10136. private _resyncMeshes;
  10137. /**
  10138. * Forces the meshes to update their light related information in their rendering used effects
  10139. * @hidden Internal Use Only
  10140. */
  10141. _markMeshesAsLightDirty(): void;
  10142. /**
  10143. * Recomputes the cached photometric scale if needed.
  10144. */
  10145. private _computePhotometricScale;
  10146. /**
  10147. * Returns the Photometric Scale according to the light type and intensity mode.
  10148. */
  10149. private _getPhotometricScale;
  10150. /**
  10151. * Reorder the light in the scene according to their defined priority.
  10152. * @hidden Internal Use Only
  10153. */
  10154. _reorderLightsInScene(): void;
  10155. /**
  10156. * Prepares the list of defines specific to the light type.
  10157. * @param defines the list of defines
  10158. * @param lightIndex defines the index of the light for the effect
  10159. */
  10160. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10161. }
  10162. }
  10163. declare module "babylonjs/Actions/action" {
  10164. import { Observable } from "babylonjs/Misc/observable";
  10165. import { Condition } from "babylonjs/Actions/condition";
  10166. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10167. import { ActionManager } from "babylonjs/Actions/actionManager";
  10168. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10169. /**
  10170. * Interface used to define Action
  10171. */
  10172. export interface IAction {
  10173. /**
  10174. * Trigger for the action
  10175. */
  10176. trigger: number;
  10177. /** Options of the trigger */
  10178. triggerOptions: any;
  10179. /**
  10180. * Gets the trigger parameters
  10181. * @returns the trigger parameters
  10182. */
  10183. getTriggerParameter(): any;
  10184. /**
  10185. * Internal only - executes current action event
  10186. * @hidden
  10187. */
  10188. _executeCurrent(evt?: ActionEvent): void;
  10189. /**
  10190. * Serialize placeholder for child classes
  10191. * @param parent of child
  10192. * @returns the serialized object
  10193. */
  10194. serialize(parent: any): any;
  10195. /**
  10196. * Internal only
  10197. * @hidden
  10198. */
  10199. _prepare(): void;
  10200. /**
  10201. * Internal only - manager for action
  10202. * @hidden
  10203. */
  10204. _actionManager: AbstractActionManager;
  10205. /**
  10206. * Adds action to chain of actions, may be a DoNothingAction
  10207. * @param action defines the next action to execute
  10208. * @returns The action passed in
  10209. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10210. */
  10211. then(action: IAction): IAction;
  10212. }
  10213. /**
  10214. * The action to be carried out following a trigger
  10215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10216. */
  10217. export class Action implements IAction {
  10218. /** the trigger, with or without parameters, for the action */
  10219. triggerOptions: any;
  10220. /**
  10221. * Trigger for the action
  10222. */
  10223. trigger: number;
  10224. /**
  10225. * Internal only - manager for action
  10226. * @hidden
  10227. */
  10228. _actionManager: ActionManager;
  10229. private _nextActiveAction;
  10230. private _child;
  10231. private _condition?;
  10232. private _triggerParameter;
  10233. /**
  10234. * An event triggered prior to action being executed.
  10235. */
  10236. onBeforeExecuteObservable: Observable<Action>;
  10237. /**
  10238. * Creates a new Action
  10239. * @param triggerOptions the trigger, with or without parameters, for the action
  10240. * @param condition an optional determinant of action
  10241. */
  10242. constructor(
  10243. /** the trigger, with or without parameters, for the action */
  10244. triggerOptions: any, condition?: Condition);
  10245. /**
  10246. * Internal only
  10247. * @hidden
  10248. */
  10249. _prepare(): void;
  10250. /**
  10251. * Gets the trigger parameters
  10252. * @returns the trigger parameters
  10253. */
  10254. getTriggerParameter(): any;
  10255. /**
  10256. * Internal only - executes current action event
  10257. * @hidden
  10258. */
  10259. _executeCurrent(evt?: ActionEvent): void;
  10260. /**
  10261. * Execute placeholder for child classes
  10262. * @param evt optional action event
  10263. */
  10264. execute(evt?: ActionEvent): void;
  10265. /**
  10266. * Skips to next active action
  10267. */
  10268. skipToNextActiveAction(): void;
  10269. /**
  10270. * Adds action to chain of actions, may be a DoNothingAction
  10271. * @param action defines the next action to execute
  10272. * @returns The action passed in
  10273. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10274. */
  10275. then(action: Action): Action;
  10276. /**
  10277. * Internal only
  10278. * @hidden
  10279. */
  10280. _getProperty(propertyPath: string): string;
  10281. /**
  10282. * Internal only
  10283. * @hidden
  10284. */
  10285. _getEffectiveTarget(target: any, propertyPath: string): any;
  10286. /**
  10287. * Serialize placeholder for child classes
  10288. * @param parent of child
  10289. * @returns the serialized object
  10290. */
  10291. serialize(parent: any): any;
  10292. /**
  10293. * Internal only called by serialize
  10294. * @hidden
  10295. */
  10296. protected _serialize(serializedAction: any, parent?: any): any;
  10297. /**
  10298. * Internal only
  10299. * @hidden
  10300. */
  10301. static _SerializeValueAsString: (value: any) => string;
  10302. /**
  10303. * Internal only
  10304. * @hidden
  10305. */
  10306. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10307. name: string;
  10308. targetType: string;
  10309. value: string;
  10310. };
  10311. }
  10312. }
  10313. declare module "babylonjs/Actions/condition" {
  10314. import { ActionManager } from "babylonjs/Actions/actionManager";
  10315. /**
  10316. * A Condition applied to an Action
  10317. */
  10318. export class Condition {
  10319. /**
  10320. * Internal only - manager for action
  10321. * @hidden
  10322. */
  10323. _actionManager: ActionManager;
  10324. /**
  10325. * Internal only
  10326. * @hidden
  10327. */
  10328. _evaluationId: number;
  10329. /**
  10330. * Internal only
  10331. * @hidden
  10332. */
  10333. _currentResult: boolean;
  10334. /**
  10335. * Creates a new Condition
  10336. * @param actionManager the manager of the action the condition is applied to
  10337. */
  10338. constructor(actionManager: ActionManager);
  10339. /**
  10340. * Check if the current condition is valid
  10341. * @returns a boolean
  10342. */
  10343. isValid(): boolean;
  10344. /**
  10345. * Internal only
  10346. * @hidden
  10347. */
  10348. _getProperty(propertyPath: string): string;
  10349. /**
  10350. * Internal only
  10351. * @hidden
  10352. */
  10353. _getEffectiveTarget(target: any, propertyPath: string): any;
  10354. /**
  10355. * Serialize placeholder for child classes
  10356. * @returns the serialized object
  10357. */
  10358. serialize(): any;
  10359. /**
  10360. * Internal only
  10361. * @hidden
  10362. */
  10363. protected _serialize(serializedCondition: any): any;
  10364. }
  10365. /**
  10366. * Defines specific conditional operators as extensions of Condition
  10367. */
  10368. export class ValueCondition extends Condition {
  10369. /** path to specify the property of the target the conditional operator uses */
  10370. propertyPath: string;
  10371. /** the value compared by the conditional operator against the current value of the property */
  10372. value: any;
  10373. /** the conditional operator, default ValueCondition.IsEqual */
  10374. operator: number;
  10375. /**
  10376. * Internal only
  10377. * @hidden
  10378. */
  10379. private static _IsEqual;
  10380. /**
  10381. * Internal only
  10382. * @hidden
  10383. */
  10384. private static _IsDifferent;
  10385. /**
  10386. * Internal only
  10387. * @hidden
  10388. */
  10389. private static _IsGreater;
  10390. /**
  10391. * Internal only
  10392. * @hidden
  10393. */
  10394. private static _IsLesser;
  10395. /**
  10396. * returns the number for IsEqual
  10397. */
  10398. static readonly IsEqual: number;
  10399. /**
  10400. * Returns the number for IsDifferent
  10401. */
  10402. static readonly IsDifferent: number;
  10403. /**
  10404. * Returns the number for IsGreater
  10405. */
  10406. static readonly IsGreater: number;
  10407. /**
  10408. * Returns the number for IsLesser
  10409. */
  10410. static readonly IsLesser: number;
  10411. /**
  10412. * Internal only The action manager for the condition
  10413. * @hidden
  10414. */
  10415. _actionManager: ActionManager;
  10416. /**
  10417. * Internal only
  10418. * @hidden
  10419. */
  10420. private _target;
  10421. /**
  10422. * Internal only
  10423. * @hidden
  10424. */
  10425. private _effectiveTarget;
  10426. /**
  10427. * Internal only
  10428. * @hidden
  10429. */
  10430. private _property;
  10431. /**
  10432. * Creates a new ValueCondition
  10433. * @param actionManager manager for the action the condition applies to
  10434. * @param target for the action
  10435. * @param propertyPath path to specify the property of the target the conditional operator uses
  10436. * @param value the value compared by the conditional operator against the current value of the property
  10437. * @param operator the conditional operator, default ValueCondition.IsEqual
  10438. */
  10439. constructor(actionManager: ActionManager, target: any,
  10440. /** path to specify the property of the target the conditional operator uses */
  10441. propertyPath: string,
  10442. /** the value compared by the conditional operator against the current value of the property */
  10443. value: any,
  10444. /** the conditional operator, default ValueCondition.IsEqual */
  10445. operator?: number);
  10446. /**
  10447. * Compares the given value with the property value for the specified conditional operator
  10448. * @returns the result of the comparison
  10449. */
  10450. isValid(): boolean;
  10451. /**
  10452. * Serialize the ValueCondition into a JSON compatible object
  10453. * @returns serialization object
  10454. */
  10455. serialize(): any;
  10456. /**
  10457. * Gets the name of the conditional operator for the ValueCondition
  10458. * @param operator the conditional operator
  10459. * @returns the name
  10460. */
  10461. static GetOperatorName(operator: number): string;
  10462. }
  10463. /**
  10464. * Defines a predicate condition as an extension of Condition
  10465. */
  10466. export class PredicateCondition extends Condition {
  10467. /** defines the predicate function used to validate the condition */
  10468. predicate: () => boolean;
  10469. /**
  10470. * Internal only - manager for action
  10471. * @hidden
  10472. */
  10473. _actionManager: ActionManager;
  10474. /**
  10475. * Creates a new PredicateCondition
  10476. * @param actionManager manager for the action the condition applies to
  10477. * @param predicate defines the predicate function used to validate the condition
  10478. */
  10479. constructor(actionManager: ActionManager,
  10480. /** defines the predicate function used to validate the condition */
  10481. predicate: () => boolean);
  10482. /**
  10483. * @returns the validity of the predicate condition
  10484. */
  10485. isValid(): boolean;
  10486. }
  10487. /**
  10488. * Defines a state condition as an extension of Condition
  10489. */
  10490. export class StateCondition extends Condition {
  10491. /** Value to compare with target state */
  10492. value: string;
  10493. /**
  10494. * Internal only - manager for action
  10495. * @hidden
  10496. */
  10497. _actionManager: ActionManager;
  10498. /**
  10499. * Internal only
  10500. * @hidden
  10501. */
  10502. private _target;
  10503. /**
  10504. * Creates a new StateCondition
  10505. * @param actionManager manager for the action the condition applies to
  10506. * @param target of the condition
  10507. * @param value to compare with target state
  10508. */
  10509. constructor(actionManager: ActionManager, target: any,
  10510. /** Value to compare with target state */
  10511. value: string);
  10512. /**
  10513. * Gets a boolean indicating if the current condition is met
  10514. * @returns the validity of the state
  10515. */
  10516. isValid(): boolean;
  10517. /**
  10518. * Serialize the StateCondition into a JSON compatible object
  10519. * @returns serialization object
  10520. */
  10521. serialize(): any;
  10522. }
  10523. }
  10524. declare module "babylonjs/Actions/directActions" {
  10525. import { Action } from "babylonjs/Actions/action";
  10526. import { Condition } from "babylonjs/Actions/condition";
  10527. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10528. /**
  10529. * This defines an action responsible to toggle a boolean once triggered.
  10530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10531. */
  10532. export class SwitchBooleanAction extends Action {
  10533. /**
  10534. * The path to the boolean property in the target object
  10535. */
  10536. propertyPath: string;
  10537. private _target;
  10538. private _effectiveTarget;
  10539. private _property;
  10540. /**
  10541. * Instantiate the action
  10542. * @param triggerOptions defines the trigger options
  10543. * @param target defines the object containing the boolean
  10544. * @param propertyPath defines the path to the boolean property in the target object
  10545. * @param condition defines the trigger related conditions
  10546. */
  10547. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10548. /** @hidden */
  10549. _prepare(): void;
  10550. /**
  10551. * Execute the action toggle the boolean value.
  10552. */
  10553. execute(): void;
  10554. /**
  10555. * Serializes the actions and its related information.
  10556. * @param parent defines the object to serialize in
  10557. * @returns the serialized object
  10558. */
  10559. serialize(parent: any): any;
  10560. }
  10561. /**
  10562. * This defines an action responsible to set a the state field of the target
  10563. * to a desired value once triggered.
  10564. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10565. */
  10566. export class SetStateAction extends Action {
  10567. /**
  10568. * The value to store in the state field.
  10569. */
  10570. value: string;
  10571. private _target;
  10572. /**
  10573. * Instantiate the action
  10574. * @param triggerOptions defines the trigger options
  10575. * @param target defines the object containing the state property
  10576. * @param value defines the value to store in the state field
  10577. * @param condition defines the trigger related conditions
  10578. */
  10579. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10580. /**
  10581. * Execute the action and store the value on the target state property.
  10582. */
  10583. execute(): void;
  10584. /**
  10585. * Serializes the actions and its related information.
  10586. * @param parent defines the object to serialize in
  10587. * @returns the serialized object
  10588. */
  10589. serialize(parent: any): any;
  10590. }
  10591. /**
  10592. * This defines an action responsible to set a property of the target
  10593. * to a desired value once triggered.
  10594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10595. */
  10596. export class SetValueAction extends Action {
  10597. /**
  10598. * The path of the property to set in the target.
  10599. */
  10600. propertyPath: string;
  10601. /**
  10602. * The value to set in the property
  10603. */
  10604. value: any;
  10605. private _target;
  10606. private _effectiveTarget;
  10607. private _property;
  10608. /**
  10609. * Instantiate the action
  10610. * @param triggerOptions defines the trigger options
  10611. * @param target defines the object containing the property
  10612. * @param propertyPath defines the path of the property to set in the target
  10613. * @param value defines the value to set in the property
  10614. * @param condition defines the trigger related conditions
  10615. */
  10616. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10617. /** @hidden */
  10618. _prepare(): void;
  10619. /**
  10620. * Execute the action and set the targetted property to the desired value.
  10621. */
  10622. execute(): void;
  10623. /**
  10624. * Serializes the actions and its related information.
  10625. * @param parent defines the object to serialize in
  10626. * @returns the serialized object
  10627. */
  10628. serialize(parent: any): any;
  10629. }
  10630. /**
  10631. * This defines an action responsible to increment the target value
  10632. * to a desired value once triggered.
  10633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10634. */
  10635. export class IncrementValueAction extends Action {
  10636. /**
  10637. * The path of the property to increment in the target.
  10638. */
  10639. propertyPath: string;
  10640. /**
  10641. * The value we should increment the property by.
  10642. */
  10643. value: any;
  10644. private _target;
  10645. private _effectiveTarget;
  10646. private _property;
  10647. /**
  10648. * Instantiate the action
  10649. * @param triggerOptions defines the trigger options
  10650. * @param target defines the object containing the property
  10651. * @param propertyPath defines the path of the property to increment in the target
  10652. * @param value defines the value value we should increment the property by
  10653. * @param condition defines the trigger related conditions
  10654. */
  10655. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10656. /** @hidden */
  10657. _prepare(): void;
  10658. /**
  10659. * Execute the action and increment the target of the value amount.
  10660. */
  10661. execute(): void;
  10662. /**
  10663. * Serializes the actions and its related information.
  10664. * @param parent defines the object to serialize in
  10665. * @returns the serialized object
  10666. */
  10667. serialize(parent: any): any;
  10668. }
  10669. /**
  10670. * This defines an action responsible to start an animation once triggered.
  10671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10672. */
  10673. export class PlayAnimationAction extends Action {
  10674. /**
  10675. * Where the animation should start (animation frame)
  10676. */
  10677. from: number;
  10678. /**
  10679. * Where the animation should stop (animation frame)
  10680. */
  10681. to: number;
  10682. /**
  10683. * Define if the animation should loop or stop after the first play.
  10684. */
  10685. loop?: boolean;
  10686. private _target;
  10687. /**
  10688. * Instantiate the action
  10689. * @param triggerOptions defines the trigger options
  10690. * @param target defines the target animation or animation name
  10691. * @param from defines from where the animation should start (animation frame)
  10692. * @param end defines where the animation should stop (animation frame)
  10693. * @param loop defines if the animation should loop or stop after the first play
  10694. * @param condition defines the trigger related conditions
  10695. */
  10696. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10697. /** @hidden */
  10698. _prepare(): void;
  10699. /**
  10700. * Execute the action and play the animation.
  10701. */
  10702. execute(): void;
  10703. /**
  10704. * Serializes the actions and its related information.
  10705. * @param parent defines the object to serialize in
  10706. * @returns the serialized object
  10707. */
  10708. serialize(parent: any): any;
  10709. }
  10710. /**
  10711. * This defines an action responsible to stop an animation once triggered.
  10712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10713. */
  10714. export class StopAnimationAction extends Action {
  10715. private _target;
  10716. /**
  10717. * Instantiate the action
  10718. * @param triggerOptions defines the trigger options
  10719. * @param target defines the target animation or animation name
  10720. * @param condition defines the trigger related conditions
  10721. */
  10722. constructor(triggerOptions: any, target: any, condition?: Condition);
  10723. /** @hidden */
  10724. _prepare(): void;
  10725. /**
  10726. * Execute the action and stop the animation.
  10727. */
  10728. execute(): void;
  10729. /**
  10730. * Serializes the actions and its related information.
  10731. * @param parent defines the object to serialize in
  10732. * @returns the serialized object
  10733. */
  10734. serialize(parent: any): any;
  10735. }
  10736. /**
  10737. * This defines an action responsible that does nothing once triggered.
  10738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10739. */
  10740. export class DoNothingAction extends Action {
  10741. /**
  10742. * Instantiate the action
  10743. * @param triggerOptions defines the trigger options
  10744. * @param condition defines the trigger related conditions
  10745. */
  10746. constructor(triggerOptions?: any, condition?: Condition);
  10747. /**
  10748. * Execute the action and do nothing.
  10749. */
  10750. execute(): void;
  10751. /**
  10752. * Serializes the actions and its related information.
  10753. * @param parent defines the object to serialize in
  10754. * @returns the serialized object
  10755. */
  10756. serialize(parent: any): any;
  10757. }
  10758. /**
  10759. * This defines an action responsible to trigger several actions once triggered.
  10760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10761. */
  10762. export class CombineAction extends Action {
  10763. /**
  10764. * The list of aggregated animations to run.
  10765. */
  10766. children: Action[];
  10767. /**
  10768. * Instantiate the action
  10769. * @param triggerOptions defines the trigger options
  10770. * @param children defines the list of aggregated animations to run
  10771. * @param condition defines the trigger related conditions
  10772. */
  10773. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10774. /** @hidden */
  10775. _prepare(): void;
  10776. /**
  10777. * Execute the action and executes all the aggregated actions.
  10778. */
  10779. execute(evt: ActionEvent): void;
  10780. /**
  10781. * Serializes the actions and its related information.
  10782. * @param parent defines the object to serialize in
  10783. * @returns the serialized object
  10784. */
  10785. serialize(parent: any): any;
  10786. }
  10787. /**
  10788. * This defines an action responsible to run code (external event) once triggered.
  10789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10790. */
  10791. export class ExecuteCodeAction extends Action {
  10792. /**
  10793. * The callback function to run.
  10794. */
  10795. func: (evt: ActionEvent) => void;
  10796. /**
  10797. * Instantiate the action
  10798. * @param triggerOptions defines the trigger options
  10799. * @param func defines the callback function to run
  10800. * @param condition defines the trigger related conditions
  10801. */
  10802. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10803. /**
  10804. * Execute the action and run the attached code.
  10805. */
  10806. execute(evt: ActionEvent): void;
  10807. }
  10808. /**
  10809. * This defines an action responsible to set the parent property of the target once triggered.
  10810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10811. */
  10812. export class SetParentAction extends Action {
  10813. private _parent;
  10814. private _target;
  10815. /**
  10816. * Instantiate the action
  10817. * @param triggerOptions defines the trigger options
  10818. * @param target defines the target containing the parent property
  10819. * @param parent defines from where the animation should start (animation frame)
  10820. * @param condition defines the trigger related conditions
  10821. */
  10822. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10823. /** @hidden */
  10824. _prepare(): void;
  10825. /**
  10826. * Execute the action and set the parent property.
  10827. */
  10828. execute(): void;
  10829. /**
  10830. * Serializes the actions and its related information.
  10831. * @param parent defines the object to serialize in
  10832. * @returns the serialized object
  10833. */
  10834. serialize(parent: any): any;
  10835. }
  10836. }
  10837. declare module "babylonjs/Actions/actionManager" {
  10838. import { Nullable } from "babylonjs/types";
  10839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10840. import { Scene } from "babylonjs/scene";
  10841. import { IAction } from "babylonjs/Actions/action";
  10842. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10843. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10844. /**
  10845. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10846. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10848. */
  10849. export class ActionManager extends AbstractActionManager {
  10850. /**
  10851. * Nothing
  10852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10853. */
  10854. static readonly NothingTrigger: number;
  10855. /**
  10856. * On pick
  10857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10858. */
  10859. static readonly OnPickTrigger: number;
  10860. /**
  10861. * On left pick
  10862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10863. */
  10864. static readonly OnLeftPickTrigger: number;
  10865. /**
  10866. * On right pick
  10867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10868. */
  10869. static readonly OnRightPickTrigger: number;
  10870. /**
  10871. * On center pick
  10872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10873. */
  10874. static readonly OnCenterPickTrigger: number;
  10875. /**
  10876. * On pick down
  10877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10878. */
  10879. static readonly OnPickDownTrigger: number;
  10880. /**
  10881. * On double pick
  10882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10883. */
  10884. static readonly OnDoublePickTrigger: number;
  10885. /**
  10886. * On pick up
  10887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10888. */
  10889. static readonly OnPickUpTrigger: number;
  10890. /**
  10891. * On pick out.
  10892. * This trigger will only be raised if you also declared a OnPickDown
  10893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10894. */
  10895. static readonly OnPickOutTrigger: number;
  10896. /**
  10897. * On long press
  10898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10899. */
  10900. static readonly OnLongPressTrigger: number;
  10901. /**
  10902. * On pointer over
  10903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10904. */
  10905. static readonly OnPointerOverTrigger: number;
  10906. /**
  10907. * On pointer out
  10908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10909. */
  10910. static readonly OnPointerOutTrigger: number;
  10911. /**
  10912. * On every frame
  10913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10914. */
  10915. static readonly OnEveryFrameTrigger: number;
  10916. /**
  10917. * On intersection enter
  10918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10919. */
  10920. static readonly OnIntersectionEnterTrigger: number;
  10921. /**
  10922. * On intersection exit
  10923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10924. */
  10925. static readonly OnIntersectionExitTrigger: number;
  10926. /**
  10927. * On key down
  10928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10929. */
  10930. static readonly OnKeyDownTrigger: number;
  10931. /**
  10932. * On key up
  10933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10934. */
  10935. static readonly OnKeyUpTrigger: number;
  10936. private _scene;
  10937. /**
  10938. * Creates a new action manager
  10939. * @param scene defines the hosting scene
  10940. */
  10941. constructor(scene: Scene);
  10942. /**
  10943. * Releases all associated resources
  10944. */
  10945. dispose(): void;
  10946. /**
  10947. * Gets hosting scene
  10948. * @returns the hosting scene
  10949. */
  10950. getScene(): Scene;
  10951. /**
  10952. * Does this action manager handles actions of any of the given triggers
  10953. * @param triggers defines the triggers to be tested
  10954. * @return a boolean indicating whether one (or more) of the triggers is handled
  10955. */
  10956. hasSpecificTriggers(triggers: number[]): boolean;
  10957. /**
  10958. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10959. * speed.
  10960. * @param triggerA defines the trigger to be tested
  10961. * @param triggerB defines the trigger to be tested
  10962. * @return a boolean indicating whether one (or more) of the triggers is handled
  10963. */
  10964. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10965. /**
  10966. * Does this action manager handles actions of a given trigger
  10967. * @param trigger defines the trigger to be tested
  10968. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10969. * @return whether the trigger is handled
  10970. */
  10971. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10972. /**
  10973. * Does this action manager has pointer triggers
  10974. */
  10975. readonly hasPointerTriggers: boolean;
  10976. /**
  10977. * Does this action manager has pick triggers
  10978. */
  10979. readonly hasPickTriggers: boolean;
  10980. /**
  10981. * Registers an action to this action manager
  10982. * @param action defines the action to be registered
  10983. * @return the action amended (prepared) after registration
  10984. */
  10985. registerAction(action: IAction): Nullable<IAction>;
  10986. /**
  10987. * Unregisters an action to this action manager
  10988. * @param action defines the action to be unregistered
  10989. * @return a boolean indicating whether the action has been unregistered
  10990. */
  10991. unregisterAction(action: IAction): Boolean;
  10992. /**
  10993. * Process a specific trigger
  10994. * @param trigger defines the trigger to process
  10995. * @param evt defines the event details to be processed
  10996. */
  10997. processTrigger(trigger: number, evt?: IActionEvent): void;
  10998. /** @hidden */
  10999. _getEffectiveTarget(target: any, propertyPath: string): any;
  11000. /** @hidden */
  11001. _getProperty(propertyPath: string): string;
  11002. /**
  11003. * Serialize this manager to a JSON object
  11004. * @param name defines the property name to store this manager
  11005. * @returns a JSON representation of this manager
  11006. */
  11007. serialize(name: string): any;
  11008. /**
  11009. * Creates a new ActionManager from a JSON data
  11010. * @param parsedActions defines the JSON data to read from
  11011. * @param object defines the hosting mesh
  11012. * @param scene defines the hosting scene
  11013. */
  11014. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11015. /**
  11016. * Get a trigger name by index
  11017. * @param trigger defines the trigger index
  11018. * @returns a trigger name
  11019. */
  11020. static GetTriggerName(trigger: number): string;
  11021. }
  11022. }
  11023. declare module "babylonjs/Culling/ray" {
  11024. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11025. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11027. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11028. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11029. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11030. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11031. import { Plane } from "babylonjs/Maths/math.plane";
  11032. /**
  11033. * Class representing a ray with position and direction
  11034. */
  11035. export class Ray {
  11036. /** origin point */
  11037. origin: Vector3;
  11038. /** direction */
  11039. direction: Vector3;
  11040. /** length of the ray */
  11041. length: number;
  11042. private static readonly TmpVector3;
  11043. private _tmpRay;
  11044. /**
  11045. * Creates a new ray
  11046. * @param origin origin point
  11047. * @param direction direction
  11048. * @param length length of the ray
  11049. */
  11050. constructor(
  11051. /** origin point */
  11052. origin: Vector3,
  11053. /** direction */
  11054. direction: Vector3,
  11055. /** length of the ray */
  11056. length?: number);
  11057. /**
  11058. * Checks if the ray intersects a box
  11059. * @param minimum bound of the box
  11060. * @param maximum bound of the box
  11061. * @param intersectionTreshold extra extend to be added to the box in all direction
  11062. * @returns if the box was hit
  11063. */
  11064. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11065. /**
  11066. * Checks if the ray intersects a box
  11067. * @param box the bounding box to check
  11068. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11069. * @returns if the box was hit
  11070. */
  11071. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11072. /**
  11073. * If the ray hits a sphere
  11074. * @param sphere the bounding sphere to check
  11075. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11076. * @returns true if it hits the sphere
  11077. */
  11078. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11079. /**
  11080. * If the ray hits a triange
  11081. * @param vertex0 triangle vertex
  11082. * @param vertex1 triangle vertex
  11083. * @param vertex2 triangle vertex
  11084. * @returns intersection information if hit
  11085. */
  11086. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11087. /**
  11088. * Checks if ray intersects a plane
  11089. * @param plane the plane to check
  11090. * @returns the distance away it was hit
  11091. */
  11092. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11093. /**
  11094. * Calculate the intercept of a ray on a given axis
  11095. * @param axis to check 'x' | 'y' | 'z'
  11096. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11097. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11098. */
  11099. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11100. /**
  11101. * Checks if ray intersects a mesh
  11102. * @param mesh the mesh to check
  11103. * @param fastCheck if only the bounding box should checked
  11104. * @returns picking info of the intersecton
  11105. */
  11106. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11107. /**
  11108. * Checks if ray intersects a mesh
  11109. * @param meshes the meshes to check
  11110. * @param fastCheck if only the bounding box should checked
  11111. * @param results array to store result in
  11112. * @returns Array of picking infos
  11113. */
  11114. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11115. private _comparePickingInfo;
  11116. private static smallnum;
  11117. private static rayl;
  11118. /**
  11119. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11120. * @param sega the first point of the segment to test the intersection against
  11121. * @param segb the second point of the segment to test the intersection against
  11122. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11123. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11124. */
  11125. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11126. /**
  11127. * Update the ray from viewport position
  11128. * @param x position
  11129. * @param y y position
  11130. * @param viewportWidth viewport width
  11131. * @param viewportHeight viewport height
  11132. * @param world world matrix
  11133. * @param view view matrix
  11134. * @param projection projection matrix
  11135. * @returns this ray updated
  11136. */
  11137. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11138. /**
  11139. * Creates a ray with origin and direction of 0,0,0
  11140. * @returns the new ray
  11141. */
  11142. static Zero(): Ray;
  11143. /**
  11144. * Creates a new ray from screen space and viewport
  11145. * @param x position
  11146. * @param y y position
  11147. * @param viewportWidth viewport width
  11148. * @param viewportHeight viewport height
  11149. * @param world world matrix
  11150. * @param view view matrix
  11151. * @param projection projection matrix
  11152. * @returns new ray
  11153. */
  11154. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11155. /**
  11156. * 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
  11157. * transformed to the given world matrix.
  11158. * @param origin The origin point
  11159. * @param end The end point
  11160. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11161. * @returns the new ray
  11162. */
  11163. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11164. /**
  11165. * Transforms a ray by a matrix
  11166. * @param ray ray to transform
  11167. * @param matrix matrix to apply
  11168. * @returns the resulting new ray
  11169. */
  11170. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11171. /**
  11172. * Transforms a ray by a matrix
  11173. * @param ray ray to transform
  11174. * @param matrix matrix to apply
  11175. * @param result ray to store result in
  11176. */
  11177. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11178. /**
  11179. * Unproject a ray from screen space to object space
  11180. * @param sourceX defines the screen space x coordinate to use
  11181. * @param sourceY defines the screen space y coordinate to use
  11182. * @param viewportWidth defines the current width of the viewport
  11183. * @param viewportHeight defines the current height of the viewport
  11184. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11185. * @param view defines the view matrix to use
  11186. * @param projection defines the projection matrix to use
  11187. */
  11188. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11189. }
  11190. /**
  11191. * Type used to define predicate used to select faces when a mesh intersection is detected
  11192. */
  11193. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11194. module "babylonjs/scene" {
  11195. interface Scene {
  11196. /** @hidden */
  11197. _tempPickingRay: Nullable<Ray>;
  11198. /** @hidden */
  11199. _cachedRayForTransform: Ray;
  11200. /** @hidden */
  11201. _pickWithRayInverseMatrix: Matrix;
  11202. /** @hidden */
  11203. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11204. /** @hidden */
  11205. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11206. }
  11207. }
  11208. }
  11209. declare module "babylonjs/sceneComponent" {
  11210. import { Scene } from "babylonjs/scene";
  11211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11212. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11213. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11214. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11215. import { Nullable } from "babylonjs/types";
  11216. import { Camera } from "babylonjs/Cameras/camera";
  11217. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11218. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11219. import { AbstractScene } from "babylonjs/abstractScene";
  11220. /**
  11221. * Groups all the scene component constants in one place to ease maintenance.
  11222. * @hidden
  11223. */
  11224. export class SceneComponentConstants {
  11225. static readonly NAME_EFFECTLAYER: string;
  11226. static readonly NAME_LAYER: string;
  11227. static readonly NAME_LENSFLARESYSTEM: string;
  11228. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11229. static readonly NAME_PARTICLESYSTEM: string;
  11230. static readonly NAME_GAMEPAD: string;
  11231. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11232. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11233. static readonly NAME_DEPTHRENDERER: string;
  11234. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11235. static readonly NAME_SPRITE: string;
  11236. static readonly NAME_OUTLINERENDERER: string;
  11237. static readonly NAME_PROCEDURALTEXTURE: string;
  11238. static readonly NAME_SHADOWGENERATOR: string;
  11239. static readonly NAME_OCTREE: string;
  11240. static readonly NAME_PHYSICSENGINE: string;
  11241. static readonly NAME_AUDIO: string;
  11242. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11243. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11244. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11245. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11246. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11247. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11248. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11249. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11250. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11251. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11252. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11253. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11254. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11255. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11256. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11257. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11258. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11259. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11260. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11261. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11262. static readonly STEP_AFTERRENDER_AUDIO: number;
  11263. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11264. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11265. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11266. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11267. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11268. static readonly STEP_POINTERMOVE_SPRITE: number;
  11269. static readonly STEP_POINTERDOWN_SPRITE: number;
  11270. static readonly STEP_POINTERUP_SPRITE: number;
  11271. }
  11272. /**
  11273. * This represents a scene component.
  11274. *
  11275. * This is used to decouple the dependency the scene is having on the different workloads like
  11276. * layers, post processes...
  11277. */
  11278. export interface ISceneComponent {
  11279. /**
  11280. * The name of the component. Each component must have a unique name.
  11281. */
  11282. name: string;
  11283. /**
  11284. * The scene the component belongs to.
  11285. */
  11286. scene: Scene;
  11287. /**
  11288. * Register the component to one instance of a scene.
  11289. */
  11290. register(): void;
  11291. /**
  11292. * Rebuilds the elements related to this component in case of
  11293. * context lost for instance.
  11294. */
  11295. rebuild(): void;
  11296. /**
  11297. * Disposes the component and the associated ressources.
  11298. */
  11299. dispose(): void;
  11300. }
  11301. /**
  11302. * This represents a SERIALIZABLE scene component.
  11303. *
  11304. * This extends Scene Component to add Serialization methods on top.
  11305. */
  11306. export interface ISceneSerializableComponent extends ISceneComponent {
  11307. /**
  11308. * Adds all the elements from the container to the scene
  11309. * @param container the container holding the elements
  11310. */
  11311. addFromContainer(container: AbstractScene): void;
  11312. /**
  11313. * Removes all the elements in the container from the scene
  11314. * @param container contains the elements to remove
  11315. * @param dispose if the removed element should be disposed (default: false)
  11316. */
  11317. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11318. /**
  11319. * Serializes the component data to the specified json object
  11320. * @param serializationObject The object to serialize to
  11321. */
  11322. serialize(serializationObject: any): void;
  11323. }
  11324. /**
  11325. * Strong typing of a Mesh related stage step action
  11326. */
  11327. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11328. /**
  11329. * Strong typing of a Evaluate Sub Mesh related stage step action
  11330. */
  11331. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11332. /**
  11333. * Strong typing of a Active Mesh related stage step action
  11334. */
  11335. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11336. /**
  11337. * Strong typing of a Camera related stage step action
  11338. */
  11339. export type CameraStageAction = (camera: Camera) => void;
  11340. /**
  11341. * Strong typing of a Camera Frame buffer related stage step action
  11342. */
  11343. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11344. /**
  11345. * Strong typing of a Render Target related stage step action
  11346. */
  11347. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11348. /**
  11349. * Strong typing of a RenderingGroup related stage step action
  11350. */
  11351. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11352. /**
  11353. * Strong typing of a Mesh Render related stage step action
  11354. */
  11355. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11356. /**
  11357. * Strong typing of a simple stage step action
  11358. */
  11359. export type SimpleStageAction = () => void;
  11360. /**
  11361. * Strong typing of a render target action.
  11362. */
  11363. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11364. /**
  11365. * Strong typing of a pointer move action.
  11366. */
  11367. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11368. /**
  11369. * Strong typing of a pointer up/down action.
  11370. */
  11371. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11372. /**
  11373. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11374. * @hidden
  11375. */
  11376. export class Stage<T extends Function> extends Array<{
  11377. index: number;
  11378. component: ISceneComponent;
  11379. action: T;
  11380. }> {
  11381. /**
  11382. * Hide ctor from the rest of the world.
  11383. * @param items The items to add.
  11384. */
  11385. private constructor();
  11386. /**
  11387. * Creates a new Stage.
  11388. * @returns A new instance of a Stage
  11389. */
  11390. static Create<T extends Function>(): Stage<T>;
  11391. /**
  11392. * Registers a step in an ordered way in the targeted stage.
  11393. * @param index Defines the position to register the step in
  11394. * @param component Defines the component attached to the step
  11395. * @param action Defines the action to launch during the step
  11396. */
  11397. registerStep(index: number, component: ISceneComponent, action: T): void;
  11398. /**
  11399. * Clears all the steps from the stage.
  11400. */
  11401. clear(): void;
  11402. }
  11403. }
  11404. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11405. import { Nullable } from "babylonjs/types";
  11406. import { Observable } from "babylonjs/Misc/observable";
  11407. import { Scene } from "babylonjs/scene";
  11408. import { Sprite } from "babylonjs/Sprites/sprite";
  11409. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11410. import { Ray } from "babylonjs/Culling/ray";
  11411. import { Camera } from "babylonjs/Cameras/camera";
  11412. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11413. import { ISceneComponent } from "babylonjs/sceneComponent";
  11414. module "babylonjs/scene" {
  11415. interface Scene {
  11416. /** @hidden */
  11417. _pointerOverSprite: Nullable<Sprite>;
  11418. /** @hidden */
  11419. _pickedDownSprite: Nullable<Sprite>;
  11420. /** @hidden */
  11421. _tempSpritePickingRay: Nullable<Ray>;
  11422. /**
  11423. * All of the sprite managers added to this scene
  11424. * @see http://doc.babylonjs.com/babylon101/sprites
  11425. */
  11426. spriteManagers: Array<ISpriteManager>;
  11427. /**
  11428. * An event triggered when sprites rendering is about to start
  11429. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11430. */
  11431. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11432. /**
  11433. * An event triggered when sprites rendering is done
  11434. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11435. */
  11436. onAfterSpritesRenderingObservable: Observable<Scene>;
  11437. /** @hidden */
  11438. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11439. /** Launch a ray to try to pick a sprite in the scene
  11440. * @param x position on screen
  11441. * @param y position on screen
  11442. * @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
  11443. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11444. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11445. * @returns a PickingInfo
  11446. */
  11447. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11448. /** Use the given ray to pick a sprite in the scene
  11449. * @param ray The ray (in world space) to use to pick meshes
  11450. * @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
  11451. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11452. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11453. * @returns a PickingInfo
  11454. */
  11455. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11456. /** @hidden */
  11457. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11458. /** Launch a ray to try to pick sprites in the scene
  11459. * @param x position on screen
  11460. * @param y position on screen
  11461. * @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
  11462. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11463. * @returns a PickingInfo array
  11464. */
  11465. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11466. /** Use the given ray to pick sprites in the scene
  11467. * @param ray The ray (in world space) to use to pick meshes
  11468. * @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
  11469. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11470. * @returns a PickingInfo array
  11471. */
  11472. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11473. /**
  11474. * Force the sprite under the pointer
  11475. * @param sprite defines the sprite to use
  11476. */
  11477. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11478. /**
  11479. * Gets the sprite under the pointer
  11480. * @returns a Sprite or null if no sprite is under the pointer
  11481. */
  11482. getPointerOverSprite(): Nullable<Sprite>;
  11483. }
  11484. }
  11485. /**
  11486. * Defines the sprite scene component responsible to manage sprites
  11487. * in a given scene.
  11488. */
  11489. export class SpriteSceneComponent implements ISceneComponent {
  11490. /**
  11491. * The component name helpfull to identify the component in the list of scene components.
  11492. */
  11493. readonly name: string;
  11494. /**
  11495. * The scene the component belongs to.
  11496. */
  11497. scene: Scene;
  11498. /** @hidden */
  11499. private _spritePredicate;
  11500. /**
  11501. * Creates a new instance of the component for the given scene
  11502. * @param scene Defines the scene to register the component in
  11503. */
  11504. constructor(scene: Scene);
  11505. /**
  11506. * Registers the component in a given scene
  11507. */
  11508. register(): void;
  11509. /**
  11510. * Rebuilds the elements related to this component in case of
  11511. * context lost for instance.
  11512. */
  11513. rebuild(): void;
  11514. /**
  11515. * Disposes the component and the associated ressources.
  11516. */
  11517. dispose(): void;
  11518. private _pickSpriteButKeepRay;
  11519. private _pointerMove;
  11520. private _pointerDown;
  11521. private _pointerUp;
  11522. }
  11523. }
  11524. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11525. /** @hidden */
  11526. export var fogFragmentDeclaration: {
  11527. name: string;
  11528. shader: string;
  11529. };
  11530. }
  11531. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11532. /** @hidden */
  11533. export var fogFragment: {
  11534. name: string;
  11535. shader: string;
  11536. };
  11537. }
  11538. declare module "babylonjs/Shaders/sprites.fragment" {
  11539. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11540. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11541. /** @hidden */
  11542. export var spritesPixelShader: {
  11543. name: string;
  11544. shader: string;
  11545. };
  11546. }
  11547. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11548. /** @hidden */
  11549. export var fogVertexDeclaration: {
  11550. name: string;
  11551. shader: string;
  11552. };
  11553. }
  11554. declare module "babylonjs/Shaders/sprites.vertex" {
  11555. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11556. /** @hidden */
  11557. export var spritesVertexShader: {
  11558. name: string;
  11559. shader: string;
  11560. };
  11561. }
  11562. declare module "babylonjs/Sprites/spriteManager" {
  11563. import { IDisposable, Scene } from "babylonjs/scene";
  11564. import { Nullable } from "babylonjs/types";
  11565. import { Observable } from "babylonjs/Misc/observable";
  11566. import { Sprite } from "babylonjs/Sprites/sprite";
  11567. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11568. import { Camera } from "babylonjs/Cameras/camera";
  11569. import { Texture } from "babylonjs/Materials/Textures/texture";
  11570. import "babylonjs/Shaders/sprites.fragment";
  11571. import "babylonjs/Shaders/sprites.vertex";
  11572. import { Ray } from "babylonjs/Culling/ray";
  11573. /**
  11574. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11575. */
  11576. export interface ISpriteManager extends IDisposable {
  11577. /**
  11578. * Restricts the camera to viewing objects with the same layerMask.
  11579. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11580. */
  11581. layerMask: number;
  11582. /**
  11583. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11584. */
  11585. isPickable: boolean;
  11586. /**
  11587. * Specifies the rendering group id for this mesh (0 by default)
  11588. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11589. */
  11590. renderingGroupId: number;
  11591. /**
  11592. * Defines the list of sprites managed by the manager.
  11593. */
  11594. sprites: Array<Sprite>;
  11595. /**
  11596. * Tests the intersection of a sprite with a specific ray.
  11597. * @param ray The ray we are sending to test the collision
  11598. * @param camera The camera space we are sending rays in
  11599. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11600. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11601. * @returns picking info or null.
  11602. */
  11603. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11604. /**
  11605. * Intersects the sprites with a ray
  11606. * @param ray defines the ray to intersect with
  11607. * @param camera defines the current active camera
  11608. * @param predicate defines a predicate used to select candidate sprites
  11609. * @returns null if no hit or a PickingInfo array
  11610. */
  11611. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11612. /**
  11613. * Renders the list of sprites on screen.
  11614. */
  11615. render(): void;
  11616. }
  11617. /**
  11618. * Class used to manage multiple sprites on the same spritesheet
  11619. * @see http://doc.babylonjs.com/babylon101/sprites
  11620. */
  11621. export class SpriteManager implements ISpriteManager {
  11622. /** defines the manager's name */
  11623. name: string;
  11624. /** Gets the list of sprites */
  11625. sprites: Sprite[];
  11626. /** Gets or sets the rendering group id (0 by default) */
  11627. renderingGroupId: number;
  11628. /** Gets or sets camera layer mask */
  11629. layerMask: number;
  11630. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11631. fogEnabled: boolean;
  11632. /** Gets or sets a boolean indicating if the sprites are pickable */
  11633. isPickable: boolean;
  11634. /** Defines the default width of a cell in the spritesheet */
  11635. cellWidth: number;
  11636. /** Defines the default height of a cell in the spritesheet */
  11637. cellHeight: number;
  11638. /** Associative array from JSON sprite data file */
  11639. private _cellData;
  11640. /** Array of sprite names from JSON sprite data file */
  11641. private _spriteMap;
  11642. /** True when packed cell data from JSON file is ready*/
  11643. private _packedAndReady;
  11644. /**
  11645. * An event triggered when the manager is disposed.
  11646. */
  11647. onDisposeObservable: Observable<SpriteManager>;
  11648. private _onDisposeObserver;
  11649. /**
  11650. * Callback called when the manager is disposed
  11651. */
  11652. onDispose: () => void;
  11653. private _capacity;
  11654. private _fromPacked;
  11655. private _spriteTexture;
  11656. private _epsilon;
  11657. private _scene;
  11658. private _vertexData;
  11659. private _buffer;
  11660. private _vertexBuffers;
  11661. private _indexBuffer;
  11662. private _effectBase;
  11663. private _effectFog;
  11664. /**
  11665. * Gets or sets the spritesheet texture
  11666. */
  11667. texture: Texture;
  11668. /**
  11669. * Creates a new sprite manager
  11670. * @param name defines the manager's name
  11671. * @param imgUrl defines the sprite sheet url
  11672. * @param capacity defines the maximum allowed number of sprites
  11673. * @param cellSize defines the size of a sprite cell
  11674. * @param scene defines the hosting scene
  11675. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11676. * @param samplingMode defines the smapling mode to use with spritesheet
  11677. * @param fromPacked set to false; do not alter
  11678. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11679. */
  11680. constructor(
  11681. /** defines the manager's name */
  11682. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11683. private _makePacked;
  11684. private _appendSpriteVertex;
  11685. /**
  11686. * Intersects the sprites with a ray
  11687. * @param ray defines the ray to intersect with
  11688. * @param camera defines the current active camera
  11689. * @param predicate defines a predicate used to select candidate sprites
  11690. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11691. * @returns null if no hit or a PickingInfo
  11692. */
  11693. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11694. /**
  11695. * Intersects the sprites with a ray
  11696. * @param ray defines the ray to intersect with
  11697. * @param camera defines the current active camera
  11698. * @param predicate defines a predicate used to select candidate sprites
  11699. * @returns null if no hit or a PickingInfo array
  11700. */
  11701. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11702. /**
  11703. * Render all child sprites
  11704. */
  11705. render(): void;
  11706. /**
  11707. * Release associated resources
  11708. */
  11709. dispose(): void;
  11710. }
  11711. }
  11712. declare module "babylonjs/Sprites/sprite" {
  11713. import { Vector3 } from "babylonjs/Maths/math.vector";
  11714. import { Nullable } from "babylonjs/types";
  11715. import { ActionManager } from "babylonjs/Actions/actionManager";
  11716. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11717. import { Color4 } from "babylonjs/Maths/math.color";
  11718. /**
  11719. * Class used to represent a sprite
  11720. * @see http://doc.babylonjs.com/babylon101/sprites
  11721. */
  11722. export class Sprite {
  11723. /** defines the name */
  11724. name: string;
  11725. /** Gets or sets the current world position */
  11726. position: Vector3;
  11727. /** Gets or sets the main color */
  11728. color: Color4;
  11729. /** Gets or sets the width */
  11730. width: number;
  11731. /** Gets or sets the height */
  11732. height: number;
  11733. /** Gets or sets rotation angle */
  11734. angle: number;
  11735. /** Gets or sets the cell index in the sprite sheet */
  11736. cellIndex: number;
  11737. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11738. cellRef: string;
  11739. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11740. invertU: number;
  11741. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11742. invertV: number;
  11743. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11744. disposeWhenFinishedAnimating: boolean;
  11745. /** Gets the list of attached animations */
  11746. animations: Animation[];
  11747. /** Gets or sets a boolean indicating if the sprite can be picked */
  11748. isPickable: boolean;
  11749. /**
  11750. * Gets or sets the associated action manager
  11751. */
  11752. actionManager: Nullable<ActionManager>;
  11753. private _animationStarted;
  11754. private _loopAnimation;
  11755. private _fromIndex;
  11756. private _toIndex;
  11757. private _delay;
  11758. private _direction;
  11759. private _manager;
  11760. private _time;
  11761. private _onAnimationEnd;
  11762. /**
  11763. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11764. */
  11765. isVisible: boolean;
  11766. /**
  11767. * Gets or sets the sprite size
  11768. */
  11769. size: number;
  11770. /**
  11771. * Creates a new Sprite
  11772. * @param name defines the name
  11773. * @param manager defines the manager
  11774. */
  11775. constructor(
  11776. /** defines the name */
  11777. name: string, manager: ISpriteManager);
  11778. /**
  11779. * Starts an animation
  11780. * @param from defines the initial key
  11781. * @param to defines the end key
  11782. * @param loop defines if the animation must loop
  11783. * @param delay defines the start delay (in ms)
  11784. * @param onAnimationEnd defines a callback to call when animation ends
  11785. */
  11786. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11787. /** Stops current animation (if any) */
  11788. stopAnimation(): void;
  11789. /** @hidden */
  11790. _animate(deltaTime: number): void;
  11791. /** Release associated resources */
  11792. dispose(): void;
  11793. }
  11794. }
  11795. declare module "babylonjs/Collisions/pickingInfo" {
  11796. import { Nullable } from "babylonjs/types";
  11797. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11799. import { Sprite } from "babylonjs/Sprites/sprite";
  11800. import { Ray } from "babylonjs/Culling/ray";
  11801. /**
  11802. * Information about the result of picking within a scene
  11803. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11804. */
  11805. export class PickingInfo {
  11806. /** @hidden */
  11807. _pickingUnavailable: boolean;
  11808. /**
  11809. * If the pick collided with an object
  11810. */
  11811. hit: boolean;
  11812. /**
  11813. * Distance away where the pick collided
  11814. */
  11815. distance: number;
  11816. /**
  11817. * The location of pick collision
  11818. */
  11819. pickedPoint: Nullable<Vector3>;
  11820. /**
  11821. * The mesh corresponding the the pick collision
  11822. */
  11823. pickedMesh: Nullable<AbstractMesh>;
  11824. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11825. bu: number;
  11826. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11827. bv: number;
  11828. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11829. faceId: number;
  11830. /** Id of the the submesh that was picked */
  11831. subMeshId: number;
  11832. /** If a sprite was picked, this will be the sprite the pick collided with */
  11833. pickedSprite: Nullable<Sprite>;
  11834. /**
  11835. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11836. */
  11837. originMesh: Nullable<AbstractMesh>;
  11838. /**
  11839. * The ray that was used to perform the picking.
  11840. */
  11841. ray: Nullable<Ray>;
  11842. /**
  11843. * Gets the normal correspodning to the face the pick collided with
  11844. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11845. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11846. * @returns The normal correspodning to the face the pick collided with
  11847. */
  11848. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11849. /**
  11850. * Gets the texture coordinates of where the pick occured
  11851. * @returns the vector containing the coordnates of the texture
  11852. */
  11853. getTextureCoordinates(): Nullable<Vector2>;
  11854. }
  11855. }
  11856. declare module "babylonjs/Events/pointerEvents" {
  11857. import { Nullable } from "babylonjs/types";
  11858. import { Vector2 } from "babylonjs/Maths/math.vector";
  11859. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11860. import { Ray } from "babylonjs/Culling/ray";
  11861. /**
  11862. * Gather the list of pointer event types as constants.
  11863. */
  11864. export class PointerEventTypes {
  11865. /**
  11866. * 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.
  11867. */
  11868. static readonly POINTERDOWN: number;
  11869. /**
  11870. * The pointerup event is fired when a pointer is no longer active.
  11871. */
  11872. static readonly POINTERUP: number;
  11873. /**
  11874. * The pointermove event is fired when a pointer changes coordinates.
  11875. */
  11876. static readonly POINTERMOVE: number;
  11877. /**
  11878. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11879. */
  11880. static readonly POINTERWHEEL: number;
  11881. /**
  11882. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11883. */
  11884. static readonly POINTERPICK: number;
  11885. /**
  11886. * The pointertap event is fired when a the object has been touched and released without drag.
  11887. */
  11888. static readonly POINTERTAP: number;
  11889. /**
  11890. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11891. */
  11892. static readonly POINTERDOUBLETAP: number;
  11893. }
  11894. /**
  11895. * Base class of pointer info types.
  11896. */
  11897. export class PointerInfoBase {
  11898. /**
  11899. * Defines the type of event (PointerEventTypes)
  11900. */
  11901. type: number;
  11902. /**
  11903. * Defines the related dom event
  11904. */
  11905. event: PointerEvent | MouseWheelEvent;
  11906. /**
  11907. * Instantiates the base class of pointers info.
  11908. * @param type Defines the type of event (PointerEventTypes)
  11909. * @param event Defines the related dom event
  11910. */
  11911. constructor(
  11912. /**
  11913. * Defines the type of event (PointerEventTypes)
  11914. */
  11915. type: number,
  11916. /**
  11917. * Defines the related dom event
  11918. */
  11919. event: PointerEvent | MouseWheelEvent);
  11920. }
  11921. /**
  11922. * This class is used to store pointer related info for the onPrePointerObservable event.
  11923. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11924. */
  11925. export class PointerInfoPre extends PointerInfoBase {
  11926. /**
  11927. * Ray from a pointer if availible (eg. 6dof controller)
  11928. */
  11929. ray: Nullable<Ray>;
  11930. /**
  11931. * Defines the local position of the pointer on the canvas.
  11932. */
  11933. localPosition: Vector2;
  11934. /**
  11935. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11936. */
  11937. skipOnPointerObservable: boolean;
  11938. /**
  11939. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11940. * @param type Defines the type of event (PointerEventTypes)
  11941. * @param event Defines the related dom event
  11942. * @param localX Defines the local x coordinates of the pointer when the event occured
  11943. * @param localY Defines the local y coordinates of the pointer when the event occured
  11944. */
  11945. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11946. }
  11947. /**
  11948. * This type contains all the data related to a pointer event in Babylon.js.
  11949. * 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.
  11950. */
  11951. export class PointerInfo extends PointerInfoBase {
  11952. /**
  11953. * Defines the picking info associated to the info (if any)\
  11954. */
  11955. pickInfo: Nullable<PickingInfo>;
  11956. /**
  11957. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11958. * @param type Defines the type of event (PointerEventTypes)
  11959. * @param event Defines the related dom event
  11960. * @param pickInfo Defines the picking info associated to the info (if any)\
  11961. */
  11962. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11963. /**
  11964. * Defines the picking info associated to the info (if any)\
  11965. */
  11966. pickInfo: Nullable<PickingInfo>);
  11967. }
  11968. /**
  11969. * Data relating to a touch event on the screen.
  11970. */
  11971. export interface PointerTouch {
  11972. /**
  11973. * X coordinate of touch.
  11974. */
  11975. x: number;
  11976. /**
  11977. * Y coordinate of touch.
  11978. */
  11979. y: number;
  11980. /**
  11981. * Id of touch. Unique for each finger.
  11982. */
  11983. pointerId: number;
  11984. /**
  11985. * Event type passed from DOM.
  11986. */
  11987. type: any;
  11988. }
  11989. }
  11990. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11991. import { Observable } from "babylonjs/Misc/observable";
  11992. import { Nullable } from "babylonjs/types";
  11993. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11994. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11995. /**
  11996. * Manage the mouse inputs to control the movement of a free camera.
  11997. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11998. */
  11999. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12000. /**
  12001. * Define if touch is enabled in the mouse input
  12002. */
  12003. touchEnabled: boolean;
  12004. /**
  12005. * Defines the camera the input is attached to.
  12006. */
  12007. camera: FreeCamera;
  12008. /**
  12009. * Defines the buttons associated with the input to handle camera move.
  12010. */
  12011. buttons: number[];
  12012. /**
  12013. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12014. */
  12015. angularSensibility: number;
  12016. private _pointerInput;
  12017. private _onMouseMove;
  12018. private _observer;
  12019. private previousPosition;
  12020. /**
  12021. * Observable for when a pointer move event occurs containing the move offset
  12022. */
  12023. onPointerMovedObservable: Observable<{
  12024. offsetX: number;
  12025. offsetY: number;
  12026. }>;
  12027. /**
  12028. * @hidden
  12029. * If the camera should be rotated automatically based on pointer movement
  12030. */
  12031. _allowCameraRotation: boolean;
  12032. /**
  12033. * Manage the mouse inputs to control the movement of a free camera.
  12034. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12035. * @param touchEnabled Defines if touch is enabled or not
  12036. */
  12037. constructor(
  12038. /**
  12039. * Define if touch is enabled in the mouse input
  12040. */
  12041. touchEnabled?: boolean);
  12042. /**
  12043. * Attach the input controls to a specific dom element to get the input from.
  12044. * @param element Defines the element the controls should be listened from
  12045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12046. */
  12047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12048. /**
  12049. * Called on JS contextmenu event.
  12050. * Override this method to provide functionality.
  12051. */
  12052. protected onContextMenu(evt: PointerEvent): void;
  12053. /**
  12054. * Detach the current controls from the specified dom element.
  12055. * @param element Defines the element to stop listening the inputs from
  12056. */
  12057. detachControl(element: Nullable<HTMLElement>): void;
  12058. /**
  12059. * Gets the class name of the current intput.
  12060. * @returns the class name
  12061. */
  12062. getClassName(): string;
  12063. /**
  12064. * Get the friendly name associated with the input class.
  12065. * @returns the input friendly name
  12066. */
  12067. getSimpleName(): string;
  12068. }
  12069. }
  12070. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12071. import { Nullable } from "babylonjs/types";
  12072. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12073. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12074. /**
  12075. * Manage the touch inputs to control the movement of a free camera.
  12076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12077. */
  12078. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12079. /**
  12080. * Defines the camera the input is attached to.
  12081. */
  12082. camera: FreeCamera;
  12083. /**
  12084. * Defines the touch sensibility for rotation.
  12085. * The higher the faster.
  12086. */
  12087. touchAngularSensibility: number;
  12088. /**
  12089. * Defines the touch sensibility for move.
  12090. * The higher the faster.
  12091. */
  12092. touchMoveSensibility: number;
  12093. private _offsetX;
  12094. private _offsetY;
  12095. private _pointerPressed;
  12096. private _pointerInput;
  12097. private _observer;
  12098. private _onLostFocus;
  12099. /**
  12100. * Attach the input controls to a specific dom element to get the input from.
  12101. * @param element Defines the element the controls should be listened from
  12102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12103. */
  12104. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12105. /**
  12106. * Detach the current controls from the specified dom element.
  12107. * @param element Defines the element to stop listening the inputs from
  12108. */
  12109. detachControl(element: Nullable<HTMLElement>): void;
  12110. /**
  12111. * Update the current camera state depending on the inputs that have been used this frame.
  12112. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12113. */
  12114. checkInputs(): void;
  12115. /**
  12116. * Gets the class name of the current intput.
  12117. * @returns the class name
  12118. */
  12119. getClassName(): string;
  12120. /**
  12121. * Get the friendly name associated with the input class.
  12122. * @returns the input friendly name
  12123. */
  12124. getSimpleName(): string;
  12125. }
  12126. }
  12127. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12128. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12129. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12130. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12131. import { Nullable } from "babylonjs/types";
  12132. /**
  12133. * Default Inputs manager for the FreeCamera.
  12134. * It groups all the default supported inputs for ease of use.
  12135. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12136. */
  12137. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12138. /**
  12139. * @hidden
  12140. */
  12141. _mouseInput: Nullable<FreeCameraMouseInput>;
  12142. /**
  12143. * Instantiates a new FreeCameraInputsManager.
  12144. * @param camera Defines the camera the inputs belong to
  12145. */
  12146. constructor(camera: FreeCamera);
  12147. /**
  12148. * Add keyboard input support to the input manager.
  12149. * @returns the current input manager
  12150. */
  12151. addKeyboard(): FreeCameraInputsManager;
  12152. /**
  12153. * Add mouse input support to the input manager.
  12154. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12155. * @returns the current input manager
  12156. */
  12157. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12158. /**
  12159. * Removes the mouse input support from the manager
  12160. * @returns the current input manager
  12161. */
  12162. removeMouse(): FreeCameraInputsManager;
  12163. /**
  12164. * Add touch input support to the input manager.
  12165. * @returns the current input manager
  12166. */
  12167. addTouch(): FreeCameraInputsManager;
  12168. /**
  12169. * Remove all attached input methods from a camera
  12170. */
  12171. clear(): void;
  12172. }
  12173. }
  12174. declare module "babylonjs/Cameras/freeCamera" {
  12175. import { Vector3 } from "babylonjs/Maths/math.vector";
  12176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12177. import { Scene } from "babylonjs/scene";
  12178. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12179. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12180. /**
  12181. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12182. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12183. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12184. */
  12185. export class FreeCamera extends TargetCamera {
  12186. /**
  12187. * Define the collision ellipsoid of the camera.
  12188. * This is helpful to simulate a camera body like the player body around the camera
  12189. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12190. */
  12191. ellipsoid: Vector3;
  12192. /**
  12193. * Define an offset for the position of the ellipsoid around the camera.
  12194. * This can be helpful to determine the center of the body near the gravity center of the body
  12195. * instead of its head.
  12196. */
  12197. ellipsoidOffset: Vector3;
  12198. /**
  12199. * Enable or disable collisions of the camera with the rest of the scene objects.
  12200. */
  12201. checkCollisions: boolean;
  12202. /**
  12203. * Enable or disable gravity on the camera.
  12204. */
  12205. applyGravity: boolean;
  12206. /**
  12207. * Define the input manager associated to the camera.
  12208. */
  12209. inputs: FreeCameraInputsManager;
  12210. /**
  12211. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12212. * Higher values reduce sensitivity.
  12213. */
  12214. /**
  12215. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12216. * Higher values reduce sensitivity.
  12217. */
  12218. angularSensibility: number;
  12219. /**
  12220. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12221. */
  12222. keysUp: number[];
  12223. /**
  12224. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12225. */
  12226. keysDown: number[];
  12227. /**
  12228. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12229. */
  12230. keysLeft: number[];
  12231. /**
  12232. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12233. */
  12234. keysRight: number[];
  12235. /**
  12236. * Event raised when the camera collide with a mesh in the scene.
  12237. */
  12238. onCollide: (collidedMesh: AbstractMesh) => void;
  12239. private _collider;
  12240. private _needMoveForGravity;
  12241. private _oldPosition;
  12242. private _diffPosition;
  12243. private _newPosition;
  12244. /** @hidden */
  12245. _localDirection: Vector3;
  12246. /** @hidden */
  12247. _transformedDirection: Vector3;
  12248. /**
  12249. * Instantiates a Free Camera.
  12250. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12251. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12252. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12253. * @param name Define the name of the camera in the scene
  12254. * @param position Define the start position of the camera in the scene
  12255. * @param scene Define the scene the camera belongs to
  12256. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12257. */
  12258. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12259. /**
  12260. * Attached controls to the current camera.
  12261. * @param element Defines the element the controls should be listened from
  12262. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12263. */
  12264. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12265. /**
  12266. * Detach the current controls from the camera.
  12267. * The camera will stop reacting to inputs.
  12268. * @param element Defines the element to stop listening the inputs from
  12269. */
  12270. detachControl(element: HTMLElement): void;
  12271. private _collisionMask;
  12272. /**
  12273. * Define a collision mask to limit the list of object the camera can collide with
  12274. */
  12275. collisionMask: number;
  12276. /** @hidden */
  12277. _collideWithWorld(displacement: Vector3): void;
  12278. private _onCollisionPositionChange;
  12279. /** @hidden */
  12280. _checkInputs(): void;
  12281. /** @hidden */
  12282. _decideIfNeedsToMove(): boolean;
  12283. /** @hidden */
  12284. _updatePosition(): void;
  12285. /**
  12286. * Destroy the camera and release the current resources hold by it.
  12287. */
  12288. dispose(): void;
  12289. /**
  12290. * Gets the current object class name.
  12291. * @return the class name
  12292. */
  12293. getClassName(): string;
  12294. }
  12295. }
  12296. declare module "babylonjs/Gamepads/gamepad" {
  12297. import { Observable } from "babylonjs/Misc/observable";
  12298. /**
  12299. * Represents a gamepad control stick position
  12300. */
  12301. export class StickValues {
  12302. /**
  12303. * The x component of the control stick
  12304. */
  12305. x: number;
  12306. /**
  12307. * The y component of the control stick
  12308. */
  12309. y: number;
  12310. /**
  12311. * Initializes the gamepad x and y control stick values
  12312. * @param x The x component of the gamepad control stick value
  12313. * @param y The y component of the gamepad control stick value
  12314. */
  12315. constructor(
  12316. /**
  12317. * The x component of the control stick
  12318. */
  12319. x: number,
  12320. /**
  12321. * The y component of the control stick
  12322. */
  12323. y: number);
  12324. }
  12325. /**
  12326. * An interface which manages callbacks for gamepad button changes
  12327. */
  12328. export interface GamepadButtonChanges {
  12329. /**
  12330. * Called when a gamepad has been changed
  12331. */
  12332. changed: boolean;
  12333. /**
  12334. * Called when a gamepad press event has been triggered
  12335. */
  12336. pressChanged: boolean;
  12337. /**
  12338. * Called when a touch event has been triggered
  12339. */
  12340. touchChanged: boolean;
  12341. /**
  12342. * Called when a value has changed
  12343. */
  12344. valueChanged: boolean;
  12345. }
  12346. /**
  12347. * Represents a gamepad
  12348. */
  12349. export class Gamepad {
  12350. /**
  12351. * The id of the gamepad
  12352. */
  12353. id: string;
  12354. /**
  12355. * The index of the gamepad
  12356. */
  12357. index: number;
  12358. /**
  12359. * The browser gamepad
  12360. */
  12361. browserGamepad: any;
  12362. /**
  12363. * Specifies what type of gamepad this represents
  12364. */
  12365. type: number;
  12366. private _leftStick;
  12367. private _rightStick;
  12368. /** @hidden */
  12369. _isConnected: boolean;
  12370. private _leftStickAxisX;
  12371. private _leftStickAxisY;
  12372. private _rightStickAxisX;
  12373. private _rightStickAxisY;
  12374. /**
  12375. * Triggered when the left control stick has been changed
  12376. */
  12377. private _onleftstickchanged;
  12378. /**
  12379. * Triggered when the right control stick has been changed
  12380. */
  12381. private _onrightstickchanged;
  12382. /**
  12383. * Represents a gamepad controller
  12384. */
  12385. static GAMEPAD: number;
  12386. /**
  12387. * Represents a generic controller
  12388. */
  12389. static GENERIC: number;
  12390. /**
  12391. * Represents an XBox controller
  12392. */
  12393. static XBOX: number;
  12394. /**
  12395. * Represents a pose-enabled controller
  12396. */
  12397. static POSE_ENABLED: number;
  12398. /**
  12399. * Represents an Dual Shock controller
  12400. */
  12401. static DUALSHOCK: number;
  12402. /**
  12403. * Specifies whether the left control stick should be Y-inverted
  12404. */
  12405. protected _invertLeftStickY: boolean;
  12406. /**
  12407. * Specifies if the gamepad has been connected
  12408. */
  12409. readonly isConnected: boolean;
  12410. /**
  12411. * Initializes the gamepad
  12412. * @param id The id of the gamepad
  12413. * @param index The index of the gamepad
  12414. * @param browserGamepad The browser gamepad
  12415. * @param leftStickX The x component of the left joystick
  12416. * @param leftStickY The y component of the left joystick
  12417. * @param rightStickX The x component of the right joystick
  12418. * @param rightStickY The y component of the right joystick
  12419. */
  12420. constructor(
  12421. /**
  12422. * The id of the gamepad
  12423. */
  12424. id: string,
  12425. /**
  12426. * The index of the gamepad
  12427. */
  12428. index: number,
  12429. /**
  12430. * The browser gamepad
  12431. */
  12432. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12433. /**
  12434. * Callback triggered when the left joystick has changed
  12435. * @param callback
  12436. */
  12437. onleftstickchanged(callback: (values: StickValues) => void): void;
  12438. /**
  12439. * Callback triggered when the right joystick has changed
  12440. * @param callback
  12441. */
  12442. onrightstickchanged(callback: (values: StickValues) => void): void;
  12443. /**
  12444. * Gets the left joystick
  12445. */
  12446. /**
  12447. * Sets the left joystick values
  12448. */
  12449. leftStick: StickValues;
  12450. /**
  12451. * Gets the right joystick
  12452. */
  12453. /**
  12454. * Sets the right joystick value
  12455. */
  12456. rightStick: StickValues;
  12457. /**
  12458. * Updates the gamepad joystick positions
  12459. */
  12460. update(): void;
  12461. /**
  12462. * Disposes the gamepad
  12463. */
  12464. dispose(): void;
  12465. }
  12466. /**
  12467. * Represents a generic gamepad
  12468. */
  12469. export class GenericPad extends Gamepad {
  12470. private _buttons;
  12471. private _onbuttondown;
  12472. private _onbuttonup;
  12473. /**
  12474. * Observable triggered when a button has been pressed
  12475. */
  12476. onButtonDownObservable: Observable<number>;
  12477. /**
  12478. * Observable triggered when a button has been released
  12479. */
  12480. onButtonUpObservable: Observable<number>;
  12481. /**
  12482. * Callback triggered when a button has been pressed
  12483. * @param callback Called when a button has been pressed
  12484. */
  12485. onbuttondown(callback: (buttonPressed: number) => void): void;
  12486. /**
  12487. * Callback triggered when a button has been released
  12488. * @param callback Called when a button has been released
  12489. */
  12490. onbuttonup(callback: (buttonReleased: number) => void): void;
  12491. /**
  12492. * Initializes the generic gamepad
  12493. * @param id The id of the generic gamepad
  12494. * @param index The index of the generic gamepad
  12495. * @param browserGamepad The browser gamepad
  12496. */
  12497. constructor(id: string, index: number, browserGamepad: any);
  12498. private _setButtonValue;
  12499. /**
  12500. * Updates the generic gamepad
  12501. */
  12502. update(): void;
  12503. /**
  12504. * Disposes the generic gamepad
  12505. */
  12506. dispose(): void;
  12507. }
  12508. }
  12509. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12510. import { Nullable } from "babylonjs/types";
  12511. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12512. import { Scene } from "babylonjs/scene";
  12513. module "babylonjs/Engines/engine" {
  12514. interface Engine {
  12515. /**
  12516. * Creates a raw texture
  12517. * @param data defines the data to store in the texture
  12518. * @param width defines the width of the texture
  12519. * @param height defines the height of the texture
  12520. * @param format defines the format of the data
  12521. * @param generateMipMaps defines if the engine should generate the mip levels
  12522. * @param invertY defines if data must be stored with Y axis inverted
  12523. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12524. * @param compression defines the compression used (null by default)
  12525. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12526. * @returns the raw texture inside an InternalTexture
  12527. */
  12528. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12529. /**
  12530. * Update a raw texture
  12531. * @param texture defines the texture to update
  12532. * @param data defines the data to store in the texture
  12533. * @param format defines the format of the data
  12534. * @param invertY defines if data must be stored with Y axis inverted
  12535. */
  12536. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12537. /**
  12538. * Update a raw texture
  12539. * @param texture defines the texture to update
  12540. * @param data defines the data to store in the texture
  12541. * @param format defines the format of the data
  12542. * @param invertY defines if data must be stored with Y axis inverted
  12543. * @param compression defines the compression used (null by default)
  12544. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12545. */
  12546. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12547. /**
  12548. * Creates a new raw cube texture
  12549. * @param data defines the array of data to use to create each face
  12550. * @param size defines the size of the textures
  12551. * @param format defines the format of the data
  12552. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12553. * @param generateMipMaps defines if the engine should generate the mip levels
  12554. * @param invertY defines if data must be stored with Y axis inverted
  12555. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12556. * @param compression defines the compression used (null by default)
  12557. * @returns the cube texture as an InternalTexture
  12558. */
  12559. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12560. /**
  12561. * Update a raw cube texture
  12562. * @param texture defines the texture to udpdate
  12563. * @param data defines the data to store
  12564. * @param format defines the data format
  12565. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12566. * @param invertY defines if data must be stored with Y axis inverted
  12567. */
  12568. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12569. /**
  12570. * Update a raw cube texture
  12571. * @param texture defines the texture to udpdate
  12572. * @param data defines the data to store
  12573. * @param format defines the data format
  12574. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12575. * @param invertY defines if data must be stored with Y axis inverted
  12576. * @param compression defines the compression used (null by default)
  12577. */
  12578. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12579. /**
  12580. * Update a raw cube texture
  12581. * @param texture defines the texture to udpdate
  12582. * @param data defines the data to store
  12583. * @param format defines the data format
  12584. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12585. * @param invertY defines if data must be stored with Y axis inverted
  12586. * @param compression defines the compression used (null by default)
  12587. * @param level defines which level of the texture to update
  12588. */
  12589. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12590. /**
  12591. * Creates a new raw cube texture from a specified url
  12592. * @param url defines the url where the data is located
  12593. * @param scene defines the current scene
  12594. * @param size defines the size of the textures
  12595. * @param format defines the format of the data
  12596. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12597. * @param noMipmap defines if the engine should avoid generating the mip levels
  12598. * @param callback defines a callback used to extract texture data from loaded data
  12599. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12600. * @param onLoad defines a callback called when texture is loaded
  12601. * @param onError defines a callback called if there is an error
  12602. * @returns the cube texture as an InternalTexture
  12603. */
  12604. 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;
  12605. /**
  12606. * Creates a new raw cube texture from a specified url
  12607. * @param url defines the url where the data is located
  12608. * @param scene defines the current scene
  12609. * @param size defines the size of the textures
  12610. * @param format defines the format of the data
  12611. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12612. * @param noMipmap defines if the engine should avoid generating the mip levels
  12613. * @param callback defines a callback used to extract texture data from loaded data
  12614. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12615. * @param onLoad defines a callback called when texture is loaded
  12616. * @param onError defines a callback called if there is an error
  12617. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12618. * @param invertY defines if data must be stored with Y axis inverted
  12619. * @returns the cube texture as an InternalTexture
  12620. */
  12621. 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;
  12622. /**
  12623. * Creates a new raw 3D texture
  12624. * @param data defines the data used to create the texture
  12625. * @param width defines the width of the texture
  12626. * @param height defines the height of the texture
  12627. * @param depth defines the depth of the texture
  12628. * @param format defines the format of the texture
  12629. * @param generateMipMaps defines if the engine must generate mip levels
  12630. * @param invertY defines if data must be stored with Y axis inverted
  12631. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12632. * @param compression defines the compressed used (can be null)
  12633. * @param textureType defines the compressed used (can be null)
  12634. * @returns a new raw 3D texture (stored in an InternalTexture)
  12635. */
  12636. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12637. /**
  12638. * Update a raw 3D texture
  12639. * @param texture defines the texture to update
  12640. * @param data defines the data to store
  12641. * @param format defines the data format
  12642. * @param invertY defines if data must be stored with Y axis inverted
  12643. */
  12644. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12645. /**
  12646. * Update a raw 3D texture
  12647. * @param texture defines the texture to update
  12648. * @param data defines the data to store
  12649. * @param format defines the data format
  12650. * @param invertY defines if data must be stored with Y axis inverted
  12651. * @param compression defines the used compression (can be null)
  12652. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12653. */
  12654. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12655. }
  12656. }
  12657. }
  12658. declare module "babylonjs/Materials/Textures/rawTexture" {
  12659. import { Scene } from "babylonjs/scene";
  12660. import { Texture } from "babylonjs/Materials/Textures/texture";
  12661. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12662. /**
  12663. * Raw texture can help creating a texture directly from an array of data.
  12664. * This can be super useful if you either get the data from an uncompressed source or
  12665. * if you wish to create your texture pixel by pixel.
  12666. */
  12667. export class RawTexture extends Texture {
  12668. /**
  12669. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12670. */
  12671. format: number;
  12672. private _engine;
  12673. /**
  12674. * Instantiates a new RawTexture.
  12675. * Raw texture can help creating a texture directly from an array of data.
  12676. * This can be super useful if you either get the data from an uncompressed source or
  12677. * if you wish to create your texture pixel by pixel.
  12678. * @param data define the array of data to use to create the texture
  12679. * @param width define the width of the texture
  12680. * @param height define the height of the texture
  12681. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12682. * @param scene define the scene the texture belongs to
  12683. * @param generateMipMaps define whether mip maps should be generated or not
  12684. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12685. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12686. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12687. */
  12688. constructor(data: ArrayBufferView, width: number, height: number,
  12689. /**
  12690. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12691. */
  12692. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12693. /**
  12694. * Updates the texture underlying data.
  12695. * @param data Define the new data of the texture
  12696. */
  12697. update(data: ArrayBufferView): void;
  12698. /**
  12699. * Creates a luminance texture from some data.
  12700. * @param data Define the texture data
  12701. * @param width Define the width of the texture
  12702. * @param height Define the height of the texture
  12703. * @param scene Define the scene the texture belongs to
  12704. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12705. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12706. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12707. * @returns the luminance texture
  12708. */
  12709. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12710. /**
  12711. * Creates a luminance alpha texture from some data.
  12712. * @param data Define the texture data
  12713. * @param width Define the width of the texture
  12714. * @param height Define the height of the texture
  12715. * @param scene Define the scene the texture belongs to
  12716. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12717. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12718. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12719. * @returns the luminance alpha texture
  12720. */
  12721. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12722. /**
  12723. * Creates an alpha texture from some data.
  12724. * @param data Define the texture data
  12725. * @param width Define the width of the texture
  12726. * @param height Define the height of the texture
  12727. * @param scene Define the scene the texture belongs to
  12728. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12729. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12730. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12731. * @returns the alpha texture
  12732. */
  12733. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12734. /**
  12735. * Creates a RGB texture from some data.
  12736. * @param data Define the texture data
  12737. * @param width Define the width of the texture
  12738. * @param height Define the height of the texture
  12739. * @param scene Define the scene the texture belongs to
  12740. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12741. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12742. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12743. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12744. * @returns the RGB alpha texture
  12745. */
  12746. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12747. /**
  12748. * Creates a RGBA texture from some data.
  12749. * @param data Define the texture data
  12750. * @param width Define the width of the texture
  12751. * @param height Define the height of the texture
  12752. * @param scene Define the scene the texture belongs to
  12753. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12754. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12755. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12756. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12757. * @returns the RGBA texture
  12758. */
  12759. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12760. /**
  12761. * Creates a R texture from some data.
  12762. * @param data Define the texture data
  12763. * @param width Define the width of the texture
  12764. * @param height Define the height of the texture
  12765. * @param scene Define the scene the texture belongs to
  12766. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12767. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12768. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12769. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12770. * @returns the R texture
  12771. */
  12772. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12773. }
  12774. }
  12775. declare module "babylonjs/Maths/math.size" {
  12776. /**
  12777. * Interface for the size containing width and height
  12778. */
  12779. export interface ISize {
  12780. /**
  12781. * Width
  12782. */
  12783. width: number;
  12784. /**
  12785. * Heighht
  12786. */
  12787. height: number;
  12788. }
  12789. /**
  12790. * Size containing widht and height
  12791. */
  12792. export class Size implements ISize {
  12793. /**
  12794. * Width
  12795. */
  12796. width: number;
  12797. /**
  12798. * Height
  12799. */
  12800. height: number;
  12801. /**
  12802. * Creates a Size object from the given width and height (floats).
  12803. * @param width width of the new size
  12804. * @param height height of the new size
  12805. */
  12806. constructor(width: number, height: number);
  12807. /**
  12808. * Returns a string with the Size width and height
  12809. * @returns a string with the Size width and height
  12810. */
  12811. toString(): string;
  12812. /**
  12813. * "Size"
  12814. * @returns the string "Size"
  12815. */
  12816. getClassName(): string;
  12817. /**
  12818. * Returns the Size hash code.
  12819. * @returns a hash code for a unique width and height
  12820. */
  12821. getHashCode(): number;
  12822. /**
  12823. * Updates the current size from the given one.
  12824. * @param src the given size
  12825. */
  12826. copyFrom(src: Size): void;
  12827. /**
  12828. * Updates in place the current Size from the given floats.
  12829. * @param width width of the new size
  12830. * @param height height of the new size
  12831. * @returns the updated Size.
  12832. */
  12833. copyFromFloats(width: number, height: number): Size;
  12834. /**
  12835. * Updates in place the current Size from the given floats.
  12836. * @param width width to set
  12837. * @param height height to set
  12838. * @returns the updated Size.
  12839. */
  12840. set(width: number, height: number): Size;
  12841. /**
  12842. * Multiplies the width and height by numbers
  12843. * @param w factor to multiple the width by
  12844. * @param h factor to multiple the height by
  12845. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12846. */
  12847. multiplyByFloats(w: number, h: number): Size;
  12848. /**
  12849. * Clones the size
  12850. * @returns a new Size copied from the given one.
  12851. */
  12852. clone(): Size;
  12853. /**
  12854. * True if the current Size and the given one width and height are strictly equal.
  12855. * @param other the other size to compare against
  12856. * @returns True if the current Size and the given one width and height are strictly equal.
  12857. */
  12858. equals(other: Size): boolean;
  12859. /**
  12860. * The surface of the Size : width * height (float).
  12861. */
  12862. readonly surface: number;
  12863. /**
  12864. * Create a new size of zero
  12865. * @returns a new Size set to (0.0, 0.0)
  12866. */
  12867. static Zero(): Size;
  12868. /**
  12869. * Sums the width and height of two sizes
  12870. * @param otherSize size to add to this size
  12871. * @returns a new Size set as the addition result of the current Size and the given one.
  12872. */
  12873. add(otherSize: Size): Size;
  12874. /**
  12875. * Subtracts the width and height of two
  12876. * @param otherSize size to subtract to this size
  12877. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12878. */
  12879. subtract(otherSize: Size): Size;
  12880. /**
  12881. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12882. * @param start starting size to lerp between
  12883. * @param end end size to lerp between
  12884. * @param amount amount to lerp between the start and end values
  12885. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12886. */
  12887. static Lerp(start: Size, end: Size, amount: number): Size;
  12888. }
  12889. }
  12890. declare module "babylonjs/Animations/runtimeAnimation" {
  12891. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12892. import { Animatable } from "babylonjs/Animations/animatable";
  12893. import { Scene } from "babylonjs/scene";
  12894. /**
  12895. * Defines a runtime animation
  12896. */
  12897. export class RuntimeAnimation {
  12898. private _events;
  12899. /**
  12900. * The current frame of the runtime animation
  12901. */
  12902. private _currentFrame;
  12903. /**
  12904. * The animation used by the runtime animation
  12905. */
  12906. private _animation;
  12907. /**
  12908. * The target of the runtime animation
  12909. */
  12910. private _target;
  12911. /**
  12912. * The initiating animatable
  12913. */
  12914. private _host;
  12915. /**
  12916. * The original value of the runtime animation
  12917. */
  12918. private _originalValue;
  12919. /**
  12920. * The original blend value of the runtime animation
  12921. */
  12922. private _originalBlendValue;
  12923. /**
  12924. * The offsets cache of the runtime animation
  12925. */
  12926. private _offsetsCache;
  12927. /**
  12928. * The high limits cache of the runtime animation
  12929. */
  12930. private _highLimitsCache;
  12931. /**
  12932. * Specifies if the runtime animation has been stopped
  12933. */
  12934. private _stopped;
  12935. /**
  12936. * The blending factor of the runtime animation
  12937. */
  12938. private _blendingFactor;
  12939. /**
  12940. * The BabylonJS scene
  12941. */
  12942. private _scene;
  12943. /**
  12944. * The current value of the runtime animation
  12945. */
  12946. private _currentValue;
  12947. /** @hidden */
  12948. _animationState: _IAnimationState;
  12949. /**
  12950. * The active target of the runtime animation
  12951. */
  12952. private _activeTargets;
  12953. private _currentActiveTarget;
  12954. private _directTarget;
  12955. /**
  12956. * The target path of the runtime animation
  12957. */
  12958. private _targetPath;
  12959. /**
  12960. * The weight of the runtime animation
  12961. */
  12962. private _weight;
  12963. /**
  12964. * The ratio offset of the runtime animation
  12965. */
  12966. private _ratioOffset;
  12967. /**
  12968. * The previous delay of the runtime animation
  12969. */
  12970. private _previousDelay;
  12971. /**
  12972. * The previous ratio of the runtime animation
  12973. */
  12974. private _previousRatio;
  12975. private _enableBlending;
  12976. private _keys;
  12977. private _minFrame;
  12978. private _maxFrame;
  12979. private _minValue;
  12980. private _maxValue;
  12981. private _targetIsArray;
  12982. /**
  12983. * Gets the current frame of the runtime animation
  12984. */
  12985. readonly currentFrame: number;
  12986. /**
  12987. * Gets the weight of the runtime animation
  12988. */
  12989. readonly weight: number;
  12990. /**
  12991. * Gets the current value of the runtime animation
  12992. */
  12993. readonly currentValue: any;
  12994. /**
  12995. * Gets the target path of the runtime animation
  12996. */
  12997. readonly targetPath: string;
  12998. /**
  12999. * Gets the actual target of the runtime animation
  13000. */
  13001. readonly target: any;
  13002. /** @hidden */
  13003. _onLoop: () => void;
  13004. /**
  13005. * Create a new RuntimeAnimation object
  13006. * @param target defines the target of the animation
  13007. * @param animation defines the source animation object
  13008. * @param scene defines the hosting scene
  13009. * @param host defines the initiating Animatable
  13010. */
  13011. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13012. private _preparePath;
  13013. /**
  13014. * Gets the animation from the runtime animation
  13015. */
  13016. readonly animation: Animation;
  13017. /**
  13018. * Resets the runtime animation to the beginning
  13019. * @param restoreOriginal defines whether to restore the target property to the original value
  13020. */
  13021. reset(restoreOriginal?: boolean): void;
  13022. /**
  13023. * Specifies if the runtime animation is stopped
  13024. * @returns Boolean specifying if the runtime animation is stopped
  13025. */
  13026. isStopped(): boolean;
  13027. /**
  13028. * Disposes of the runtime animation
  13029. */
  13030. dispose(): void;
  13031. /**
  13032. * Apply the interpolated value to the target
  13033. * @param currentValue defines the value computed by the animation
  13034. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13035. */
  13036. setValue(currentValue: any, weight: number): void;
  13037. private _getOriginalValues;
  13038. private _setValue;
  13039. /**
  13040. * Gets the loop pmode of the runtime animation
  13041. * @returns Loop Mode
  13042. */
  13043. private _getCorrectLoopMode;
  13044. /**
  13045. * Move the current animation to a given frame
  13046. * @param frame defines the frame to move to
  13047. */
  13048. goToFrame(frame: number): void;
  13049. /**
  13050. * @hidden Internal use only
  13051. */
  13052. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13053. /**
  13054. * Execute the current animation
  13055. * @param delay defines the delay to add to the current frame
  13056. * @param from defines the lower bound of the animation range
  13057. * @param to defines the upper bound of the animation range
  13058. * @param loop defines if the current animation must loop
  13059. * @param speedRatio defines the current speed ratio
  13060. * @param weight defines the weight of the animation (default is -1 so no weight)
  13061. * @param onLoop optional callback called when animation loops
  13062. * @returns a boolean indicating if the animation is running
  13063. */
  13064. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13065. }
  13066. }
  13067. declare module "babylonjs/Animations/animatable" {
  13068. import { Animation } from "babylonjs/Animations/animation";
  13069. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13070. import { Nullable } from "babylonjs/types";
  13071. import { Observable } from "babylonjs/Misc/observable";
  13072. import { Scene } from "babylonjs/scene";
  13073. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13074. import { Node } from "babylonjs/node";
  13075. /**
  13076. * Class used to store an actual running animation
  13077. */
  13078. export class Animatable {
  13079. /** defines the target object */
  13080. target: any;
  13081. /** defines the starting frame number (default is 0) */
  13082. fromFrame: number;
  13083. /** defines the ending frame number (default is 100) */
  13084. toFrame: number;
  13085. /** defines if the animation must loop (default is false) */
  13086. loopAnimation: boolean;
  13087. /** defines a callback to call when animation ends if it is not looping */
  13088. onAnimationEnd?: (() => void) | null | undefined;
  13089. /** defines a callback to call when animation loops */
  13090. onAnimationLoop?: (() => void) | null | undefined;
  13091. private _localDelayOffset;
  13092. private _pausedDelay;
  13093. private _runtimeAnimations;
  13094. private _paused;
  13095. private _scene;
  13096. private _speedRatio;
  13097. private _weight;
  13098. private _syncRoot;
  13099. /**
  13100. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13101. * This will only apply for non looping animation (default is true)
  13102. */
  13103. disposeOnEnd: boolean;
  13104. /**
  13105. * Gets a boolean indicating if the animation has started
  13106. */
  13107. animationStarted: boolean;
  13108. /**
  13109. * Observer raised when the animation ends
  13110. */
  13111. onAnimationEndObservable: Observable<Animatable>;
  13112. /**
  13113. * Observer raised when the animation loops
  13114. */
  13115. onAnimationLoopObservable: Observable<Animatable>;
  13116. /**
  13117. * Gets the root Animatable used to synchronize and normalize animations
  13118. */
  13119. readonly syncRoot: Nullable<Animatable>;
  13120. /**
  13121. * Gets the current frame of the first RuntimeAnimation
  13122. * Used to synchronize Animatables
  13123. */
  13124. readonly masterFrame: number;
  13125. /**
  13126. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13127. */
  13128. weight: number;
  13129. /**
  13130. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13131. */
  13132. speedRatio: number;
  13133. /**
  13134. * Creates a new Animatable
  13135. * @param scene defines the hosting scene
  13136. * @param target defines the target object
  13137. * @param fromFrame defines the starting frame number (default is 0)
  13138. * @param toFrame defines the ending frame number (default is 100)
  13139. * @param loopAnimation defines if the animation must loop (default is false)
  13140. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13141. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13142. * @param animations defines a group of animation to add to the new Animatable
  13143. * @param onAnimationLoop defines a callback to call when animation loops
  13144. */
  13145. constructor(scene: Scene,
  13146. /** defines the target object */
  13147. target: any,
  13148. /** defines the starting frame number (default is 0) */
  13149. fromFrame?: number,
  13150. /** defines the ending frame number (default is 100) */
  13151. toFrame?: number,
  13152. /** defines if the animation must loop (default is false) */
  13153. loopAnimation?: boolean, speedRatio?: number,
  13154. /** defines a callback to call when animation ends if it is not looping */
  13155. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13156. /** defines a callback to call when animation loops */
  13157. onAnimationLoop?: (() => void) | null | undefined);
  13158. /**
  13159. * Synchronize and normalize current Animatable with a source Animatable
  13160. * This is useful when using animation weights and when animations are not of the same length
  13161. * @param root defines the root Animatable to synchronize with
  13162. * @returns the current Animatable
  13163. */
  13164. syncWith(root: Animatable): Animatable;
  13165. /**
  13166. * Gets the list of runtime animations
  13167. * @returns an array of RuntimeAnimation
  13168. */
  13169. getAnimations(): RuntimeAnimation[];
  13170. /**
  13171. * Adds more animations to the current animatable
  13172. * @param target defines the target of the animations
  13173. * @param animations defines the new animations to add
  13174. */
  13175. appendAnimations(target: any, animations: Animation[]): void;
  13176. /**
  13177. * Gets the source animation for a specific property
  13178. * @param property defines the propertyu to look for
  13179. * @returns null or the source animation for the given property
  13180. */
  13181. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13182. /**
  13183. * Gets the runtime animation for a specific property
  13184. * @param property defines the propertyu to look for
  13185. * @returns null or the runtime animation for the given property
  13186. */
  13187. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13188. /**
  13189. * Resets the animatable to its original state
  13190. */
  13191. reset(): void;
  13192. /**
  13193. * Allows the animatable to blend with current running animations
  13194. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13195. * @param blendingSpeed defines the blending speed to use
  13196. */
  13197. enableBlending(blendingSpeed: number): void;
  13198. /**
  13199. * Disable animation blending
  13200. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13201. */
  13202. disableBlending(): void;
  13203. /**
  13204. * Jump directly to a given frame
  13205. * @param frame defines the frame to jump to
  13206. */
  13207. goToFrame(frame: number): void;
  13208. /**
  13209. * Pause the animation
  13210. */
  13211. pause(): void;
  13212. /**
  13213. * Restart the animation
  13214. */
  13215. restart(): void;
  13216. private _raiseOnAnimationEnd;
  13217. /**
  13218. * Stop and delete the current animation
  13219. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13220. * @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)
  13221. */
  13222. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13223. /**
  13224. * Wait asynchronously for the animation to end
  13225. * @returns a promise which will be fullfilled when the animation ends
  13226. */
  13227. waitAsync(): Promise<Animatable>;
  13228. /** @hidden */
  13229. _animate(delay: number): boolean;
  13230. }
  13231. module "babylonjs/scene" {
  13232. interface Scene {
  13233. /** @hidden */
  13234. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13235. /** @hidden */
  13236. _processLateAnimationBindingsForMatrices(holder: {
  13237. totalWeight: number;
  13238. animations: RuntimeAnimation[];
  13239. originalValue: Matrix;
  13240. }): any;
  13241. /** @hidden */
  13242. _processLateAnimationBindingsForQuaternions(holder: {
  13243. totalWeight: number;
  13244. animations: RuntimeAnimation[];
  13245. originalValue: Quaternion;
  13246. }, refQuaternion: Quaternion): Quaternion;
  13247. /** @hidden */
  13248. _processLateAnimationBindings(): void;
  13249. /**
  13250. * Will start the animation sequence of a given target
  13251. * @param target defines the target
  13252. * @param from defines from which frame should animation start
  13253. * @param to defines until which frame should animation run.
  13254. * @param weight defines the weight to apply to the animation (1.0 by default)
  13255. * @param loop defines if the animation loops
  13256. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13257. * @param onAnimationEnd defines the function to be executed when the animation ends
  13258. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13259. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13260. * @param onAnimationLoop defines the callback to call when an animation loops
  13261. * @returns the animatable object created for this animation
  13262. */
  13263. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13264. /**
  13265. * Will start the animation sequence of a given target
  13266. * @param target defines the target
  13267. * @param from defines from which frame should animation start
  13268. * @param to defines until which frame should animation run.
  13269. * @param loop defines if the animation loops
  13270. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13271. * @param onAnimationEnd defines the function to be executed when the animation ends
  13272. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13273. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13274. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13275. * @param onAnimationLoop defines the callback to call when an animation loops
  13276. * @returns the animatable object created for this animation
  13277. */
  13278. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13279. /**
  13280. * Will start the animation sequence of a given target and its hierarchy
  13281. * @param target defines the target
  13282. * @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.
  13283. * @param from defines from which frame should animation start
  13284. * @param to defines until which frame should animation run.
  13285. * @param loop defines if the animation loops
  13286. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13287. * @param onAnimationEnd defines the function to be executed when the animation ends
  13288. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13289. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13290. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13291. * @param onAnimationLoop defines the callback to call when an animation loops
  13292. * @returns the list of created animatables
  13293. */
  13294. 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[];
  13295. /**
  13296. * Begin a new animation on a given node
  13297. * @param target defines the target where the animation will take place
  13298. * @param animations defines the list of animations to start
  13299. * @param from defines the initial value
  13300. * @param to defines the final value
  13301. * @param loop defines if you want animation to loop (off by default)
  13302. * @param speedRatio defines the speed ratio to apply to all animations
  13303. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13304. * @param onAnimationLoop defines the callback to call when an animation loops
  13305. * @returns the list of created animatables
  13306. */
  13307. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13308. /**
  13309. * Begin a new animation on a given node and its hierarchy
  13310. * @param target defines the root node where the animation will take place
  13311. * @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.
  13312. * @param animations defines the list of animations to start
  13313. * @param from defines the initial value
  13314. * @param to defines the final value
  13315. * @param loop defines if you want animation to loop (off by default)
  13316. * @param speedRatio defines the speed ratio to apply to all animations
  13317. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13318. * @param onAnimationLoop defines the callback to call when an animation loops
  13319. * @returns the list of animatables created for all nodes
  13320. */
  13321. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13322. /**
  13323. * Gets the animatable associated with a specific target
  13324. * @param target defines the target of the animatable
  13325. * @returns the required animatable if found
  13326. */
  13327. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13328. /**
  13329. * Gets all animatables associated with a given target
  13330. * @param target defines the target to look animatables for
  13331. * @returns an array of Animatables
  13332. */
  13333. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13334. /**
  13335. * Stops and removes all animations that have been applied to the scene
  13336. */
  13337. stopAllAnimations(): void;
  13338. /**
  13339. * Gets the current delta time used by animation engine
  13340. */
  13341. deltaTime: number;
  13342. }
  13343. }
  13344. module "babylonjs/Bones/bone" {
  13345. interface Bone {
  13346. /**
  13347. * Copy an animation range from another bone
  13348. * @param source defines the source bone
  13349. * @param rangeName defines the range name to copy
  13350. * @param frameOffset defines the frame offset
  13351. * @param rescaleAsRequired defines if rescaling must be applied if required
  13352. * @param skelDimensionsRatio defines the scaling ratio
  13353. * @returns true if operation was successful
  13354. */
  13355. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13356. }
  13357. }
  13358. }
  13359. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13360. /**
  13361. * Class used to override all child animations of a given target
  13362. */
  13363. export class AnimationPropertiesOverride {
  13364. /**
  13365. * Gets or sets a value indicating if animation blending must be used
  13366. */
  13367. enableBlending: boolean;
  13368. /**
  13369. * Gets or sets the blending speed to use when enableBlending is true
  13370. */
  13371. blendingSpeed: number;
  13372. /**
  13373. * Gets or sets the default loop mode to use
  13374. */
  13375. loopMode: number;
  13376. }
  13377. }
  13378. declare module "babylonjs/Bones/skeleton" {
  13379. import { Bone } from "babylonjs/Bones/bone";
  13380. import { Observable } from "babylonjs/Misc/observable";
  13381. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13382. import { Scene } from "babylonjs/scene";
  13383. import { Nullable } from "babylonjs/types";
  13384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13385. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13386. import { Animatable } from "babylonjs/Animations/animatable";
  13387. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13388. import { Animation } from "babylonjs/Animations/animation";
  13389. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13390. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13391. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13392. /**
  13393. * Class used to handle skinning animations
  13394. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13395. */
  13396. export class Skeleton implements IAnimatable {
  13397. /** defines the skeleton name */
  13398. name: string;
  13399. /** defines the skeleton Id */
  13400. id: string;
  13401. /**
  13402. * Defines the list of child bones
  13403. */
  13404. bones: Bone[];
  13405. /**
  13406. * Defines an estimate of the dimension of the skeleton at rest
  13407. */
  13408. dimensionsAtRest: Vector3;
  13409. /**
  13410. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13411. */
  13412. needInitialSkinMatrix: boolean;
  13413. /**
  13414. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13415. */
  13416. overrideMesh: Nullable<AbstractMesh>;
  13417. /**
  13418. * Gets the list of animations attached to this skeleton
  13419. */
  13420. animations: Array<Animation>;
  13421. private _scene;
  13422. private _isDirty;
  13423. private _transformMatrices;
  13424. private _transformMatrixTexture;
  13425. private _meshesWithPoseMatrix;
  13426. private _animatables;
  13427. private _identity;
  13428. private _synchronizedWithMesh;
  13429. private _ranges;
  13430. private _lastAbsoluteTransformsUpdateId;
  13431. private _canUseTextureForBones;
  13432. private _uniqueId;
  13433. /** @hidden */
  13434. _numBonesWithLinkedTransformNode: number;
  13435. /** @hidden */
  13436. _hasWaitingData: Nullable<boolean>;
  13437. /**
  13438. * Specifies if the skeleton should be serialized
  13439. */
  13440. doNotSerialize: boolean;
  13441. private _useTextureToStoreBoneMatrices;
  13442. /**
  13443. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13444. * Please note that this option is not available if the hardware does not support it
  13445. */
  13446. useTextureToStoreBoneMatrices: boolean;
  13447. private _animationPropertiesOverride;
  13448. /**
  13449. * Gets or sets the animation properties override
  13450. */
  13451. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13452. /**
  13453. * List of inspectable custom properties (used by the Inspector)
  13454. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13455. */
  13456. inspectableCustomProperties: IInspectable[];
  13457. /**
  13458. * An observable triggered before computing the skeleton's matrices
  13459. */
  13460. onBeforeComputeObservable: Observable<Skeleton>;
  13461. /**
  13462. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13463. */
  13464. readonly isUsingTextureForMatrices: boolean;
  13465. /**
  13466. * Gets the unique ID of this skeleton
  13467. */
  13468. readonly uniqueId: number;
  13469. /**
  13470. * Creates a new skeleton
  13471. * @param name defines the skeleton name
  13472. * @param id defines the skeleton Id
  13473. * @param scene defines the hosting scene
  13474. */
  13475. constructor(
  13476. /** defines the skeleton name */
  13477. name: string,
  13478. /** defines the skeleton Id */
  13479. id: string, scene: Scene);
  13480. /**
  13481. * Gets the current object class name.
  13482. * @return the class name
  13483. */
  13484. getClassName(): string;
  13485. /**
  13486. * Returns an array containing the root bones
  13487. * @returns an array containing the root bones
  13488. */
  13489. getChildren(): Array<Bone>;
  13490. /**
  13491. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13492. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13493. * @returns a Float32Array containing matrices data
  13494. */
  13495. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13496. /**
  13497. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13498. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13499. * @returns a raw texture containing the data
  13500. */
  13501. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13502. /**
  13503. * Gets the current hosting scene
  13504. * @returns a scene object
  13505. */
  13506. getScene(): Scene;
  13507. /**
  13508. * Gets a string representing the current skeleton data
  13509. * @param fullDetails defines a boolean indicating if we want a verbose version
  13510. * @returns a string representing the current skeleton data
  13511. */
  13512. toString(fullDetails?: boolean): string;
  13513. /**
  13514. * Get bone's index searching by name
  13515. * @param name defines bone's name to search for
  13516. * @return the indice of the bone. Returns -1 if not found
  13517. */
  13518. getBoneIndexByName(name: string): number;
  13519. /**
  13520. * Creater a new animation range
  13521. * @param name defines the name of the range
  13522. * @param from defines the start key
  13523. * @param to defines the end key
  13524. */
  13525. createAnimationRange(name: string, from: number, to: number): void;
  13526. /**
  13527. * Delete a specific animation range
  13528. * @param name defines the name of the range
  13529. * @param deleteFrames defines if frames must be removed as well
  13530. */
  13531. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13532. /**
  13533. * Gets a specific animation range
  13534. * @param name defines the name of the range to look for
  13535. * @returns the requested animation range or null if not found
  13536. */
  13537. getAnimationRange(name: string): Nullable<AnimationRange>;
  13538. /**
  13539. * Gets the list of all animation ranges defined on this skeleton
  13540. * @returns an array
  13541. */
  13542. getAnimationRanges(): Nullable<AnimationRange>[];
  13543. /**
  13544. * Copy animation range from a source skeleton.
  13545. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13546. * @param source defines the source skeleton
  13547. * @param name defines the name of the range to copy
  13548. * @param rescaleAsRequired defines if rescaling must be applied if required
  13549. * @returns true if operation was successful
  13550. */
  13551. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13552. /**
  13553. * Forces the skeleton to go to rest pose
  13554. */
  13555. returnToRest(): void;
  13556. private _getHighestAnimationFrame;
  13557. /**
  13558. * Begin a specific animation range
  13559. * @param name defines the name of the range to start
  13560. * @param loop defines if looping must be turned on (false by default)
  13561. * @param speedRatio defines the speed ratio to apply (1 by default)
  13562. * @param onAnimationEnd defines a callback which will be called when animation will end
  13563. * @returns a new animatable
  13564. */
  13565. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13566. /** @hidden */
  13567. _markAsDirty(): void;
  13568. /** @hidden */
  13569. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13570. /** @hidden */
  13571. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13572. private _computeTransformMatrices;
  13573. /**
  13574. * Build all resources required to render a skeleton
  13575. */
  13576. prepare(): void;
  13577. /**
  13578. * Gets the list of animatables currently running for this skeleton
  13579. * @returns an array of animatables
  13580. */
  13581. getAnimatables(): IAnimatable[];
  13582. /**
  13583. * Clone the current skeleton
  13584. * @param name defines the name of the new skeleton
  13585. * @param id defines the id of the new skeleton
  13586. * @returns the new skeleton
  13587. */
  13588. clone(name: string, id: string): Skeleton;
  13589. /**
  13590. * Enable animation blending for this skeleton
  13591. * @param blendingSpeed defines the blending speed to apply
  13592. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13593. */
  13594. enableBlending(blendingSpeed?: number): void;
  13595. /**
  13596. * Releases all resources associated with the current skeleton
  13597. */
  13598. dispose(): void;
  13599. /**
  13600. * Serialize the skeleton in a JSON object
  13601. * @returns a JSON object
  13602. */
  13603. serialize(): any;
  13604. /**
  13605. * Creates a new skeleton from serialized data
  13606. * @param parsedSkeleton defines the serialized data
  13607. * @param scene defines the hosting scene
  13608. * @returns a new skeleton
  13609. */
  13610. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13611. /**
  13612. * Compute all node absolute transforms
  13613. * @param forceUpdate defines if computation must be done even if cache is up to date
  13614. */
  13615. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13616. /**
  13617. * Gets the root pose matrix
  13618. * @returns a matrix
  13619. */
  13620. getPoseMatrix(): Nullable<Matrix>;
  13621. /**
  13622. * Sorts bones per internal index
  13623. */
  13624. sortBones(): void;
  13625. private _sortBones;
  13626. }
  13627. }
  13628. declare module "babylonjs/Bones/bone" {
  13629. import { Skeleton } from "babylonjs/Bones/skeleton";
  13630. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13631. import { Nullable } from "babylonjs/types";
  13632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13633. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13634. import { Node } from "babylonjs/node";
  13635. import { Space } from "babylonjs/Maths/math.axis";
  13636. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13637. /**
  13638. * Class used to store bone information
  13639. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13640. */
  13641. export class Bone extends Node {
  13642. /**
  13643. * defines the bone name
  13644. */
  13645. name: string;
  13646. private static _tmpVecs;
  13647. private static _tmpQuat;
  13648. private static _tmpMats;
  13649. /**
  13650. * Gets the list of child bones
  13651. */
  13652. children: Bone[];
  13653. /** Gets the animations associated with this bone */
  13654. animations: import("babylonjs/Animations/animation").Animation[];
  13655. /**
  13656. * Gets or sets bone length
  13657. */
  13658. length: number;
  13659. /**
  13660. * @hidden Internal only
  13661. * Set this value to map this bone to a different index in the transform matrices
  13662. * Set this value to -1 to exclude the bone from the transform matrices
  13663. */
  13664. _index: Nullable<number>;
  13665. private _skeleton;
  13666. private _localMatrix;
  13667. private _restPose;
  13668. private _baseMatrix;
  13669. private _absoluteTransform;
  13670. private _invertedAbsoluteTransform;
  13671. private _parent;
  13672. private _scalingDeterminant;
  13673. private _worldTransform;
  13674. private _localScaling;
  13675. private _localRotation;
  13676. private _localPosition;
  13677. private _needToDecompose;
  13678. private _needToCompose;
  13679. /** @hidden */
  13680. _linkedTransformNode: Nullable<TransformNode>;
  13681. /** @hidden */
  13682. _waitingTransformNodeId: Nullable<string>;
  13683. /** @hidden */
  13684. /** @hidden */
  13685. _matrix: Matrix;
  13686. /**
  13687. * Create a new bone
  13688. * @param name defines the bone name
  13689. * @param skeleton defines the parent skeleton
  13690. * @param parentBone defines the parent (can be null if the bone is the root)
  13691. * @param localMatrix defines the local matrix
  13692. * @param restPose defines the rest pose matrix
  13693. * @param baseMatrix defines the base matrix
  13694. * @param index defines index of the bone in the hiearchy
  13695. */
  13696. constructor(
  13697. /**
  13698. * defines the bone name
  13699. */
  13700. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13701. /**
  13702. * Gets the current object class name.
  13703. * @return the class name
  13704. */
  13705. getClassName(): string;
  13706. /**
  13707. * Gets the parent skeleton
  13708. * @returns a skeleton
  13709. */
  13710. getSkeleton(): Skeleton;
  13711. /**
  13712. * Gets parent bone
  13713. * @returns a bone or null if the bone is the root of the bone hierarchy
  13714. */
  13715. getParent(): Nullable<Bone>;
  13716. /**
  13717. * Returns an array containing the root bones
  13718. * @returns an array containing the root bones
  13719. */
  13720. getChildren(): Array<Bone>;
  13721. /**
  13722. * Sets the parent bone
  13723. * @param parent defines the parent (can be null if the bone is the root)
  13724. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13725. */
  13726. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13727. /**
  13728. * Gets the local matrix
  13729. * @returns a matrix
  13730. */
  13731. getLocalMatrix(): Matrix;
  13732. /**
  13733. * Gets the base matrix (initial matrix which remains unchanged)
  13734. * @returns a matrix
  13735. */
  13736. getBaseMatrix(): Matrix;
  13737. /**
  13738. * Gets the rest pose matrix
  13739. * @returns a matrix
  13740. */
  13741. getRestPose(): Matrix;
  13742. /**
  13743. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13744. */
  13745. getWorldMatrix(): Matrix;
  13746. /**
  13747. * Sets the local matrix to rest pose matrix
  13748. */
  13749. returnToRest(): void;
  13750. /**
  13751. * Gets the inverse of the absolute transform matrix.
  13752. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13753. * @returns a matrix
  13754. */
  13755. getInvertedAbsoluteTransform(): Matrix;
  13756. /**
  13757. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13758. * @returns a matrix
  13759. */
  13760. getAbsoluteTransform(): Matrix;
  13761. /**
  13762. * Links with the given transform node.
  13763. * The local matrix of this bone is copied from the transform node every frame.
  13764. * @param transformNode defines the transform node to link to
  13765. */
  13766. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13767. /**
  13768. * Gets the node used to drive the bone's transformation
  13769. * @returns a transform node or null
  13770. */
  13771. getTransformNode(): Nullable<TransformNode>;
  13772. /** Gets or sets current position (in local space) */
  13773. position: Vector3;
  13774. /** Gets or sets current rotation (in local space) */
  13775. rotation: Vector3;
  13776. /** Gets or sets current rotation quaternion (in local space) */
  13777. rotationQuaternion: Quaternion;
  13778. /** Gets or sets current scaling (in local space) */
  13779. scaling: Vector3;
  13780. /**
  13781. * Gets the animation properties override
  13782. */
  13783. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13784. private _decompose;
  13785. private _compose;
  13786. /**
  13787. * Update the base and local matrices
  13788. * @param matrix defines the new base or local matrix
  13789. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13790. * @param updateLocalMatrix defines if the local matrix should be updated
  13791. */
  13792. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13793. /** @hidden */
  13794. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13795. /**
  13796. * Flag the bone as dirty (Forcing it to update everything)
  13797. */
  13798. markAsDirty(): void;
  13799. /** @hidden */
  13800. _markAsDirtyAndCompose(): void;
  13801. private _markAsDirtyAndDecompose;
  13802. /**
  13803. * Translate the bone in local or world space
  13804. * @param vec The amount to translate the bone
  13805. * @param space The space that the translation is in
  13806. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13807. */
  13808. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13809. /**
  13810. * Set the postion of the bone in local or world space
  13811. * @param position The position to set the bone
  13812. * @param space The space that the position is in
  13813. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13814. */
  13815. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13816. /**
  13817. * Set the absolute position of the bone (world space)
  13818. * @param position The position to set the bone
  13819. * @param mesh The mesh that this bone is attached to
  13820. */
  13821. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13822. /**
  13823. * Scale the bone on the x, y and z axes (in local space)
  13824. * @param x The amount to scale the bone on the x axis
  13825. * @param y The amount to scale the bone on the y axis
  13826. * @param z The amount to scale the bone on the z axis
  13827. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13828. */
  13829. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13830. /**
  13831. * Set the bone scaling in local space
  13832. * @param scale defines the scaling vector
  13833. */
  13834. setScale(scale: Vector3): void;
  13835. /**
  13836. * Gets the current scaling in local space
  13837. * @returns the current scaling vector
  13838. */
  13839. getScale(): Vector3;
  13840. /**
  13841. * Gets the current scaling in local space and stores it in a target vector
  13842. * @param result defines the target vector
  13843. */
  13844. getScaleToRef(result: Vector3): void;
  13845. /**
  13846. * Set the yaw, pitch, and roll of the bone in local or world space
  13847. * @param yaw The rotation of the bone on the y axis
  13848. * @param pitch The rotation of the bone on the x axis
  13849. * @param roll The rotation of the bone on the z axis
  13850. * @param space The space that the axes of rotation are in
  13851. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13852. */
  13853. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13854. /**
  13855. * Add a rotation to the bone on an axis in local or world space
  13856. * @param axis The axis to rotate the bone on
  13857. * @param amount The amount to rotate the bone
  13858. * @param space The space that the axis is in
  13859. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13860. */
  13861. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13862. /**
  13863. * Set the rotation of the bone to a particular axis angle in local or world space
  13864. * @param axis The axis to rotate the bone on
  13865. * @param angle The angle that the bone should be rotated to
  13866. * @param space The space that the axis is in
  13867. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13868. */
  13869. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13870. /**
  13871. * Set the euler rotation of the bone in local of world space
  13872. * @param rotation The euler rotation that the bone should be set to
  13873. * @param space The space that the rotation is in
  13874. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13875. */
  13876. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13877. /**
  13878. * Set the quaternion rotation of the bone in local of world space
  13879. * @param quat The quaternion rotation that the bone should be set to
  13880. * @param space The space that the rotation is in
  13881. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13882. */
  13883. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13884. /**
  13885. * Set the rotation matrix of the bone in local of world space
  13886. * @param rotMat The rotation matrix that the bone should be set to
  13887. * @param space The space that the rotation is in
  13888. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13889. */
  13890. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13891. private _rotateWithMatrix;
  13892. private _getNegativeRotationToRef;
  13893. /**
  13894. * Get the position of the bone in local or world space
  13895. * @param space The space that the returned position is in
  13896. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13897. * @returns The position of the bone
  13898. */
  13899. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13900. /**
  13901. * Copy the position of the bone to a vector3 in local or world space
  13902. * @param space The space that the returned position is in
  13903. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13904. * @param result The vector3 to copy the position to
  13905. */
  13906. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13907. /**
  13908. * Get the absolute position of the bone (world space)
  13909. * @param mesh The mesh that this bone is attached to
  13910. * @returns The absolute position of the bone
  13911. */
  13912. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13913. /**
  13914. * Copy the absolute position of the bone (world space) to the result param
  13915. * @param mesh The mesh that this bone is attached to
  13916. * @param result The vector3 to copy the absolute position to
  13917. */
  13918. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13919. /**
  13920. * Compute the absolute transforms of this bone and its children
  13921. */
  13922. computeAbsoluteTransforms(): void;
  13923. /**
  13924. * Get the world direction from an axis that is in the local space of the bone
  13925. * @param localAxis The local direction that is used to compute the world direction
  13926. * @param mesh The mesh that this bone is attached to
  13927. * @returns The world direction
  13928. */
  13929. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13930. /**
  13931. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13932. * @param localAxis The local direction that is used to compute the world direction
  13933. * @param mesh The mesh that this bone is attached to
  13934. * @param result The vector3 that the world direction will be copied to
  13935. */
  13936. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13937. /**
  13938. * Get the euler rotation of the bone in local or world space
  13939. * @param space The space that the rotation should be in
  13940. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13941. * @returns The euler rotation
  13942. */
  13943. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13944. /**
  13945. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13946. * @param space The space that the rotation should be in
  13947. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13948. * @param result The vector3 that the rotation should be copied to
  13949. */
  13950. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13951. /**
  13952. * Get the quaternion rotation of the bone in either local or world space
  13953. * @param space The space that the rotation should be in
  13954. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13955. * @returns The quaternion rotation
  13956. */
  13957. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13958. /**
  13959. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13960. * @param space The space that the rotation should be in
  13961. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13962. * @param result The quaternion that the rotation should be copied to
  13963. */
  13964. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13965. /**
  13966. * Get the rotation matrix of the bone in local or world space
  13967. * @param space The space that the rotation should be in
  13968. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13969. * @returns The rotation matrix
  13970. */
  13971. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13972. /**
  13973. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13974. * @param space The space that the rotation should be in
  13975. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13976. * @param result The quaternion that the rotation should be copied to
  13977. */
  13978. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13979. /**
  13980. * Get the world position of a point that is in the local space of the bone
  13981. * @param position The local position
  13982. * @param mesh The mesh that this bone is attached to
  13983. * @returns The world position
  13984. */
  13985. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13986. /**
  13987. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13988. * @param position The local position
  13989. * @param mesh The mesh that this bone is attached to
  13990. * @param result The vector3 that the world position should be copied to
  13991. */
  13992. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13993. /**
  13994. * Get the local position of a point that is in world space
  13995. * @param position The world position
  13996. * @param mesh The mesh that this bone is attached to
  13997. * @returns The local position
  13998. */
  13999. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14000. /**
  14001. * Get the local position of a point that is in world space and copy it to the result param
  14002. * @param position The world position
  14003. * @param mesh The mesh that this bone is attached to
  14004. * @param result The vector3 that the local position should be copied to
  14005. */
  14006. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14007. }
  14008. }
  14009. declare module "babylonjs/Meshes/transformNode" {
  14010. import { DeepImmutable } from "babylonjs/types";
  14011. import { Observable } from "babylonjs/Misc/observable";
  14012. import { Nullable } from "babylonjs/types";
  14013. import { Camera } from "babylonjs/Cameras/camera";
  14014. import { Scene } from "babylonjs/scene";
  14015. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14016. import { Node } from "babylonjs/node";
  14017. import { Bone } from "babylonjs/Bones/bone";
  14018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14019. import { Space } from "babylonjs/Maths/math.axis";
  14020. /**
  14021. * 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.
  14022. * @see https://doc.babylonjs.com/how_to/transformnode
  14023. */
  14024. export class TransformNode extends Node {
  14025. /**
  14026. * Object will not rotate to face the camera
  14027. */
  14028. static BILLBOARDMODE_NONE: number;
  14029. /**
  14030. * Object will rotate to face the camera but only on the x axis
  14031. */
  14032. static BILLBOARDMODE_X: number;
  14033. /**
  14034. * Object will rotate to face the camera but only on the y axis
  14035. */
  14036. static BILLBOARDMODE_Y: number;
  14037. /**
  14038. * Object will rotate to face the camera but only on the z axis
  14039. */
  14040. static BILLBOARDMODE_Z: number;
  14041. /**
  14042. * Object will rotate to face the camera
  14043. */
  14044. static BILLBOARDMODE_ALL: number;
  14045. /**
  14046. * Object will rotate to face the camera's position instead of orientation
  14047. */
  14048. static BILLBOARDMODE_USE_POSITION: number;
  14049. private _forward;
  14050. private _forwardInverted;
  14051. private _up;
  14052. private _right;
  14053. private _rightInverted;
  14054. private _position;
  14055. private _rotation;
  14056. private _rotationQuaternion;
  14057. protected _scaling: Vector3;
  14058. protected _isDirty: boolean;
  14059. private _transformToBoneReferal;
  14060. private _isAbsoluteSynced;
  14061. private _billboardMode;
  14062. /**
  14063. * Gets or sets the billboard mode. Default is 0.
  14064. *
  14065. * | Value | Type | Description |
  14066. * | --- | --- | --- |
  14067. * | 0 | BILLBOARDMODE_NONE | |
  14068. * | 1 | BILLBOARDMODE_X | |
  14069. * | 2 | BILLBOARDMODE_Y | |
  14070. * | 4 | BILLBOARDMODE_Z | |
  14071. * | 7 | BILLBOARDMODE_ALL | |
  14072. *
  14073. */
  14074. billboardMode: number;
  14075. private _preserveParentRotationForBillboard;
  14076. /**
  14077. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14078. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14079. */
  14080. preserveParentRotationForBillboard: boolean;
  14081. /**
  14082. * 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
  14083. */
  14084. scalingDeterminant: number;
  14085. private _infiniteDistance;
  14086. /**
  14087. * Gets or sets the distance of the object to max, often used by skybox
  14088. */
  14089. infiniteDistance: boolean;
  14090. /**
  14091. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14092. * By default the system will update normals to compensate
  14093. */
  14094. ignoreNonUniformScaling: boolean;
  14095. /**
  14096. * 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
  14097. */
  14098. reIntegrateRotationIntoRotationQuaternion: boolean;
  14099. /** @hidden */
  14100. _poseMatrix: Nullable<Matrix>;
  14101. /** @hidden */
  14102. _localMatrix: Matrix;
  14103. private _usePivotMatrix;
  14104. private _absolutePosition;
  14105. private _absoluteScaling;
  14106. private _absoluteRotationQuaternion;
  14107. private _pivotMatrix;
  14108. private _pivotMatrixInverse;
  14109. protected _postMultiplyPivotMatrix: boolean;
  14110. protected _isWorldMatrixFrozen: boolean;
  14111. /** @hidden */
  14112. _indexInSceneTransformNodesArray: number;
  14113. /**
  14114. * An event triggered after the world matrix is updated
  14115. */
  14116. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14117. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14118. /**
  14119. * Gets a string identifying the name of the class
  14120. * @returns "TransformNode" string
  14121. */
  14122. getClassName(): string;
  14123. /**
  14124. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14125. */
  14126. position: Vector3;
  14127. /**
  14128. * 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)).
  14129. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14130. */
  14131. rotation: Vector3;
  14132. /**
  14133. * 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)).
  14134. */
  14135. scaling: Vector3;
  14136. /**
  14137. * 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).
  14138. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14139. */
  14140. rotationQuaternion: Nullable<Quaternion>;
  14141. /**
  14142. * The forward direction of that transform in world space.
  14143. */
  14144. readonly forward: Vector3;
  14145. /**
  14146. * The up direction of that transform in world space.
  14147. */
  14148. readonly up: Vector3;
  14149. /**
  14150. * The right direction of that transform in world space.
  14151. */
  14152. readonly right: Vector3;
  14153. /**
  14154. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14155. * @param matrix the matrix to copy the pose from
  14156. * @returns this TransformNode.
  14157. */
  14158. updatePoseMatrix(matrix: Matrix): TransformNode;
  14159. /**
  14160. * Returns the mesh Pose matrix.
  14161. * @returns the pose matrix
  14162. */
  14163. getPoseMatrix(): Matrix;
  14164. /** @hidden */
  14165. _isSynchronized(): boolean;
  14166. /** @hidden */
  14167. _initCache(): void;
  14168. /**
  14169. * Flag the transform node as dirty (Forcing it to update everything)
  14170. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14171. * @returns this transform node
  14172. */
  14173. markAsDirty(property: string): TransformNode;
  14174. /**
  14175. * Returns the current mesh absolute position.
  14176. * Returns a Vector3.
  14177. */
  14178. readonly absolutePosition: Vector3;
  14179. /**
  14180. * Returns the current mesh absolute scaling.
  14181. * Returns a Vector3.
  14182. */
  14183. readonly absoluteScaling: Vector3;
  14184. /**
  14185. * Returns the current mesh absolute rotation.
  14186. * Returns a Quaternion.
  14187. */
  14188. readonly absoluteRotationQuaternion: Quaternion;
  14189. /**
  14190. * Sets a new matrix to apply before all other transformation
  14191. * @param matrix defines the transform matrix
  14192. * @returns the current TransformNode
  14193. */
  14194. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14195. /**
  14196. * Sets a new pivot matrix to the current node
  14197. * @param matrix defines the new pivot matrix to use
  14198. * @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
  14199. * @returns the current TransformNode
  14200. */
  14201. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14202. /**
  14203. * Returns the mesh pivot matrix.
  14204. * Default : Identity.
  14205. * @returns the matrix
  14206. */
  14207. getPivotMatrix(): Matrix;
  14208. /**
  14209. * Instantiate (when possible) or clone that node with its hierarchy
  14210. * @param newParent defines the new parent to use for the instance (or clone)
  14211. * @returns an instance (or a clone) of the current node with its hiearchy
  14212. */
  14213. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14214. /**
  14215. * Prevents the World matrix to be computed any longer
  14216. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14217. * @returns the TransformNode.
  14218. */
  14219. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14220. /**
  14221. * Allows back the World matrix computation.
  14222. * @returns the TransformNode.
  14223. */
  14224. unfreezeWorldMatrix(): this;
  14225. /**
  14226. * True if the World matrix has been frozen.
  14227. */
  14228. readonly isWorldMatrixFrozen: boolean;
  14229. /**
  14230. * Retuns the mesh absolute position in the World.
  14231. * @returns a Vector3.
  14232. */
  14233. getAbsolutePosition(): Vector3;
  14234. /**
  14235. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14236. * @param absolutePosition the absolute position to set
  14237. * @returns the TransformNode.
  14238. */
  14239. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14240. /**
  14241. * Sets the mesh position in its local space.
  14242. * @param vector3 the position to set in localspace
  14243. * @returns the TransformNode.
  14244. */
  14245. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14246. /**
  14247. * Returns the mesh position in the local space from the current World matrix values.
  14248. * @returns a new Vector3.
  14249. */
  14250. getPositionExpressedInLocalSpace(): Vector3;
  14251. /**
  14252. * Translates the mesh along the passed Vector3 in its local space.
  14253. * @param vector3 the distance to translate in localspace
  14254. * @returns the TransformNode.
  14255. */
  14256. locallyTranslate(vector3: Vector3): TransformNode;
  14257. private static _lookAtVectorCache;
  14258. /**
  14259. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14260. * @param targetPoint the position (must be in same space as current mesh) to look at
  14261. * @param yawCor optional yaw (y-axis) correction in radians
  14262. * @param pitchCor optional pitch (x-axis) correction in radians
  14263. * @param rollCor optional roll (z-axis) correction in radians
  14264. * @param space the choosen space of the target
  14265. * @returns the TransformNode.
  14266. */
  14267. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14268. /**
  14269. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14270. * This Vector3 is expressed in the World space.
  14271. * @param localAxis axis to rotate
  14272. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14273. */
  14274. getDirection(localAxis: Vector3): Vector3;
  14275. /**
  14276. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14277. * localAxis is expressed in the mesh local space.
  14278. * result is computed in the Wordl space from the mesh World matrix.
  14279. * @param localAxis axis to rotate
  14280. * @param result the resulting transformnode
  14281. * @returns this TransformNode.
  14282. */
  14283. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14284. /**
  14285. * Sets this transform node rotation to the given local axis.
  14286. * @param localAxis the axis in local space
  14287. * @param yawCor optional yaw (y-axis) correction in radians
  14288. * @param pitchCor optional pitch (x-axis) correction in radians
  14289. * @param rollCor optional roll (z-axis) correction in radians
  14290. * @returns this TransformNode
  14291. */
  14292. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14293. /**
  14294. * Sets a new pivot point to the current node
  14295. * @param point defines the new pivot point to use
  14296. * @param space defines if the point is in world or local space (local by default)
  14297. * @returns the current TransformNode
  14298. */
  14299. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14300. /**
  14301. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14302. * @returns the pivot point
  14303. */
  14304. getPivotPoint(): Vector3;
  14305. /**
  14306. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14307. * @param result the vector3 to store the result
  14308. * @returns this TransformNode.
  14309. */
  14310. getPivotPointToRef(result: Vector3): TransformNode;
  14311. /**
  14312. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14313. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14314. */
  14315. getAbsolutePivotPoint(): Vector3;
  14316. /**
  14317. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14318. * @param result vector3 to store the result
  14319. * @returns this TransformNode.
  14320. */
  14321. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14322. /**
  14323. * Defines the passed node as the parent of the current node.
  14324. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14325. * @see https://doc.babylonjs.com/how_to/parenting
  14326. * @param node the node ot set as the parent
  14327. * @returns this TransformNode.
  14328. */
  14329. setParent(node: Nullable<Node>): TransformNode;
  14330. private _nonUniformScaling;
  14331. /**
  14332. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14333. */
  14334. readonly nonUniformScaling: boolean;
  14335. /** @hidden */
  14336. _updateNonUniformScalingState(value: boolean): boolean;
  14337. /**
  14338. * Attach the current TransformNode to another TransformNode associated with a bone
  14339. * @param bone Bone affecting the TransformNode
  14340. * @param affectedTransformNode TransformNode associated with the bone
  14341. * @returns this object
  14342. */
  14343. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14344. /**
  14345. * Detach the transform node if its associated with a bone
  14346. * @returns this object
  14347. */
  14348. detachFromBone(): TransformNode;
  14349. private static _rotationAxisCache;
  14350. /**
  14351. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14352. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14353. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14354. * The passed axis is also normalized.
  14355. * @param axis the axis to rotate around
  14356. * @param amount the amount to rotate in radians
  14357. * @param space Space to rotate in (Default: local)
  14358. * @returns the TransformNode.
  14359. */
  14360. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14361. /**
  14362. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14363. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14364. * The passed axis is also normalized. .
  14365. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14366. * @param point the point to rotate around
  14367. * @param axis the axis to rotate around
  14368. * @param amount the amount to rotate in radians
  14369. * @returns the TransformNode
  14370. */
  14371. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14372. /**
  14373. * Translates the mesh along the axis vector for the passed distance in the given space.
  14374. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14375. * @param axis the axis to translate in
  14376. * @param distance the distance to translate
  14377. * @param space Space to rotate in (Default: local)
  14378. * @returns the TransformNode.
  14379. */
  14380. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14381. /**
  14382. * Adds a rotation step to the mesh current rotation.
  14383. * x, y, z are Euler angles expressed in radians.
  14384. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14385. * This means this rotation is made in the mesh local space only.
  14386. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14387. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14388. * ```javascript
  14389. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14390. * ```
  14391. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14392. * 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.
  14393. * @param x Rotation to add
  14394. * @param y Rotation to add
  14395. * @param z Rotation to add
  14396. * @returns the TransformNode.
  14397. */
  14398. addRotation(x: number, y: number, z: number): TransformNode;
  14399. /**
  14400. * @hidden
  14401. */
  14402. protected _getEffectiveParent(): Nullable<Node>;
  14403. /**
  14404. * Computes the world matrix of the node
  14405. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14406. * @returns the world matrix
  14407. */
  14408. computeWorldMatrix(force?: boolean): Matrix;
  14409. protected _afterComputeWorldMatrix(): void;
  14410. /**
  14411. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14412. * @param func callback function to add
  14413. *
  14414. * @returns the TransformNode.
  14415. */
  14416. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14417. /**
  14418. * Removes a registered callback function.
  14419. * @param func callback function to remove
  14420. * @returns the TransformNode.
  14421. */
  14422. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14423. /**
  14424. * Gets the position of the current mesh in camera space
  14425. * @param camera defines the camera to use
  14426. * @returns a position
  14427. */
  14428. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14429. /**
  14430. * Returns the distance from the mesh to the active camera
  14431. * @param camera defines the camera to use
  14432. * @returns the distance
  14433. */
  14434. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14435. /**
  14436. * Clone the current transform node
  14437. * @param name Name of the new clone
  14438. * @param newParent New parent for the clone
  14439. * @param doNotCloneChildren Do not clone children hierarchy
  14440. * @returns the new transform node
  14441. */
  14442. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14443. /**
  14444. * Serializes the objects information.
  14445. * @param currentSerializationObject defines the object to serialize in
  14446. * @returns the serialized object
  14447. */
  14448. serialize(currentSerializationObject?: any): any;
  14449. /**
  14450. * Returns a new TransformNode object parsed from the source provided.
  14451. * @param parsedTransformNode is the source.
  14452. * @param scene the scne the object belongs to
  14453. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14454. * @returns a new TransformNode object parsed from the source provided.
  14455. */
  14456. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14457. /**
  14458. * Get all child-transformNodes of this node
  14459. * @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
  14460. * @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
  14461. * @returns an array of TransformNode
  14462. */
  14463. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14464. /**
  14465. * Releases resources associated with this transform node.
  14466. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14467. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14468. */
  14469. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14470. /**
  14471. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14472. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14473. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14474. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14475. * @returns the current mesh
  14476. */
  14477. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14478. private _syncAbsoluteScalingAndRotation;
  14479. }
  14480. }
  14481. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14482. import { Observable } from "babylonjs/Misc/observable";
  14483. import { Nullable } from "babylonjs/types";
  14484. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14485. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14487. import { Ray } from "babylonjs/Culling/ray";
  14488. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14489. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14490. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14491. /**
  14492. * Defines the types of pose enabled controllers that are supported
  14493. */
  14494. export enum PoseEnabledControllerType {
  14495. /**
  14496. * HTC Vive
  14497. */
  14498. VIVE = 0,
  14499. /**
  14500. * Oculus Rift
  14501. */
  14502. OCULUS = 1,
  14503. /**
  14504. * Windows mixed reality
  14505. */
  14506. WINDOWS = 2,
  14507. /**
  14508. * Samsung gear VR
  14509. */
  14510. GEAR_VR = 3,
  14511. /**
  14512. * Google Daydream
  14513. */
  14514. DAYDREAM = 4,
  14515. /**
  14516. * Generic
  14517. */
  14518. GENERIC = 5
  14519. }
  14520. /**
  14521. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14522. */
  14523. export interface MutableGamepadButton {
  14524. /**
  14525. * Value of the button/trigger
  14526. */
  14527. value: number;
  14528. /**
  14529. * If the button/trigger is currently touched
  14530. */
  14531. touched: boolean;
  14532. /**
  14533. * If the button/trigger is currently pressed
  14534. */
  14535. pressed: boolean;
  14536. }
  14537. /**
  14538. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14539. * @hidden
  14540. */
  14541. export interface ExtendedGamepadButton extends GamepadButton {
  14542. /**
  14543. * If the button/trigger is currently pressed
  14544. */
  14545. readonly pressed: boolean;
  14546. /**
  14547. * If the button/trigger is currently touched
  14548. */
  14549. readonly touched: boolean;
  14550. /**
  14551. * Value of the button/trigger
  14552. */
  14553. readonly value: number;
  14554. }
  14555. /** @hidden */
  14556. export interface _GamePadFactory {
  14557. /**
  14558. * Returns wether or not the current gamepad can be created for this type of controller.
  14559. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14560. * @returns true if it can be created, otherwise false
  14561. */
  14562. canCreate(gamepadInfo: any): boolean;
  14563. /**
  14564. * Creates a new instance of the Gamepad.
  14565. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14566. * @returns the new gamepad instance
  14567. */
  14568. create(gamepadInfo: any): Gamepad;
  14569. }
  14570. /**
  14571. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14572. */
  14573. export class PoseEnabledControllerHelper {
  14574. /** @hidden */
  14575. static _ControllerFactories: _GamePadFactory[];
  14576. /** @hidden */
  14577. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14578. /**
  14579. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14580. * @param vrGamepad the gamepad to initialized
  14581. * @returns a vr controller of the type the gamepad identified as
  14582. */
  14583. static InitiateController(vrGamepad: any): Gamepad;
  14584. }
  14585. /**
  14586. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14587. */
  14588. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14589. /**
  14590. * If the controller is used in a webXR session
  14591. */
  14592. isXR: boolean;
  14593. private _deviceRoomPosition;
  14594. private _deviceRoomRotationQuaternion;
  14595. /**
  14596. * The device position in babylon space
  14597. */
  14598. devicePosition: Vector3;
  14599. /**
  14600. * The device rotation in babylon space
  14601. */
  14602. deviceRotationQuaternion: Quaternion;
  14603. /**
  14604. * The scale factor of the device in babylon space
  14605. */
  14606. deviceScaleFactor: number;
  14607. /**
  14608. * (Likely devicePosition should be used instead) The device position in its room space
  14609. */
  14610. position: Vector3;
  14611. /**
  14612. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14613. */
  14614. rotationQuaternion: Quaternion;
  14615. /**
  14616. * The type of controller (Eg. Windows mixed reality)
  14617. */
  14618. controllerType: PoseEnabledControllerType;
  14619. protected _calculatedPosition: Vector3;
  14620. private _calculatedRotation;
  14621. /**
  14622. * The raw pose from the device
  14623. */
  14624. rawPose: DevicePose;
  14625. private _trackPosition;
  14626. private _maxRotationDistFromHeadset;
  14627. private _draggedRoomRotation;
  14628. /**
  14629. * @hidden
  14630. */
  14631. _disableTrackPosition(fixedPosition: Vector3): void;
  14632. /**
  14633. * Internal, the mesh attached to the controller
  14634. * @hidden
  14635. */
  14636. _mesh: Nullable<AbstractMesh>;
  14637. private _poseControlledCamera;
  14638. private _leftHandSystemQuaternion;
  14639. /**
  14640. * Internal, matrix used to convert room space to babylon space
  14641. * @hidden
  14642. */
  14643. _deviceToWorld: Matrix;
  14644. /**
  14645. * Node to be used when casting a ray from the controller
  14646. * @hidden
  14647. */
  14648. _pointingPoseNode: Nullable<TransformNode>;
  14649. /**
  14650. * Name of the child mesh that can be used to cast a ray from the controller
  14651. */
  14652. static readonly POINTING_POSE: string;
  14653. /**
  14654. * Creates a new PoseEnabledController from a gamepad
  14655. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14656. */
  14657. constructor(browserGamepad: any);
  14658. private _workingMatrix;
  14659. /**
  14660. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14661. */
  14662. update(): void;
  14663. /**
  14664. * Updates only the pose device and mesh without doing any button event checking
  14665. */
  14666. protected _updatePoseAndMesh(): void;
  14667. /**
  14668. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14669. * @param poseData raw pose fromthe device
  14670. */
  14671. updateFromDevice(poseData: DevicePose): void;
  14672. /**
  14673. * @hidden
  14674. */
  14675. _meshAttachedObservable: Observable<AbstractMesh>;
  14676. /**
  14677. * Attaches a mesh to the controller
  14678. * @param mesh the mesh to be attached
  14679. */
  14680. attachToMesh(mesh: AbstractMesh): void;
  14681. /**
  14682. * Attaches the controllers mesh to a camera
  14683. * @param camera the camera the mesh should be attached to
  14684. */
  14685. attachToPoseControlledCamera(camera: TargetCamera): void;
  14686. /**
  14687. * Disposes of the controller
  14688. */
  14689. dispose(): void;
  14690. /**
  14691. * The mesh that is attached to the controller
  14692. */
  14693. readonly mesh: Nullable<AbstractMesh>;
  14694. /**
  14695. * Gets the ray of the controller in the direction the controller is pointing
  14696. * @param length the length the resulting ray should be
  14697. * @returns a ray in the direction the controller is pointing
  14698. */
  14699. getForwardRay(length?: number): Ray;
  14700. }
  14701. }
  14702. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14703. import { Observable } from "babylonjs/Misc/observable";
  14704. import { Scene } from "babylonjs/scene";
  14705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14706. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14707. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14708. import { Nullable } from "babylonjs/types";
  14709. /**
  14710. * Defines the WebVRController object that represents controllers tracked in 3D space
  14711. */
  14712. export abstract class WebVRController extends PoseEnabledController {
  14713. /**
  14714. * Internal, the default controller model for the controller
  14715. */
  14716. protected _defaultModel: Nullable<AbstractMesh>;
  14717. /**
  14718. * Fired when the trigger state has changed
  14719. */
  14720. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14721. /**
  14722. * Fired when the main button state has changed
  14723. */
  14724. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14725. /**
  14726. * Fired when the secondary button state has changed
  14727. */
  14728. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14729. /**
  14730. * Fired when the pad state has changed
  14731. */
  14732. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14733. /**
  14734. * Fired when controllers stick values have changed
  14735. */
  14736. onPadValuesChangedObservable: Observable<StickValues>;
  14737. /**
  14738. * Array of button availible on the controller
  14739. */
  14740. protected _buttons: Array<MutableGamepadButton>;
  14741. private _onButtonStateChange;
  14742. /**
  14743. * Fired when a controller button's state has changed
  14744. * @param callback the callback containing the button that was modified
  14745. */
  14746. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14747. /**
  14748. * X and Y axis corresponding to the controllers joystick
  14749. */
  14750. pad: StickValues;
  14751. /**
  14752. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14753. */
  14754. hand: string;
  14755. /**
  14756. * The default controller model for the controller
  14757. */
  14758. readonly defaultModel: Nullable<AbstractMesh>;
  14759. /**
  14760. * Creates a new WebVRController from a gamepad
  14761. * @param vrGamepad the gamepad that the WebVRController should be created from
  14762. */
  14763. constructor(vrGamepad: any);
  14764. /**
  14765. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14766. */
  14767. update(): void;
  14768. /**
  14769. * Function to be called when a button is modified
  14770. */
  14771. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14772. /**
  14773. * Loads a mesh and attaches it to the controller
  14774. * @param scene the scene the mesh should be added to
  14775. * @param meshLoaded callback for when the mesh has been loaded
  14776. */
  14777. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14778. private _setButtonValue;
  14779. private _changes;
  14780. private _checkChanges;
  14781. /**
  14782. * Disposes of th webVRCOntroller
  14783. */
  14784. dispose(): void;
  14785. }
  14786. }
  14787. declare module "babylonjs/Lights/hemisphericLight" {
  14788. import { Nullable } from "babylonjs/types";
  14789. import { Scene } from "babylonjs/scene";
  14790. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14791. import { Color3 } from "babylonjs/Maths/math.color";
  14792. import { Effect } from "babylonjs/Materials/effect";
  14793. import { Light } from "babylonjs/Lights/light";
  14794. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14795. /**
  14796. * The HemisphericLight simulates the ambient environment light,
  14797. * so the passed direction is the light reflection direction, not the incoming direction.
  14798. */
  14799. export class HemisphericLight extends Light {
  14800. /**
  14801. * The groundColor is the light in the opposite direction to the one specified during creation.
  14802. * 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.
  14803. */
  14804. groundColor: Color3;
  14805. /**
  14806. * The light reflection direction, not the incoming direction.
  14807. */
  14808. direction: Vector3;
  14809. /**
  14810. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14811. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14812. * The HemisphericLight can't cast shadows.
  14813. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14814. * @param name The friendly name of the light
  14815. * @param direction The direction of the light reflection
  14816. * @param scene The scene the light belongs to
  14817. */
  14818. constructor(name: string, direction: Vector3, scene: Scene);
  14819. protected _buildUniformLayout(): void;
  14820. /**
  14821. * Returns the string "HemisphericLight".
  14822. * @return The class name
  14823. */
  14824. getClassName(): string;
  14825. /**
  14826. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14827. * Returns the updated direction.
  14828. * @param target The target the direction should point to
  14829. * @return The computed direction
  14830. */
  14831. setDirectionToTarget(target: Vector3): Vector3;
  14832. /**
  14833. * Returns the shadow generator associated to the light.
  14834. * @returns Always null for hemispheric lights because it does not support shadows.
  14835. */
  14836. getShadowGenerator(): Nullable<IShadowGenerator>;
  14837. /**
  14838. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14839. * @param effect The effect to update
  14840. * @param lightIndex The index of the light in the effect to update
  14841. * @returns The hemispheric light
  14842. */
  14843. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14844. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14845. /**
  14846. * Computes the world matrix of the node
  14847. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14848. * @param useWasUpdatedFlag defines a reserved property
  14849. * @returns the world matrix
  14850. */
  14851. computeWorldMatrix(): Matrix;
  14852. /**
  14853. * Returns the integer 3.
  14854. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14855. */
  14856. getTypeID(): number;
  14857. /**
  14858. * Prepares the list of defines specific to the light type.
  14859. * @param defines the list of defines
  14860. * @param lightIndex defines the index of the light for the effect
  14861. */
  14862. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14863. }
  14864. }
  14865. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14866. /** @hidden */
  14867. export var vrMultiviewToSingleviewPixelShader: {
  14868. name: string;
  14869. shader: string;
  14870. };
  14871. }
  14872. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14873. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14874. import { Scene } from "babylonjs/scene";
  14875. /**
  14876. * Renders to multiple views with a single draw call
  14877. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14878. */
  14879. export class MultiviewRenderTarget extends RenderTargetTexture {
  14880. /**
  14881. * Creates a multiview render target
  14882. * @param scene scene used with the render target
  14883. * @param size the size of the render target (used for each view)
  14884. */
  14885. constructor(scene: Scene, size?: number | {
  14886. width: number;
  14887. height: number;
  14888. } | {
  14889. ratio: number;
  14890. });
  14891. /**
  14892. * @hidden
  14893. * @param faceIndex the face index, if its a cube texture
  14894. */
  14895. _bindFrameBuffer(faceIndex?: number): void;
  14896. /**
  14897. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14898. * @returns the view count
  14899. */
  14900. getViewCount(): number;
  14901. }
  14902. }
  14903. declare module "babylonjs/Maths/math.frustum" {
  14904. import { Matrix } from "babylonjs/Maths/math.vector";
  14905. import { DeepImmutable } from "babylonjs/types";
  14906. import { Plane } from "babylonjs/Maths/math.plane";
  14907. /**
  14908. * Represents a camera frustum
  14909. */
  14910. export class Frustum {
  14911. /**
  14912. * Gets the planes representing the frustum
  14913. * @param transform matrix to be applied to the returned planes
  14914. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14915. */
  14916. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14917. /**
  14918. * Gets the near frustum plane transformed by the transform matrix
  14919. * @param transform transformation matrix to be applied to the resulting frustum plane
  14920. * @param frustumPlane the resuling frustum plane
  14921. */
  14922. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14923. /**
  14924. * Gets the far frustum plane transformed by the transform matrix
  14925. * @param transform transformation matrix to be applied to the resulting frustum plane
  14926. * @param frustumPlane the resuling frustum plane
  14927. */
  14928. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14929. /**
  14930. * Gets the left frustum plane transformed by the transform matrix
  14931. * @param transform transformation matrix to be applied to the resulting frustum plane
  14932. * @param frustumPlane the resuling frustum plane
  14933. */
  14934. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14935. /**
  14936. * Gets the right frustum plane transformed by the transform matrix
  14937. * @param transform transformation matrix to be applied to the resulting frustum plane
  14938. * @param frustumPlane the resuling frustum plane
  14939. */
  14940. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14941. /**
  14942. * Gets the top frustum plane transformed by the transform matrix
  14943. * @param transform transformation matrix to be applied to the resulting frustum plane
  14944. * @param frustumPlane the resuling frustum plane
  14945. */
  14946. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14947. /**
  14948. * Gets the bottom frustum plane transformed by the transform matrix
  14949. * @param transform transformation matrix to be applied to the resulting frustum plane
  14950. * @param frustumPlane the resuling frustum plane
  14951. */
  14952. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14953. /**
  14954. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14955. * @param transform transformation matrix to be applied to the resulting frustum planes
  14956. * @param frustumPlanes the resuling frustum planes
  14957. */
  14958. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14959. }
  14960. }
  14961. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14962. import { Camera } from "babylonjs/Cameras/camera";
  14963. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14964. import { Nullable } from "babylonjs/types";
  14965. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14966. import { Matrix } from "babylonjs/Maths/math.vector";
  14967. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14968. module "babylonjs/Engines/engine" {
  14969. interface Engine {
  14970. /**
  14971. * Creates a new multiview render target
  14972. * @param width defines the width of the texture
  14973. * @param height defines the height of the texture
  14974. * @returns the created multiview texture
  14975. */
  14976. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14977. /**
  14978. * Binds a multiview framebuffer to be drawn to
  14979. * @param multiviewTexture texture to bind
  14980. */
  14981. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14982. }
  14983. }
  14984. module "babylonjs/Cameras/camera" {
  14985. interface Camera {
  14986. /**
  14987. * @hidden
  14988. * 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)
  14989. */
  14990. _useMultiviewToSingleView: boolean;
  14991. /**
  14992. * @hidden
  14993. * 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)
  14994. */
  14995. _multiviewTexture: Nullable<RenderTargetTexture>;
  14996. /**
  14997. * @hidden
  14998. * ensures the multiview texture of the camera exists and has the specified width/height
  14999. * @param width height to set on the multiview texture
  15000. * @param height width to set on the multiview texture
  15001. */
  15002. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15003. }
  15004. }
  15005. module "babylonjs/scene" {
  15006. interface Scene {
  15007. /** @hidden */
  15008. _transformMatrixR: Matrix;
  15009. /** @hidden */
  15010. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15011. /** @hidden */
  15012. _createMultiviewUbo(): void;
  15013. /** @hidden */
  15014. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15015. /** @hidden */
  15016. _renderMultiviewToSingleView(camera: Camera): void;
  15017. }
  15018. }
  15019. }
  15020. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15021. import { Camera } from "babylonjs/Cameras/camera";
  15022. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15023. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15024. import "babylonjs/Engines/Extensions/engine.multiview";
  15025. /**
  15026. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15027. * This will not be used for webXR as it supports displaying texture arrays directly
  15028. */
  15029. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15030. /**
  15031. * Initializes a VRMultiviewToSingleview
  15032. * @param name name of the post process
  15033. * @param camera camera to be applied to
  15034. * @param scaleFactor scaling factor to the size of the output texture
  15035. */
  15036. constructor(name: string, camera: Camera, scaleFactor: number);
  15037. }
  15038. }
  15039. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15040. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15041. import { Nullable } from "babylonjs/types";
  15042. import { Size } from "babylonjs/Maths/math.size";
  15043. import { Observable } from "babylonjs/Misc/observable";
  15044. module "babylonjs/Engines/engine" {
  15045. interface Engine {
  15046. /** @hidden */
  15047. _vrDisplay: any;
  15048. /** @hidden */
  15049. _vrSupported: boolean;
  15050. /** @hidden */
  15051. _oldSize: Size;
  15052. /** @hidden */
  15053. _oldHardwareScaleFactor: number;
  15054. /** @hidden */
  15055. _vrExclusivePointerMode: boolean;
  15056. /** @hidden */
  15057. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15058. /** @hidden */
  15059. _onVRDisplayPointerRestricted: () => void;
  15060. /** @hidden */
  15061. _onVRDisplayPointerUnrestricted: () => void;
  15062. /** @hidden */
  15063. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15064. /** @hidden */
  15065. _onVrDisplayDisconnect: Nullable<() => void>;
  15066. /** @hidden */
  15067. _onVrDisplayPresentChange: Nullable<() => void>;
  15068. /**
  15069. * Observable signaled when VR display mode changes
  15070. */
  15071. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15072. /**
  15073. * Observable signaled when VR request present is complete
  15074. */
  15075. onVRRequestPresentComplete: Observable<boolean>;
  15076. /**
  15077. * Observable signaled when VR request present starts
  15078. */
  15079. onVRRequestPresentStart: Observable<Engine>;
  15080. /**
  15081. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15082. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15083. */
  15084. isInVRExclusivePointerMode: boolean;
  15085. /**
  15086. * Gets a boolean indicating if a webVR device was detected
  15087. * @returns true if a webVR device was detected
  15088. */
  15089. isVRDevicePresent(): boolean;
  15090. /**
  15091. * Gets the current webVR device
  15092. * @returns the current webVR device (or null)
  15093. */
  15094. getVRDevice(): any;
  15095. /**
  15096. * Initializes a webVR display and starts listening to display change events
  15097. * The onVRDisplayChangedObservable will be notified upon these changes
  15098. * @returns A promise containing a VRDisplay and if vr is supported
  15099. */
  15100. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15101. /** @hidden */
  15102. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15103. /**
  15104. * Call this function to switch to webVR mode
  15105. * Will do nothing if webVR is not supported or if there is no webVR device
  15106. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15107. */
  15108. enableVR(): void;
  15109. /** @hidden */
  15110. _onVRFullScreenTriggered(): void;
  15111. }
  15112. }
  15113. }
  15114. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15115. import { Nullable } from "babylonjs/types";
  15116. import { Observable } from "babylonjs/Misc/observable";
  15117. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15118. import { Scene } from "babylonjs/scene";
  15119. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15120. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15121. import { Node } from "babylonjs/node";
  15122. import { Ray } from "babylonjs/Culling/ray";
  15123. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15124. import "babylonjs/Engines/Extensions/engine.webVR";
  15125. /**
  15126. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15127. * IMPORTANT!! The data is right-hand data.
  15128. * @export
  15129. * @interface DevicePose
  15130. */
  15131. export interface DevicePose {
  15132. /**
  15133. * The position of the device, values in array are [x,y,z].
  15134. */
  15135. readonly position: Nullable<Float32Array>;
  15136. /**
  15137. * The linearVelocity of the device, values in array are [x,y,z].
  15138. */
  15139. readonly linearVelocity: Nullable<Float32Array>;
  15140. /**
  15141. * The linearAcceleration of the device, values in array are [x,y,z].
  15142. */
  15143. readonly linearAcceleration: Nullable<Float32Array>;
  15144. /**
  15145. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15146. */
  15147. readonly orientation: Nullable<Float32Array>;
  15148. /**
  15149. * The angularVelocity of the device, values in array are [x,y,z].
  15150. */
  15151. readonly angularVelocity: Nullable<Float32Array>;
  15152. /**
  15153. * The angularAcceleration of the device, values in array are [x,y,z].
  15154. */
  15155. readonly angularAcceleration: Nullable<Float32Array>;
  15156. }
  15157. /**
  15158. * Interface representing a pose controlled object in Babylon.
  15159. * A pose controlled object has both regular pose values as well as pose values
  15160. * from an external device such as a VR head mounted display
  15161. */
  15162. export interface PoseControlled {
  15163. /**
  15164. * The position of the object in babylon space.
  15165. */
  15166. position: Vector3;
  15167. /**
  15168. * The rotation quaternion of the object in babylon space.
  15169. */
  15170. rotationQuaternion: Quaternion;
  15171. /**
  15172. * The position of the device in babylon space.
  15173. */
  15174. devicePosition?: Vector3;
  15175. /**
  15176. * The rotation quaternion of the device in babylon space.
  15177. */
  15178. deviceRotationQuaternion: Quaternion;
  15179. /**
  15180. * The raw pose coming from the device.
  15181. */
  15182. rawPose: Nullable<DevicePose>;
  15183. /**
  15184. * The scale of the device to be used when translating from device space to babylon space.
  15185. */
  15186. deviceScaleFactor: number;
  15187. /**
  15188. * Updates the poseControlled values based on the input device pose.
  15189. * @param poseData the pose data to update the object with
  15190. */
  15191. updateFromDevice(poseData: DevicePose): void;
  15192. }
  15193. /**
  15194. * Set of options to customize the webVRCamera
  15195. */
  15196. export interface WebVROptions {
  15197. /**
  15198. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15199. */
  15200. trackPosition?: boolean;
  15201. /**
  15202. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15203. */
  15204. positionScale?: number;
  15205. /**
  15206. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15207. */
  15208. displayName?: string;
  15209. /**
  15210. * Should the native controller meshes be initialized. (default: true)
  15211. */
  15212. controllerMeshes?: boolean;
  15213. /**
  15214. * Creating a default HemiLight only on controllers. (default: true)
  15215. */
  15216. defaultLightingOnControllers?: boolean;
  15217. /**
  15218. * If you don't want to use the default VR button of the helper. (default: false)
  15219. */
  15220. useCustomVRButton?: boolean;
  15221. /**
  15222. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15223. */
  15224. customVRButton?: HTMLButtonElement;
  15225. /**
  15226. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15227. */
  15228. rayLength?: number;
  15229. /**
  15230. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15231. */
  15232. defaultHeight?: number;
  15233. /**
  15234. * If multiview should be used if availible (default: false)
  15235. */
  15236. useMultiview?: boolean;
  15237. }
  15238. /**
  15239. * This represents a WebVR camera.
  15240. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15241. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15242. */
  15243. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15244. private webVROptions;
  15245. /**
  15246. * @hidden
  15247. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15248. */
  15249. _vrDevice: any;
  15250. /**
  15251. * The rawPose of the vrDevice.
  15252. */
  15253. rawPose: Nullable<DevicePose>;
  15254. private _onVREnabled;
  15255. private _specsVersion;
  15256. private _attached;
  15257. private _frameData;
  15258. protected _descendants: Array<Node>;
  15259. private _deviceRoomPosition;
  15260. /** @hidden */
  15261. _deviceRoomRotationQuaternion: Quaternion;
  15262. private _standingMatrix;
  15263. /**
  15264. * Represents device position in babylon space.
  15265. */
  15266. devicePosition: Vector3;
  15267. /**
  15268. * Represents device rotation in babylon space.
  15269. */
  15270. deviceRotationQuaternion: Quaternion;
  15271. /**
  15272. * The scale of the device to be used when translating from device space to babylon space.
  15273. */
  15274. deviceScaleFactor: number;
  15275. private _deviceToWorld;
  15276. private _worldToDevice;
  15277. /**
  15278. * References to the webVR controllers for the vrDevice.
  15279. */
  15280. controllers: Array<WebVRController>;
  15281. /**
  15282. * Emits an event when a controller is attached.
  15283. */
  15284. onControllersAttachedObservable: Observable<WebVRController[]>;
  15285. /**
  15286. * Emits an event when a controller's mesh has been loaded;
  15287. */
  15288. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15289. /**
  15290. * Emits an event when the HMD's pose has been updated.
  15291. */
  15292. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15293. private _poseSet;
  15294. /**
  15295. * If the rig cameras be used as parent instead of this camera.
  15296. */
  15297. rigParenting: boolean;
  15298. private _lightOnControllers;
  15299. private _defaultHeight?;
  15300. /**
  15301. * Instantiates a WebVRFreeCamera.
  15302. * @param name The name of the WebVRFreeCamera
  15303. * @param position The starting anchor position for the camera
  15304. * @param scene The scene the camera belongs to
  15305. * @param webVROptions a set of customizable options for the webVRCamera
  15306. */
  15307. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15308. /**
  15309. * Gets the device distance from the ground in meters.
  15310. * @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.
  15311. */
  15312. deviceDistanceToRoomGround(): number;
  15313. /**
  15314. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15315. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15316. */
  15317. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15318. /**
  15319. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15320. * @returns A promise with a boolean set to if the standing matrix is supported.
  15321. */
  15322. useStandingMatrixAsync(): Promise<boolean>;
  15323. /**
  15324. * Disposes the camera
  15325. */
  15326. dispose(): void;
  15327. /**
  15328. * Gets a vrController by name.
  15329. * @param name The name of the controller to retreive
  15330. * @returns the controller matching the name specified or null if not found
  15331. */
  15332. getControllerByName(name: string): Nullable<WebVRController>;
  15333. private _leftController;
  15334. /**
  15335. * The controller corresponding to the users left hand.
  15336. */
  15337. readonly leftController: Nullable<WebVRController>;
  15338. private _rightController;
  15339. /**
  15340. * The controller corresponding to the users right hand.
  15341. */
  15342. readonly rightController: Nullable<WebVRController>;
  15343. /**
  15344. * Casts a ray forward from the vrCamera's gaze.
  15345. * @param length Length of the ray (default: 100)
  15346. * @returns the ray corresponding to the gaze
  15347. */
  15348. getForwardRay(length?: number): Ray;
  15349. /**
  15350. * @hidden
  15351. * Updates the camera based on device's frame data
  15352. */
  15353. _checkInputs(): void;
  15354. /**
  15355. * Updates the poseControlled values based on the input device pose.
  15356. * @param poseData Pose coming from the device
  15357. */
  15358. updateFromDevice(poseData: DevicePose): void;
  15359. private _htmlElementAttached;
  15360. private _detachIfAttached;
  15361. /**
  15362. * WebVR's attach control will start broadcasting frames to the device.
  15363. * Note that in certain browsers (chrome for example) this function must be called
  15364. * within a user-interaction callback. Example:
  15365. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15366. *
  15367. * @param element html element to attach the vrDevice to
  15368. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15369. */
  15370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15371. /**
  15372. * Detaches the camera from the html element and disables VR
  15373. *
  15374. * @param element html element to detach from
  15375. */
  15376. detachControl(element: HTMLElement): void;
  15377. /**
  15378. * @returns the name of this class
  15379. */
  15380. getClassName(): string;
  15381. /**
  15382. * Calls resetPose on the vrDisplay
  15383. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15384. */
  15385. resetToCurrentRotation(): void;
  15386. /**
  15387. * @hidden
  15388. * Updates the rig cameras (left and right eye)
  15389. */
  15390. _updateRigCameras(): void;
  15391. private _workingVector;
  15392. private _oneVector;
  15393. private _workingMatrix;
  15394. private updateCacheCalled;
  15395. private _correctPositionIfNotTrackPosition;
  15396. /**
  15397. * @hidden
  15398. * Updates the cached values of the camera
  15399. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15400. */
  15401. _updateCache(ignoreParentClass?: boolean): void;
  15402. /**
  15403. * @hidden
  15404. * Get current device position in babylon world
  15405. */
  15406. _computeDevicePosition(): void;
  15407. /**
  15408. * Updates the current device position and rotation in the babylon world
  15409. */
  15410. update(): void;
  15411. /**
  15412. * @hidden
  15413. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15414. * @returns an identity matrix
  15415. */
  15416. _getViewMatrix(): Matrix;
  15417. private _tmpMatrix;
  15418. /**
  15419. * This function is called by the two RIG cameras.
  15420. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15421. * @hidden
  15422. */
  15423. _getWebVRViewMatrix(): Matrix;
  15424. /** @hidden */
  15425. _getWebVRProjectionMatrix(): Matrix;
  15426. private _onGamepadConnectedObserver;
  15427. private _onGamepadDisconnectedObserver;
  15428. private _updateCacheWhenTrackingDisabledObserver;
  15429. /**
  15430. * Initializes the controllers and their meshes
  15431. */
  15432. initControllers(): void;
  15433. }
  15434. }
  15435. declare module "babylonjs/PostProcesses/postProcess" {
  15436. import { Nullable } from "babylonjs/types";
  15437. import { SmartArray } from "babylonjs/Misc/smartArray";
  15438. import { Observable } from "babylonjs/Misc/observable";
  15439. import { Vector2 } from "babylonjs/Maths/math.vector";
  15440. import { Camera } from "babylonjs/Cameras/camera";
  15441. import { Effect } from "babylonjs/Materials/effect";
  15442. import "babylonjs/Shaders/postprocess.vertex";
  15443. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15444. import { Engine } from "babylonjs/Engines/engine";
  15445. import { Color4 } from "babylonjs/Maths/math.color";
  15446. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15447. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15448. /**
  15449. * Size options for a post process
  15450. */
  15451. export type PostProcessOptions = {
  15452. width: number;
  15453. height: number;
  15454. };
  15455. /**
  15456. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15457. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15458. */
  15459. export class PostProcess {
  15460. /** Name of the PostProcess. */
  15461. name: string;
  15462. /**
  15463. * Gets or sets the unique id of the post process
  15464. */
  15465. uniqueId: number;
  15466. /**
  15467. * Width of the texture to apply the post process on
  15468. */
  15469. width: number;
  15470. /**
  15471. * Height of the texture to apply the post process on
  15472. */
  15473. height: number;
  15474. /**
  15475. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15476. * @hidden
  15477. */
  15478. _outputTexture: Nullable<InternalTexture>;
  15479. /**
  15480. * Sampling mode used by the shader
  15481. * See https://doc.babylonjs.com/classes/3.1/texture
  15482. */
  15483. renderTargetSamplingMode: number;
  15484. /**
  15485. * Clear color to use when screen clearing
  15486. */
  15487. clearColor: Color4;
  15488. /**
  15489. * If the buffer needs to be cleared before applying the post process. (default: true)
  15490. * Should be set to false if shader will overwrite all previous pixels.
  15491. */
  15492. autoClear: boolean;
  15493. /**
  15494. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15495. */
  15496. alphaMode: number;
  15497. /**
  15498. * Sets the setAlphaBlendConstants of the babylon engine
  15499. */
  15500. alphaConstants: Color4;
  15501. /**
  15502. * Animations to be used for the post processing
  15503. */
  15504. animations: import("babylonjs/Animations/animation").Animation[];
  15505. /**
  15506. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15507. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15508. */
  15509. enablePixelPerfectMode: boolean;
  15510. /**
  15511. * Force the postprocess to be applied without taking in account viewport
  15512. */
  15513. forceFullscreenViewport: boolean;
  15514. /**
  15515. * List of inspectable custom properties (used by the Inspector)
  15516. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15517. */
  15518. inspectableCustomProperties: IInspectable[];
  15519. /**
  15520. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15521. *
  15522. * | Value | Type | Description |
  15523. * | ----- | ----------------------------------- | ----------- |
  15524. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15525. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15526. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15527. *
  15528. */
  15529. scaleMode: number;
  15530. /**
  15531. * Force textures to be a power of two (default: false)
  15532. */
  15533. alwaysForcePOT: boolean;
  15534. private _samples;
  15535. /**
  15536. * Number of sample textures (default: 1)
  15537. */
  15538. samples: number;
  15539. /**
  15540. * Modify the scale of the post process to be the same as the viewport (default: false)
  15541. */
  15542. adaptScaleToCurrentViewport: boolean;
  15543. private _camera;
  15544. private _scene;
  15545. private _engine;
  15546. private _options;
  15547. private _reusable;
  15548. private _textureType;
  15549. /**
  15550. * Smart array of input and output textures for the post process.
  15551. * @hidden
  15552. */
  15553. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15554. /**
  15555. * The index in _textures that corresponds to the output texture.
  15556. * @hidden
  15557. */
  15558. _currentRenderTextureInd: number;
  15559. private _effect;
  15560. private _samplers;
  15561. private _fragmentUrl;
  15562. private _vertexUrl;
  15563. private _parameters;
  15564. private _scaleRatio;
  15565. protected _indexParameters: any;
  15566. private _shareOutputWithPostProcess;
  15567. private _texelSize;
  15568. private _forcedOutputTexture;
  15569. /**
  15570. * Returns the fragment url or shader name used in the post process.
  15571. * @returns the fragment url or name in the shader store.
  15572. */
  15573. getEffectName(): string;
  15574. /**
  15575. * An event triggered when the postprocess is activated.
  15576. */
  15577. onActivateObservable: Observable<Camera>;
  15578. private _onActivateObserver;
  15579. /**
  15580. * A function that is added to the onActivateObservable
  15581. */
  15582. onActivate: Nullable<(camera: Camera) => void>;
  15583. /**
  15584. * An event triggered when the postprocess changes its size.
  15585. */
  15586. onSizeChangedObservable: Observable<PostProcess>;
  15587. private _onSizeChangedObserver;
  15588. /**
  15589. * A function that is added to the onSizeChangedObservable
  15590. */
  15591. onSizeChanged: (postProcess: PostProcess) => void;
  15592. /**
  15593. * An event triggered when the postprocess applies its effect.
  15594. */
  15595. onApplyObservable: Observable<Effect>;
  15596. private _onApplyObserver;
  15597. /**
  15598. * A function that is added to the onApplyObservable
  15599. */
  15600. onApply: (effect: Effect) => void;
  15601. /**
  15602. * An event triggered before rendering the postprocess
  15603. */
  15604. onBeforeRenderObservable: Observable<Effect>;
  15605. private _onBeforeRenderObserver;
  15606. /**
  15607. * A function that is added to the onBeforeRenderObservable
  15608. */
  15609. onBeforeRender: (effect: Effect) => void;
  15610. /**
  15611. * An event triggered after rendering the postprocess
  15612. */
  15613. onAfterRenderObservable: Observable<Effect>;
  15614. private _onAfterRenderObserver;
  15615. /**
  15616. * A function that is added to the onAfterRenderObservable
  15617. */
  15618. onAfterRender: (efect: Effect) => void;
  15619. /**
  15620. * 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
  15621. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15622. */
  15623. inputTexture: InternalTexture;
  15624. /**
  15625. * Gets the camera which post process is applied to.
  15626. * @returns The camera the post process is applied to.
  15627. */
  15628. getCamera(): Camera;
  15629. /**
  15630. * Gets the texel size of the postprocess.
  15631. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15632. */
  15633. readonly texelSize: Vector2;
  15634. /**
  15635. * Creates a new instance PostProcess
  15636. * @param name The name of the PostProcess.
  15637. * @param fragmentUrl The url of the fragment shader to be used.
  15638. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15639. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15640. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15641. * @param camera The camera to apply the render pass to.
  15642. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15643. * @param engine The engine which the post process will be applied. (default: current engine)
  15644. * @param reusable If the post process can be reused on the same frame. (default: false)
  15645. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15646. * @param textureType Type of textures used when performing the post process. (default: 0)
  15647. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15648. * @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
  15649. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15650. */
  15651. constructor(
  15652. /** Name of the PostProcess. */
  15653. 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);
  15654. /**
  15655. * Gets a string idenfifying the name of the class
  15656. * @returns "PostProcess" string
  15657. */
  15658. getClassName(): string;
  15659. /**
  15660. * Gets the engine which this post process belongs to.
  15661. * @returns The engine the post process was enabled with.
  15662. */
  15663. getEngine(): Engine;
  15664. /**
  15665. * The effect that is created when initializing the post process.
  15666. * @returns The created effect corresponding the the postprocess.
  15667. */
  15668. getEffect(): Effect;
  15669. /**
  15670. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15671. * @param postProcess The post process to share the output with.
  15672. * @returns This post process.
  15673. */
  15674. shareOutputWith(postProcess: PostProcess): PostProcess;
  15675. /**
  15676. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15677. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15678. */
  15679. useOwnOutput(): void;
  15680. /**
  15681. * Updates the effect with the current post process compile time values and recompiles the shader.
  15682. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15683. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15684. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15685. * @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
  15686. * @param onCompiled Called when the shader has been compiled.
  15687. * @param onError Called if there is an error when compiling a shader.
  15688. */
  15689. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15690. /**
  15691. * The post process is reusable if it can be used multiple times within one frame.
  15692. * @returns If the post process is reusable
  15693. */
  15694. isReusable(): boolean;
  15695. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15696. markTextureDirty(): void;
  15697. /**
  15698. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15699. * 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.
  15700. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15701. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15702. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15703. * @returns The target texture that was bound to be written to.
  15704. */
  15705. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15706. /**
  15707. * If the post process is supported.
  15708. */
  15709. readonly isSupported: boolean;
  15710. /**
  15711. * The aspect ratio of the output texture.
  15712. */
  15713. readonly aspectRatio: number;
  15714. /**
  15715. * Get a value indicating if the post-process is ready to be used
  15716. * @returns true if the post-process is ready (shader is compiled)
  15717. */
  15718. isReady(): boolean;
  15719. /**
  15720. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15721. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15722. */
  15723. apply(): Nullable<Effect>;
  15724. private _disposeTextures;
  15725. /**
  15726. * Disposes the post process.
  15727. * @param camera The camera to dispose the post process on.
  15728. */
  15729. dispose(camera?: Camera): void;
  15730. }
  15731. }
  15732. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15733. /** @hidden */
  15734. export var kernelBlurVaryingDeclaration: {
  15735. name: string;
  15736. shader: string;
  15737. };
  15738. }
  15739. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15740. /** @hidden */
  15741. export var kernelBlurFragment: {
  15742. name: string;
  15743. shader: string;
  15744. };
  15745. }
  15746. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15747. /** @hidden */
  15748. export var kernelBlurFragment2: {
  15749. name: string;
  15750. shader: string;
  15751. };
  15752. }
  15753. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15754. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15755. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15756. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15757. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15758. /** @hidden */
  15759. export var kernelBlurPixelShader: {
  15760. name: string;
  15761. shader: string;
  15762. };
  15763. }
  15764. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15765. /** @hidden */
  15766. export var kernelBlurVertex: {
  15767. name: string;
  15768. shader: string;
  15769. };
  15770. }
  15771. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15772. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15773. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15774. /** @hidden */
  15775. export var kernelBlurVertexShader: {
  15776. name: string;
  15777. shader: string;
  15778. };
  15779. }
  15780. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15781. import { Vector2 } from "babylonjs/Maths/math.vector";
  15782. import { Nullable } from "babylonjs/types";
  15783. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15784. import { Camera } from "babylonjs/Cameras/camera";
  15785. import { Effect } from "babylonjs/Materials/effect";
  15786. import { Engine } from "babylonjs/Engines/engine";
  15787. import "babylonjs/Shaders/kernelBlur.fragment";
  15788. import "babylonjs/Shaders/kernelBlur.vertex";
  15789. /**
  15790. * The Blur Post Process which blurs an image based on a kernel and direction.
  15791. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15792. */
  15793. export class BlurPostProcess extends PostProcess {
  15794. /** The direction in which to blur the image. */
  15795. direction: Vector2;
  15796. private blockCompilation;
  15797. protected _kernel: number;
  15798. protected _idealKernel: number;
  15799. protected _packedFloat: boolean;
  15800. private _staticDefines;
  15801. /**
  15802. * Sets the length in pixels of the blur sample region
  15803. */
  15804. /**
  15805. * Gets the length in pixels of the blur sample region
  15806. */
  15807. kernel: number;
  15808. /**
  15809. * Sets wether or not the blur needs to unpack/repack floats
  15810. */
  15811. /**
  15812. * Gets wether or not the blur is unpacking/repacking floats
  15813. */
  15814. packedFloat: boolean;
  15815. /**
  15816. * Creates a new instance BlurPostProcess
  15817. * @param name The name of the effect.
  15818. * @param direction The direction in which to blur the image.
  15819. * @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.
  15820. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15821. * @param camera The camera to apply the render pass to.
  15822. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15823. * @param engine The engine which the post process will be applied. (default: current engine)
  15824. * @param reusable If the post process can be reused on the same frame. (default: false)
  15825. * @param textureType Type of textures used when performing the post process. (default: 0)
  15826. * @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)
  15827. */
  15828. constructor(name: string,
  15829. /** The direction in which to blur the image. */
  15830. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15831. /**
  15832. * Updates the effect with the current post process compile time values and recompiles the shader.
  15833. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15834. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15835. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15836. * @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
  15837. * @param onCompiled Called when the shader has been compiled.
  15838. * @param onError Called if there is an error when compiling a shader.
  15839. */
  15840. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15841. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15842. /**
  15843. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15844. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15845. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15846. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15847. * The gaps between physical kernels are compensated for in the weighting of the samples
  15848. * @param idealKernel Ideal blur kernel.
  15849. * @return Nearest best kernel.
  15850. */
  15851. protected _nearestBestKernel(idealKernel: number): number;
  15852. /**
  15853. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15854. * @param x The point on the Gaussian distribution to sample.
  15855. * @return the value of the Gaussian function at x.
  15856. */
  15857. protected _gaussianWeight(x: number): number;
  15858. /**
  15859. * Generates a string that can be used as a floating point number in GLSL.
  15860. * @param x Value to print.
  15861. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15862. * @return GLSL float string.
  15863. */
  15864. protected _glslFloat(x: number, decimalFigures?: number): string;
  15865. }
  15866. }
  15867. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15868. import { Scene } from "babylonjs/scene";
  15869. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15870. import { Plane } from "babylonjs/Maths/math.plane";
  15871. /**
  15872. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15873. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15874. * You can then easily use it as a reflectionTexture on a flat surface.
  15875. * In case the surface is not a plane, please consider relying on reflection probes.
  15876. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15877. */
  15878. export class MirrorTexture extends RenderTargetTexture {
  15879. private scene;
  15880. /**
  15881. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15882. * 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.
  15883. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15884. */
  15885. mirrorPlane: Plane;
  15886. /**
  15887. * Define the blur ratio used to blur the reflection if needed.
  15888. */
  15889. blurRatio: number;
  15890. /**
  15891. * Define the adaptive blur kernel used to blur the reflection if needed.
  15892. * This will autocompute the closest best match for the `blurKernel`
  15893. */
  15894. adaptiveBlurKernel: number;
  15895. /**
  15896. * Define the blur kernel used to blur the reflection if needed.
  15897. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15898. */
  15899. blurKernel: number;
  15900. /**
  15901. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15902. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15903. */
  15904. blurKernelX: number;
  15905. /**
  15906. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15907. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15908. */
  15909. blurKernelY: number;
  15910. private _autoComputeBlurKernel;
  15911. protected _onRatioRescale(): void;
  15912. private _updateGammaSpace;
  15913. private _imageProcessingConfigChangeObserver;
  15914. private _transformMatrix;
  15915. private _mirrorMatrix;
  15916. private _savedViewMatrix;
  15917. private _blurX;
  15918. private _blurY;
  15919. private _adaptiveBlurKernel;
  15920. private _blurKernelX;
  15921. private _blurKernelY;
  15922. private _blurRatio;
  15923. /**
  15924. * Instantiates a Mirror Texture.
  15925. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15926. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15927. * You can then easily use it as a reflectionTexture on a flat surface.
  15928. * In case the surface is not a plane, please consider relying on reflection probes.
  15929. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15930. * @param name
  15931. * @param size
  15932. * @param scene
  15933. * @param generateMipMaps
  15934. * @param type
  15935. * @param samplingMode
  15936. * @param generateDepthBuffer
  15937. */
  15938. constructor(name: string, size: number | {
  15939. width: number;
  15940. height: number;
  15941. } | {
  15942. ratio: number;
  15943. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15944. private _preparePostProcesses;
  15945. /**
  15946. * Clone the mirror texture.
  15947. * @returns the cloned texture
  15948. */
  15949. clone(): MirrorTexture;
  15950. /**
  15951. * Serialize the texture to a JSON representation you could use in Parse later on
  15952. * @returns the serialized JSON representation
  15953. */
  15954. serialize(): any;
  15955. /**
  15956. * Dispose the texture and release its associated resources.
  15957. */
  15958. dispose(): void;
  15959. }
  15960. }
  15961. declare module "babylonjs/Materials/Textures/texture" {
  15962. import { Observable } from "babylonjs/Misc/observable";
  15963. import { Nullable } from "babylonjs/types";
  15964. import { Matrix } from "babylonjs/Maths/math.vector";
  15965. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15966. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15967. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15968. import { Scene } from "babylonjs/scene";
  15969. /**
  15970. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15971. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15972. */
  15973. export class Texture extends BaseTexture {
  15974. /**
  15975. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15976. */
  15977. static SerializeBuffers: boolean;
  15978. /** @hidden */
  15979. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15980. /** @hidden */
  15981. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15982. /** @hidden */
  15983. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15984. /** nearest is mag = nearest and min = nearest and mip = linear */
  15985. static readonly NEAREST_SAMPLINGMODE: number;
  15986. /** nearest is mag = nearest and min = nearest and mip = linear */
  15987. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15988. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15989. static readonly BILINEAR_SAMPLINGMODE: number;
  15990. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15991. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15992. /** Trilinear is mag = linear and min = linear and mip = linear */
  15993. static readonly TRILINEAR_SAMPLINGMODE: number;
  15994. /** Trilinear is mag = linear and min = linear and mip = linear */
  15995. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15996. /** mag = nearest and min = nearest and mip = nearest */
  15997. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15998. /** mag = nearest and min = linear and mip = nearest */
  15999. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16000. /** mag = nearest and min = linear and mip = linear */
  16001. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16002. /** mag = nearest and min = linear and mip = none */
  16003. static readonly NEAREST_LINEAR: number;
  16004. /** mag = nearest and min = nearest and mip = none */
  16005. static readonly NEAREST_NEAREST: number;
  16006. /** mag = linear and min = nearest and mip = nearest */
  16007. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16008. /** mag = linear and min = nearest and mip = linear */
  16009. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16010. /** mag = linear and min = linear and mip = none */
  16011. static readonly LINEAR_LINEAR: number;
  16012. /** mag = linear and min = nearest and mip = none */
  16013. static readonly LINEAR_NEAREST: number;
  16014. /** Explicit coordinates mode */
  16015. static readonly EXPLICIT_MODE: number;
  16016. /** Spherical coordinates mode */
  16017. static readonly SPHERICAL_MODE: number;
  16018. /** Planar coordinates mode */
  16019. static readonly PLANAR_MODE: number;
  16020. /** Cubic coordinates mode */
  16021. static readonly CUBIC_MODE: number;
  16022. /** Projection coordinates mode */
  16023. static readonly PROJECTION_MODE: number;
  16024. /** Inverse Cubic coordinates mode */
  16025. static readonly SKYBOX_MODE: number;
  16026. /** Inverse Cubic coordinates mode */
  16027. static readonly INVCUBIC_MODE: number;
  16028. /** Equirectangular coordinates mode */
  16029. static readonly EQUIRECTANGULAR_MODE: number;
  16030. /** Equirectangular Fixed coordinates mode */
  16031. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16032. /** Equirectangular Fixed Mirrored coordinates mode */
  16033. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16034. /** Texture is not repeating outside of 0..1 UVs */
  16035. static readonly CLAMP_ADDRESSMODE: number;
  16036. /** Texture is repeating outside of 0..1 UVs */
  16037. static readonly WRAP_ADDRESSMODE: number;
  16038. /** Texture is repeating and mirrored */
  16039. static readonly MIRROR_ADDRESSMODE: number;
  16040. /**
  16041. * 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
  16042. */
  16043. static UseSerializedUrlIfAny: boolean;
  16044. /**
  16045. * Define the url of the texture.
  16046. */
  16047. url: Nullable<string>;
  16048. /**
  16049. * Define an offset on the texture to offset the u coordinates of the UVs
  16050. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16051. */
  16052. uOffset: number;
  16053. /**
  16054. * Define an offset on the texture to offset the v coordinates of the UVs
  16055. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16056. */
  16057. vOffset: number;
  16058. /**
  16059. * Define an offset on the texture to scale the u coordinates of the UVs
  16060. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16061. */
  16062. uScale: number;
  16063. /**
  16064. * Define an offset on the texture to scale the v coordinates of the UVs
  16065. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16066. */
  16067. vScale: number;
  16068. /**
  16069. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16070. * @see http://doc.babylonjs.com/how_to/more_materials
  16071. */
  16072. uAng: number;
  16073. /**
  16074. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16075. * @see http://doc.babylonjs.com/how_to/more_materials
  16076. */
  16077. vAng: number;
  16078. /**
  16079. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16080. * @see http://doc.babylonjs.com/how_to/more_materials
  16081. */
  16082. wAng: number;
  16083. /**
  16084. * Defines the center of rotation (U)
  16085. */
  16086. uRotationCenter: number;
  16087. /**
  16088. * Defines the center of rotation (V)
  16089. */
  16090. vRotationCenter: number;
  16091. /**
  16092. * Defines the center of rotation (W)
  16093. */
  16094. wRotationCenter: number;
  16095. /**
  16096. * Are mip maps generated for this texture or not.
  16097. */
  16098. readonly noMipmap: boolean;
  16099. /**
  16100. * List of inspectable custom properties (used by the Inspector)
  16101. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16102. */
  16103. inspectableCustomProperties: Nullable<IInspectable[]>;
  16104. private _noMipmap;
  16105. /** @hidden */
  16106. _invertY: boolean;
  16107. private _rowGenerationMatrix;
  16108. private _cachedTextureMatrix;
  16109. private _projectionModeMatrix;
  16110. private _t0;
  16111. private _t1;
  16112. private _t2;
  16113. private _cachedUOffset;
  16114. private _cachedVOffset;
  16115. private _cachedUScale;
  16116. private _cachedVScale;
  16117. private _cachedUAng;
  16118. private _cachedVAng;
  16119. private _cachedWAng;
  16120. private _cachedProjectionMatrixId;
  16121. private _cachedCoordinatesMode;
  16122. /** @hidden */
  16123. protected _initialSamplingMode: number;
  16124. /** @hidden */
  16125. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16126. private _deleteBuffer;
  16127. protected _format: Nullable<number>;
  16128. private _delayedOnLoad;
  16129. private _delayedOnError;
  16130. /**
  16131. * Observable triggered once the texture has been loaded.
  16132. */
  16133. onLoadObservable: Observable<Texture>;
  16134. protected _isBlocking: boolean;
  16135. /**
  16136. * Is the texture preventing material to render while loading.
  16137. * If false, a default texture will be used instead of the loading one during the preparation step.
  16138. */
  16139. isBlocking: boolean;
  16140. /**
  16141. * Get the current sampling mode associated with the texture.
  16142. */
  16143. readonly samplingMode: number;
  16144. /**
  16145. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16146. */
  16147. readonly invertY: boolean;
  16148. /**
  16149. * Instantiates a new texture.
  16150. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16151. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16152. * @param url define the url of the picture to load as a texture
  16153. * @param scene define the scene or engine the texture will belong to
  16154. * @param noMipmap define if the texture will require mip maps or not
  16155. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16156. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16157. * @param onLoad define a callback triggered when the texture has been loaded
  16158. * @param onError define a callback triggered when an error occurred during the loading session
  16159. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16160. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16161. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16162. */
  16163. 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);
  16164. /**
  16165. * Update the url (and optional buffer) of this texture if url was null during construction.
  16166. * @param url the url of the texture
  16167. * @param buffer the buffer of the texture (defaults to null)
  16168. * @param onLoad callback called when the texture is loaded (defaults to null)
  16169. */
  16170. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16171. /**
  16172. * Finish the loading sequence of a texture flagged as delayed load.
  16173. * @hidden
  16174. */
  16175. delayLoad(): void;
  16176. private _prepareRowForTextureGeneration;
  16177. /**
  16178. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16179. * @returns the transform matrix of the texture.
  16180. */
  16181. getTextureMatrix(): Matrix;
  16182. /**
  16183. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16184. * @returns The reflection texture transform
  16185. */
  16186. getReflectionTextureMatrix(): Matrix;
  16187. /**
  16188. * Clones the texture.
  16189. * @returns the cloned texture
  16190. */
  16191. clone(): Texture;
  16192. /**
  16193. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16194. * @returns The JSON representation of the texture
  16195. */
  16196. serialize(): any;
  16197. /**
  16198. * Get the current class name of the texture useful for serialization or dynamic coding.
  16199. * @returns "Texture"
  16200. */
  16201. getClassName(): string;
  16202. /**
  16203. * Dispose the texture and release its associated resources.
  16204. */
  16205. dispose(): void;
  16206. /**
  16207. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16208. * @param parsedTexture Define the JSON representation of the texture
  16209. * @param scene Define the scene the parsed texture should be instantiated in
  16210. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16211. * @returns The parsed texture if successful
  16212. */
  16213. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16214. /**
  16215. * Creates a texture from its base 64 representation.
  16216. * @param data Define the base64 payload without the data: prefix
  16217. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16218. * @param scene Define the scene the texture should belong to
  16219. * @param noMipmap Forces the texture to not create mip map information if true
  16220. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16221. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16222. * @param onLoad define a callback triggered when the texture has been loaded
  16223. * @param onError define a callback triggered when an error occurred during the loading session
  16224. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16225. * @returns the created texture
  16226. */
  16227. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16228. /**
  16229. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16230. * @param data Define the base64 payload without the data: prefix
  16231. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16232. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16233. * @param scene Define the scene the texture should belong to
  16234. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16235. * @param noMipmap Forces the texture to not create mip map information if true
  16236. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16237. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16238. * @param onLoad define a callback triggered when the texture has been loaded
  16239. * @param onError define a callback triggered when an error occurred during the loading session
  16240. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16241. * @returns the created texture
  16242. */
  16243. 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;
  16244. }
  16245. }
  16246. declare module "babylonjs/PostProcesses/postProcessManager" {
  16247. import { Nullable } from "babylonjs/types";
  16248. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16249. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16250. import { Scene } from "babylonjs/scene";
  16251. /**
  16252. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16253. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16254. */
  16255. export class PostProcessManager {
  16256. private _scene;
  16257. private _indexBuffer;
  16258. private _vertexBuffers;
  16259. /**
  16260. * Creates a new instance PostProcess
  16261. * @param scene The scene that the post process is associated with.
  16262. */
  16263. constructor(scene: Scene);
  16264. private _prepareBuffers;
  16265. private _buildIndexBuffer;
  16266. /**
  16267. * Rebuilds the vertex buffers of the manager.
  16268. * @hidden
  16269. */
  16270. _rebuild(): void;
  16271. /**
  16272. * Prepares a frame to be run through a post process.
  16273. * @param sourceTexture The input texture to the post procesess. (default: null)
  16274. * @param postProcesses An array of post processes to be run. (default: null)
  16275. * @returns True if the post processes were able to be run.
  16276. * @hidden
  16277. */
  16278. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16279. /**
  16280. * Manually render a set of post processes to a texture.
  16281. * @param postProcesses An array of post processes to be run.
  16282. * @param targetTexture The target texture to render to.
  16283. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16284. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16285. * @param lodLevel defines which lod of the texture to render to
  16286. */
  16287. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16288. /**
  16289. * Finalize the result of the output of the postprocesses.
  16290. * @param doNotPresent If true the result will not be displayed to the screen.
  16291. * @param targetTexture The target texture to render to.
  16292. * @param faceIndex The index of the face to bind the target texture to.
  16293. * @param postProcesses The array of post processes to render.
  16294. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16295. * @hidden
  16296. */
  16297. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16298. /**
  16299. * Disposes of the post process manager.
  16300. */
  16301. dispose(): void;
  16302. }
  16303. }
  16304. declare module "babylonjs/Misc/gradients" {
  16305. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16306. /** Interface used by value gradients (color, factor, ...) */
  16307. export interface IValueGradient {
  16308. /**
  16309. * Gets or sets the gradient value (between 0 and 1)
  16310. */
  16311. gradient: number;
  16312. }
  16313. /** Class used to store color4 gradient */
  16314. export class ColorGradient implements IValueGradient {
  16315. /**
  16316. * Gets or sets the gradient value (between 0 and 1)
  16317. */
  16318. gradient: number;
  16319. /**
  16320. * Gets or sets first associated color
  16321. */
  16322. color1: Color4;
  16323. /**
  16324. * Gets or sets second associated color
  16325. */
  16326. color2?: Color4;
  16327. /**
  16328. * Will get a color picked randomly between color1 and color2.
  16329. * If color2 is undefined then color1 will be used
  16330. * @param result defines the target Color4 to store the result in
  16331. */
  16332. getColorToRef(result: Color4): void;
  16333. }
  16334. /** Class used to store color 3 gradient */
  16335. export class Color3Gradient implements IValueGradient {
  16336. /**
  16337. * Gets or sets the gradient value (between 0 and 1)
  16338. */
  16339. gradient: number;
  16340. /**
  16341. * Gets or sets the associated color
  16342. */
  16343. color: Color3;
  16344. }
  16345. /** Class used to store factor gradient */
  16346. export class FactorGradient implements IValueGradient {
  16347. /**
  16348. * Gets or sets the gradient value (between 0 and 1)
  16349. */
  16350. gradient: number;
  16351. /**
  16352. * Gets or sets first associated factor
  16353. */
  16354. factor1: number;
  16355. /**
  16356. * Gets or sets second associated factor
  16357. */
  16358. factor2?: number;
  16359. /**
  16360. * Will get a number picked randomly between factor1 and factor2.
  16361. * If factor2 is undefined then factor1 will be used
  16362. * @returns the picked number
  16363. */
  16364. getFactor(): number;
  16365. }
  16366. /**
  16367. * Helper used to simplify some generic gradient tasks
  16368. */
  16369. export class GradientHelper {
  16370. /**
  16371. * Gets the current gradient from an array of IValueGradient
  16372. * @param ratio defines the current ratio to get
  16373. * @param gradients defines the array of IValueGradient
  16374. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16375. */
  16376. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16377. }
  16378. }
  16379. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16380. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16381. import { Nullable } from "babylonjs/types";
  16382. module "babylonjs/Engines/thinEngine" {
  16383. interface ThinEngine {
  16384. /**
  16385. * Creates a dynamic texture
  16386. * @param width defines the width of the texture
  16387. * @param height defines the height of the texture
  16388. * @param generateMipMaps defines if the engine should generate the mip levels
  16389. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16390. * @returns the dynamic texture inside an InternalTexture
  16391. */
  16392. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16393. /**
  16394. * Update the content of a dynamic texture
  16395. * @param texture defines the texture to update
  16396. * @param canvas defines the canvas containing the source
  16397. * @param invertY defines if data must be stored with Y axis inverted
  16398. * @param premulAlpha defines if alpha is stored as premultiplied
  16399. * @param format defines the format of the data
  16400. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16401. */
  16402. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16403. }
  16404. }
  16405. }
  16406. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16407. import { Scene } from "babylonjs/scene";
  16408. import { Texture } from "babylonjs/Materials/Textures/texture";
  16409. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16410. /**
  16411. * A class extending Texture allowing drawing on a texture
  16412. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16413. */
  16414. export class DynamicTexture extends Texture {
  16415. private _generateMipMaps;
  16416. private _canvas;
  16417. private _context;
  16418. private _engine;
  16419. /**
  16420. * Creates a DynamicTexture
  16421. * @param name defines the name of the texture
  16422. * @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
  16423. * @param scene defines the scene where you want the texture
  16424. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16425. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16426. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16427. */
  16428. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16429. /**
  16430. * Get the current class name of the texture useful for serialization or dynamic coding.
  16431. * @returns "DynamicTexture"
  16432. */
  16433. getClassName(): string;
  16434. /**
  16435. * Gets the current state of canRescale
  16436. */
  16437. readonly canRescale: boolean;
  16438. private _recreate;
  16439. /**
  16440. * Scales the texture
  16441. * @param ratio the scale factor to apply to both width and height
  16442. */
  16443. scale(ratio: number): void;
  16444. /**
  16445. * Resizes the texture
  16446. * @param width the new width
  16447. * @param height the new height
  16448. */
  16449. scaleTo(width: number, height: number): void;
  16450. /**
  16451. * Gets the context of the canvas used by the texture
  16452. * @returns the canvas context of the dynamic texture
  16453. */
  16454. getContext(): CanvasRenderingContext2D;
  16455. /**
  16456. * Clears the texture
  16457. */
  16458. clear(): void;
  16459. /**
  16460. * Updates the texture
  16461. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16462. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16463. */
  16464. update(invertY?: boolean, premulAlpha?: boolean): void;
  16465. /**
  16466. * Draws text onto the texture
  16467. * @param text defines the text to be drawn
  16468. * @param x defines the placement of the text from the left
  16469. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16470. * @param font defines the font to be used with font-style, font-size, font-name
  16471. * @param color defines the color used for the text
  16472. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16473. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16474. * @param update defines whether texture is immediately update (default is true)
  16475. */
  16476. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16477. /**
  16478. * Clones the texture
  16479. * @returns the clone of the texture.
  16480. */
  16481. clone(): DynamicTexture;
  16482. /**
  16483. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16484. * @returns a serialized dynamic texture object
  16485. */
  16486. serialize(): any;
  16487. /** @hidden */
  16488. _rebuild(): void;
  16489. }
  16490. }
  16491. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16492. import { Scene } from "babylonjs/scene";
  16493. import { ISceneComponent } from "babylonjs/sceneComponent";
  16494. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16495. module "babylonjs/abstractScene" {
  16496. interface AbstractScene {
  16497. /**
  16498. * The list of procedural textures added to the scene
  16499. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16500. */
  16501. proceduralTextures: Array<ProceduralTexture>;
  16502. }
  16503. }
  16504. /**
  16505. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16506. * in a given scene.
  16507. */
  16508. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16509. /**
  16510. * The component name helpfull to identify the component in the list of scene components.
  16511. */
  16512. readonly name: string;
  16513. /**
  16514. * The scene the component belongs to.
  16515. */
  16516. scene: Scene;
  16517. /**
  16518. * Creates a new instance of the component for the given scene
  16519. * @param scene Defines the scene to register the component in
  16520. */
  16521. constructor(scene: Scene);
  16522. /**
  16523. * Registers the component in a given scene
  16524. */
  16525. register(): void;
  16526. /**
  16527. * Rebuilds the elements related to this component in case of
  16528. * context lost for instance.
  16529. */
  16530. rebuild(): void;
  16531. /**
  16532. * Disposes the component and the associated ressources.
  16533. */
  16534. dispose(): void;
  16535. private _beforeClear;
  16536. }
  16537. }
  16538. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16539. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16540. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16541. module "babylonjs/Engines/thinEngine" {
  16542. interface ThinEngine {
  16543. /**
  16544. * Creates a new render target cube texture
  16545. * @param size defines the size of the texture
  16546. * @param options defines the options used to create the texture
  16547. * @returns a new render target cube texture stored in an InternalTexture
  16548. */
  16549. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16550. }
  16551. }
  16552. }
  16553. declare module "babylonjs/Shaders/procedural.vertex" {
  16554. /** @hidden */
  16555. export var proceduralVertexShader: {
  16556. name: string;
  16557. shader: string;
  16558. };
  16559. }
  16560. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16561. import { Observable } from "babylonjs/Misc/observable";
  16562. import { Nullable } from "babylonjs/types";
  16563. import { Scene } from "babylonjs/scene";
  16564. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16565. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16566. import { Effect } from "babylonjs/Materials/effect";
  16567. import { Texture } from "babylonjs/Materials/Textures/texture";
  16568. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16569. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16570. import "babylonjs/Shaders/procedural.vertex";
  16571. /**
  16572. * 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.
  16573. * This is the base class of any Procedural texture and contains most of the shareable code.
  16574. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16575. */
  16576. export class ProceduralTexture extends Texture {
  16577. isCube: boolean;
  16578. /**
  16579. * Define if the texture is enabled or not (disabled texture will not render)
  16580. */
  16581. isEnabled: boolean;
  16582. /**
  16583. * Define if the texture must be cleared before rendering (default is true)
  16584. */
  16585. autoClear: boolean;
  16586. /**
  16587. * Callback called when the texture is generated
  16588. */
  16589. onGenerated: () => void;
  16590. /**
  16591. * Event raised when the texture is generated
  16592. */
  16593. onGeneratedObservable: Observable<ProceduralTexture>;
  16594. /** @hidden */
  16595. _generateMipMaps: boolean;
  16596. /** @hidden **/
  16597. _effect: Effect;
  16598. /** @hidden */
  16599. _textures: {
  16600. [key: string]: Texture;
  16601. };
  16602. private _size;
  16603. private _currentRefreshId;
  16604. private _refreshRate;
  16605. private _vertexBuffers;
  16606. private _indexBuffer;
  16607. private _uniforms;
  16608. private _samplers;
  16609. private _fragment;
  16610. private _floats;
  16611. private _ints;
  16612. private _floatsArrays;
  16613. private _colors3;
  16614. private _colors4;
  16615. private _vectors2;
  16616. private _vectors3;
  16617. private _matrices;
  16618. private _fallbackTexture;
  16619. private _fallbackTextureUsed;
  16620. private _engine;
  16621. private _cachedDefines;
  16622. private _contentUpdateId;
  16623. private _contentData;
  16624. /**
  16625. * Instantiates a new procedural texture.
  16626. * 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.
  16627. * This is the base class of any Procedural texture and contains most of the shareable code.
  16628. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16629. * @param name Define the name of the texture
  16630. * @param size Define the size of the texture to create
  16631. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16632. * @param scene Define the scene the texture belongs to
  16633. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16634. * @param generateMipMaps Define if the texture should creates mip maps or not
  16635. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16636. */
  16637. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16638. /**
  16639. * The effect that is created when initializing the post process.
  16640. * @returns The created effect corresponding the the postprocess.
  16641. */
  16642. getEffect(): Effect;
  16643. /**
  16644. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16645. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16646. */
  16647. getContent(): Nullable<ArrayBufferView>;
  16648. private _createIndexBuffer;
  16649. /** @hidden */
  16650. _rebuild(): void;
  16651. /**
  16652. * Resets the texture in order to recreate its associated resources.
  16653. * This can be called in case of context loss
  16654. */
  16655. reset(): void;
  16656. protected _getDefines(): string;
  16657. /**
  16658. * Is the texture ready to be used ? (rendered at least once)
  16659. * @returns true if ready, otherwise, false.
  16660. */
  16661. isReady(): boolean;
  16662. /**
  16663. * Resets the refresh counter of the texture and start bak from scratch.
  16664. * Could be useful to regenerate the texture if it is setup to render only once.
  16665. */
  16666. resetRefreshCounter(): void;
  16667. /**
  16668. * Set the fragment shader to use in order to render the texture.
  16669. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16670. */
  16671. setFragment(fragment: any): void;
  16672. /**
  16673. * Define the refresh rate of the texture or the rendering frequency.
  16674. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16675. */
  16676. refreshRate: number;
  16677. /** @hidden */
  16678. _shouldRender(): boolean;
  16679. /**
  16680. * Get the size the texture is rendering at.
  16681. * @returns the size (texture is always squared)
  16682. */
  16683. getRenderSize(): number;
  16684. /**
  16685. * Resize the texture to new value.
  16686. * @param size Define the new size the texture should have
  16687. * @param generateMipMaps Define whether the new texture should create mip maps
  16688. */
  16689. resize(size: number, generateMipMaps: boolean): void;
  16690. private _checkUniform;
  16691. /**
  16692. * Set a texture in the shader program used to render.
  16693. * @param name Define the name of the uniform samplers as defined in the shader
  16694. * @param texture Define the texture to bind to this sampler
  16695. * @return the texture itself allowing "fluent" like uniform updates
  16696. */
  16697. setTexture(name: string, texture: Texture): ProceduralTexture;
  16698. /**
  16699. * Set a float in the shader.
  16700. * @param name Define the name of the uniform as defined in the shader
  16701. * @param value Define the value to give to the uniform
  16702. * @return the texture itself allowing "fluent" like uniform updates
  16703. */
  16704. setFloat(name: string, value: number): ProceduralTexture;
  16705. /**
  16706. * Set a int in the shader.
  16707. * @param name Define the name of the uniform as defined in the shader
  16708. * @param value Define the value to give to the uniform
  16709. * @return the texture itself allowing "fluent" like uniform updates
  16710. */
  16711. setInt(name: string, value: number): ProceduralTexture;
  16712. /**
  16713. * Set an array of floats in the shader.
  16714. * @param name Define the name of the uniform as defined in the shader
  16715. * @param value Define the value to give to the uniform
  16716. * @return the texture itself allowing "fluent" like uniform updates
  16717. */
  16718. setFloats(name: string, value: number[]): ProceduralTexture;
  16719. /**
  16720. * Set a vec3 in the shader from a Color3.
  16721. * @param name Define the name of the uniform as defined in the shader
  16722. * @param value Define the value to give to the uniform
  16723. * @return the texture itself allowing "fluent" like uniform updates
  16724. */
  16725. setColor3(name: string, value: Color3): ProceduralTexture;
  16726. /**
  16727. * Set a vec4 in the shader from a Color4.
  16728. * @param name Define the name of the uniform as defined in the shader
  16729. * @param value Define the value to give to the uniform
  16730. * @return the texture itself allowing "fluent" like uniform updates
  16731. */
  16732. setColor4(name: string, value: Color4): ProceduralTexture;
  16733. /**
  16734. * Set a vec2 in the shader from a Vector2.
  16735. * @param name Define the name of the uniform as defined in the shader
  16736. * @param value Define the value to give to the uniform
  16737. * @return the texture itself allowing "fluent" like uniform updates
  16738. */
  16739. setVector2(name: string, value: Vector2): ProceduralTexture;
  16740. /**
  16741. * Set a vec3 in the shader from a Vector3.
  16742. * @param name Define the name of the uniform as defined in the shader
  16743. * @param value Define the value to give to the uniform
  16744. * @return the texture itself allowing "fluent" like uniform updates
  16745. */
  16746. setVector3(name: string, value: Vector3): ProceduralTexture;
  16747. /**
  16748. * Set a mat4 in the shader from a MAtrix.
  16749. * @param name Define the name of the uniform as defined in the shader
  16750. * @param value Define the value to give to the uniform
  16751. * @return the texture itself allowing "fluent" like uniform updates
  16752. */
  16753. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16754. /**
  16755. * Render the texture to its associated render target.
  16756. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16757. */
  16758. render(useCameraPostProcess?: boolean): void;
  16759. /**
  16760. * Clone the texture.
  16761. * @returns the cloned texture
  16762. */
  16763. clone(): ProceduralTexture;
  16764. /**
  16765. * Dispose the texture and release its asoociated resources.
  16766. */
  16767. dispose(): void;
  16768. }
  16769. }
  16770. declare module "babylonjs/Particles/baseParticleSystem" {
  16771. import { Nullable } from "babylonjs/types";
  16772. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16774. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16775. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16776. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16777. import { Scene } from "babylonjs/scene";
  16778. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16779. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16780. import { Texture } from "babylonjs/Materials/Textures/texture";
  16781. import { Color4 } from "babylonjs/Maths/math.color";
  16782. import { Animation } from "babylonjs/Animations/animation";
  16783. /**
  16784. * This represents the base class for particle system in Babylon.
  16785. * 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.
  16786. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16787. * @example https://doc.babylonjs.com/babylon101/particles
  16788. */
  16789. export class BaseParticleSystem {
  16790. /**
  16791. * Source color is added to the destination color without alpha affecting the result
  16792. */
  16793. static BLENDMODE_ONEONE: number;
  16794. /**
  16795. * Blend current color and particle color using particle’s alpha
  16796. */
  16797. static BLENDMODE_STANDARD: number;
  16798. /**
  16799. * Add current color and particle color multiplied by particle’s alpha
  16800. */
  16801. static BLENDMODE_ADD: number;
  16802. /**
  16803. * Multiply current color with particle color
  16804. */
  16805. static BLENDMODE_MULTIPLY: number;
  16806. /**
  16807. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16808. */
  16809. static BLENDMODE_MULTIPLYADD: number;
  16810. /**
  16811. * List of animations used by the particle system.
  16812. */
  16813. animations: Animation[];
  16814. /**
  16815. * The id of the Particle system.
  16816. */
  16817. id: string;
  16818. /**
  16819. * The friendly name of the Particle system.
  16820. */
  16821. name: string;
  16822. /**
  16823. * The rendering group used by the Particle system to chose when to render.
  16824. */
  16825. renderingGroupId: number;
  16826. /**
  16827. * The emitter represents the Mesh or position we are attaching the particle system to.
  16828. */
  16829. emitter: Nullable<AbstractMesh | Vector3>;
  16830. /**
  16831. * The maximum number of particles to emit per frame
  16832. */
  16833. emitRate: number;
  16834. /**
  16835. * If you want to launch only a few particles at once, that can be done, as well.
  16836. */
  16837. manualEmitCount: number;
  16838. /**
  16839. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16840. */
  16841. updateSpeed: number;
  16842. /**
  16843. * The amount of time the particle system is running (depends of the overall update speed).
  16844. */
  16845. targetStopDuration: number;
  16846. /**
  16847. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16848. */
  16849. disposeOnStop: boolean;
  16850. /**
  16851. * Minimum power of emitting particles.
  16852. */
  16853. minEmitPower: number;
  16854. /**
  16855. * Maximum power of emitting particles.
  16856. */
  16857. maxEmitPower: number;
  16858. /**
  16859. * Minimum life time of emitting particles.
  16860. */
  16861. minLifeTime: number;
  16862. /**
  16863. * Maximum life time of emitting particles.
  16864. */
  16865. maxLifeTime: number;
  16866. /**
  16867. * Minimum Size of emitting particles.
  16868. */
  16869. minSize: number;
  16870. /**
  16871. * Maximum Size of emitting particles.
  16872. */
  16873. maxSize: number;
  16874. /**
  16875. * Minimum scale of emitting particles on X axis.
  16876. */
  16877. minScaleX: number;
  16878. /**
  16879. * Maximum scale of emitting particles on X axis.
  16880. */
  16881. maxScaleX: number;
  16882. /**
  16883. * Minimum scale of emitting particles on Y axis.
  16884. */
  16885. minScaleY: number;
  16886. /**
  16887. * Maximum scale of emitting particles on Y axis.
  16888. */
  16889. maxScaleY: number;
  16890. /**
  16891. * Gets or sets the minimal initial rotation in radians.
  16892. */
  16893. minInitialRotation: number;
  16894. /**
  16895. * Gets or sets the maximal initial rotation in radians.
  16896. */
  16897. maxInitialRotation: number;
  16898. /**
  16899. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16900. */
  16901. minAngularSpeed: number;
  16902. /**
  16903. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16904. */
  16905. maxAngularSpeed: number;
  16906. /**
  16907. * The texture used to render each particle. (this can be a spritesheet)
  16908. */
  16909. particleTexture: Nullable<Texture>;
  16910. /**
  16911. * The layer mask we are rendering the particles through.
  16912. */
  16913. layerMask: number;
  16914. /**
  16915. * This can help using your own shader to render the particle system.
  16916. * The according effect will be created
  16917. */
  16918. customShader: any;
  16919. /**
  16920. * By default particle system starts as soon as they are created. This prevents the
  16921. * automatic start to happen and let you decide when to start emitting particles.
  16922. */
  16923. preventAutoStart: boolean;
  16924. private _noiseTexture;
  16925. /**
  16926. * Gets or sets a texture used to add random noise to particle positions
  16927. */
  16928. noiseTexture: Nullable<ProceduralTexture>;
  16929. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16930. noiseStrength: Vector3;
  16931. /**
  16932. * Callback triggered when the particle animation is ending.
  16933. */
  16934. onAnimationEnd: Nullable<() => void>;
  16935. /**
  16936. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16937. */
  16938. blendMode: number;
  16939. /**
  16940. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16941. * to override the particles.
  16942. */
  16943. forceDepthWrite: boolean;
  16944. /** 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 */
  16945. preWarmCycles: number;
  16946. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16947. preWarmStepOffset: number;
  16948. /**
  16949. * 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)
  16950. */
  16951. spriteCellChangeSpeed: number;
  16952. /**
  16953. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16954. */
  16955. startSpriteCellID: number;
  16956. /**
  16957. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16958. */
  16959. endSpriteCellID: number;
  16960. /**
  16961. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16962. */
  16963. spriteCellWidth: number;
  16964. /**
  16965. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16966. */
  16967. spriteCellHeight: number;
  16968. /**
  16969. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16970. */
  16971. spriteRandomStartCell: boolean;
  16972. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16973. translationPivot: Vector2;
  16974. /** @hidden */
  16975. protected _isAnimationSheetEnabled: boolean;
  16976. /**
  16977. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16978. */
  16979. beginAnimationOnStart: boolean;
  16980. /**
  16981. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16982. */
  16983. beginAnimationFrom: number;
  16984. /**
  16985. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16986. */
  16987. beginAnimationTo: number;
  16988. /**
  16989. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16990. */
  16991. beginAnimationLoop: boolean;
  16992. /**
  16993. * Gets or sets a world offset applied to all particles
  16994. */
  16995. worldOffset: Vector3;
  16996. /**
  16997. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16998. */
  16999. isAnimationSheetEnabled: boolean;
  17000. /**
  17001. * Get hosting scene
  17002. * @returns the scene
  17003. */
  17004. getScene(): Scene;
  17005. /**
  17006. * You can use gravity if you want to give an orientation to your particles.
  17007. */
  17008. gravity: Vector3;
  17009. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17010. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17011. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17012. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17013. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17014. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17015. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17016. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17017. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17018. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17019. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17020. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17021. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17022. /**
  17023. * Defines the delay in milliseconds before starting the system (0 by default)
  17024. */
  17025. startDelay: number;
  17026. /**
  17027. * Gets the current list of drag gradients.
  17028. * You must use addDragGradient and removeDragGradient to udpate this list
  17029. * @returns the list of drag gradients
  17030. */
  17031. getDragGradients(): Nullable<Array<FactorGradient>>;
  17032. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17033. limitVelocityDamping: number;
  17034. /**
  17035. * Gets the current list of limit velocity gradients.
  17036. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17037. * @returns the list of limit velocity gradients
  17038. */
  17039. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17040. /**
  17041. * Gets the current list of color gradients.
  17042. * You must use addColorGradient and removeColorGradient to udpate this list
  17043. * @returns the list of color gradients
  17044. */
  17045. getColorGradients(): Nullable<Array<ColorGradient>>;
  17046. /**
  17047. * Gets the current list of size gradients.
  17048. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17049. * @returns the list of size gradients
  17050. */
  17051. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17052. /**
  17053. * Gets the current list of color remap gradients.
  17054. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17055. * @returns the list of color remap gradients
  17056. */
  17057. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17058. /**
  17059. * Gets the current list of alpha remap gradients.
  17060. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17061. * @returns the list of alpha remap gradients
  17062. */
  17063. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17064. /**
  17065. * Gets the current list of life time gradients.
  17066. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17067. * @returns the list of life time gradients
  17068. */
  17069. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17070. /**
  17071. * Gets the current list of angular speed gradients.
  17072. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17073. * @returns the list of angular speed gradients
  17074. */
  17075. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17076. /**
  17077. * Gets the current list of velocity gradients.
  17078. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17079. * @returns the list of velocity gradients
  17080. */
  17081. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17082. /**
  17083. * Gets the current list of start size gradients.
  17084. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17085. * @returns the list of start size gradients
  17086. */
  17087. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17088. /**
  17089. * Gets the current list of emit rate gradients.
  17090. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17091. * @returns the list of emit rate gradients
  17092. */
  17093. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17094. /**
  17095. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17096. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17097. */
  17098. direction1: Vector3;
  17099. /**
  17100. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17101. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17102. */
  17103. direction2: Vector3;
  17104. /**
  17105. * 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.
  17106. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17107. */
  17108. minEmitBox: Vector3;
  17109. /**
  17110. * 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.
  17111. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17112. */
  17113. maxEmitBox: Vector3;
  17114. /**
  17115. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17116. */
  17117. color1: Color4;
  17118. /**
  17119. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17120. */
  17121. color2: Color4;
  17122. /**
  17123. * Color the particle will have at the end of its lifetime
  17124. */
  17125. colorDead: Color4;
  17126. /**
  17127. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17128. */
  17129. textureMask: Color4;
  17130. /**
  17131. * The particle emitter type defines the emitter used by the particle system.
  17132. * It can be for example box, sphere, or cone...
  17133. */
  17134. particleEmitterType: IParticleEmitterType;
  17135. /** @hidden */
  17136. _isSubEmitter: boolean;
  17137. /**
  17138. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17139. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17140. */
  17141. billboardMode: number;
  17142. protected _isBillboardBased: boolean;
  17143. /**
  17144. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17145. */
  17146. isBillboardBased: boolean;
  17147. /**
  17148. * The scene the particle system belongs to.
  17149. */
  17150. protected _scene: Scene;
  17151. /**
  17152. * Local cache of defines for image processing.
  17153. */
  17154. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17155. /**
  17156. * Default configuration related to image processing available in the standard Material.
  17157. */
  17158. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17159. /**
  17160. * Gets the image processing configuration used either in this material.
  17161. */
  17162. /**
  17163. * Sets the Default image processing configuration used either in the this material.
  17164. *
  17165. * If sets to null, the scene one is in use.
  17166. */
  17167. imageProcessingConfiguration: ImageProcessingConfiguration;
  17168. /**
  17169. * Attaches a new image processing configuration to the Standard Material.
  17170. * @param configuration
  17171. */
  17172. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17173. /** @hidden */
  17174. protected _reset(): void;
  17175. /** @hidden */
  17176. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17177. /**
  17178. * Instantiates a particle system.
  17179. * 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.
  17180. * @param name The name of the particle system
  17181. */
  17182. constructor(name: string);
  17183. /**
  17184. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17185. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17186. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17187. * @returns the emitter
  17188. */
  17189. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17190. /**
  17191. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17192. * @param radius The radius of the hemisphere to emit from
  17193. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17194. * @returns the emitter
  17195. */
  17196. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17197. /**
  17198. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17199. * @param radius The radius of the sphere to emit from
  17200. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17201. * @returns the emitter
  17202. */
  17203. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17204. /**
  17205. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17206. * @param radius The radius of the sphere to emit from
  17207. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17208. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17209. * @returns the emitter
  17210. */
  17211. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17212. /**
  17213. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17214. * @param radius The radius of the emission cylinder
  17215. * @param height The height of the emission cylinder
  17216. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17217. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17218. * @returns the emitter
  17219. */
  17220. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17221. /**
  17222. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17223. * @param radius The radius of the cylinder to emit from
  17224. * @param height The height of the emission cylinder
  17225. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17226. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17227. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17228. * @returns the emitter
  17229. */
  17230. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17231. /**
  17232. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17233. * @param radius The radius of the cone to emit from
  17234. * @param angle The base angle of the cone
  17235. * @returns the emitter
  17236. */
  17237. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17238. /**
  17239. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17240. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17241. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17242. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17243. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17244. * @returns the emitter
  17245. */
  17246. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17247. }
  17248. }
  17249. declare module "babylonjs/Particles/subEmitter" {
  17250. import { Scene } from "babylonjs/scene";
  17251. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17252. /**
  17253. * Type of sub emitter
  17254. */
  17255. export enum SubEmitterType {
  17256. /**
  17257. * Attached to the particle over it's lifetime
  17258. */
  17259. ATTACHED = 0,
  17260. /**
  17261. * Created when the particle dies
  17262. */
  17263. END = 1
  17264. }
  17265. /**
  17266. * Sub emitter class used to emit particles from an existing particle
  17267. */
  17268. export class SubEmitter {
  17269. /**
  17270. * the particle system to be used by the sub emitter
  17271. */
  17272. particleSystem: ParticleSystem;
  17273. /**
  17274. * Type of the submitter (Default: END)
  17275. */
  17276. type: SubEmitterType;
  17277. /**
  17278. * 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)
  17279. * Note: This only is supported when using an emitter of type Mesh
  17280. */
  17281. inheritDirection: boolean;
  17282. /**
  17283. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17284. */
  17285. inheritedVelocityAmount: number;
  17286. /**
  17287. * Creates a sub emitter
  17288. * @param particleSystem the particle system to be used by the sub emitter
  17289. */
  17290. constructor(
  17291. /**
  17292. * the particle system to be used by the sub emitter
  17293. */
  17294. particleSystem: ParticleSystem);
  17295. /**
  17296. * Clones the sub emitter
  17297. * @returns the cloned sub emitter
  17298. */
  17299. clone(): SubEmitter;
  17300. /**
  17301. * Serialize current object to a JSON object
  17302. * @returns the serialized object
  17303. */
  17304. serialize(): any;
  17305. /** @hidden */
  17306. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17307. /**
  17308. * Creates a new SubEmitter from a serialized JSON version
  17309. * @param serializationObject defines the JSON object to read from
  17310. * @param scene defines the hosting scene
  17311. * @param rootUrl defines the rootUrl for data loading
  17312. * @returns a new SubEmitter
  17313. */
  17314. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17315. /** Release associated resources */
  17316. dispose(): void;
  17317. }
  17318. }
  17319. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17320. /** @hidden */
  17321. export var clipPlaneFragmentDeclaration: {
  17322. name: string;
  17323. shader: string;
  17324. };
  17325. }
  17326. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17327. /** @hidden */
  17328. export var imageProcessingDeclaration: {
  17329. name: string;
  17330. shader: string;
  17331. };
  17332. }
  17333. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17334. /** @hidden */
  17335. export var imageProcessingFunctions: {
  17336. name: string;
  17337. shader: string;
  17338. };
  17339. }
  17340. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17341. /** @hidden */
  17342. export var clipPlaneFragment: {
  17343. name: string;
  17344. shader: string;
  17345. };
  17346. }
  17347. declare module "babylonjs/Shaders/particles.fragment" {
  17348. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17349. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17350. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17351. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17352. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17353. /** @hidden */
  17354. export var particlesPixelShader: {
  17355. name: string;
  17356. shader: string;
  17357. };
  17358. }
  17359. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17360. /** @hidden */
  17361. export var clipPlaneVertexDeclaration: {
  17362. name: string;
  17363. shader: string;
  17364. };
  17365. }
  17366. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17367. /** @hidden */
  17368. export var clipPlaneVertex: {
  17369. name: string;
  17370. shader: string;
  17371. };
  17372. }
  17373. declare module "babylonjs/Shaders/particles.vertex" {
  17374. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17375. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17376. /** @hidden */
  17377. export var particlesVertexShader: {
  17378. name: string;
  17379. shader: string;
  17380. };
  17381. }
  17382. declare module "babylonjs/Particles/particleSystem" {
  17383. import { Nullable } from "babylonjs/types";
  17384. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17385. import { Observable } from "babylonjs/Misc/observable";
  17386. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17387. import { Effect } from "babylonjs/Materials/effect";
  17388. import { Scene, IDisposable } from "babylonjs/scene";
  17389. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17390. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17391. import { Particle } from "babylonjs/Particles/particle";
  17392. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17393. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17394. import "babylonjs/Shaders/particles.fragment";
  17395. import "babylonjs/Shaders/particles.vertex";
  17396. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17397. /**
  17398. * This represents a particle system in Babylon.
  17399. * 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.
  17400. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17401. * @example https://doc.babylonjs.com/babylon101/particles
  17402. */
  17403. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17404. /**
  17405. * Billboard mode will only apply to Y axis
  17406. */
  17407. static readonly BILLBOARDMODE_Y: number;
  17408. /**
  17409. * Billboard mode will apply to all axes
  17410. */
  17411. static readonly BILLBOARDMODE_ALL: number;
  17412. /**
  17413. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17414. */
  17415. static readonly BILLBOARDMODE_STRETCHED: number;
  17416. /**
  17417. * This function can be defined to provide custom update for active particles.
  17418. * This function will be called instead of regular update (age, position, color, etc.).
  17419. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17420. */
  17421. updateFunction: (particles: Particle[]) => void;
  17422. private _emitterWorldMatrix;
  17423. /**
  17424. * This function can be defined to specify initial direction for every new particle.
  17425. * It by default use the emitterType defined function
  17426. */
  17427. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17428. /**
  17429. * This function can be defined to specify initial position for every new particle.
  17430. * It by default use the emitterType defined function
  17431. */
  17432. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17433. /**
  17434. * @hidden
  17435. */
  17436. _inheritedVelocityOffset: Vector3;
  17437. /**
  17438. * An event triggered when the system is disposed
  17439. */
  17440. onDisposeObservable: Observable<ParticleSystem>;
  17441. private _onDisposeObserver;
  17442. /**
  17443. * Sets a callback that will be triggered when the system is disposed
  17444. */
  17445. onDispose: () => void;
  17446. private _particles;
  17447. private _epsilon;
  17448. private _capacity;
  17449. private _stockParticles;
  17450. private _newPartsExcess;
  17451. private _vertexData;
  17452. private _vertexBuffer;
  17453. private _vertexBuffers;
  17454. private _spriteBuffer;
  17455. private _indexBuffer;
  17456. private _effect;
  17457. private _customEffect;
  17458. private _cachedDefines;
  17459. private _scaledColorStep;
  17460. private _colorDiff;
  17461. private _scaledDirection;
  17462. private _scaledGravity;
  17463. private _currentRenderId;
  17464. private _alive;
  17465. private _useInstancing;
  17466. private _started;
  17467. private _stopped;
  17468. private _actualFrame;
  17469. private _scaledUpdateSpeed;
  17470. private _vertexBufferSize;
  17471. /** @hidden */
  17472. _currentEmitRateGradient: Nullable<FactorGradient>;
  17473. /** @hidden */
  17474. _currentEmitRate1: number;
  17475. /** @hidden */
  17476. _currentEmitRate2: number;
  17477. /** @hidden */
  17478. _currentStartSizeGradient: Nullable<FactorGradient>;
  17479. /** @hidden */
  17480. _currentStartSize1: number;
  17481. /** @hidden */
  17482. _currentStartSize2: number;
  17483. private readonly _rawTextureWidth;
  17484. private _rampGradientsTexture;
  17485. private _useRampGradients;
  17486. /** Gets or sets a boolean indicating that ramp gradients must be used
  17487. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17488. */
  17489. useRampGradients: boolean;
  17490. /**
  17491. * 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.
  17492. * 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: [])
  17493. */
  17494. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17495. private _subEmitters;
  17496. /**
  17497. * @hidden
  17498. * If the particle systems emitter should be disposed when the particle system is disposed
  17499. */
  17500. _disposeEmitterOnDispose: boolean;
  17501. /**
  17502. * The current active Sub-systems, this property is used by the root particle system only.
  17503. */
  17504. activeSubSystems: Array<ParticleSystem>;
  17505. private _rootParticleSystem;
  17506. /**
  17507. * Gets the current list of active particles
  17508. */
  17509. readonly particles: Particle[];
  17510. /**
  17511. * Returns the string "ParticleSystem"
  17512. * @returns a string containing the class name
  17513. */
  17514. getClassName(): string;
  17515. /**
  17516. * Instantiates a particle system.
  17517. * 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.
  17518. * @param name The name of the particle system
  17519. * @param capacity The max number of particles alive at the same time
  17520. * @param scene The scene the particle system belongs to
  17521. * @param customEffect a custom effect used to change the way particles are rendered by default
  17522. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17523. * @param epsilon Offset used to render the particles
  17524. */
  17525. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17526. private _addFactorGradient;
  17527. private _removeFactorGradient;
  17528. /**
  17529. * Adds a new life time gradient
  17530. * @param gradient defines the gradient to use (between 0 and 1)
  17531. * @param factor defines the life time factor to affect to the specified gradient
  17532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17533. * @returns the current particle system
  17534. */
  17535. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17536. /**
  17537. * Remove a specific life time gradient
  17538. * @param gradient defines the gradient to remove
  17539. * @returns the current particle system
  17540. */
  17541. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17542. /**
  17543. * Adds a new size gradient
  17544. * @param gradient defines the gradient to use (between 0 and 1)
  17545. * @param factor defines the size factor to affect to the specified gradient
  17546. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17547. * @returns the current particle system
  17548. */
  17549. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17550. /**
  17551. * Remove a specific size gradient
  17552. * @param gradient defines the gradient to remove
  17553. * @returns the current particle system
  17554. */
  17555. removeSizeGradient(gradient: number): IParticleSystem;
  17556. /**
  17557. * Adds a new color remap gradient
  17558. * @param gradient defines the gradient to use (between 0 and 1)
  17559. * @param min defines the color remap minimal range
  17560. * @param max defines the color remap maximal range
  17561. * @returns the current particle system
  17562. */
  17563. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17564. /**
  17565. * Remove a specific color remap gradient
  17566. * @param gradient defines the gradient to remove
  17567. * @returns the current particle system
  17568. */
  17569. removeColorRemapGradient(gradient: number): IParticleSystem;
  17570. /**
  17571. * Adds a new alpha remap gradient
  17572. * @param gradient defines the gradient to use (between 0 and 1)
  17573. * @param min defines the alpha remap minimal range
  17574. * @param max defines the alpha remap maximal range
  17575. * @returns the current particle system
  17576. */
  17577. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17578. /**
  17579. * Remove a specific alpha remap gradient
  17580. * @param gradient defines the gradient to remove
  17581. * @returns the current particle system
  17582. */
  17583. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17584. /**
  17585. * Adds a new angular speed gradient
  17586. * @param gradient defines the gradient to use (between 0 and 1)
  17587. * @param factor defines the angular speed to affect to the specified gradient
  17588. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17589. * @returns the current particle system
  17590. */
  17591. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17592. /**
  17593. * Remove a specific angular speed gradient
  17594. * @param gradient defines the gradient to remove
  17595. * @returns the current particle system
  17596. */
  17597. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17598. /**
  17599. * Adds a new velocity gradient
  17600. * @param gradient defines the gradient to use (between 0 and 1)
  17601. * @param factor defines the velocity to affect to the specified gradient
  17602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17603. * @returns the current particle system
  17604. */
  17605. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17606. /**
  17607. * Remove a specific velocity gradient
  17608. * @param gradient defines the gradient to remove
  17609. * @returns the current particle system
  17610. */
  17611. removeVelocityGradient(gradient: number): IParticleSystem;
  17612. /**
  17613. * Adds a new limit velocity gradient
  17614. * @param gradient defines the gradient to use (between 0 and 1)
  17615. * @param factor defines the limit velocity value to affect to the specified gradient
  17616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17617. * @returns the current particle system
  17618. */
  17619. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17620. /**
  17621. * Remove a specific limit velocity gradient
  17622. * @param gradient defines the gradient to remove
  17623. * @returns the current particle system
  17624. */
  17625. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17626. /**
  17627. * Adds a new drag gradient
  17628. * @param gradient defines the gradient to use (between 0 and 1)
  17629. * @param factor defines the drag value to affect to the specified gradient
  17630. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17631. * @returns the current particle system
  17632. */
  17633. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17634. /**
  17635. * Remove a specific drag gradient
  17636. * @param gradient defines the gradient to remove
  17637. * @returns the current particle system
  17638. */
  17639. removeDragGradient(gradient: number): IParticleSystem;
  17640. /**
  17641. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17642. * @param gradient defines the gradient to use (between 0 and 1)
  17643. * @param factor defines the emit rate value to affect to the specified gradient
  17644. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17645. * @returns the current particle system
  17646. */
  17647. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17648. /**
  17649. * Remove a specific emit rate gradient
  17650. * @param gradient defines the gradient to remove
  17651. * @returns the current particle system
  17652. */
  17653. removeEmitRateGradient(gradient: number): IParticleSystem;
  17654. /**
  17655. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17656. * @param gradient defines the gradient to use (between 0 and 1)
  17657. * @param factor defines the start size value to affect to the specified gradient
  17658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17659. * @returns the current particle system
  17660. */
  17661. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17662. /**
  17663. * Remove a specific start size gradient
  17664. * @param gradient defines the gradient to remove
  17665. * @returns the current particle system
  17666. */
  17667. removeStartSizeGradient(gradient: number): IParticleSystem;
  17668. private _createRampGradientTexture;
  17669. /**
  17670. * Gets the current list of ramp gradients.
  17671. * You must use addRampGradient and removeRampGradient to udpate this list
  17672. * @returns the list of ramp gradients
  17673. */
  17674. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17675. /**
  17676. * Adds a new ramp gradient used to remap particle colors
  17677. * @param gradient defines the gradient to use (between 0 and 1)
  17678. * @param color defines the color to affect to the specified gradient
  17679. * @returns the current particle system
  17680. */
  17681. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17682. /**
  17683. * Remove a specific ramp gradient
  17684. * @param gradient defines the gradient to remove
  17685. * @returns the current particle system
  17686. */
  17687. removeRampGradient(gradient: number): ParticleSystem;
  17688. /**
  17689. * Adds a new color gradient
  17690. * @param gradient defines the gradient to use (between 0 and 1)
  17691. * @param color1 defines the color to affect to the specified gradient
  17692. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17693. * @returns this particle system
  17694. */
  17695. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17696. /**
  17697. * Remove a specific color gradient
  17698. * @param gradient defines the gradient to remove
  17699. * @returns this particle system
  17700. */
  17701. removeColorGradient(gradient: number): IParticleSystem;
  17702. private _fetchR;
  17703. protected _reset(): void;
  17704. private _resetEffect;
  17705. private _createVertexBuffers;
  17706. private _createIndexBuffer;
  17707. /**
  17708. * Gets the maximum number of particles active at the same time.
  17709. * @returns The max number of active particles.
  17710. */
  17711. getCapacity(): number;
  17712. /**
  17713. * Gets whether there are still active particles in the system.
  17714. * @returns True if it is alive, otherwise false.
  17715. */
  17716. isAlive(): boolean;
  17717. /**
  17718. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17719. * @returns True if it has been started, otherwise false.
  17720. */
  17721. isStarted(): boolean;
  17722. private _prepareSubEmitterInternalArray;
  17723. /**
  17724. * Starts the particle system and begins to emit
  17725. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17726. */
  17727. start(delay?: number): void;
  17728. /**
  17729. * Stops the particle system.
  17730. * @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.
  17731. */
  17732. stop(stopSubEmitters?: boolean): void;
  17733. /**
  17734. * Remove all active particles
  17735. */
  17736. reset(): void;
  17737. /**
  17738. * @hidden (for internal use only)
  17739. */
  17740. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17741. /**
  17742. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17743. * Its lifetime will start back at 0.
  17744. */
  17745. recycleParticle: (particle: Particle) => void;
  17746. private _stopSubEmitters;
  17747. private _createParticle;
  17748. private _removeFromRoot;
  17749. private _emitFromParticle;
  17750. private _update;
  17751. /** @hidden */
  17752. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17753. /** @hidden */
  17754. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17755. /** @hidden */
  17756. private _getEffect;
  17757. /**
  17758. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17759. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17760. */
  17761. animate(preWarmOnly?: boolean): void;
  17762. private _appendParticleVertices;
  17763. /**
  17764. * Rebuilds the particle system.
  17765. */
  17766. rebuild(): void;
  17767. /**
  17768. * Is this system ready to be used/rendered
  17769. * @return true if the system is ready
  17770. */
  17771. isReady(): boolean;
  17772. private _render;
  17773. /**
  17774. * Renders the particle system in its current state.
  17775. * @returns the current number of particles
  17776. */
  17777. render(): number;
  17778. /**
  17779. * Disposes the particle system and free the associated resources
  17780. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17781. */
  17782. dispose(disposeTexture?: boolean): void;
  17783. /**
  17784. * Clones the particle system.
  17785. * @param name The name of the cloned object
  17786. * @param newEmitter The new emitter to use
  17787. * @returns the cloned particle system
  17788. */
  17789. clone(name: string, newEmitter: any): ParticleSystem;
  17790. /**
  17791. * Serializes the particle system to a JSON object.
  17792. * @returns the JSON object
  17793. */
  17794. serialize(): any;
  17795. /** @hidden */
  17796. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17797. /** @hidden */
  17798. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17799. /**
  17800. * Parses a JSON object to create a particle system.
  17801. * @param parsedParticleSystem The JSON object to parse
  17802. * @param scene The scene to create the particle system in
  17803. * @param rootUrl The root url to use to load external dependencies like texture
  17804. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17805. * @returns the Parsed particle system
  17806. */
  17807. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17808. }
  17809. }
  17810. declare module "babylonjs/Particles/particle" {
  17811. import { Nullable } from "babylonjs/types";
  17812. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17813. import { Color4 } from "babylonjs/Maths/math.color";
  17814. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17815. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17816. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17817. /**
  17818. * A particle represents one of the element emitted by a particle system.
  17819. * This is mainly define by its coordinates, direction, velocity and age.
  17820. */
  17821. export class Particle {
  17822. /**
  17823. * The particle system the particle belongs to.
  17824. */
  17825. particleSystem: ParticleSystem;
  17826. private static _Count;
  17827. /**
  17828. * Unique ID of the particle
  17829. */
  17830. id: number;
  17831. /**
  17832. * The world position of the particle in the scene.
  17833. */
  17834. position: Vector3;
  17835. /**
  17836. * The world direction of the particle in the scene.
  17837. */
  17838. direction: Vector3;
  17839. /**
  17840. * The color of the particle.
  17841. */
  17842. color: Color4;
  17843. /**
  17844. * The color change of the particle per step.
  17845. */
  17846. colorStep: Color4;
  17847. /**
  17848. * Defines how long will the life of the particle be.
  17849. */
  17850. lifeTime: number;
  17851. /**
  17852. * The current age of the particle.
  17853. */
  17854. age: number;
  17855. /**
  17856. * The current size of the particle.
  17857. */
  17858. size: number;
  17859. /**
  17860. * The current scale of the particle.
  17861. */
  17862. scale: Vector2;
  17863. /**
  17864. * The current angle of the particle.
  17865. */
  17866. angle: number;
  17867. /**
  17868. * Defines how fast is the angle changing.
  17869. */
  17870. angularSpeed: number;
  17871. /**
  17872. * Defines the cell index used by the particle to be rendered from a sprite.
  17873. */
  17874. cellIndex: number;
  17875. /**
  17876. * The information required to support color remapping
  17877. */
  17878. remapData: Vector4;
  17879. /** @hidden */
  17880. _randomCellOffset?: number;
  17881. /** @hidden */
  17882. _initialDirection: Nullable<Vector3>;
  17883. /** @hidden */
  17884. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17885. /** @hidden */
  17886. _initialStartSpriteCellID: number;
  17887. /** @hidden */
  17888. _initialEndSpriteCellID: number;
  17889. /** @hidden */
  17890. _currentColorGradient: Nullable<ColorGradient>;
  17891. /** @hidden */
  17892. _currentColor1: Color4;
  17893. /** @hidden */
  17894. _currentColor2: Color4;
  17895. /** @hidden */
  17896. _currentSizeGradient: Nullable<FactorGradient>;
  17897. /** @hidden */
  17898. _currentSize1: number;
  17899. /** @hidden */
  17900. _currentSize2: number;
  17901. /** @hidden */
  17902. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17903. /** @hidden */
  17904. _currentAngularSpeed1: number;
  17905. /** @hidden */
  17906. _currentAngularSpeed2: number;
  17907. /** @hidden */
  17908. _currentVelocityGradient: Nullable<FactorGradient>;
  17909. /** @hidden */
  17910. _currentVelocity1: number;
  17911. /** @hidden */
  17912. _currentVelocity2: number;
  17913. /** @hidden */
  17914. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17915. /** @hidden */
  17916. _currentLimitVelocity1: number;
  17917. /** @hidden */
  17918. _currentLimitVelocity2: number;
  17919. /** @hidden */
  17920. _currentDragGradient: Nullable<FactorGradient>;
  17921. /** @hidden */
  17922. _currentDrag1: number;
  17923. /** @hidden */
  17924. _currentDrag2: number;
  17925. /** @hidden */
  17926. _randomNoiseCoordinates1: Vector3;
  17927. /** @hidden */
  17928. _randomNoiseCoordinates2: Vector3;
  17929. /**
  17930. * Creates a new instance Particle
  17931. * @param particleSystem the particle system the particle belongs to
  17932. */
  17933. constructor(
  17934. /**
  17935. * The particle system the particle belongs to.
  17936. */
  17937. particleSystem: ParticleSystem);
  17938. private updateCellInfoFromSystem;
  17939. /**
  17940. * Defines how the sprite cell index is updated for the particle
  17941. */
  17942. updateCellIndex(): void;
  17943. /** @hidden */
  17944. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17945. /** @hidden */
  17946. _inheritParticleInfoToSubEmitters(): void;
  17947. /** @hidden */
  17948. _reset(): void;
  17949. /**
  17950. * Copy the properties of particle to another one.
  17951. * @param other the particle to copy the information to.
  17952. */
  17953. copyTo(other: Particle): void;
  17954. }
  17955. }
  17956. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17957. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17958. import { Effect } from "babylonjs/Materials/effect";
  17959. import { Particle } from "babylonjs/Particles/particle";
  17960. /**
  17961. * Particle emitter represents a volume emitting particles.
  17962. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17963. */
  17964. export interface IParticleEmitterType {
  17965. /**
  17966. * Called by the particle System when the direction is computed for the created particle.
  17967. * @param worldMatrix is the world matrix of the particle system
  17968. * @param directionToUpdate is the direction vector to update with the result
  17969. * @param particle is the particle we are computed the direction for
  17970. */
  17971. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17972. /**
  17973. * Called by the particle System when the position is computed for the created particle.
  17974. * @param worldMatrix is the world matrix of the particle system
  17975. * @param positionToUpdate is the position vector to update with the result
  17976. * @param particle is the particle we are computed the position for
  17977. */
  17978. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17979. /**
  17980. * Clones the current emitter and returns a copy of it
  17981. * @returns the new emitter
  17982. */
  17983. clone(): IParticleEmitterType;
  17984. /**
  17985. * Called by the GPUParticleSystem to setup the update shader
  17986. * @param effect defines the update shader
  17987. */
  17988. applyToShader(effect: Effect): void;
  17989. /**
  17990. * Returns a string to use to update the GPU particles update shader
  17991. * @returns the effect defines string
  17992. */
  17993. getEffectDefines(): string;
  17994. /**
  17995. * Returns a string representing the class name
  17996. * @returns a string containing the class name
  17997. */
  17998. getClassName(): string;
  17999. /**
  18000. * Serializes the particle system to a JSON object.
  18001. * @returns the JSON object
  18002. */
  18003. serialize(): any;
  18004. /**
  18005. * Parse properties from a JSON object
  18006. * @param serializationObject defines the JSON object
  18007. */
  18008. parse(serializationObject: any): void;
  18009. }
  18010. }
  18011. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18012. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18013. import { Effect } from "babylonjs/Materials/effect";
  18014. import { Particle } from "babylonjs/Particles/particle";
  18015. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18016. /**
  18017. * Particle emitter emitting particles from the inside of a box.
  18018. * It emits the particles randomly between 2 given directions.
  18019. */
  18020. export class BoxParticleEmitter implements IParticleEmitterType {
  18021. /**
  18022. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18023. */
  18024. direction1: Vector3;
  18025. /**
  18026. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18027. */
  18028. direction2: Vector3;
  18029. /**
  18030. * 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.
  18031. */
  18032. minEmitBox: Vector3;
  18033. /**
  18034. * 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.
  18035. */
  18036. maxEmitBox: Vector3;
  18037. /**
  18038. * Creates a new instance BoxParticleEmitter
  18039. */
  18040. constructor();
  18041. /**
  18042. * Called by the particle System when the direction is computed for the created particle.
  18043. * @param worldMatrix is the world matrix of the particle system
  18044. * @param directionToUpdate is the direction vector to update with the result
  18045. * @param particle is the particle we are computed the direction for
  18046. */
  18047. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18048. /**
  18049. * Called by the particle System when the position is computed for the created particle.
  18050. * @param worldMatrix is the world matrix of the particle system
  18051. * @param positionToUpdate is the position vector to update with the result
  18052. * @param particle is the particle we are computed the position for
  18053. */
  18054. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18055. /**
  18056. * Clones the current emitter and returns a copy of it
  18057. * @returns the new emitter
  18058. */
  18059. clone(): BoxParticleEmitter;
  18060. /**
  18061. * Called by the GPUParticleSystem to setup the update shader
  18062. * @param effect defines the update shader
  18063. */
  18064. applyToShader(effect: Effect): void;
  18065. /**
  18066. * Returns a string to use to update the GPU particles update shader
  18067. * @returns a string containng the defines string
  18068. */
  18069. getEffectDefines(): string;
  18070. /**
  18071. * Returns the string "BoxParticleEmitter"
  18072. * @returns a string containing the class name
  18073. */
  18074. getClassName(): string;
  18075. /**
  18076. * Serializes the particle system to a JSON object.
  18077. * @returns the JSON object
  18078. */
  18079. serialize(): any;
  18080. /**
  18081. * Parse properties from a JSON object
  18082. * @param serializationObject defines the JSON object
  18083. */
  18084. parse(serializationObject: any): void;
  18085. }
  18086. }
  18087. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18088. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18089. import { Effect } from "babylonjs/Materials/effect";
  18090. import { Particle } from "babylonjs/Particles/particle";
  18091. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18092. /**
  18093. * Particle emitter emitting particles from the inside of a cone.
  18094. * It emits the particles alongside the cone volume from the base to the particle.
  18095. * The emission direction might be randomized.
  18096. */
  18097. export class ConeParticleEmitter implements IParticleEmitterType {
  18098. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18099. directionRandomizer: number;
  18100. private _radius;
  18101. private _angle;
  18102. private _height;
  18103. /**
  18104. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18105. */
  18106. radiusRange: number;
  18107. /**
  18108. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18109. */
  18110. heightRange: number;
  18111. /**
  18112. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18113. */
  18114. emitFromSpawnPointOnly: boolean;
  18115. /**
  18116. * Gets or sets the radius of the emission cone
  18117. */
  18118. radius: number;
  18119. /**
  18120. * Gets or sets the angle of the emission cone
  18121. */
  18122. angle: number;
  18123. private _buildHeight;
  18124. /**
  18125. * Creates a new instance ConeParticleEmitter
  18126. * @param radius the radius of the emission cone (1 by default)
  18127. * @param angle the cone base angle (PI by default)
  18128. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18129. */
  18130. constructor(radius?: number, angle?: number,
  18131. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18132. directionRandomizer?: number);
  18133. /**
  18134. * Called by the particle System when the direction is computed for the created particle.
  18135. * @param worldMatrix is the world matrix of the particle system
  18136. * @param directionToUpdate is the direction vector to update with the result
  18137. * @param particle is the particle we are computed the direction for
  18138. */
  18139. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18140. /**
  18141. * Called by the particle System when the position is computed for the created particle.
  18142. * @param worldMatrix is the world matrix of the particle system
  18143. * @param positionToUpdate is the position vector to update with the result
  18144. * @param particle is the particle we are computed the position for
  18145. */
  18146. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18147. /**
  18148. * Clones the current emitter and returns a copy of it
  18149. * @returns the new emitter
  18150. */
  18151. clone(): ConeParticleEmitter;
  18152. /**
  18153. * Called by the GPUParticleSystem to setup the update shader
  18154. * @param effect defines the update shader
  18155. */
  18156. applyToShader(effect: Effect): void;
  18157. /**
  18158. * Returns a string to use to update the GPU particles update shader
  18159. * @returns a string containng the defines string
  18160. */
  18161. getEffectDefines(): string;
  18162. /**
  18163. * Returns the string "ConeParticleEmitter"
  18164. * @returns a string containing the class name
  18165. */
  18166. getClassName(): string;
  18167. /**
  18168. * Serializes the particle system to a JSON object.
  18169. * @returns the JSON object
  18170. */
  18171. serialize(): any;
  18172. /**
  18173. * Parse properties from a JSON object
  18174. * @param serializationObject defines the JSON object
  18175. */
  18176. parse(serializationObject: any): void;
  18177. }
  18178. }
  18179. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18180. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18181. import { Effect } from "babylonjs/Materials/effect";
  18182. import { Particle } from "babylonjs/Particles/particle";
  18183. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18184. /**
  18185. * Particle emitter emitting particles from the inside of a cylinder.
  18186. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18187. */
  18188. export class CylinderParticleEmitter implements IParticleEmitterType {
  18189. /**
  18190. * The radius of the emission cylinder.
  18191. */
  18192. radius: number;
  18193. /**
  18194. * The height of the emission cylinder.
  18195. */
  18196. height: number;
  18197. /**
  18198. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18199. */
  18200. radiusRange: number;
  18201. /**
  18202. * How much to randomize the particle direction [0-1].
  18203. */
  18204. directionRandomizer: number;
  18205. /**
  18206. * Creates a new instance CylinderParticleEmitter
  18207. * @param radius the radius of the emission cylinder (1 by default)
  18208. * @param height the height of the emission cylinder (1 by default)
  18209. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18210. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18211. */
  18212. constructor(
  18213. /**
  18214. * The radius of the emission cylinder.
  18215. */
  18216. radius?: number,
  18217. /**
  18218. * The height of the emission cylinder.
  18219. */
  18220. height?: number,
  18221. /**
  18222. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18223. */
  18224. radiusRange?: number,
  18225. /**
  18226. * How much to randomize the particle direction [0-1].
  18227. */
  18228. directionRandomizer?: number);
  18229. /**
  18230. * Called by the particle System when the direction is computed for the created particle.
  18231. * @param worldMatrix is the world matrix of the particle system
  18232. * @param directionToUpdate is the direction vector to update with the result
  18233. * @param particle is the particle we are computed the direction for
  18234. */
  18235. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18236. /**
  18237. * Called by the particle System when the position is computed for the created particle.
  18238. * @param worldMatrix is the world matrix of the particle system
  18239. * @param positionToUpdate is the position vector to update with the result
  18240. * @param particle is the particle we are computed the position for
  18241. */
  18242. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18243. /**
  18244. * Clones the current emitter and returns a copy of it
  18245. * @returns the new emitter
  18246. */
  18247. clone(): CylinderParticleEmitter;
  18248. /**
  18249. * Called by the GPUParticleSystem to setup the update shader
  18250. * @param effect defines the update shader
  18251. */
  18252. applyToShader(effect: Effect): void;
  18253. /**
  18254. * Returns a string to use to update the GPU particles update shader
  18255. * @returns a string containng the defines string
  18256. */
  18257. getEffectDefines(): string;
  18258. /**
  18259. * Returns the string "CylinderParticleEmitter"
  18260. * @returns a string containing the class name
  18261. */
  18262. getClassName(): string;
  18263. /**
  18264. * Serializes the particle system to a JSON object.
  18265. * @returns the JSON object
  18266. */
  18267. serialize(): any;
  18268. /**
  18269. * Parse properties from a JSON object
  18270. * @param serializationObject defines the JSON object
  18271. */
  18272. parse(serializationObject: any): void;
  18273. }
  18274. /**
  18275. * Particle emitter emitting particles from the inside of a cylinder.
  18276. * It emits the particles randomly between two vectors.
  18277. */
  18278. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18279. /**
  18280. * The min limit of the emission direction.
  18281. */
  18282. direction1: Vector3;
  18283. /**
  18284. * The max limit of the emission direction.
  18285. */
  18286. direction2: Vector3;
  18287. /**
  18288. * Creates a new instance CylinderDirectedParticleEmitter
  18289. * @param radius the radius of the emission cylinder (1 by default)
  18290. * @param height the height of the emission cylinder (1 by default)
  18291. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18292. * @param direction1 the min limit of the emission direction (up vector by default)
  18293. * @param direction2 the max limit of the emission direction (up vector by default)
  18294. */
  18295. constructor(radius?: number, height?: number, radiusRange?: number,
  18296. /**
  18297. * The min limit of the emission direction.
  18298. */
  18299. direction1?: Vector3,
  18300. /**
  18301. * The max limit of the emission direction.
  18302. */
  18303. direction2?: Vector3);
  18304. /**
  18305. * Called by the particle System when the direction is computed for the created particle.
  18306. * @param worldMatrix is the world matrix of the particle system
  18307. * @param directionToUpdate is the direction vector to update with the result
  18308. * @param particle is the particle we are computed the direction for
  18309. */
  18310. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18311. /**
  18312. * Clones the current emitter and returns a copy of it
  18313. * @returns the new emitter
  18314. */
  18315. clone(): CylinderDirectedParticleEmitter;
  18316. /**
  18317. * Called by the GPUParticleSystem to setup the update shader
  18318. * @param effect defines the update shader
  18319. */
  18320. applyToShader(effect: Effect): void;
  18321. /**
  18322. * Returns a string to use to update the GPU particles update shader
  18323. * @returns a string containng the defines string
  18324. */
  18325. getEffectDefines(): string;
  18326. /**
  18327. * Returns the string "CylinderDirectedParticleEmitter"
  18328. * @returns a string containing the class name
  18329. */
  18330. getClassName(): string;
  18331. /**
  18332. * Serializes the particle system to a JSON object.
  18333. * @returns the JSON object
  18334. */
  18335. serialize(): any;
  18336. /**
  18337. * Parse properties from a JSON object
  18338. * @param serializationObject defines the JSON object
  18339. */
  18340. parse(serializationObject: any): void;
  18341. }
  18342. }
  18343. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18344. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18345. import { Effect } from "babylonjs/Materials/effect";
  18346. import { Particle } from "babylonjs/Particles/particle";
  18347. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18348. /**
  18349. * Particle emitter emitting particles from the inside of a hemisphere.
  18350. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18351. */
  18352. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18353. /**
  18354. * The radius of the emission hemisphere.
  18355. */
  18356. radius: number;
  18357. /**
  18358. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18359. */
  18360. radiusRange: number;
  18361. /**
  18362. * How much to randomize the particle direction [0-1].
  18363. */
  18364. directionRandomizer: number;
  18365. /**
  18366. * Creates a new instance HemisphericParticleEmitter
  18367. * @param radius the radius of the emission hemisphere (1 by default)
  18368. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18369. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18370. */
  18371. constructor(
  18372. /**
  18373. * The radius of the emission hemisphere.
  18374. */
  18375. radius?: number,
  18376. /**
  18377. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18378. */
  18379. radiusRange?: number,
  18380. /**
  18381. * How much to randomize the particle direction [0-1].
  18382. */
  18383. directionRandomizer?: number);
  18384. /**
  18385. * Called by the particle System when the direction is computed for the created particle.
  18386. * @param worldMatrix is the world matrix of the particle system
  18387. * @param directionToUpdate is the direction vector to update with the result
  18388. * @param particle is the particle we are computed the direction for
  18389. */
  18390. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18391. /**
  18392. * Called by the particle System when the position is computed for the created particle.
  18393. * @param worldMatrix is the world matrix of the particle system
  18394. * @param positionToUpdate is the position vector to update with the result
  18395. * @param particle is the particle we are computed the position for
  18396. */
  18397. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18398. /**
  18399. * Clones the current emitter and returns a copy of it
  18400. * @returns the new emitter
  18401. */
  18402. clone(): HemisphericParticleEmitter;
  18403. /**
  18404. * Called by the GPUParticleSystem to setup the update shader
  18405. * @param effect defines the update shader
  18406. */
  18407. applyToShader(effect: Effect): void;
  18408. /**
  18409. * Returns a string to use to update the GPU particles update shader
  18410. * @returns a string containng the defines string
  18411. */
  18412. getEffectDefines(): string;
  18413. /**
  18414. * Returns the string "HemisphericParticleEmitter"
  18415. * @returns a string containing the class name
  18416. */
  18417. getClassName(): string;
  18418. /**
  18419. * Serializes the particle system to a JSON object.
  18420. * @returns the JSON object
  18421. */
  18422. serialize(): any;
  18423. /**
  18424. * Parse properties from a JSON object
  18425. * @param serializationObject defines the JSON object
  18426. */
  18427. parse(serializationObject: any): void;
  18428. }
  18429. }
  18430. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18431. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18432. import { Effect } from "babylonjs/Materials/effect";
  18433. import { Particle } from "babylonjs/Particles/particle";
  18434. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18435. /**
  18436. * Particle emitter emitting particles from a point.
  18437. * It emits the particles randomly between 2 given directions.
  18438. */
  18439. export class PointParticleEmitter implements IParticleEmitterType {
  18440. /**
  18441. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18442. */
  18443. direction1: Vector3;
  18444. /**
  18445. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18446. */
  18447. direction2: Vector3;
  18448. /**
  18449. * Creates a new instance PointParticleEmitter
  18450. */
  18451. constructor();
  18452. /**
  18453. * Called by the particle System when the direction is computed for the created particle.
  18454. * @param worldMatrix is the world matrix of the particle system
  18455. * @param directionToUpdate is the direction vector to update with the result
  18456. * @param particle is the particle we are computed the direction for
  18457. */
  18458. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18459. /**
  18460. * Called by the particle System when the position is computed for the created particle.
  18461. * @param worldMatrix is the world matrix of the particle system
  18462. * @param positionToUpdate is the position vector to update with the result
  18463. * @param particle is the particle we are computed the position for
  18464. */
  18465. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18466. /**
  18467. * Clones the current emitter and returns a copy of it
  18468. * @returns the new emitter
  18469. */
  18470. clone(): PointParticleEmitter;
  18471. /**
  18472. * Called by the GPUParticleSystem to setup the update shader
  18473. * @param effect defines the update shader
  18474. */
  18475. applyToShader(effect: Effect): void;
  18476. /**
  18477. * Returns a string to use to update the GPU particles update shader
  18478. * @returns a string containng the defines string
  18479. */
  18480. getEffectDefines(): string;
  18481. /**
  18482. * Returns the string "PointParticleEmitter"
  18483. * @returns a string containing the class name
  18484. */
  18485. getClassName(): string;
  18486. /**
  18487. * Serializes the particle system to a JSON object.
  18488. * @returns the JSON object
  18489. */
  18490. serialize(): any;
  18491. /**
  18492. * Parse properties from a JSON object
  18493. * @param serializationObject defines the JSON object
  18494. */
  18495. parse(serializationObject: any): void;
  18496. }
  18497. }
  18498. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18499. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18500. import { Effect } from "babylonjs/Materials/effect";
  18501. import { Particle } from "babylonjs/Particles/particle";
  18502. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18503. /**
  18504. * Particle emitter emitting particles from the inside of a sphere.
  18505. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18506. */
  18507. export class SphereParticleEmitter implements IParticleEmitterType {
  18508. /**
  18509. * The radius of the emission sphere.
  18510. */
  18511. radius: number;
  18512. /**
  18513. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18514. */
  18515. radiusRange: number;
  18516. /**
  18517. * How much to randomize the particle direction [0-1].
  18518. */
  18519. directionRandomizer: number;
  18520. /**
  18521. * Creates a new instance SphereParticleEmitter
  18522. * @param radius the radius of the emission sphere (1 by default)
  18523. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18524. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18525. */
  18526. constructor(
  18527. /**
  18528. * The radius of the emission sphere.
  18529. */
  18530. radius?: number,
  18531. /**
  18532. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18533. */
  18534. radiusRange?: number,
  18535. /**
  18536. * How much to randomize the particle direction [0-1].
  18537. */
  18538. directionRandomizer?: number);
  18539. /**
  18540. * Called by the particle System when the direction is computed for the created particle.
  18541. * @param worldMatrix is the world matrix of the particle system
  18542. * @param directionToUpdate is the direction vector to update with the result
  18543. * @param particle is the particle we are computed the direction for
  18544. */
  18545. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18546. /**
  18547. * Called by the particle System when the position is computed for the created particle.
  18548. * @param worldMatrix is the world matrix of the particle system
  18549. * @param positionToUpdate is the position vector to update with the result
  18550. * @param particle is the particle we are computed the position for
  18551. */
  18552. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18553. /**
  18554. * Clones the current emitter and returns a copy of it
  18555. * @returns the new emitter
  18556. */
  18557. clone(): SphereParticleEmitter;
  18558. /**
  18559. * Called by the GPUParticleSystem to setup the update shader
  18560. * @param effect defines the update shader
  18561. */
  18562. applyToShader(effect: Effect): void;
  18563. /**
  18564. * Returns a string to use to update the GPU particles update shader
  18565. * @returns a string containng the defines string
  18566. */
  18567. getEffectDefines(): string;
  18568. /**
  18569. * Returns the string "SphereParticleEmitter"
  18570. * @returns a string containing the class name
  18571. */
  18572. getClassName(): string;
  18573. /**
  18574. * Serializes the particle system to a JSON object.
  18575. * @returns the JSON object
  18576. */
  18577. serialize(): any;
  18578. /**
  18579. * Parse properties from a JSON object
  18580. * @param serializationObject defines the JSON object
  18581. */
  18582. parse(serializationObject: any): void;
  18583. }
  18584. /**
  18585. * Particle emitter emitting particles from the inside of a sphere.
  18586. * It emits the particles randomly between two vectors.
  18587. */
  18588. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18589. /**
  18590. * The min limit of the emission direction.
  18591. */
  18592. direction1: Vector3;
  18593. /**
  18594. * The max limit of the emission direction.
  18595. */
  18596. direction2: Vector3;
  18597. /**
  18598. * Creates a new instance SphereDirectedParticleEmitter
  18599. * @param radius the radius of the emission sphere (1 by default)
  18600. * @param direction1 the min limit of the emission direction (up vector by default)
  18601. * @param direction2 the max limit of the emission direction (up vector by default)
  18602. */
  18603. constructor(radius?: number,
  18604. /**
  18605. * The min limit of the emission direction.
  18606. */
  18607. direction1?: Vector3,
  18608. /**
  18609. * The max limit of the emission direction.
  18610. */
  18611. direction2?: Vector3);
  18612. /**
  18613. * Called by the particle System when the direction is computed for the created particle.
  18614. * @param worldMatrix is the world matrix of the particle system
  18615. * @param directionToUpdate is the direction vector to update with the result
  18616. * @param particle is the particle we are computed the direction for
  18617. */
  18618. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18619. /**
  18620. * Clones the current emitter and returns a copy of it
  18621. * @returns the new emitter
  18622. */
  18623. clone(): SphereDirectedParticleEmitter;
  18624. /**
  18625. * Called by the GPUParticleSystem to setup the update shader
  18626. * @param effect defines the update shader
  18627. */
  18628. applyToShader(effect: Effect): void;
  18629. /**
  18630. * Returns a string to use to update the GPU particles update shader
  18631. * @returns a string containng the defines string
  18632. */
  18633. getEffectDefines(): string;
  18634. /**
  18635. * Returns the string "SphereDirectedParticleEmitter"
  18636. * @returns a string containing the class name
  18637. */
  18638. getClassName(): string;
  18639. /**
  18640. * Serializes the particle system to a JSON object.
  18641. * @returns the JSON object
  18642. */
  18643. serialize(): any;
  18644. /**
  18645. * Parse properties from a JSON object
  18646. * @param serializationObject defines the JSON object
  18647. */
  18648. parse(serializationObject: any): void;
  18649. }
  18650. }
  18651. declare module "babylonjs/Particles/EmitterTypes/index" {
  18652. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18653. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18654. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18655. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18656. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18657. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18658. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18659. }
  18660. declare module "babylonjs/Particles/IParticleSystem" {
  18661. import { Nullable } from "babylonjs/types";
  18662. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18663. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18665. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18666. import { Texture } from "babylonjs/Materials/Textures/texture";
  18667. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18668. import { Scene } from "babylonjs/scene";
  18669. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18670. import { Animation } from "babylonjs/Animations/animation";
  18671. /**
  18672. * Interface representing a particle system in Babylon.js.
  18673. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18674. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18675. */
  18676. export interface IParticleSystem {
  18677. /**
  18678. * List of animations used by the particle system.
  18679. */
  18680. animations: Animation[];
  18681. /**
  18682. * The id of the Particle system.
  18683. */
  18684. id: string;
  18685. /**
  18686. * The name of the Particle system.
  18687. */
  18688. name: string;
  18689. /**
  18690. * The emitter represents the Mesh or position we are attaching the particle system to.
  18691. */
  18692. emitter: Nullable<AbstractMesh | Vector3>;
  18693. /**
  18694. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18695. */
  18696. isBillboardBased: boolean;
  18697. /**
  18698. * The rendering group used by the Particle system to chose when to render.
  18699. */
  18700. renderingGroupId: number;
  18701. /**
  18702. * The layer mask we are rendering the particles through.
  18703. */
  18704. layerMask: number;
  18705. /**
  18706. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18707. */
  18708. updateSpeed: number;
  18709. /**
  18710. * The amount of time the particle system is running (depends of the overall update speed).
  18711. */
  18712. targetStopDuration: number;
  18713. /**
  18714. * The texture used to render each particle. (this can be a spritesheet)
  18715. */
  18716. particleTexture: Nullable<Texture>;
  18717. /**
  18718. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18719. */
  18720. blendMode: number;
  18721. /**
  18722. * Minimum life time of emitting particles.
  18723. */
  18724. minLifeTime: number;
  18725. /**
  18726. * Maximum life time of emitting particles.
  18727. */
  18728. maxLifeTime: number;
  18729. /**
  18730. * Minimum Size of emitting particles.
  18731. */
  18732. minSize: number;
  18733. /**
  18734. * Maximum Size of emitting particles.
  18735. */
  18736. maxSize: number;
  18737. /**
  18738. * Minimum scale of emitting particles on X axis.
  18739. */
  18740. minScaleX: number;
  18741. /**
  18742. * Maximum scale of emitting particles on X axis.
  18743. */
  18744. maxScaleX: number;
  18745. /**
  18746. * Minimum scale of emitting particles on Y axis.
  18747. */
  18748. minScaleY: number;
  18749. /**
  18750. * Maximum scale of emitting particles on Y axis.
  18751. */
  18752. maxScaleY: number;
  18753. /**
  18754. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18755. */
  18756. color1: Color4;
  18757. /**
  18758. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18759. */
  18760. color2: Color4;
  18761. /**
  18762. * Color the particle will have at the end of its lifetime.
  18763. */
  18764. colorDead: Color4;
  18765. /**
  18766. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18767. */
  18768. emitRate: number;
  18769. /**
  18770. * You can use gravity if you want to give an orientation to your particles.
  18771. */
  18772. gravity: Vector3;
  18773. /**
  18774. * Minimum power of emitting particles.
  18775. */
  18776. minEmitPower: number;
  18777. /**
  18778. * Maximum power of emitting particles.
  18779. */
  18780. maxEmitPower: number;
  18781. /**
  18782. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18783. */
  18784. minAngularSpeed: number;
  18785. /**
  18786. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18787. */
  18788. maxAngularSpeed: number;
  18789. /**
  18790. * Gets or sets the minimal initial rotation in radians.
  18791. */
  18792. minInitialRotation: number;
  18793. /**
  18794. * Gets or sets the maximal initial rotation in radians.
  18795. */
  18796. maxInitialRotation: number;
  18797. /**
  18798. * The particle emitter type defines the emitter used by the particle system.
  18799. * It can be for example box, sphere, or cone...
  18800. */
  18801. particleEmitterType: Nullable<IParticleEmitterType>;
  18802. /**
  18803. * Defines the delay in milliseconds before starting the system (0 by default)
  18804. */
  18805. startDelay: number;
  18806. /**
  18807. * 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
  18808. */
  18809. preWarmCycles: number;
  18810. /**
  18811. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18812. */
  18813. preWarmStepOffset: number;
  18814. /**
  18815. * 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)
  18816. */
  18817. spriteCellChangeSpeed: number;
  18818. /**
  18819. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18820. */
  18821. startSpriteCellID: number;
  18822. /**
  18823. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18824. */
  18825. endSpriteCellID: number;
  18826. /**
  18827. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18828. */
  18829. spriteCellWidth: number;
  18830. /**
  18831. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18832. */
  18833. spriteCellHeight: number;
  18834. /**
  18835. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18836. */
  18837. spriteRandomStartCell: boolean;
  18838. /**
  18839. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18840. */
  18841. isAnimationSheetEnabled: boolean;
  18842. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18843. translationPivot: Vector2;
  18844. /**
  18845. * Gets or sets a texture used to add random noise to particle positions
  18846. */
  18847. noiseTexture: Nullable<BaseTexture>;
  18848. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18849. noiseStrength: Vector3;
  18850. /**
  18851. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18852. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18853. */
  18854. billboardMode: number;
  18855. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18856. limitVelocityDamping: number;
  18857. /**
  18858. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18859. */
  18860. beginAnimationOnStart: boolean;
  18861. /**
  18862. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18863. */
  18864. beginAnimationFrom: number;
  18865. /**
  18866. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18867. */
  18868. beginAnimationTo: number;
  18869. /**
  18870. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18871. */
  18872. beginAnimationLoop: boolean;
  18873. /**
  18874. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18875. */
  18876. disposeOnStop: boolean;
  18877. /**
  18878. * Gets the maximum number of particles active at the same time.
  18879. * @returns The max number of active particles.
  18880. */
  18881. getCapacity(): number;
  18882. /**
  18883. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18884. * @returns True if it has been started, otherwise false.
  18885. */
  18886. isStarted(): boolean;
  18887. /**
  18888. * Animates the particle system for this frame.
  18889. */
  18890. animate(): void;
  18891. /**
  18892. * Renders the particle system in its current state.
  18893. * @returns the current number of particles
  18894. */
  18895. render(): number;
  18896. /**
  18897. * Dispose the particle system and frees its associated resources.
  18898. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18899. */
  18900. dispose(disposeTexture?: boolean): void;
  18901. /**
  18902. * Clones the particle system.
  18903. * @param name The name of the cloned object
  18904. * @param newEmitter The new emitter to use
  18905. * @returns the cloned particle system
  18906. */
  18907. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18908. /**
  18909. * Serializes the particle system to a JSON object.
  18910. * @returns the JSON object
  18911. */
  18912. serialize(): any;
  18913. /**
  18914. * Rebuild the particle system
  18915. */
  18916. rebuild(): void;
  18917. /**
  18918. * Starts the particle system and begins to emit
  18919. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18920. */
  18921. start(delay?: number): void;
  18922. /**
  18923. * Stops the particle system.
  18924. */
  18925. stop(): void;
  18926. /**
  18927. * Remove all active particles
  18928. */
  18929. reset(): void;
  18930. /**
  18931. * Is this system ready to be used/rendered
  18932. * @return true if the system is ready
  18933. */
  18934. isReady(): boolean;
  18935. /**
  18936. * Adds a new color gradient
  18937. * @param gradient defines the gradient to use (between 0 and 1)
  18938. * @param color1 defines the color to affect to the specified gradient
  18939. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18940. * @returns the current particle system
  18941. */
  18942. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18943. /**
  18944. * Remove a specific color gradient
  18945. * @param gradient defines the gradient to remove
  18946. * @returns the current particle system
  18947. */
  18948. removeColorGradient(gradient: number): IParticleSystem;
  18949. /**
  18950. * Adds a new size gradient
  18951. * @param gradient defines the gradient to use (between 0 and 1)
  18952. * @param factor defines the size factor to affect to the specified gradient
  18953. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18954. * @returns the current particle system
  18955. */
  18956. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18957. /**
  18958. * Remove a specific size gradient
  18959. * @param gradient defines the gradient to remove
  18960. * @returns the current particle system
  18961. */
  18962. removeSizeGradient(gradient: number): IParticleSystem;
  18963. /**
  18964. * Gets the current list of color gradients.
  18965. * You must use addColorGradient and removeColorGradient to udpate this list
  18966. * @returns the list of color gradients
  18967. */
  18968. getColorGradients(): Nullable<Array<ColorGradient>>;
  18969. /**
  18970. * Gets the current list of size gradients.
  18971. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18972. * @returns the list of size gradients
  18973. */
  18974. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18975. /**
  18976. * Gets the current list of angular speed gradients.
  18977. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18978. * @returns the list of angular speed gradients
  18979. */
  18980. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18981. /**
  18982. * Adds a new angular speed gradient
  18983. * @param gradient defines the gradient to use (between 0 and 1)
  18984. * @param factor defines the angular speed to affect to the specified gradient
  18985. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18986. * @returns the current particle system
  18987. */
  18988. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18989. /**
  18990. * Remove a specific angular speed gradient
  18991. * @param gradient defines the gradient to remove
  18992. * @returns the current particle system
  18993. */
  18994. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18995. /**
  18996. * Gets the current list of velocity gradients.
  18997. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18998. * @returns the list of velocity gradients
  18999. */
  19000. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19001. /**
  19002. * Adds a new velocity gradient
  19003. * @param gradient defines the gradient to use (between 0 and 1)
  19004. * @param factor defines the velocity to affect to the specified gradient
  19005. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19006. * @returns the current particle system
  19007. */
  19008. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19009. /**
  19010. * Remove a specific velocity gradient
  19011. * @param gradient defines the gradient to remove
  19012. * @returns the current particle system
  19013. */
  19014. removeVelocityGradient(gradient: number): IParticleSystem;
  19015. /**
  19016. * Gets the current list of limit velocity gradients.
  19017. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19018. * @returns the list of limit velocity gradients
  19019. */
  19020. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19021. /**
  19022. * Adds a new limit velocity gradient
  19023. * @param gradient defines the gradient to use (between 0 and 1)
  19024. * @param factor defines the limit velocity to affect to the specified gradient
  19025. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19026. * @returns the current particle system
  19027. */
  19028. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19029. /**
  19030. * Remove a specific limit velocity gradient
  19031. * @param gradient defines the gradient to remove
  19032. * @returns the current particle system
  19033. */
  19034. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19035. /**
  19036. * Adds a new drag gradient
  19037. * @param gradient defines the gradient to use (between 0 and 1)
  19038. * @param factor defines the drag to affect to the specified gradient
  19039. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19040. * @returns the current particle system
  19041. */
  19042. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19043. /**
  19044. * Remove a specific drag gradient
  19045. * @param gradient defines the gradient to remove
  19046. * @returns the current particle system
  19047. */
  19048. removeDragGradient(gradient: number): IParticleSystem;
  19049. /**
  19050. * Gets the current list of drag gradients.
  19051. * You must use addDragGradient and removeDragGradient to udpate this list
  19052. * @returns the list of drag gradients
  19053. */
  19054. getDragGradients(): Nullable<Array<FactorGradient>>;
  19055. /**
  19056. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19057. * @param gradient defines the gradient to use (between 0 and 1)
  19058. * @param factor defines the emit rate to affect to the specified gradient
  19059. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19060. * @returns the current particle system
  19061. */
  19062. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19063. /**
  19064. * Remove a specific emit rate gradient
  19065. * @param gradient defines the gradient to remove
  19066. * @returns the current particle system
  19067. */
  19068. removeEmitRateGradient(gradient: number): IParticleSystem;
  19069. /**
  19070. * Gets the current list of emit rate gradients.
  19071. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19072. * @returns the list of emit rate gradients
  19073. */
  19074. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19075. /**
  19076. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19077. * @param gradient defines the gradient to use (between 0 and 1)
  19078. * @param factor defines the start size to affect to the specified gradient
  19079. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19080. * @returns the current particle system
  19081. */
  19082. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19083. /**
  19084. * Remove a specific start size gradient
  19085. * @param gradient defines the gradient to remove
  19086. * @returns the current particle system
  19087. */
  19088. removeStartSizeGradient(gradient: number): IParticleSystem;
  19089. /**
  19090. * Gets the current list of start size gradients.
  19091. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19092. * @returns the list of start size gradients
  19093. */
  19094. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19095. /**
  19096. * Adds a new life time gradient
  19097. * @param gradient defines the gradient to use (between 0 and 1)
  19098. * @param factor defines the life time factor to affect to the specified gradient
  19099. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19100. * @returns the current particle system
  19101. */
  19102. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19103. /**
  19104. * Remove a specific life time gradient
  19105. * @param gradient defines the gradient to remove
  19106. * @returns the current particle system
  19107. */
  19108. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19109. /**
  19110. * Gets the current list of life time gradients.
  19111. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19112. * @returns the list of life time gradients
  19113. */
  19114. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19115. /**
  19116. * Gets the current list of color gradients.
  19117. * You must use addColorGradient and removeColorGradient to udpate this list
  19118. * @returns the list of color gradients
  19119. */
  19120. getColorGradients(): Nullable<Array<ColorGradient>>;
  19121. /**
  19122. * Adds a new ramp gradient used to remap particle colors
  19123. * @param gradient defines the gradient to use (between 0 and 1)
  19124. * @param color defines the color to affect to the specified gradient
  19125. * @returns the current particle system
  19126. */
  19127. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19128. /**
  19129. * Gets the current list of ramp gradients.
  19130. * You must use addRampGradient and removeRampGradient to udpate this list
  19131. * @returns the list of ramp gradients
  19132. */
  19133. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19134. /** Gets or sets a boolean indicating that ramp gradients must be used
  19135. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19136. */
  19137. useRampGradients: boolean;
  19138. /**
  19139. * Adds a new color remap gradient
  19140. * @param gradient defines the gradient to use (between 0 and 1)
  19141. * @param min defines the color remap minimal range
  19142. * @param max defines the color remap maximal range
  19143. * @returns the current particle system
  19144. */
  19145. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19146. /**
  19147. * Gets the current list of color remap gradients.
  19148. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19149. * @returns the list of color remap gradients
  19150. */
  19151. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19152. /**
  19153. * Adds a new alpha remap gradient
  19154. * @param gradient defines the gradient to use (between 0 and 1)
  19155. * @param min defines the alpha remap minimal range
  19156. * @param max defines the alpha remap maximal range
  19157. * @returns the current particle system
  19158. */
  19159. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19160. /**
  19161. * Gets the current list of alpha remap gradients.
  19162. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19163. * @returns the list of alpha remap gradients
  19164. */
  19165. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19166. /**
  19167. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19168. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19169. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19170. * @returns the emitter
  19171. */
  19172. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19173. /**
  19174. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19175. * @param radius The radius of the hemisphere to emit from
  19176. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19177. * @returns the emitter
  19178. */
  19179. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19180. /**
  19181. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19182. * @param radius The radius of the sphere to emit from
  19183. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19184. * @returns the emitter
  19185. */
  19186. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19187. /**
  19188. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19189. * @param radius The radius of the sphere to emit from
  19190. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19191. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19192. * @returns the emitter
  19193. */
  19194. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19195. /**
  19196. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19197. * @param radius The radius of the emission cylinder
  19198. * @param height The height of the emission cylinder
  19199. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19200. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19201. * @returns the emitter
  19202. */
  19203. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19204. /**
  19205. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19206. * @param radius The radius of the cylinder to emit from
  19207. * @param height The height of the emission cylinder
  19208. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19209. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19210. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19211. * @returns the emitter
  19212. */
  19213. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19214. /**
  19215. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19216. * @param radius The radius of the cone to emit from
  19217. * @param angle The base angle of the cone
  19218. * @returns the emitter
  19219. */
  19220. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19221. /**
  19222. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19223. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19224. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19225. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19226. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19227. * @returns the emitter
  19228. */
  19229. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19230. /**
  19231. * Get hosting scene
  19232. * @returns the scene
  19233. */
  19234. getScene(): Scene;
  19235. }
  19236. }
  19237. declare module "babylonjs/Materials/shaderMaterial" {
  19238. import { Scene } from "babylonjs/scene";
  19239. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19241. import { Mesh } from "babylonjs/Meshes/mesh";
  19242. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19244. import { Texture } from "babylonjs/Materials/Textures/texture";
  19245. import { Material } from "babylonjs/Materials/material";
  19246. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19247. /**
  19248. * Defines the options associated with the creation of a shader material.
  19249. */
  19250. export interface IShaderMaterialOptions {
  19251. /**
  19252. * Does the material work in alpha blend mode
  19253. */
  19254. needAlphaBlending: boolean;
  19255. /**
  19256. * Does the material work in alpha test mode
  19257. */
  19258. needAlphaTesting: boolean;
  19259. /**
  19260. * The list of attribute names used in the shader
  19261. */
  19262. attributes: string[];
  19263. /**
  19264. * The list of unifrom names used in the shader
  19265. */
  19266. uniforms: string[];
  19267. /**
  19268. * The list of UBO names used in the shader
  19269. */
  19270. uniformBuffers: string[];
  19271. /**
  19272. * The list of sampler names used in the shader
  19273. */
  19274. samplers: string[];
  19275. /**
  19276. * The list of defines used in the shader
  19277. */
  19278. defines: string[];
  19279. }
  19280. /**
  19281. * 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.
  19282. *
  19283. * This returned material effects how the mesh will look based on the code in the shaders.
  19284. *
  19285. * @see http://doc.babylonjs.com/how_to/shader_material
  19286. */
  19287. export class ShaderMaterial extends Material {
  19288. private _shaderPath;
  19289. private _options;
  19290. private _textures;
  19291. private _textureArrays;
  19292. private _floats;
  19293. private _ints;
  19294. private _floatsArrays;
  19295. private _colors3;
  19296. private _colors3Arrays;
  19297. private _colors4;
  19298. private _colors4Arrays;
  19299. private _vectors2;
  19300. private _vectors3;
  19301. private _vectors4;
  19302. private _matrices;
  19303. private _matrices3x3;
  19304. private _matrices2x2;
  19305. private _vectors2Arrays;
  19306. private _vectors3Arrays;
  19307. private _vectors4Arrays;
  19308. private _cachedWorldViewMatrix;
  19309. private _cachedWorldViewProjectionMatrix;
  19310. private _renderId;
  19311. /**
  19312. * Instantiate a new shader material.
  19313. * 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.
  19314. * This returned material effects how the mesh will look based on the code in the shaders.
  19315. * @see http://doc.babylonjs.com/how_to/shader_material
  19316. * @param name Define the name of the material in the scene
  19317. * @param scene Define the scene the material belongs to
  19318. * @param shaderPath Defines the route to the shader code in one of three ways:
  19319. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19320. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19321. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19322. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19323. * @param options Define the options used to create the shader
  19324. */
  19325. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19326. /**
  19327. * Gets the options used to compile the shader.
  19328. * They can be modified to trigger a new compilation
  19329. */
  19330. readonly options: IShaderMaterialOptions;
  19331. /**
  19332. * Gets the current class name of the material e.g. "ShaderMaterial"
  19333. * Mainly use in serialization.
  19334. * @returns the class name
  19335. */
  19336. getClassName(): string;
  19337. /**
  19338. * Specifies if the material will require alpha blending
  19339. * @returns a boolean specifying if alpha blending is needed
  19340. */
  19341. needAlphaBlending(): boolean;
  19342. /**
  19343. * Specifies if this material should be rendered in alpha test mode
  19344. * @returns a boolean specifying if an alpha test is needed.
  19345. */
  19346. needAlphaTesting(): boolean;
  19347. private _checkUniform;
  19348. /**
  19349. * Set a texture in the shader.
  19350. * @param name Define the name of the uniform samplers as defined in the shader
  19351. * @param texture Define the texture to bind to this sampler
  19352. * @return the material itself allowing "fluent" like uniform updates
  19353. */
  19354. setTexture(name: string, texture: Texture): ShaderMaterial;
  19355. /**
  19356. * Set a texture array in the shader.
  19357. * @param name Define the name of the uniform sampler array as defined in the shader
  19358. * @param textures Define the list of textures to bind to this sampler
  19359. * @return the material itself allowing "fluent" like uniform updates
  19360. */
  19361. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19362. /**
  19363. * Set a float in the shader.
  19364. * @param name Define the name of the uniform as defined in the shader
  19365. * @param value Define the value to give to the uniform
  19366. * @return the material itself allowing "fluent" like uniform updates
  19367. */
  19368. setFloat(name: string, value: number): ShaderMaterial;
  19369. /**
  19370. * Set a int in the shader.
  19371. * @param name Define the name of the uniform as defined in the shader
  19372. * @param value Define the value to give to the uniform
  19373. * @return the material itself allowing "fluent" like uniform updates
  19374. */
  19375. setInt(name: string, value: number): ShaderMaterial;
  19376. /**
  19377. * Set an array of floats in the shader.
  19378. * @param name Define the name of the uniform as defined in the shader
  19379. * @param value Define the value to give to the uniform
  19380. * @return the material itself allowing "fluent" like uniform updates
  19381. */
  19382. setFloats(name: string, value: number[]): ShaderMaterial;
  19383. /**
  19384. * Set a vec3 in the shader from a Color3.
  19385. * @param name Define the name of the uniform as defined in the shader
  19386. * @param value Define the value to give to the uniform
  19387. * @return the material itself allowing "fluent" like uniform updates
  19388. */
  19389. setColor3(name: string, value: Color3): ShaderMaterial;
  19390. /**
  19391. * Set a vec3 array in the shader from a Color3 array.
  19392. * @param name Define the name of the uniform as defined in the shader
  19393. * @param value Define the value to give to the uniform
  19394. * @return the material itself allowing "fluent" like uniform updates
  19395. */
  19396. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19397. /**
  19398. * Set a vec4 in the shader from a Color4.
  19399. * @param name Define the name of the uniform as defined in the shader
  19400. * @param value Define the value to give to the uniform
  19401. * @return the material itself allowing "fluent" like uniform updates
  19402. */
  19403. setColor4(name: string, value: Color4): ShaderMaterial;
  19404. /**
  19405. * Set a vec4 array in the shader from a Color4 array.
  19406. * @param name Define the name of the uniform as defined in the shader
  19407. * @param value Define the value to give to the uniform
  19408. * @return the material itself allowing "fluent" like uniform updates
  19409. */
  19410. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19411. /**
  19412. * Set a vec2 in the shader from a Vector2.
  19413. * @param name Define the name of the uniform as defined in the shader
  19414. * @param value Define the value to give to the uniform
  19415. * @return the material itself allowing "fluent" like uniform updates
  19416. */
  19417. setVector2(name: string, value: Vector2): ShaderMaterial;
  19418. /**
  19419. * Set a vec3 in the shader from a Vector3.
  19420. * @param name Define the name of the uniform as defined in the shader
  19421. * @param value Define the value to give to the uniform
  19422. * @return the material itself allowing "fluent" like uniform updates
  19423. */
  19424. setVector3(name: string, value: Vector3): ShaderMaterial;
  19425. /**
  19426. * Set a vec4 in the shader from a Vector4.
  19427. * @param name Define the name of the uniform as defined in the shader
  19428. * @param value Define the value to give to the uniform
  19429. * @return the material itself allowing "fluent" like uniform updates
  19430. */
  19431. setVector4(name: string, value: Vector4): ShaderMaterial;
  19432. /**
  19433. * Set a mat4 in the shader from a Matrix.
  19434. * @param name Define the name of the uniform as defined in the shader
  19435. * @param value Define the value to give to the uniform
  19436. * @return the material itself allowing "fluent" like uniform updates
  19437. */
  19438. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19439. /**
  19440. * Set a mat3 in the shader from a Float32Array.
  19441. * @param name Define the name of the uniform as defined in the shader
  19442. * @param value Define the value to give to the uniform
  19443. * @return the material itself allowing "fluent" like uniform updates
  19444. */
  19445. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19446. /**
  19447. * Set a mat2 in the shader from a Float32Array.
  19448. * @param name Define the name of the uniform as defined in the shader
  19449. * @param value Define the value to give to the uniform
  19450. * @return the material itself allowing "fluent" like uniform updates
  19451. */
  19452. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19453. /**
  19454. * Set a vec2 array in the shader from a number array.
  19455. * @param name Define the name of the uniform as defined in the shader
  19456. * @param value Define the value to give to the uniform
  19457. * @return the material itself allowing "fluent" like uniform updates
  19458. */
  19459. setArray2(name: string, value: number[]): ShaderMaterial;
  19460. /**
  19461. * Set a vec3 array in the shader from a number array.
  19462. * @param name Define the name of the uniform as defined in the shader
  19463. * @param value Define the value to give to the uniform
  19464. * @return the material itself allowing "fluent" like uniform updates
  19465. */
  19466. setArray3(name: string, value: number[]): ShaderMaterial;
  19467. /**
  19468. * Set a vec4 array in the shader from a number array.
  19469. * @param name Define the name of the uniform as defined in the shader
  19470. * @param value Define the value to give to the uniform
  19471. * @return the material itself allowing "fluent" like uniform updates
  19472. */
  19473. setArray4(name: string, value: number[]): ShaderMaterial;
  19474. private _checkCache;
  19475. /**
  19476. * Specifies that the submesh is ready to be used
  19477. * @param mesh defines the mesh to check
  19478. * @param subMesh defines which submesh to check
  19479. * @param useInstances specifies that instances should be used
  19480. * @returns a boolean indicating that the submesh is ready or not
  19481. */
  19482. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19483. /**
  19484. * Checks if the material is ready to render the requested mesh
  19485. * @param mesh Define the mesh to render
  19486. * @param useInstances Define whether or not the material is used with instances
  19487. * @returns true if ready, otherwise false
  19488. */
  19489. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19490. /**
  19491. * Binds the world matrix to the material
  19492. * @param world defines the world transformation matrix
  19493. */
  19494. bindOnlyWorldMatrix(world: Matrix): void;
  19495. /**
  19496. * Binds the material to the mesh
  19497. * @param world defines the world transformation matrix
  19498. * @param mesh defines the mesh to bind the material to
  19499. */
  19500. bind(world: Matrix, mesh?: Mesh): void;
  19501. /**
  19502. * Gets the active textures from the material
  19503. * @returns an array of textures
  19504. */
  19505. getActiveTextures(): BaseTexture[];
  19506. /**
  19507. * Specifies if the material uses a texture
  19508. * @param texture defines the texture to check against the material
  19509. * @returns a boolean specifying if the material uses the texture
  19510. */
  19511. hasTexture(texture: BaseTexture): boolean;
  19512. /**
  19513. * Makes a duplicate of the material, and gives it a new name
  19514. * @param name defines the new name for the duplicated material
  19515. * @returns the cloned material
  19516. */
  19517. clone(name: string): ShaderMaterial;
  19518. /**
  19519. * Disposes the material
  19520. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19521. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19522. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19523. */
  19524. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19525. /**
  19526. * Serializes this material in a JSON representation
  19527. * @returns the serialized material object
  19528. */
  19529. serialize(): any;
  19530. /**
  19531. * Creates a shader material from parsed shader material data
  19532. * @param source defines the JSON represnetation of the material
  19533. * @param scene defines the hosting scene
  19534. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19535. * @returns a new material
  19536. */
  19537. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19538. }
  19539. }
  19540. declare module "babylonjs/Shaders/color.fragment" {
  19541. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19542. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19543. /** @hidden */
  19544. export var colorPixelShader: {
  19545. name: string;
  19546. shader: string;
  19547. };
  19548. }
  19549. declare module "babylonjs/Shaders/color.vertex" {
  19550. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19551. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19552. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19553. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19554. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19555. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19556. /** @hidden */
  19557. export var colorVertexShader: {
  19558. name: string;
  19559. shader: string;
  19560. };
  19561. }
  19562. declare module "babylonjs/Meshes/linesMesh" {
  19563. import { Nullable } from "babylonjs/types";
  19564. import { Scene } from "babylonjs/scene";
  19565. import { Color3 } from "babylonjs/Maths/math.color";
  19566. import { Node } from "babylonjs/node";
  19567. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19568. import { Mesh } from "babylonjs/Meshes/mesh";
  19569. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19570. import { Effect } from "babylonjs/Materials/effect";
  19571. import { Material } from "babylonjs/Materials/material";
  19572. import "babylonjs/Shaders/color.fragment";
  19573. import "babylonjs/Shaders/color.vertex";
  19574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19575. /**
  19576. * Line mesh
  19577. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19578. */
  19579. export class LinesMesh extends Mesh {
  19580. /**
  19581. * If vertex color should be applied to the mesh
  19582. */
  19583. readonly useVertexColor?: boolean | undefined;
  19584. /**
  19585. * If vertex alpha should be applied to the mesh
  19586. */
  19587. readonly useVertexAlpha?: boolean | undefined;
  19588. /**
  19589. * Color of the line (Default: White)
  19590. */
  19591. color: Color3;
  19592. /**
  19593. * Alpha of the line (Default: 1)
  19594. */
  19595. alpha: number;
  19596. /**
  19597. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19598. * This margin is expressed in world space coordinates, so its value may vary.
  19599. * Default value is 0.1
  19600. */
  19601. intersectionThreshold: number;
  19602. private _colorShader;
  19603. private color4;
  19604. /**
  19605. * Creates a new LinesMesh
  19606. * @param name defines the name
  19607. * @param scene defines the hosting scene
  19608. * @param parent defines the parent mesh if any
  19609. * @param source defines the optional source LinesMesh used to clone data from
  19610. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19611. * When false, achieved by calling a clone(), also passing False.
  19612. * This will make creation of children, recursive.
  19613. * @param useVertexColor defines if this LinesMesh supports vertex color
  19614. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19615. */
  19616. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19617. /**
  19618. * If vertex color should be applied to the mesh
  19619. */
  19620. useVertexColor?: boolean | undefined,
  19621. /**
  19622. * If vertex alpha should be applied to the mesh
  19623. */
  19624. useVertexAlpha?: boolean | undefined);
  19625. private _addClipPlaneDefine;
  19626. private _removeClipPlaneDefine;
  19627. isReady(): boolean;
  19628. /**
  19629. * Returns the string "LineMesh"
  19630. */
  19631. getClassName(): string;
  19632. /**
  19633. * @hidden
  19634. */
  19635. /**
  19636. * @hidden
  19637. */
  19638. material: Material;
  19639. /**
  19640. * @hidden
  19641. */
  19642. readonly checkCollisions: boolean;
  19643. /** @hidden */
  19644. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19645. /** @hidden */
  19646. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19647. /**
  19648. * Disposes of the line mesh
  19649. * @param doNotRecurse If children should be disposed
  19650. */
  19651. dispose(doNotRecurse?: boolean): void;
  19652. /**
  19653. * Returns a new LineMesh object cloned from the current one.
  19654. */
  19655. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19656. /**
  19657. * Creates a new InstancedLinesMesh object from the mesh model.
  19658. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19659. * @param name defines the name of the new instance
  19660. * @returns a new InstancedLinesMesh
  19661. */
  19662. createInstance(name: string): InstancedLinesMesh;
  19663. }
  19664. /**
  19665. * Creates an instance based on a source LinesMesh
  19666. */
  19667. export class InstancedLinesMesh extends InstancedMesh {
  19668. /**
  19669. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19670. * This margin is expressed in world space coordinates, so its value may vary.
  19671. * Initilized with the intersectionThreshold value of the source LinesMesh
  19672. */
  19673. intersectionThreshold: number;
  19674. constructor(name: string, source: LinesMesh);
  19675. /**
  19676. * Returns the string "InstancedLinesMesh".
  19677. */
  19678. getClassName(): string;
  19679. }
  19680. }
  19681. declare module "babylonjs/Shaders/line.fragment" {
  19682. /** @hidden */
  19683. export var linePixelShader: {
  19684. name: string;
  19685. shader: string;
  19686. };
  19687. }
  19688. declare module "babylonjs/Shaders/line.vertex" {
  19689. /** @hidden */
  19690. export var lineVertexShader: {
  19691. name: string;
  19692. shader: string;
  19693. };
  19694. }
  19695. declare module "babylonjs/Rendering/edgesRenderer" {
  19696. import { Nullable } from "babylonjs/types";
  19697. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19699. import { Vector3 } from "babylonjs/Maths/math.vector";
  19700. import { IDisposable } from "babylonjs/scene";
  19701. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19702. import "babylonjs/Shaders/line.fragment";
  19703. import "babylonjs/Shaders/line.vertex";
  19704. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19705. module "babylonjs/Meshes/abstractMesh" {
  19706. interface AbstractMesh {
  19707. /**
  19708. * Gets the edgesRenderer associated with the mesh
  19709. */
  19710. edgesRenderer: Nullable<EdgesRenderer>;
  19711. }
  19712. }
  19713. module "babylonjs/Meshes/linesMesh" {
  19714. interface LinesMesh {
  19715. /**
  19716. * Enables the edge rendering mode on the mesh.
  19717. * This mode makes the mesh edges visible
  19718. * @param epsilon defines the maximal distance between two angles to detect a face
  19719. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19720. * @returns the currentAbstractMesh
  19721. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19722. */
  19723. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19724. }
  19725. }
  19726. module "babylonjs/Meshes/linesMesh" {
  19727. interface InstancedLinesMesh {
  19728. /**
  19729. * Enables the edge rendering mode on the mesh.
  19730. * This mode makes the mesh edges visible
  19731. * @param epsilon defines the maximal distance between two angles to detect a face
  19732. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19733. * @returns the current InstancedLinesMesh
  19734. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19735. */
  19736. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19737. }
  19738. }
  19739. /**
  19740. * Defines the minimum contract an Edges renderer should follow.
  19741. */
  19742. export interface IEdgesRenderer extends IDisposable {
  19743. /**
  19744. * Gets or sets a boolean indicating if the edgesRenderer is active
  19745. */
  19746. isEnabled: boolean;
  19747. /**
  19748. * Renders the edges of the attached mesh,
  19749. */
  19750. render(): void;
  19751. /**
  19752. * Checks wether or not the edges renderer is ready to render.
  19753. * @return true if ready, otherwise false.
  19754. */
  19755. isReady(): boolean;
  19756. }
  19757. /**
  19758. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19759. */
  19760. export class EdgesRenderer implements IEdgesRenderer {
  19761. /**
  19762. * Define the size of the edges with an orthographic camera
  19763. */
  19764. edgesWidthScalerForOrthographic: number;
  19765. /**
  19766. * Define the size of the edges with a perspective camera
  19767. */
  19768. edgesWidthScalerForPerspective: number;
  19769. protected _source: AbstractMesh;
  19770. protected _linesPositions: number[];
  19771. protected _linesNormals: number[];
  19772. protected _linesIndices: number[];
  19773. protected _epsilon: number;
  19774. protected _indicesCount: number;
  19775. protected _lineShader: ShaderMaterial;
  19776. protected _ib: DataBuffer;
  19777. protected _buffers: {
  19778. [key: string]: Nullable<VertexBuffer>;
  19779. };
  19780. protected _checkVerticesInsteadOfIndices: boolean;
  19781. private _meshRebuildObserver;
  19782. private _meshDisposeObserver;
  19783. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19784. isEnabled: boolean;
  19785. /**
  19786. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19787. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19788. * @param source Mesh used to create edges
  19789. * @param epsilon sum of angles in adjacency to check for edge
  19790. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19791. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19792. */
  19793. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19794. protected _prepareRessources(): void;
  19795. /** @hidden */
  19796. _rebuild(): void;
  19797. /**
  19798. * Releases the required resources for the edges renderer
  19799. */
  19800. dispose(): void;
  19801. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19802. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19803. /**
  19804. * Checks if the pair of p0 and p1 is en edge
  19805. * @param faceIndex
  19806. * @param edge
  19807. * @param faceNormals
  19808. * @param p0
  19809. * @param p1
  19810. * @private
  19811. */
  19812. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19813. /**
  19814. * push line into the position, normal and index buffer
  19815. * @protected
  19816. */
  19817. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19818. /**
  19819. * Generates lines edges from adjacencjes
  19820. * @private
  19821. */
  19822. _generateEdgesLines(): void;
  19823. /**
  19824. * Checks wether or not the edges renderer is ready to render.
  19825. * @return true if ready, otherwise false.
  19826. */
  19827. isReady(): boolean;
  19828. /**
  19829. * Renders the edges of the attached mesh,
  19830. */
  19831. render(): void;
  19832. }
  19833. /**
  19834. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19835. */
  19836. export class LineEdgesRenderer extends EdgesRenderer {
  19837. /**
  19838. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19839. * @param source LineMesh used to generate edges
  19840. * @param epsilon not important (specified angle for edge detection)
  19841. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19842. */
  19843. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19844. /**
  19845. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19846. */
  19847. _generateEdgesLines(): void;
  19848. }
  19849. }
  19850. declare module "babylonjs/Rendering/renderingGroup" {
  19851. import { SmartArray } from "babylonjs/Misc/smartArray";
  19852. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19854. import { Nullable } from "babylonjs/types";
  19855. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19856. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19857. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19858. import { Material } from "babylonjs/Materials/material";
  19859. import { Scene } from "babylonjs/scene";
  19860. /**
  19861. * This represents the object necessary to create a rendering group.
  19862. * This is exclusively used and created by the rendering manager.
  19863. * To modify the behavior, you use the available helpers in your scene or meshes.
  19864. * @hidden
  19865. */
  19866. export class RenderingGroup {
  19867. index: number;
  19868. private static _zeroVector;
  19869. private _scene;
  19870. private _opaqueSubMeshes;
  19871. private _transparentSubMeshes;
  19872. private _alphaTestSubMeshes;
  19873. private _depthOnlySubMeshes;
  19874. private _particleSystems;
  19875. private _spriteManagers;
  19876. private _opaqueSortCompareFn;
  19877. private _alphaTestSortCompareFn;
  19878. private _transparentSortCompareFn;
  19879. private _renderOpaque;
  19880. private _renderAlphaTest;
  19881. private _renderTransparent;
  19882. /** @hidden */
  19883. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19884. onBeforeTransparentRendering: () => void;
  19885. /**
  19886. * Set the opaque sort comparison function.
  19887. * If null the sub meshes will be render in the order they were created
  19888. */
  19889. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19890. /**
  19891. * Set the alpha test sort comparison function.
  19892. * If null the sub meshes will be render in the order they were created
  19893. */
  19894. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19895. /**
  19896. * Set the transparent sort comparison function.
  19897. * If null the sub meshes will be render in the order they were created
  19898. */
  19899. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19900. /**
  19901. * Creates a new rendering group.
  19902. * @param index The rendering group index
  19903. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19904. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19905. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19906. */
  19907. 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>);
  19908. /**
  19909. * Render all the sub meshes contained in the group.
  19910. * @param customRenderFunction Used to override the default render behaviour of the group.
  19911. * @returns true if rendered some submeshes.
  19912. */
  19913. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19914. /**
  19915. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19916. * @param subMeshes The submeshes to render
  19917. */
  19918. private renderOpaqueSorted;
  19919. /**
  19920. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19921. * @param subMeshes The submeshes to render
  19922. */
  19923. private renderAlphaTestSorted;
  19924. /**
  19925. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19926. * @param subMeshes The submeshes to render
  19927. */
  19928. private renderTransparentSorted;
  19929. /**
  19930. * Renders the submeshes in a specified order.
  19931. * @param subMeshes The submeshes to sort before render
  19932. * @param sortCompareFn The comparison function use to sort
  19933. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19934. * @param transparent Specifies to activate blending if true
  19935. */
  19936. private static renderSorted;
  19937. /**
  19938. * Renders the submeshes in the order they were dispatched (no sort applied).
  19939. * @param subMeshes The submeshes to render
  19940. */
  19941. private static renderUnsorted;
  19942. /**
  19943. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19944. * are rendered back to front if in the same alpha index.
  19945. *
  19946. * @param a The first submesh
  19947. * @param b The second submesh
  19948. * @returns The result of the comparison
  19949. */
  19950. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19951. /**
  19952. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19953. * are rendered back to front.
  19954. *
  19955. * @param a The first submesh
  19956. * @param b The second submesh
  19957. * @returns The result of the comparison
  19958. */
  19959. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19960. /**
  19961. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19962. * are rendered front to back (prevent overdraw).
  19963. *
  19964. * @param a The first submesh
  19965. * @param b The second submesh
  19966. * @returns The result of the comparison
  19967. */
  19968. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19969. /**
  19970. * Resets the different lists of submeshes to prepare a new frame.
  19971. */
  19972. prepare(): void;
  19973. dispose(): void;
  19974. /**
  19975. * Inserts the submesh in its correct queue depending on its material.
  19976. * @param subMesh The submesh to dispatch
  19977. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19978. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19979. */
  19980. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19981. dispatchSprites(spriteManager: ISpriteManager): void;
  19982. dispatchParticles(particleSystem: IParticleSystem): void;
  19983. private _renderParticles;
  19984. private _renderSprites;
  19985. }
  19986. }
  19987. declare module "babylonjs/Rendering/renderingManager" {
  19988. import { Nullable } from "babylonjs/types";
  19989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19990. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19991. import { SmartArray } from "babylonjs/Misc/smartArray";
  19992. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19993. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19994. import { Material } from "babylonjs/Materials/material";
  19995. import { Scene } from "babylonjs/scene";
  19996. import { Camera } from "babylonjs/Cameras/camera";
  19997. /**
  19998. * Interface describing the different options available in the rendering manager
  19999. * regarding Auto Clear between groups.
  20000. */
  20001. export interface IRenderingManagerAutoClearSetup {
  20002. /**
  20003. * Defines whether or not autoclear is enable.
  20004. */
  20005. autoClear: boolean;
  20006. /**
  20007. * Defines whether or not to autoclear the depth buffer.
  20008. */
  20009. depth: boolean;
  20010. /**
  20011. * Defines whether or not to autoclear the stencil buffer.
  20012. */
  20013. stencil: boolean;
  20014. }
  20015. /**
  20016. * This class is used by the onRenderingGroupObservable
  20017. */
  20018. export class RenderingGroupInfo {
  20019. /**
  20020. * The Scene that being rendered
  20021. */
  20022. scene: Scene;
  20023. /**
  20024. * The camera currently used for the rendering pass
  20025. */
  20026. camera: Nullable<Camera>;
  20027. /**
  20028. * The ID of the renderingGroup being processed
  20029. */
  20030. renderingGroupId: number;
  20031. }
  20032. /**
  20033. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20034. * It is enable to manage the different groups as well as the different necessary sort functions.
  20035. * This should not be used directly aside of the few static configurations
  20036. */
  20037. export class RenderingManager {
  20038. /**
  20039. * The max id used for rendering groups (not included)
  20040. */
  20041. static MAX_RENDERINGGROUPS: number;
  20042. /**
  20043. * The min id used for rendering groups (included)
  20044. */
  20045. static MIN_RENDERINGGROUPS: number;
  20046. /**
  20047. * Used to globally prevent autoclearing scenes.
  20048. */
  20049. static AUTOCLEAR: boolean;
  20050. /**
  20051. * @hidden
  20052. */
  20053. _useSceneAutoClearSetup: boolean;
  20054. private _scene;
  20055. private _renderingGroups;
  20056. private _depthStencilBufferAlreadyCleaned;
  20057. private _autoClearDepthStencil;
  20058. private _customOpaqueSortCompareFn;
  20059. private _customAlphaTestSortCompareFn;
  20060. private _customTransparentSortCompareFn;
  20061. private _renderingGroupInfo;
  20062. /**
  20063. * Instantiates a new rendering group for a particular scene
  20064. * @param scene Defines the scene the groups belongs to
  20065. */
  20066. constructor(scene: Scene);
  20067. private _clearDepthStencilBuffer;
  20068. /**
  20069. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20070. * @hidden
  20071. */
  20072. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20073. /**
  20074. * Resets the different information of the group to prepare a new frame
  20075. * @hidden
  20076. */
  20077. reset(): void;
  20078. /**
  20079. * Dispose and release the group and its associated resources.
  20080. * @hidden
  20081. */
  20082. dispose(): void;
  20083. /**
  20084. * Clear the info related to rendering groups preventing retention points during dispose.
  20085. */
  20086. freeRenderingGroups(): void;
  20087. private _prepareRenderingGroup;
  20088. /**
  20089. * Add a sprite manager to the rendering manager in order to render it this frame.
  20090. * @param spriteManager Define the sprite manager to render
  20091. */
  20092. dispatchSprites(spriteManager: ISpriteManager): void;
  20093. /**
  20094. * Add a particle system to the rendering manager in order to render it this frame.
  20095. * @param particleSystem Define the particle system to render
  20096. */
  20097. dispatchParticles(particleSystem: IParticleSystem): void;
  20098. /**
  20099. * Add a submesh to the manager in order to render it this frame
  20100. * @param subMesh The submesh to dispatch
  20101. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20102. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20103. */
  20104. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20105. /**
  20106. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20107. * This allowed control for front to back rendering or reversly depending of the special needs.
  20108. *
  20109. * @param renderingGroupId The rendering group id corresponding to its index
  20110. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20111. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20112. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20113. */
  20114. 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;
  20115. /**
  20116. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20117. *
  20118. * @param renderingGroupId The rendering group id corresponding to its index
  20119. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20120. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20121. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20122. */
  20123. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20124. /**
  20125. * Gets the current auto clear configuration for one rendering group of the rendering
  20126. * manager.
  20127. * @param index the rendering group index to get the information for
  20128. * @returns The auto clear setup for the requested rendering group
  20129. */
  20130. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20131. }
  20132. }
  20133. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20134. import { Observable } from "babylonjs/Misc/observable";
  20135. import { SmartArray } from "babylonjs/Misc/smartArray";
  20136. import { Nullable } from "babylonjs/types";
  20137. import { Camera } from "babylonjs/Cameras/camera";
  20138. import { Scene } from "babylonjs/scene";
  20139. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20140. import { Color4 } from "babylonjs/Maths/math.color";
  20141. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20143. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20144. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20145. import { Texture } from "babylonjs/Materials/Textures/texture";
  20146. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20147. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20148. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20149. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20150. import { Engine } from "babylonjs/Engines/engine";
  20151. /**
  20152. * This Helps creating a texture that will be created from a camera in your scene.
  20153. * It is basically a dynamic texture that could be used to create special effects for instance.
  20154. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20155. */
  20156. export class RenderTargetTexture extends Texture {
  20157. isCube: boolean;
  20158. /**
  20159. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20160. */
  20161. static readonly REFRESHRATE_RENDER_ONCE: number;
  20162. /**
  20163. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20164. */
  20165. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20166. /**
  20167. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20168. * the central point of your effect and can save a lot of performances.
  20169. */
  20170. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20171. /**
  20172. * Use this predicate to dynamically define the list of mesh you want to render.
  20173. * If set, the renderList property will be overwritten.
  20174. */
  20175. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20176. private _renderList;
  20177. /**
  20178. * Use this list to define the list of mesh you want to render.
  20179. */
  20180. renderList: Nullable<Array<AbstractMesh>>;
  20181. private _hookArray;
  20182. /**
  20183. * Define if particles should be rendered in your texture.
  20184. */
  20185. renderParticles: boolean;
  20186. /**
  20187. * Define if sprites should be rendered in your texture.
  20188. */
  20189. renderSprites: boolean;
  20190. /**
  20191. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20192. */
  20193. coordinatesMode: number;
  20194. /**
  20195. * Define the camera used to render the texture.
  20196. */
  20197. activeCamera: Nullable<Camera>;
  20198. /**
  20199. * Override the render function of the texture with your own one.
  20200. */
  20201. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20202. /**
  20203. * Define if camera post processes should be use while rendering the texture.
  20204. */
  20205. useCameraPostProcesses: boolean;
  20206. /**
  20207. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20208. */
  20209. ignoreCameraViewport: boolean;
  20210. private _postProcessManager;
  20211. private _postProcesses;
  20212. private _resizeObserver;
  20213. /**
  20214. * An event triggered when the texture is unbind.
  20215. */
  20216. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20217. /**
  20218. * An event triggered when the texture is unbind.
  20219. */
  20220. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20221. private _onAfterUnbindObserver;
  20222. /**
  20223. * Set a after unbind callback in the texture.
  20224. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20225. */
  20226. onAfterUnbind: () => void;
  20227. /**
  20228. * An event triggered before rendering the texture
  20229. */
  20230. onBeforeRenderObservable: Observable<number>;
  20231. private _onBeforeRenderObserver;
  20232. /**
  20233. * Set a before render callback in the texture.
  20234. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20235. */
  20236. onBeforeRender: (faceIndex: number) => void;
  20237. /**
  20238. * An event triggered after rendering the texture
  20239. */
  20240. onAfterRenderObservable: Observable<number>;
  20241. private _onAfterRenderObserver;
  20242. /**
  20243. * Set a after render callback in the texture.
  20244. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20245. */
  20246. onAfterRender: (faceIndex: number) => void;
  20247. /**
  20248. * An event triggered after the texture clear
  20249. */
  20250. onClearObservable: Observable<Engine>;
  20251. private _onClearObserver;
  20252. /**
  20253. * Set a clear callback in the texture.
  20254. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20255. */
  20256. onClear: (Engine: Engine) => void;
  20257. /**
  20258. * An event triggered when the texture is resized.
  20259. */
  20260. onResizeObservable: Observable<RenderTargetTexture>;
  20261. /**
  20262. * Define the clear color of the Render Target if it should be different from the scene.
  20263. */
  20264. clearColor: Color4;
  20265. protected _size: number | {
  20266. width: number;
  20267. height: number;
  20268. };
  20269. protected _initialSizeParameter: number | {
  20270. width: number;
  20271. height: number;
  20272. } | {
  20273. ratio: number;
  20274. };
  20275. protected _sizeRatio: Nullable<number>;
  20276. /** @hidden */
  20277. _generateMipMaps: boolean;
  20278. protected _renderingManager: RenderingManager;
  20279. /** @hidden */
  20280. _waitingRenderList: string[];
  20281. protected _doNotChangeAspectRatio: boolean;
  20282. protected _currentRefreshId: number;
  20283. protected _refreshRate: number;
  20284. protected _textureMatrix: Matrix;
  20285. protected _samples: number;
  20286. protected _renderTargetOptions: RenderTargetCreationOptions;
  20287. /**
  20288. * Gets render target creation options that were used.
  20289. */
  20290. readonly renderTargetOptions: RenderTargetCreationOptions;
  20291. protected _engine: Engine;
  20292. protected _onRatioRescale(): void;
  20293. /**
  20294. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20295. * It must define where the camera used to render the texture is set
  20296. */
  20297. boundingBoxPosition: Vector3;
  20298. private _boundingBoxSize;
  20299. /**
  20300. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20301. * When defined, the cubemap will switch to local mode
  20302. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20303. * @example https://www.babylonjs-playground.com/#RNASML
  20304. */
  20305. boundingBoxSize: Vector3;
  20306. /**
  20307. * In case the RTT has been created with a depth texture, get the associated
  20308. * depth texture.
  20309. * Otherwise, return null.
  20310. */
  20311. depthStencilTexture: Nullable<InternalTexture>;
  20312. /**
  20313. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20314. * or used a shadow, depth texture...
  20315. * @param name The friendly name of the texture
  20316. * @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)
  20317. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20318. * @param generateMipMaps True if mip maps need to be generated after render.
  20319. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20320. * @param type The type of the buffer in the RTT (int, half float, float...)
  20321. * @param isCube True if a cube texture needs to be created
  20322. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20323. * @param generateDepthBuffer True to generate a depth buffer
  20324. * @param generateStencilBuffer True to generate a stencil buffer
  20325. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20326. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20327. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20328. */
  20329. constructor(name: string, size: number | {
  20330. width: number;
  20331. height: number;
  20332. } | {
  20333. ratio: number;
  20334. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20335. /**
  20336. * Creates a depth stencil texture.
  20337. * This is only available in WebGL 2 or with the depth texture extension available.
  20338. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20339. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20340. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20341. */
  20342. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20343. private _processSizeParameter;
  20344. /**
  20345. * Define the number of samples to use in case of MSAA.
  20346. * It defaults to one meaning no MSAA has been enabled.
  20347. */
  20348. samples: number;
  20349. /**
  20350. * Resets the refresh counter of the texture and start bak from scratch.
  20351. * Could be useful to regenerate the texture if it is setup to render only once.
  20352. */
  20353. resetRefreshCounter(): void;
  20354. /**
  20355. * Define the refresh rate of the texture or the rendering frequency.
  20356. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20357. */
  20358. refreshRate: number;
  20359. /**
  20360. * Adds a post process to the render target rendering passes.
  20361. * @param postProcess define the post process to add
  20362. */
  20363. addPostProcess(postProcess: PostProcess): void;
  20364. /**
  20365. * Clear all the post processes attached to the render target
  20366. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20367. */
  20368. clearPostProcesses(dispose?: boolean): void;
  20369. /**
  20370. * Remove one of the post process from the list of attached post processes to the texture
  20371. * @param postProcess define the post process to remove from the list
  20372. */
  20373. removePostProcess(postProcess: PostProcess): void;
  20374. /** @hidden */
  20375. _shouldRender(): boolean;
  20376. /**
  20377. * Gets the actual render size of the texture.
  20378. * @returns the width of the render size
  20379. */
  20380. getRenderSize(): number;
  20381. /**
  20382. * Gets the actual render width of the texture.
  20383. * @returns the width of the render size
  20384. */
  20385. getRenderWidth(): number;
  20386. /**
  20387. * Gets the actual render height of the texture.
  20388. * @returns the height of the render size
  20389. */
  20390. getRenderHeight(): number;
  20391. /**
  20392. * Get if the texture can be rescaled or not.
  20393. */
  20394. readonly canRescale: boolean;
  20395. /**
  20396. * Resize the texture using a ratio.
  20397. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20398. */
  20399. scale(ratio: number): void;
  20400. /**
  20401. * Get the texture reflection matrix used to rotate/transform the reflection.
  20402. * @returns the reflection matrix
  20403. */
  20404. getReflectionTextureMatrix(): Matrix;
  20405. /**
  20406. * Resize the texture to a new desired size.
  20407. * Be carrefull as it will recreate all the data in the new texture.
  20408. * @param size Define the new size. It can be:
  20409. * - a number for squared texture,
  20410. * - an object containing { width: number, height: number }
  20411. * - or an object containing a ratio { ratio: number }
  20412. */
  20413. resize(size: number | {
  20414. width: number;
  20415. height: number;
  20416. } | {
  20417. ratio: number;
  20418. }): void;
  20419. /**
  20420. * Renders all the objects from the render list into the texture.
  20421. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20422. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20423. */
  20424. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20425. private _bestReflectionRenderTargetDimension;
  20426. /**
  20427. * @hidden
  20428. * @param faceIndex face index to bind to if this is a cubetexture
  20429. */
  20430. _bindFrameBuffer(faceIndex?: number): void;
  20431. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20432. private renderToTarget;
  20433. /**
  20434. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20435. * This allowed control for front to back rendering or reversly depending of the special needs.
  20436. *
  20437. * @param renderingGroupId The rendering group id corresponding to its index
  20438. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20439. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20440. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20441. */
  20442. 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;
  20443. /**
  20444. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20445. *
  20446. * @param renderingGroupId The rendering group id corresponding to its index
  20447. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20448. */
  20449. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20450. /**
  20451. * Clones the texture.
  20452. * @returns the cloned texture
  20453. */
  20454. clone(): RenderTargetTexture;
  20455. /**
  20456. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20457. * @returns The JSON representation of the texture
  20458. */
  20459. serialize(): any;
  20460. /**
  20461. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20462. */
  20463. disposeFramebufferObjects(): void;
  20464. /**
  20465. * Dispose the texture and release its associated resources.
  20466. */
  20467. dispose(): void;
  20468. /** @hidden */
  20469. _rebuild(): void;
  20470. /**
  20471. * Clear the info related to rendering groups preventing retention point in material dispose.
  20472. */
  20473. freeRenderingGroups(): void;
  20474. /**
  20475. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20476. * @returns the view count
  20477. */
  20478. getViewCount(): number;
  20479. }
  20480. }
  20481. declare module "babylonjs/Materials/material" {
  20482. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20483. import { SmartArray } from "babylonjs/Misc/smartArray";
  20484. import { Observable } from "babylonjs/Misc/observable";
  20485. import { Nullable } from "babylonjs/types";
  20486. import { Scene } from "babylonjs/scene";
  20487. import { Matrix } from "babylonjs/Maths/math.vector";
  20488. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20490. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20491. import { Effect } from "babylonjs/Materials/effect";
  20492. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20493. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20494. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20495. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20496. import { Mesh } from "babylonjs/Meshes/mesh";
  20497. import { Animation } from "babylonjs/Animations/animation";
  20498. /**
  20499. * Base class for the main features of a material in Babylon.js
  20500. */
  20501. export class Material implements IAnimatable {
  20502. /**
  20503. * Returns the triangle fill mode
  20504. */
  20505. static readonly TriangleFillMode: number;
  20506. /**
  20507. * Returns the wireframe mode
  20508. */
  20509. static readonly WireFrameFillMode: number;
  20510. /**
  20511. * Returns the point fill mode
  20512. */
  20513. static readonly PointFillMode: number;
  20514. /**
  20515. * Returns the point list draw mode
  20516. */
  20517. static readonly PointListDrawMode: number;
  20518. /**
  20519. * Returns the line list draw mode
  20520. */
  20521. static readonly LineListDrawMode: number;
  20522. /**
  20523. * Returns the line loop draw mode
  20524. */
  20525. static readonly LineLoopDrawMode: number;
  20526. /**
  20527. * Returns the line strip draw mode
  20528. */
  20529. static readonly LineStripDrawMode: number;
  20530. /**
  20531. * Returns the triangle strip draw mode
  20532. */
  20533. static readonly TriangleStripDrawMode: number;
  20534. /**
  20535. * Returns the triangle fan draw mode
  20536. */
  20537. static readonly TriangleFanDrawMode: number;
  20538. /**
  20539. * Stores the clock-wise side orientation
  20540. */
  20541. static readonly ClockWiseSideOrientation: number;
  20542. /**
  20543. * Stores the counter clock-wise side orientation
  20544. */
  20545. static readonly CounterClockWiseSideOrientation: number;
  20546. /**
  20547. * The dirty texture flag value
  20548. */
  20549. static readonly TextureDirtyFlag: number;
  20550. /**
  20551. * The dirty light flag value
  20552. */
  20553. static readonly LightDirtyFlag: number;
  20554. /**
  20555. * The dirty fresnel flag value
  20556. */
  20557. static readonly FresnelDirtyFlag: number;
  20558. /**
  20559. * The dirty attribute flag value
  20560. */
  20561. static readonly AttributesDirtyFlag: number;
  20562. /**
  20563. * The dirty misc flag value
  20564. */
  20565. static readonly MiscDirtyFlag: number;
  20566. /**
  20567. * The all dirty flag value
  20568. */
  20569. static readonly AllDirtyFlag: number;
  20570. /**
  20571. * The ID of the material
  20572. */
  20573. id: string;
  20574. /**
  20575. * Gets or sets the unique id of the material
  20576. */
  20577. uniqueId: number;
  20578. /**
  20579. * The name of the material
  20580. */
  20581. name: string;
  20582. /**
  20583. * Gets or sets user defined metadata
  20584. */
  20585. metadata: any;
  20586. /**
  20587. * For internal use only. Please do not use.
  20588. */
  20589. reservedDataStore: any;
  20590. /**
  20591. * Specifies if the ready state should be checked on each call
  20592. */
  20593. checkReadyOnEveryCall: boolean;
  20594. /**
  20595. * Specifies if the ready state should be checked once
  20596. */
  20597. checkReadyOnlyOnce: boolean;
  20598. /**
  20599. * The state of the material
  20600. */
  20601. state: string;
  20602. /**
  20603. * The alpha value of the material
  20604. */
  20605. protected _alpha: number;
  20606. /**
  20607. * List of inspectable custom properties (used by the Inspector)
  20608. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20609. */
  20610. inspectableCustomProperties: IInspectable[];
  20611. /**
  20612. * Sets the alpha value of the material
  20613. */
  20614. /**
  20615. * Gets the alpha value of the material
  20616. */
  20617. alpha: number;
  20618. /**
  20619. * Specifies if back face culling is enabled
  20620. */
  20621. protected _backFaceCulling: boolean;
  20622. /**
  20623. * Sets the back-face culling state
  20624. */
  20625. /**
  20626. * Gets the back-face culling state
  20627. */
  20628. backFaceCulling: boolean;
  20629. /**
  20630. * Stores the value for side orientation
  20631. */
  20632. sideOrientation: number;
  20633. /**
  20634. * Callback triggered when the material is compiled
  20635. */
  20636. onCompiled: Nullable<(effect: Effect) => void>;
  20637. /**
  20638. * Callback triggered when an error occurs
  20639. */
  20640. onError: Nullable<(effect: Effect, errors: string) => void>;
  20641. /**
  20642. * Callback triggered to get the render target textures
  20643. */
  20644. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20645. /**
  20646. * Gets a boolean indicating that current material needs to register RTT
  20647. */
  20648. readonly hasRenderTargetTextures: boolean;
  20649. /**
  20650. * Specifies if the material should be serialized
  20651. */
  20652. doNotSerialize: boolean;
  20653. /**
  20654. * @hidden
  20655. */
  20656. _storeEffectOnSubMeshes: boolean;
  20657. /**
  20658. * Stores the animations for the material
  20659. */
  20660. animations: Nullable<Array<Animation>>;
  20661. /**
  20662. * An event triggered when the material is disposed
  20663. */
  20664. onDisposeObservable: Observable<Material>;
  20665. /**
  20666. * An observer which watches for dispose events
  20667. */
  20668. private _onDisposeObserver;
  20669. private _onUnBindObservable;
  20670. /**
  20671. * Called during a dispose event
  20672. */
  20673. onDispose: () => void;
  20674. private _onBindObservable;
  20675. /**
  20676. * An event triggered when the material is bound
  20677. */
  20678. readonly onBindObservable: Observable<AbstractMesh>;
  20679. /**
  20680. * An observer which watches for bind events
  20681. */
  20682. private _onBindObserver;
  20683. /**
  20684. * Called during a bind event
  20685. */
  20686. onBind: (Mesh: AbstractMesh) => void;
  20687. /**
  20688. * An event triggered when the material is unbound
  20689. */
  20690. readonly onUnBindObservable: Observable<Material>;
  20691. /**
  20692. * Stores the value of the alpha mode
  20693. */
  20694. private _alphaMode;
  20695. /**
  20696. * Sets the value of the alpha mode.
  20697. *
  20698. * | Value | Type | Description |
  20699. * | --- | --- | --- |
  20700. * | 0 | ALPHA_DISABLE | |
  20701. * | 1 | ALPHA_ADD | |
  20702. * | 2 | ALPHA_COMBINE | |
  20703. * | 3 | ALPHA_SUBTRACT | |
  20704. * | 4 | ALPHA_MULTIPLY | |
  20705. * | 5 | ALPHA_MAXIMIZED | |
  20706. * | 6 | ALPHA_ONEONE | |
  20707. * | 7 | ALPHA_PREMULTIPLIED | |
  20708. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20709. * | 9 | ALPHA_INTERPOLATE | |
  20710. * | 10 | ALPHA_SCREENMODE | |
  20711. *
  20712. */
  20713. /**
  20714. * Gets the value of the alpha mode
  20715. */
  20716. alphaMode: number;
  20717. /**
  20718. * Stores the state of the need depth pre-pass value
  20719. */
  20720. private _needDepthPrePass;
  20721. /**
  20722. * Sets the need depth pre-pass value
  20723. */
  20724. /**
  20725. * Gets the depth pre-pass value
  20726. */
  20727. needDepthPrePass: boolean;
  20728. /**
  20729. * Specifies if depth writing should be disabled
  20730. */
  20731. disableDepthWrite: boolean;
  20732. /**
  20733. * Specifies if depth writing should be forced
  20734. */
  20735. forceDepthWrite: boolean;
  20736. /**
  20737. * Specifies if there should be a separate pass for culling
  20738. */
  20739. separateCullingPass: boolean;
  20740. /**
  20741. * Stores the state specifing if fog should be enabled
  20742. */
  20743. private _fogEnabled;
  20744. /**
  20745. * Sets the state for enabling fog
  20746. */
  20747. /**
  20748. * Gets the value of the fog enabled state
  20749. */
  20750. fogEnabled: boolean;
  20751. /**
  20752. * Stores the size of points
  20753. */
  20754. pointSize: number;
  20755. /**
  20756. * Stores the z offset value
  20757. */
  20758. zOffset: number;
  20759. /**
  20760. * Gets a value specifying if wireframe mode is enabled
  20761. */
  20762. /**
  20763. * Sets the state of wireframe mode
  20764. */
  20765. wireframe: boolean;
  20766. /**
  20767. * Gets the value specifying if point clouds are enabled
  20768. */
  20769. /**
  20770. * Sets the state of point cloud mode
  20771. */
  20772. pointsCloud: boolean;
  20773. /**
  20774. * Gets the material fill mode
  20775. */
  20776. /**
  20777. * Sets the material fill mode
  20778. */
  20779. fillMode: number;
  20780. /**
  20781. * @hidden
  20782. * Stores the effects for the material
  20783. */
  20784. _effect: Nullable<Effect>;
  20785. /**
  20786. * @hidden
  20787. * Specifies if the material was previously ready
  20788. */
  20789. _wasPreviouslyReady: boolean;
  20790. /**
  20791. * Specifies if uniform buffers should be used
  20792. */
  20793. private _useUBO;
  20794. /**
  20795. * Stores a reference to the scene
  20796. */
  20797. private _scene;
  20798. /**
  20799. * Stores the fill mode state
  20800. */
  20801. private _fillMode;
  20802. /**
  20803. * Specifies if the depth write state should be cached
  20804. */
  20805. private _cachedDepthWriteState;
  20806. /**
  20807. * Stores the uniform buffer
  20808. */
  20809. protected _uniformBuffer: UniformBuffer;
  20810. /** @hidden */
  20811. _indexInSceneMaterialArray: number;
  20812. /** @hidden */
  20813. meshMap: Nullable<{
  20814. [id: string]: AbstractMesh | undefined;
  20815. }>;
  20816. /**
  20817. * Creates a material instance
  20818. * @param name defines the name of the material
  20819. * @param scene defines the scene to reference
  20820. * @param doNotAdd specifies if the material should be added to the scene
  20821. */
  20822. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20823. /**
  20824. * Returns a string representation of the current material
  20825. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20826. * @returns a string with material information
  20827. */
  20828. toString(fullDetails?: boolean): string;
  20829. /**
  20830. * Gets the class name of the material
  20831. * @returns a string with the class name of the material
  20832. */
  20833. getClassName(): string;
  20834. /**
  20835. * Specifies if updates for the material been locked
  20836. */
  20837. readonly isFrozen: boolean;
  20838. /**
  20839. * Locks updates for the material
  20840. */
  20841. freeze(): void;
  20842. /**
  20843. * Unlocks updates for the material
  20844. */
  20845. unfreeze(): void;
  20846. /**
  20847. * Specifies if the material is ready to be used
  20848. * @param mesh defines the mesh to check
  20849. * @param useInstances specifies if instances should be used
  20850. * @returns a boolean indicating if the material is ready to be used
  20851. */
  20852. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20853. /**
  20854. * Specifies that the submesh is ready to be used
  20855. * @param mesh defines the mesh to check
  20856. * @param subMesh defines which submesh to check
  20857. * @param useInstances specifies that instances should be used
  20858. * @returns a boolean indicating that the submesh is ready or not
  20859. */
  20860. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20861. /**
  20862. * Returns the material effect
  20863. * @returns the effect associated with the material
  20864. */
  20865. getEffect(): Nullable<Effect>;
  20866. /**
  20867. * Returns the current scene
  20868. * @returns a Scene
  20869. */
  20870. getScene(): Scene;
  20871. /**
  20872. * Specifies if the material will require alpha blending
  20873. * @returns a boolean specifying if alpha blending is needed
  20874. */
  20875. needAlphaBlending(): boolean;
  20876. /**
  20877. * Specifies if the mesh will require alpha blending
  20878. * @param mesh defines the mesh to check
  20879. * @returns a boolean specifying if alpha blending is needed for the mesh
  20880. */
  20881. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20882. /**
  20883. * Specifies if this material should be rendered in alpha test mode
  20884. * @returns a boolean specifying if an alpha test is needed.
  20885. */
  20886. needAlphaTesting(): boolean;
  20887. /**
  20888. * Gets the texture used for the alpha test
  20889. * @returns the texture to use for alpha testing
  20890. */
  20891. getAlphaTestTexture(): Nullable<BaseTexture>;
  20892. /**
  20893. * Marks the material to indicate that it needs to be re-calculated
  20894. */
  20895. markDirty(): void;
  20896. /** @hidden */
  20897. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20898. /**
  20899. * Binds the material to the mesh
  20900. * @param world defines the world transformation matrix
  20901. * @param mesh defines the mesh to bind the material to
  20902. */
  20903. bind(world: Matrix, mesh?: Mesh): void;
  20904. /**
  20905. * Binds the submesh to the material
  20906. * @param world defines the world transformation matrix
  20907. * @param mesh defines the mesh containing the submesh
  20908. * @param subMesh defines the submesh to bind the material to
  20909. */
  20910. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20911. /**
  20912. * Binds the world matrix to the material
  20913. * @param world defines the world transformation matrix
  20914. */
  20915. bindOnlyWorldMatrix(world: Matrix): void;
  20916. /**
  20917. * Binds the scene's uniform buffer to the effect.
  20918. * @param effect defines the effect to bind to the scene uniform buffer
  20919. * @param sceneUbo defines the uniform buffer storing scene data
  20920. */
  20921. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20922. /**
  20923. * Binds the view matrix to the effect
  20924. * @param effect defines the effect to bind the view matrix to
  20925. */
  20926. bindView(effect: Effect): void;
  20927. /**
  20928. * Binds the view projection matrix to the effect
  20929. * @param effect defines the effect to bind the view projection matrix to
  20930. */
  20931. bindViewProjection(effect: Effect): void;
  20932. /**
  20933. * Specifies if material alpha testing should be turned on for the mesh
  20934. * @param mesh defines the mesh to check
  20935. */
  20936. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20937. /**
  20938. * Processes to execute after binding the material to a mesh
  20939. * @param mesh defines the rendered mesh
  20940. */
  20941. protected _afterBind(mesh?: Mesh): void;
  20942. /**
  20943. * Unbinds the material from the mesh
  20944. */
  20945. unbind(): void;
  20946. /**
  20947. * Gets the active textures from the material
  20948. * @returns an array of textures
  20949. */
  20950. getActiveTextures(): BaseTexture[];
  20951. /**
  20952. * Specifies if the material uses a texture
  20953. * @param texture defines the texture to check against the material
  20954. * @returns a boolean specifying if the material uses the texture
  20955. */
  20956. hasTexture(texture: BaseTexture): boolean;
  20957. /**
  20958. * Makes a duplicate of the material, and gives it a new name
  20959. * @param name defines the new name for the duplicated material
  20960. * @returns the cloned material
  20961. */
  20962. clone(name: string): Nullable<Material>;
  20963. /**
  20964. * Gets the meshes bound to the material
  20965. * @returns an array of meshes bound to the material
  20966. */
  20967. getBindedMeshes(): AbstractMesh[];
  20968. /**
  20969. * Force shader compilation
  20970. * @param mesh defines the mesh associated with this material
  20971. * @param onCompiled defines a function to execute once the material is compiled
  20972. * @param options defines the options to configure the compilation
  20973. * @param onError defines a function to execute if the material fails compiling
  20974. */
  20975. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20976. clipPlane: boolean;
  20977. }>, onError?: (reason: string) => void): void;
  20978. /**
  20979. * Force shader compilation
  20980. * @param mesh defines the mesh that will use this material
  20981. * @param options defines additional options for compiling the shaders
  20982. * @returns a promise that resolves when the compilation completes
  20983. */
  20984. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20985. clipPlane: boolean;
  20986. }>): Promise<void>;
  20987. private static readonly _AllDirtyCallBack;
  20988. private static readonly _ImageProcessingDirtyCallBack;
  20989. private static readonly _TextureDirtyCallBack;
  20990. private static readonly _FresnelDirtyCallBack;
  20991. private static readonly _MiscDirtyCallBack;
  20992. private static readonly _LightsDirtyCallBack;
  20993. private static readonly _AttributeDirtyCallBack;
  20994. private static _FresnelAndMiscDirtyCallBack;
  20995. private static _TextureAndMiscDirtyCallBack;
  20996. private static readonly _DirtyCallbackArray;
  20997. private static readonly _RunDirtyCallBacks;
  20998. /**
  20999. * Marks a define in the material to indicate that it needs to be re-computed
  21000. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21001. */
  21002. markAsDirty(flag: number): void;
  21003. /**
  21004. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21005. * @param func defines a function which checks material defines against the submeshes
  21006. */
  21007. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21008. /**
  21009. * Indicates that we need to re-calculated for all submeshes
  21010. */
  21011. protected _markAllSubMeshesAsAllDirty(): void;
  21012. /**
  21013. * Indicates that image processing needs to be re-calculated for all submeshes
  21014. */
  21015. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21016. /**
  21017. * Indicates that textures need to be re-calculated for all submeshes
  21018. */
  21019. protected _markAllSubMeshesAsTexturesDirty(): void;
  21020. /**
  21021. * Indicates that fresnel needs to be re-calculated for all submeshes
  21022. */
  21023. protected _markAllSubMeshesAsFresnelDirty(): void;
  21024. /**
  21025. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21026. */
  21027. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21028. /**
  21029. * Indicates that lights need to be re-calculated for all submeshes
  21030. */
  21031. protected _markAllSubMeshesAsLightsDirty(): void;
  21032. /**
  21033. * Indicates that attributes need to be re-calculated for all submeshes
  21034. */
  21035. protected _markAllSubMeshesAsAttributesDirty(): void;
  21036. /**
  21037. * Indicates that misc needs to be re-calculated for all submeshes
  21038. */
  21039. protected _markAllSubMeshesAsMiscDirty(): void;
  21040. /**
  21041. * Indicates that textures and misc need to be re-calculated for all submeshes
  21042. */
  21043. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21044. /**
  21045. * Disposes the material
  21046. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21047. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21048. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21049. */
  21050. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21051. /** @hidden */
  21052. private releaseVertexArrayObject;
  21053. /**
  21054. * Serializes this material
  21055. * @returns the serialized material object
  21056. */
  21057. serialize(): any;
  21058. /**
  21059. * Creates a material from parsed material data
  21060. * @param parsedMaterial defines parsed material data
  21061. * @param scene defines the hosting scene
  21062. * @param rootUrl defines the root URL to use to load textures
  21063. * @returns a new material
  21064. */
  21065. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21066. }
  21067. }
  21068. declare module "babylonjs/Meshes/instancedMesh" {
  21069. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21070. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  21071. import { Camera } from "babylonjs/Cameras/camera";
  21072. import { Node } from "babylonjs/node";
  21073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21074. import { Mesh } from "babylonjs/Meshes/mesh";
  21075. import { Material } from "babylonjs/Materials/material";
  21076. import { Skeleton } from "babylonjs/Bones/skeleton";
  21077. import { Light } from "babylonjs/Lights/light";
  21078. /**
  21079. * Creates an instance based on a source mesh.
  21080. */
  21081. export class InstancedMesh extends AbstractMesh {
  21082. private _sourceMesh;
  21083. private _currentLOD;
  21084. /** @hidden */
  21085. _actAsRegularMesh: boolean;
  21086. /** @hidden */
  21087. _indexInSourceMeshInstanceArray: number;
  21088. constructor(name: string, source: Mesh);
  21089. /**
  21090. * Returns the string "InstancedMesh".
  21091. */
  21092. getClassName(): string;
  21093. /** Gets the list of lights affecting that mesh */
  21094. readonly lightSources: Light[];
  21095. _resyncLightSources(): void;
  21096. _resyncLighSource(light: Light): void;
  21097. _removeLightSource(light: Light, dispose: boolean): void;
  21098. /**
  21099. * If the source mesh receives shadows
  21100. */
  21101. readonly receiveShadows: boolean;
  21102. /**
  21103. * The material of the source mesh
  21104. */
  21105. readonly material: Nullable<Material>;
  21106. /**
  21107. * Visibility of the source mesh
  21108. */
  21109. readonly visibility: number;
  21110. /**
  21111. * Skeleton of the source mesh
  21112. */
  21113. readonly skeleton: Nullable<Skeleton>;
  21114. /**
  21115. * Rendering ground id of the source mesh
  21116. */
  21117. renderingGroupId: number;
  21118. /**
  21119. * Returns the total number of vertices (integer).
  21120. */
  21121. getTotalVertices(): number;
  21122. /**
  21123. * Returns a positive integer : the total number of indices in this mesh geometry.
  21124. * @returns the numner of indices or zero if the mesh has no geometry.
  21125. */
  21126. getTotalIndices(): number;
  21127. /**
  21128. * The source mesh of the instance
  21129. */
  21130. readonly sourceMesh: Mesh;
  21131. /**
  21132. * Is this node ready to be used/rendered
  21133. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21134. * @return {boolean} is it ready
  21135. */
  21136. isReady(completeCheck?: boolean): boolean;
  21137. /**
  21138. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21139. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  21140. * @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.
  21141. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  21142. */
  21143. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  21144. /**
  21145. * Sets the vertex data of the mesh geometry for the requested `kind`.
  21146. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  21147. * The `data` are either a numeric array either a Float32Array.
  21148. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  21149. * 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).
  21150. * Note that a new underlying VertexBuffer object is created each call.
  21151. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  21152. *
  21153. * Possible `kind` values :
  21154. * - VertexBuffer.PositionKind
  21155. * - VertexBuffer.UVKind
  21156. * - VertexBuffer.UV2Kind
  21157. * - VertexBuffer.UV3Kind
  21158. * - VertexBuffer.UV4Kind
  21159. * - VertexBuffer.UV5Kind
  21160. * - VertexBuffer.UV6Kind
  21161. * - VertexBuffer.ColorKind
  21162. * - VertexBuffer.MatricesIndicesKind
  21163. * - VertexBuffer.MatricesIndicesExtraKind
  21164. * - VertexBuffer.MatricesWeightsKind
  21165. * - VertexBuffer.MatricesWeightsExtraKind
  21166. *
  21167. * Returns the Mesh.
  21168. */
  21169. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  21170. /**
  21171. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  21172. * If the mesh has no geometry, it is simply returned as it is.
  21173. * The `data` are either a numeric array either a Float32Array.
  21174. * No new underlying VertexBuffer object is created.
  21175. * 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.
  21176. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  21177. *
  21178. * Possible `kind` values :
  21179. * - VertexBuffer.PositionKind
  21180. * - VertexBuffer.UVKind
  21181. * - VertexBuffer.UV2Kind
  21182. * - VertexBuffer.UV3Kind
  21183. * - VertexBuffer.UV4Kind
  21184. * - VertexBuffer.UV5Kind
  21185. * - VertexBuffer.UV6Kind
  21186. * - VertexBuffer.ColorKind
  21187. * - VertexBuffer.MatricesIndicesKind
  21188. * - VertexBuffer.MatricesIndicesExtraKind
  21189. * - VertexBuffer.MatricesWeightsKind
  21190. * - VertexBuffer.MatricesWeightsExtraKind
  21191. *
  21192. * Returns the Mesh.
  21193. */
  21194. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21195. /**
  21196. * Sets the mesh indices.
  21197. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  21198. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  21199. * This method creates a new index buffer each call.
  21200. * Returns the Mesh.
  21201. */
  21202. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  21203. /**
  21204. * Boolean : True if the mesh owns the requested kind of data.
  21205. */
  21206. isVerticesDataPresent(kind: string): boolean;
  21207. /**
  21208. * Returns an array of indices (IndicesArray).
  21209. */
  21210. getIndices(): Nullable<IndicesArray>;
  21211. readonly _positions: Nullable<Vector3[]>;
  21212. /**
  21213. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21214. * This means the mesh underlying bounding box and sphere are recomputed.
  21215. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21216. * @returns the current mesh
  21217. */
  21218. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  21219. /** @hidden */
  21220. _preActivate(): InstancedMesh;
  21221. /** @hidden */
  21222. _activate(renderId: number, intermediateRendering: boolean): boolean;
  21223. /** @hidden */
  21224. _postActivate(): void;
  21225. getWorldMatrix(): Matrix;
  21226. readonly isAnInstance: boolean;
  21227. /**
  21228. * Returns the current associated LOD AbstractMesh.
  21229. */
  21230. getLOD(camera: Camera): AbstractMesh;
  21231. /** @hidden */
  21232. _syncSubMeshes(): InstancedMesh;
  21233. /** @hidden */
  21234. _generatePointsArray(): boolean;
  21235. /**
  21236. * Creates a new InstancedMesh from the current mesh.
  21237. * - name (string) : the cloned mesh name
  21238. * - newParent (optional Node) : the optional Node to parent the clone to.
  21239. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  21240. *
  21241. * Returns the clone.
  21242. */
  21243. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  21244. /**
  21245. * Disposes the InstancedMesh.
  21246. * Returns nothing.
  21247. */
  21248. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21249. }
  21250. }
  21251. declare module "babylonjs/Materials/multiMaterial" {
  21252. import { Nullable } from "babylonjs/types";
  21253. import { Scene } from "babylonjs/scene";
  21254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21255. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21256. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21257. import { Material } from "babylonjs/Materials/material";
  21258. /**
  21259. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21260. * separate meshes. This can be use to improve performances.
  21261. * @see http://doc.babylonjs.com/how_to/multi_materials
  21262. */
  21263. export class MultiMaterial extends Material {
  21264. private _subMaterials;
  21265. /**
  21266. * Gets or Sets the list of Materials used within the multi material.
  21267. * They need to be ordered according to the submeshes order in the associated mesh
  21268. */
  21269. subMaterials: Nullable<Material>[];
  21270. /**
  21271. * Function used to align with Node.getChildren()
  21272. * @returns the list of Materials used within the multi material
  21273. */
  21274. getChildren(): Nullable<Material>[];
  21275. /**
  21276. * Instantiates a new Multi Material
  21277. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21278. * separate meshes. This can be use to improve performances.
  21279. * @see http://doc.babylonjs.com/how_to/multi_materials
  21280. * @param name Define the name in the scene
  21281. * @param scene Define the scene the material belongs to
  21282. */
  21283. constructor(name: string, scene: Scene);
  21284. private _hookArray;
  21285. /**
  21286. * Get one of the submaterial by its index in the submaterials array
  21287. * @param index The index to look the sub material at
  21288. * @returns The Material if the index has been defined
  21289. */
  21290. getSubMaterial(index: number): Nullable<Material>;
  21291. /**
  21292. * Get the list of active textures for the whole sub materials list.
  21293. * @returns All the textures that will be used during the rendering
  21294. */
  21295. getActiveTextures(): BaseTexture[];
  21296. /**
  21297. * Gets the current class name of the material e.g. "MultiMaterial"
  21298. * Mainly use in serialization.
  21299. * @returns the class name
  21300. */
  21301. getClassName(): string;
  21302. /**
  21303. * Checks if the material is ready to render the requested sub mesh
  21304. * @param mesh Define the mesh the submesh belongs to
  21305. * @param subMesh Define the sub mesh to look readyness for
  21306. * @param useInstances Define whether or not the material is used with instances
  21307. * @returns true if ready, otherwise false
  21308. */
  21309. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21310. /**
  21311. * Clones the current material and its related sub materials
  21312. * @param name Define the name of the newly cloned material
  21313. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21314. * @returns the cloned material
  21315. */
  21316. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21317. /**
  21318. * Serializes the materials into a JSON representation.
  21319. * @returns the JSON representation
  21320. */
  21321. serialize(): any;
  21322. /**
  21323. * Dispose the material and release its associated resources
  21324. * @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)
  21325. * @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)
  21326. * @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)
  21327. */
  21328. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21329. /**
  21330. * Creates a MultiMaterial from parsed MultiMaterial data.
  21331. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21332. * @param scene defines the hosting scene
  21333. * @returns a new MultiMaterial
  21334. */
  21335. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21336. }
  21337. }
  21338. declare module "babylonjs/Meshes/subMesh" {
  21339. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21340. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21341. import { Engine } from "babylonjs/Engines/engine";
  21342. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21343. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21344. import { Effect } from "babylonjs/Materials/effect";
  21345. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21346. import { Plane } from "babylonjs/Maths/math.plane";
  21347. import { Collider } from "babylonjs/Collisions/collider";
  21348. import { Material } from "babylonjs/Materials/material";
  21349. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21351. import { Mesh } from "babylonjs/Meshes/mesh";
  21352. import { Ray } from "babylonjs/Culling/ray";
  21353. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21354. /**
  21355. * Base class for submeshes
  21356. */
  21357. export class BaseSubMesh {
  21358. /** @hidden */
  21359. _materialDefines: Nullable<MaterialDefines>;
  21360. /** @hidden */
  21361. _materialEffect: Nullable<Effect>;
  21362. /**
  21363. * Gets associated effect
  21364. */
  21365. readonly effect: Nullable<Effect>;
  21366. /**
  21367. * Sets associated effect (effect used to render this submesh)
  21368. * @param effect defines the effect to associate with
  21369. * @param defines defines the set of defines used to compile this effect
  21370. */
  21371. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21372. }
  21373. /**
  21374. * Defines a subdivision inside a mesh
  21375. */
  21376. export class SubMesh extends BaseSubMesh implements ICullable {
  21377. /** the material index to use */
  21378. materialIndex: number;
  21379. /** vertex index start */
  21380. verticesStart: number;
  21381. /** vertices count */
  21382. verticesCount: number;
  21383. /** index start */
  21384. indexStart: number;
  21385. /** indices count */
  21386. indexCount: number;
  21387. /** @hidden */
  21388. _linesIndexCount: number;
  21389. private _mesh;
  21390. private _renderingMesh;
  21391. private _boundingInfo;
  21392. private _linesIndexBuffer;
  21393. /** @hidden */
  21394. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21395. /** @hidden */
  21396. _trianglePlanes: Plane[];
  21397. /** @hidden */
  21398. _lastColliderTransformMatrix: Nullable<Matrix>;
  21399. /** @hidden */
  21400. _renderId: number;
  21401. /** @hidden */
  21402. _alphaIndex: number;
  21403. /** @hidden */
  21404. _distanceToCamera: number;
  21405. /** @hidden */
  21406. _id: number;
  21407. private _currentMaterial;
  21408. /**
  21409. * Add a new submesh to a mesh
  21410. * @param materialIndex defines the material index to use
  21411. * @param verticesStart defines vertex index start
  21412. * @param verticesCount defines vertices count
  21413. * @param indexStart defines index start
  21414. * @param indexCount defines indices count
  21415. * @param mesh defines the parent mesh
  21416. * @param renderingMesh defines an optional rendering mesh
  21417. * @param createBoundingBox defines if bounding box should be created for this submesh
  21418. * @returns the new submesh
  21419. */
  21420. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21421. /**
  21422. * Creates a new submesh
  21423. * @param materialIndex defines the material index to use
  21424. * @param verticesStart defines vertex index start
  21425. * @param verticesCount defines vertices count
  21426. * @param indexStart defines index start
  21427. * @param indexCount defines indices count
  21428. * @param mesh defines the parent mesh
  21429. * @param renderingMesh defines an optional rendering mesh
  21430. * @param createBoundingBox defines if bounding box should be created for this submesh
  21431. */
  21432. constructor(
  21433. /** the material index to use */
  21434. materialIndex: number,
  21435. /** vertex index start */
  21436. verticesStart: number,
  21437. /** vertices count */
  21438. verticesCount: number,
  21439. /** index start */
  21440. indexStart: number,
  21441. /** indices count */
  21442. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21443. /**
  21444. * Returns true if this submesh covers the entire parent mesh
  21445. * @ignorenaming
  21446. */
  21447. readonly IsGlobal: boolean;
  21448. /**
  21449. * Returns the submesh BoudingInfo object
  21450. * @returns current bounding info (or mesh's one if the submesh is global)
  21451. */
  21452. getBoundingInfo(): BoundingInfo;
  21453. /**
  21454. * Sets the submesh BoundingInfo
  21455. * @param boundingInfo defines the new bounding info to use
  21456. * @returns the SubMesh
  21457. */
  21458. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21459. /**
  21460. * Returns the mesh of the current submesh
  21461. * @return the parent mesh
  21462. */
  21463. getMesh(): AbstractMesh;
  21464. /**
  21465. * Returns the rendering mesh of the submesh
  21466. * @returns the rendering mesh (could be different from parent mesh)
  21467. */
  21468. getRenderingMesh(): Mesh;
  21469. /**
  21470. * Returns the submesh material
  21471. * @returns null or the current material
  21472. */
  21473. getMaterial(): Nullable<Material>;
  21474. /**
  21475. * Sets a new updated BoundingInfo object to the submesh
  21476. * @param data defines an optional position array to use to determine the bounding info
  21477. * @returns the SubMesh
  21478. */
  21479. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21480. /** @hidden */
  21481. _checkCollision(collider: Collider): boolean;
  21482. /**
  21483. * Updates the submesh BoundingInfo
  21484. * @param world defines the world matrix to use to update the bounding info
  21485. * @returns the submesh
  21486. */
  21487. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21488. /**
  21489. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21490. * @param frustumPlanes defines the frustum planes
  21491. * @returns true if the submesh is intersecting with the frustum
  21492. */
  21493. isInFrustum(frustumPlanes: Plane[]): boolean;
  21494. /**
  21495. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21496. * @param frustumPlanes defines the frustum planes
  21497. * @returns true if the submesh is inside the frustum
  21498. */
  21499. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21500. /**
  21501. * Renders the submesh
  21502. * @param enableAlphaMode defines if alpha needs to be used
  21503. * @returns the submesh
  21504. */
  21505. render(enableAlphaMode: boolean): SubMesh;
  21506. /**
  21507. * @hidden
  21508. */
  21509. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21510. /**
  21511. * Checks if the submesh intersects with a ray
  21512. * @param ray defines the ray to test
  21513. * @returns true is the passed ray intersects the submesh bounding box
  21514. */
  21515. canIntersects(ray: Ray): boolean;
  21516. /**
  21517. * Intersects current submesh with a ray
  21518. * @param ray defines the ray to test
  21519. * @param positions defines mesh's positions array
  21520. * @param indices defines mesh's indices array
  21521. * @param fastCheck defines if only bounding info should be used
  21522. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21523. * @returns intersection info or null if no intersection
  21524. */
  21525. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21526. /** @hidden */
  21527. private _intersectLines;
  21528. /** @hidden */
  21529. private _intersectUnIndexedLines;
  21530. /** @hidden */
  21531. private _intersectTriangles;
  21532. /** @hidden */
  21533. private _intersectUnIndexedTriangles;
  21534. /** @hidden */
  21535. _rebuild(): void;
  21536. /**
  21537. * Creates a new submesh from the passed mesh
  21538. * @param newMesh defines the new hosting mesh
  21539. * @param newRenderingMesh defines an optional rendering mesh
  21540. * @returns the new submesh
  21541. */
  21542. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21543. /**
  21544. * Release associated resources
  21545. */
  21546. dispose(): void;
  21547. /**
  21548. * Gets the class name
  21549. * @returns the string "SubMesh".
  21550. */
  21551. getClassName(): string;
  21552. /**
  21553. * Creates a new submesh from indices data
  21554. * @param materialIndex the index of the main mesh material
  21555. * @param startIndex the index where to start the copy in the mesh indices array
  21556. * @param indexCount the number of indices to copy then from the startIndex
  21557. * @param mesh the main mesh to create the submesh from
  21558. * @param renderingMesh the optional rendering mesh
  21559. * @returns a new submesh
  21560. */
  21561. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21562. }
  21563. }
  21564. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21565. /**
  21566. * Class used to represent data loading progression
  21567. */
  21568. export class SceneLoaderFlags {
  21569. private static _ForceFullSceneLoadingForIncremental;
  21570. private static _ShowLoadingScreen;
  21571. private static _CleanBoneMatrixWeights;
  21572. private static _loggingLevel;
  21573. /**
  21574. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21575. */
  21576. static ForceFullSceneLoadingForIncremental: boolean;
  21577. /**
  21578. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21579. */
  21580. static ShowLoadingScreen: boolean;
  21581. /**
  21582. * Defines the current logging level (while loading the scene)
  21583. * @ignorenaming
  21584. */
  21585. static loggingLevel: number;
  21586. /**
  21587. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21588. */
  21589. static CleanBoneMatrixWeights: boolean;
  21590. }
  21591. }
  21592. declare module "babylonjs/Meshes/geometry" {
  21593. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21594. import { Scene } from "babylonjs/scene";
  21595. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21596. import { Engine } from "babylonjs/Engines/engine";
  21597. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21598. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21599. import { Effect } from "babylonjs/Materials/effect";
  21600. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21601. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21602. import { Mesh } from "babylonjs/Meshes/mesh";
  21603. /**
  21604. * Class used to store geometry data (vertex buffers + index buffer)
  21605. */
  21606. export class Geometry implements IGetSetVerticesData {
  21607. /**
  21608. * Gets or sets the ID of the geometry
  21609. */
  21610. id: string;
  21611. /**
  21612. * Gets or sets the unique ID of the geometry
  21613. */
  21614. uniqueId: number;
  21615. /**
  21616. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21617. */
  21618. delayLoadState: number;
  21619. /**
  21620. * Gets the file containing the data to load when running in delay load state
  21621. */
  21622. delayLoadingFile: Nullable<string>;
  21623. /**
  21624. * Callback called when the geometry is updated
  21625. */
  21626. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21627. private _scene;
  21628. private _engine;
  21629. private _meshes;
  21630. private _totalVertices;
  21631. /** @hidden */
  21632. _indices: IndicesArray;
  21633. /** @hidden */
  21634. _vertexBuffers: {
  21635. [key: string]: VertexBuffer;
  21636. };
  21637. private _isDisposed;
  21638. private _extend;
  21639. private _boundingBias;
  21640. /** @hidden */
  21641. _delayInfo: Array<string>;
  21642. private _indexBuffer;
  21643. private _indexBufferIsUpdatable;
  21644. /** @hidden */
  21645. _boundingInfo: Nullable<BoundingInfo>;
  21646. /** @hidden */
  21647. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21648. /** @hidden */
  21649. _softwareSkinningFrameId: number;
  21650. private _vertexArrayObjects;
  21651. private _updatable;
  21652. /** @hidden */
  21653. _positions: Nullable<Vector3[]>;
  21654. /**
  21655. * 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
  21656. */
  21657. /**
  21658. * 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
  21659. */
  21660. boundingBias: Vector2;
  21661. /**
  21662. * Static function used to attach a new empty geometry to a mesh
  21663. * @param mesh defines the mesh to attach the geometry to
  21664. * @returns the new Geometry
  21665. */
  21666. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21667. /**
  21668. * Creates a new geometry
  21669. * @param id defines the unique ID
  21670. * @param scene defines the hosting scene
  21671. * @param vertexData defines the VertexData used to get geometry data
  21672. * @param updatable defines if geometry must be updatable (false by default)
  21673. * @param mesh defines the mesh that will be associated with the geometry
  21674. */
  21675. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21676. /**
  21677. * Gets the current extend of the geometry
  21678. */
  21679. readonly extend: {
  21680. minimum: Vector3;
  21681. maximum: Vector3;
  21682. };
  21683. /**
  21684. * Gets the hosting scene
  21685. * @returns the hosting Scene
  21686. */
  21687. getScene(): Scene;
  21688. /**
  21689. * Gets the hosting engine
  21690. * @returns the hosting Engine
  21691. */
  21692. getEngine(): Engine;
  21693. /**
  21694. * Defines if the geometry is ready to use
  21695. * @returns true if the geometry is ready to be used
  21696. */
  21697. isReady(): boolean;
  21698. /**
  21699. * Gets a value indicating that the geometry should not be serialized
  21700. */
  21701. readonly doNotSerialize: boolean;
  21702. /** @hidden */
  21703. _rebuild(): void;
  21704. /**
  21705. * Affects all geometry data in one call
  21706. * @param vertexData defines the geometry data
  21707. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21708. */
  21709. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21710. /**
  21711. * Set specific vertex data
  21712. * @param kind defines the data kind (Position, normal, etc...)
  21713. * @param data defines the vertex data to use
  21714. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21715. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21716. */
  21717. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21718. /**
  21719. * Removes a specific vertex data
  21720. * @param kind defines the data kind (Position, normal, etc...)
  21721. */
  21722. removeVerticesData(kind: string): void;
  21723. /**
  21724. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21725. * @param buffer defines the vertex buffer to use
  21726. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21727. */
  21728. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21729. /**
  21730. * Update a specific vertex buffer
  21731. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21732. * It will do nothing if the buffer is not updatable
  21733. * @param kind defines the data kind (Position, normal, etc...)
  21734. * @param data defines the data to use
  21735. * @param offset defines the offset in the target buffer where to store the data
  21736. * @param useBytes set to true if the offset is in bytes
  21737. */
  21738. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21739. /**
  21740. * Update a specific vertex buffer
  21741. * This function will create a new buffer if the current one is not updatable
  21742. * @param kind defines the data kind (Position, normal, etc...)
  21743. * @param data defines the data to use
  21744. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21745. */
  21746. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21747. private _updateBoundingInfo;
  21748. /** @hidden */
  21749. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21750. /**
  21751. * Gets total number of vertices
  21752. * @returns the total number of vertices
  21753. */
  21754. getTotalVertices(): number;
  21755. /**
  21756. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21757. * @param kind defines the data kind (Position, normal, etc...)
  21758. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21759. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21760. * @returns a float array containing vertex data
  21761. */
  21762. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21763. /**
  21764. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21765. * @param kind defines the data kind (Position, normal, etc...)
  21766. * @returns true if the vertex buffer with the specified kind is updatable
  21767. */
  21768. isVertexBufferUpdatable(kind: string): boolean;
  21769. /**
  21770. * Gets a specific vertex buffer
  21771. * @param kind defines the data kind (Position, normal, etc...)
  21772. * @returns a VertexBuffer
  21773. */
  21774. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21775. /**
  21776. * Returns all vertex buffers
  21777. * @return an object holding all vertex buffers indexed by kind
  21778. */
  21779. getVertexBuffers(): Nullable<{
  21780. [key: string]: VertexBuffer;
  21781. }>;
  21782. /**
  21783. * Gets a boolean indicating if specific vertex buffer is present
  21784. * @param kind defines the data kind (Position, normal, etc...)
  21785. * @returns true if data is present
  21786. */
  21787. isVerticesDataPresent(kind: string): boolean;
  21788. /**
  21789. * Gets a list of all attached data kinds (Position, normal, etc...)
  21790. * @returns a list of string containing all kinds
  21791. */
  21792. getVerticesDataKinds(): string[];
  21793. /**
  21794. * Update index buffer
  21795. * @param indices defines the indices to store in the index buffer
  21796. * @param offset defines the offset in the target buffer where to store the data
  21797. * @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)
  21798. */
  21799. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21800. /**
  21801. * Creates a new index buffer
  21802. * @param indices defines the indices to store in the index buffer
  21803. * @param totalVertices defines the total number of vertices (could be null)
  21804. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21805. */
  21806. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21807. /**
  21808. * Return the total number of indices
  21809. * @returns the total number of indices
  21810. */
  21811. getTotalIndices(): number;
  21812. /**
  21813. * Gets the index buffer array
  21814. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21815. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21816. * @returns the index buffer array
  21817. */
  21818. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21819. /**
  21820. * Gets the index buffer
  21821. * @return the index buffer
  21822. */
  21823. getIndexBuffer(): Nullable<DataBuffer>;
  21824. /** @hidden */
  21825. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21826. /**
  21827. * Release the associated resources for a specific mesh
  21828. * @param mesh defines the source mesh
  21829. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21830. */
  21831. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21832. /**
  21833. * Apply current geometry to a given mesh
  21834. * @param mesh defines the mesh to apply geometry to
  21835. */
  21836. applyToMesh(mesh: Mesh): void;
  21837. private _updateExtend;
  21838. private _applyToMesh;
  21839. private notifyUpdate;
  21840. /**
  21841. * Load the geometry if it was flagged as delay loaded
  21842. * @param scene defines the hosting scene
  21843. * @param onLoaded defines a callback called when the geometry is loaded
  21844. */
  21845. load(scene: Scene, onLoaded?: () => void): void;
  21846. private _queueLoad;
  21847. /**
  21848. * Invert the geometry to move from a right handed system to a left handed one.
  21849. */
  21850. toLeftHanded(): void;
  21851. /** @hidden */
  21852. _resetPointsArrayCache(): void;
  21853. /** @hidden */
  21854. _generatePointsArray(): boolean;
  21855. /**
  21856. * Gets a value indicating if the geometry is disposed
  21857. * @returns true if the geometry was disposed
  21858. */
  21859. isDisposed(): boolean;
  21860. private _disposeVertexArrayObjects;
  21861. /**
  21862. * Free all associated resources
  21863. */
  21864. dispose(): void;
  21865. /**
  21866. * Clone the current geometry into a new geometry
  21867. * @param id defines the unique ID of the new geometry
  21868. * @returns a new geometry object
  21869. */
  21870. copy(id: string): Geometry;
  21871. /**
  21872. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21873. * @return a JSON representation of the current geometry data (without the vertices data)
  21874. */
  21875. serialize(): any;
  21876. private toNumberArray;
  21877. /**
  21878. * Serialize all vertices data into a JSON oject
  21879. * @returns a JSON representation of the current geometry data
  21880. */
  21881. serializeVerticeData(): any;
  21882. /**
  21883. * Extracts a clone of a mesh geometry
  21884. * @param mesh defines the source mesh
  21885. * @param id defines the unique ID of the new geometry object
  21886. * @returns the new geometry object
  21887. */
  21888. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21889. /**
  21890. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21891. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21892. * Be aware Math.random() could cause collisions, but:
  21893. * "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"
  21894. * @returns a string containing a new GUID
  21895. */
  21896. static RandomId(): string;
  21897. /** @hidden */
  21898. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21899. private static _CleanMatricesWeights;
  21900. /**
  21901. * Create a new geometry from persisted data (Using .babylon file format)
  21902. * @param parsedVertexData defines the persisted data
  21903. * @param scene defines the hosting scene
  21904. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21905. * @returns the new geometry object
  21906. */
  21907. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21908. }
  21909. }
  21910. declare module "babylonjs/Meshes/mesh.vertexData" {
  21911. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21912. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21913. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21914. import { Geometry } from "babylonjs/Meshes/geometry";
  21915. import { Mesh } from "babylonjs/Meshes/mesh";
  21916. /**
  21917. * Define an interface for all classes that will get and set the data on vertices
  21918. */
  21919. export interface IGetSetVerticesData {
  21920. /**
  21921. * Gets a boolean indicating if specific vertex data is present
  21922. * @param kind defines the vertex data kind to use
  21923. * @returns true is data kind is present
  21924. */
  21925. isVerticesDataPresent(kind: string): boolean;
  21926. /**
  21927. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21928. * @param kind defines the data kind (Position, normal, etc...)
  21929. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21930. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21931. * @returns a float array containing vertex data
  21932. */
  21933. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21934. /**
  21935. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21936. * @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.
  21937. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21938. * @returns the indices array or an empty array if the mesh has no geometry
  21939. */
  21940. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21941. /**
  21942. * Set specific vertex data
  21943. * @param kind defines the data kind (Position, normal, etc...)
  21944. * @param data defines the vertex data to use
  21945. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21946. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21947. */
  21948. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21949. /**
  21950. * Update a specific associated vertex buffer
  21951. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21952. * - VertexBuffer.PositionKind
  21953. * - VertexBuffer.UVKind
  21954. * - VertexBuffer.UV2Kind
  21955. * - VertexBuffer.UV3Kind
  21956. * - VertexBuffer.UV4Kind
  21957. * - VertexBuffer.UV5Kind
  21958. * - VertexBuffer.UV6Kind
  21959. * - VertexBuffer.ColorKind
  21960. * - VertexBuffer.MatricesIndicesKind
  21961. * - VertexBuffer.MatricesIndicesExtraKind
  21962. * - VertexBuffer.MatricesWeightsKind
  21963. * - VertexBuffer.MatricesWeightsExtraKind
  21964. * @param data defines the data source
  21965. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21966. * @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)
  21967. */
  21968. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21969. /**
  21970. * Creates a new index buffer
  21971. * @param indices defines the indices to store in the index buffer
  21972. * @param totalVertices defines the total number of vertices (could be null)
  21973. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21974. */
  21975. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21976. }
  21977. /**
  21978. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21979. */
  21980. export class VertexData {
  21981. /**
  21982. * Mesh side orientation : usually the external or front surface
  21983. */
  21984. static readonly FRONTSIDE: number;
  21985. /**
  21986. * Mesh side orientation : usually the internal or back surface
  21987. */
  21988. static readonly BACKSIDE: number;
  21989. /**
  21990. * Mesh side orientation : both internal and external or front and back surfaces
  21991. */
  21992. static readonly DOUBLESIDE: number;
  21993. /**
  21994. * Mesh side orientation : by default, `FRONTSIDE`
  21995. */
  21996. static readonly DEFAULTSIDE: number;
  21997. /**
  21998. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21999. */
  22000. positions: Nullable<FloatArray>;
  22001. /**
  22002. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22003. */
  22004. normals: Nullable<FloatArray>;
  22005. /**
  22006. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22007. */
  22008. tangents: Nullable<FloatArray>;
  22009. /**
  22010. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22011. */
  22012. uvs: Nullable<FloatArray>;
  22013. /**
  22014. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22015. */
  22016. uvs2: Nullable<FloatArray>;
  22017. /**
  22018. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22019. */
  22020. uvs3: Nullable<FloatArray>;
  22021. /**
  22022. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22023. */
  22024. uvs4: Nullable<FloatArray>;
  22025. /**
  22026. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22027. */
  22028. uvs5: Nullable<FloatArray>;
  22029. /**
  22030. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22031. */
  22032. uvs6: Nullable<FloatArray>;
  22033. /**
  22034. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22035. */
  22036. colors: Nullable<FloatArray>;
  22037. /**
  22038. * 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).
  22039. */
  22040. matricesIndices: Nullable<FloatArray>;
  22041. /**
  22042. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22043. */
  22044. matricesWeights: Nullable<FloatArray>;
  22045. /**
  22046. * An array extending the number of possible indices
  22047. */
  22048. matricesIndicesExtra: Nullable<FloatArray>;
  22049. /**
  22050. * An array extending the number of possible weights when the number of indices is extended
  22051. */
  22052. matricesWeightsExtra: Nullable<FloatArray>;
  22053. /**
  22054. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22055. */
  22056. indices: Nullable<IndicesArray>;
  22057. /**
  22058. * Uses the passed data array to set the set the values for the specified kind of data
  22059. * @param data a linear array of floating numbers
  22060. * @param kind the type of data that is being set, eg positions, colors etc
  22061. */
  22062. set(data: FloatArray, kind: string): void;
  22063. /**
  22064. * Associates the vertexData to the passed Mesh.
  22065. * Sets it as updatable or not (default `false`)
  22066. * @param mesh the mesh the vertexData is applied to
  22067. * @param updatable when used and having the value true allows new data to update the vertexData
  22068. * @returns the VertexData
  22069. */
  22070. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22071. /**
  22072. * Associates the vertexData to the passed Geometry.
  22073. * Sets it as updatable or not (default `false`)
  22074. * @param geometry the geometry the vertexData is applied to
  22075. * @param updatable when used and having the value true allows new data to update the vertexData
  22076. * @returns VertexData
  22077. */
  22078. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22079. /**
  22080. * Updates the associated mesh
  22081. * @param mesh the mesh to be updated
  22082. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22083. * @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
  22084. * @returns VertexData
  22085. */
  22086. updateMesh(mesh: Mesh): VertexData;
  22087. /**
  22088. * Updates the associated geometry
  22089. * @param geometry the geometry to be updated
  22090. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22091. * @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
  22092. * @returns VertexData.
  22093. */
  22094. updateGeometry(geometry: Geometry): VertexData;
  22095. private _applyTo;
  22096. private _update;
  22097. /**
  22098. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22099. * @param matrix the transforming matrix
  22100. * @returns the VertexData
  22101. */
  22102. transform(matrix: Matrix): VertexData;
  22103. /**
  22104. * Merges the passed VertexData into the current one
  22105. * @param other the VertexData to be merged into the current one
  22106. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22107. * @returns the modified VertexData
  22108. */
  22109. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22110. private _mergeElement;
  22111. private _validate;
  22112. /**
  22113. * Serializes the VertexData
  22114. * @returns a serialized object
  22115. */
  22116. serialize(): any;
  22117. /**
  22118. * Extracts the vertexData from a mesh
  22119. * @param mesh the mesh from which to extract the VertexData
  22120. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22121. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22122. * @returns the object VertexData associated to the passed mesh
  22123. */
  22124. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22125. /**
  22126. * Extracts the vertexData from the geometry
  22127. * @param geometry the geometry from which to extract the VertexData
  22128. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22129. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22130. * @returns the object VertexData associated to the passed mesh
  22131. */
  22132. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22133. private static _ExtractFrom;
  22134. /**
  22135. * Creates the VertexData for a Ribbon
  22136. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22137. * * pathArray array of paths, each of which an array of successive Vector3
  22138. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22139. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22140. * * 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
  22141. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22142. * * 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)
  22143. * * 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)
  22144. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22145. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22146. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22147. * @returns the VertexData of the ribbon
  22148. */
  22149. static CreateRibbon(options: {
  22150. pathArray: Vector3[][];
  22151. closeArray?: boolean;
  22152. closePath?: boolean;
  22153. offset?: number;
  22154. sideOrientation?: number;
  22155. frontUVs?: Vector4;
  22156. backUVs?: Vector4;
  22157. invertUV?: boolean;
  22158. uvs?: Vector2[];
  22159. colors?: Color4[];
  22160. }): VertexData;
  22161. /**
  22162. * Creates the VertexData for a box
  22163. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22164. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22165. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22166. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22167. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22168. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22169. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22170. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22171. * * 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)
  22172. * * 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)
  22173. * @returns the VertexData of the box
  22174. */
  22175. static CreateBox(options: {
  22176. size?: number;
  22177. width?: number;
  22178. height?: number;
  22179. depth?: number;
  22180. faceUV?: Vector4[];
  22181. faceColors?: Color4[];
  22182. sideOrientation?: number;
  22183. frontUVs?: Vector4;
  22184. backUVs?: Vector4;
  22185. }): VertexData;
  22186. /**
  22187. * Creates the VertexData for a tiled box
  22188. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22189. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22190. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22191. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22192. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22193. * @returns the VertexData of the box
  22194. */
  22195. static CreateTiledBox(options: {
  22196. pattern?: number;
  22197. width?: number;
  22198. height?: number;
  22199. depth?: number;
  22200. tileSize?: number;
  22201. tileWidth?: number;
  22202. tileHeight?: number;
  22203. alignHorizontal?: number;
  22204. alignVertical?: number;
  22205. faceUV?: Vector4[];
  22206. faceColors?: Color4[];
  22207. sideOrientation?: number;
  22208. }): VertexData;
  22209. /**
  22210. * Creates the VertexData for a tiled plane
  22211. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22212. * * pattern a limited pattern arrangement depending on the number
  22213. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22214. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22215. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22216. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22217. * * 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)
  22218. * * 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)
  22219. * @returns the VertexData of the tiled plane
  22220. */
  22221. static CreateTiledPlane(options: {
  22222. pattern?: number;
  22223. tileSize?: number;
  22224. tileWidth?: number;
  22225. tileHeight?: number;
  22226. size?: number;
  22227. width?: number;
  22228. height?: number;
  22229. alignHorizontal?: number;
  22230. alignVertical?: number;
  22231. sideOrientation?: number;
  22232. frontUVs?: Vector4;
  22233. backUVs?: Vector4;
  22234. }): VertexData;
  22235. /**
  22236. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22237. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22238. * * segments sets the number of horizontal strips optional, default 32
  22239. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22240. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22241. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22242. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22243. * * 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
  22244. * * 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
  22245. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22246. * * 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)
  22247. * * 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)
  22248. * @returns the VertexData of the ellipsoid
  22249. */
  22250. static CreateSphere(options: {
  22251. segments?: number;
  22252. diameter?: number;
  22253. diameterX?: number;
  22254. diameterY?: number;
  22255. diameterZ?: number;
  22256. arc?: number;
  22257. slice?: number;
  22258. sideOrientation?: number;
  22259. frontUVs?: Vector4;
  22260. backUVs?: Vector4;
  22261. }): VertexData;
  22262. /**
  22263. * Creates the VertexData for a cylinder, cone or prism
  22264. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22265. * * height sets the height (y direction) of the cylinder, optional, default 2
  22266. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22267. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22268. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22269. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22270. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22271. * * 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
  22272. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22273. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22274. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22275. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22276. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22277. * * 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)
  22278. * * 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)
  22279. * @returns the VertexData of the cylinder, cone or prism
  22280. */
  22281. static CreateCylinder(options: {
  22282. height?: number;
  22283. diameterTop?: number;
  22284. diameterBottom?: number;
  22285. diameter?: number;
  22286. tessellation?: number;
  22287. subdivisions?: number;
  22288. arc?: number;
  22289. faceColors?: Color4[];
  22290. faceUV?: Vector4[];
  22291. hasRings?: boolean;
  22292. enclose?: boolean;
  22293. sideOrientation?: number;
  22294. frontUVs?: Vector4;
  22295. backUVs?: Vector4;
  22296. }): VertexData;
  22297. /**
  22298. * Creates the VertexData for a torus
  22299. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22300. * * diameter the diameter of the torus, optional default 1
  22301. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22302. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22303. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22304. * * 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)
  22305. * * 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)
  22306. * @returns the VertexData of the torus
  22307. */
  22308. static CreateTorus(options: {
  22309. diameter?: number;
  22310. thickness?: number;
  22311. tessellation?: number;
  22312. sideOrientation?: number;
  22313. frontUVs?: Vector4;
  22314. backUVs?: Vector4;
  22315. }): VertexData;
  22316. /**
  22317. * Creates the VertexData of the LineSystem
  22318. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22319. * - lines an array of lines, each line being an array of successive Vector3
  22320. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22321. * @returns the VertexData of the LineSystem
  22322. */
  22323. static CreateLineSystem(options: {
  22324. lines: Vector3[][];
  22325. colors?: Nullable<Color4[][]>;
  22326. }): VertexData;
  22327. /**
  22328. * Create the VertexData for a DashedLines
  22329. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22330. * - points an array successive Vector3
  22331. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22332. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22333. * - dashNb the intended total number of dashes, optional, default 200
  22334. * @returns the VertexData for the DashedLines
  22335. */
  22336. static CreateDashedLines(options: {
  22337. points: Vector3[];
  22338. dashSize?: number;
  22339. gapSize?: number;
  22340. dashNb?: number;
  22341. }): VertexData;
  22342. /**
  22343. * Creates the VertexData for a Ground
  22344. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22345. * - width the width (x direction) of the ground, optional, default 1
  22346. * - height the height (z direction) of the ground, optional, default 1
  22347. * - subdivisions the number of subdivisions per side, optional, default 1
  22348. * @returns the VertexData of the Ground
  22349. */
  22350. static CreateGround(options: {
  22351. width?: number;
  22352. height?: number;
  22353. subdivisions?: number;
  22354. subdivisionsX?: number;
  22355. subdivisionsY?: number;
  22356. }): VertexData;
  22357. /**
  22358. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22359. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22360. * * xmin the ground minimum X coordinate, optional, default -1
  22361. * * zmin the ground minimum Z coordinate, optional, default -1
  22362. * * xmax the ground maximum X coordinate, optional, default 1
  22363. * * zmax the ground maximum Z coordinate, optional, default 1
  22364. * * 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}
  22365. * * 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}
  22366. * @returns the VertexData of the TiledGround
  22367. */
  22368. static CreateTiledGround(options: {
  22369. xmin: number;
  22370. zmin: number;
  22371. xmax: number;
  22372. zmax: number;
  22373. subdivisions?: {
  22374. w: number;
  22375. h: number;
  22376. };
  22377. precision?: {
  22378. w: number;
  22379. h: number;
  22380. };
  22381. }): VertexData;
  22382. /**
  22383. * Creates the VertexData of the Ground designed from a heightmap
  22384. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22385. * * width the width (x direction) of the ground
  22386. * * height the height (z direction) of the ground
  22387. * * subdivisions the number of subdivisions per side
  22388. * * minHeight the minimum altitude on the ground, optional, default 0
  22389. * * maxHeight the maximum altitude on the ground, optional default 1
  22390. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22391. * * buffer the array holding the image color data
  22392. * * bufferWidth the width of image
  22393. * * bufferHeight the height of image
  22394. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22395. * @returns the VertexData of the Ground designed from a heightmap
  22396. */
  22397. static CreateGroundFromHeightMap(options: {
  22398. width: number;
  22399. height: number;
  22400. subdivisions: number;
  22401. minHeight: number;
  22402. maxHeight: number;
  22403. colorFilter: Color3;
  22404. buffer: Uint8Array;
  22405. bufferWidth: number;
  22406. bufferHeight: number;
  22407. alphaFilter: number;
  22408. }): VertexData;
  22409. /**
  22410. * Creates the VertexData for a Plane
  22411. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22412. * * size sets the width and height of the plane to the value of size, optional default 1
  22413. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22414. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22415. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22416. * * 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)
  22417. * * 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)
  22418. * @returns the VertexData of the box
  22419. */
  22420. static CreatePlane(options: {
  22421. size?: number;
  22422. width?: number;
  22423. height?: number;
  22424. sideOrientation?: number;
  22425. frontUVs?: Vector4;
  22426. backUVs?: Vector4;
  22427. }): VertexData;
  22428. /**
  22429. * Creates the VertexData of the Disc or regular Polygon
  22430. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22431. * * radius the radius of the disc, optional default 0.5
  22432. * * tessellation the number of polygon sides, optional, default 64
  22433. * * 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
  22434. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22435. * * 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)
  22436. * * 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)
  22437. * @returns the VertexData of the box
  22438. */
  22439. static CreateDisc(options: {
  22440. radius?: number;
  22441. tessellation?: number;
  22442. arc?: number;
  22443. sideOrientation?: number;
  22444. frontUVs?: Vector4;
  22445. backUVs?: Vector4;
  22446. }): VertexData;
  22447. /**
  22448. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22449. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22450. * @param polygon a mesh built from polygonTriangulation.build()
  22451. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22452. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22453. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22454. * @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)
  22455. * @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)
  22456. * @returns the VertexData of the Polygon
  22457. */
  22458. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22459. /**
  22460. * Creates the VertexData of the IcoSphere
  22461. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22462. * * radius the radius of the IcoSphere, optional default 1
  22463. * * radiusX allows stretching in the x direction, optional, default radius
  22464. * * radiusY allows stretching in the y direction, optional, default radius
  22465. * * radiusZ allows stretching in the z direction, optional, default radius
  22466. * * flat when true creates a flat shaded mesh, optional, default true
  22467. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22468. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22469. * * 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)
  22470. * * 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)
  22471. * @returns the VertexData of the IcoSphere
  22472. */
  22473. static CreateIcoSphere(options: {
  22474. radius?: number;
  22475. radiusX?: number;
  22476. radiusY?: number;
  22477. radiusZ?: number;
  22478. flat?: boolean;
  22479. subdivisions?: number;
  22480. sideOrientation?: number;
  22481. frontUVs?: Vector4;
  22482. backUVs?: Vector4;
  22483. }): VertexData;
  22484. /**
  22485. * Creates the VertexData for a Polyhedron
  22486. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22487. * * type provided types are:
  22488. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22489. * * 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)
  22490. * * size the size of the IcoSphere, optional default 1
  22491. * * sizeX allows stretching in the x direction, optional, default size
  22492. * * sizeY allows stretching in the y direction, optional, default size
  22493. * * sizeZ allows stretching in the z direction, optional, default size
  22494. * * 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
  22495. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22496. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22497. * * flat when true creates a flat shaded mesh, optional, default true
  22498. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22499. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22500. * * 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)
  22501. * * 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)
  22502. * @returns the VertexData of the Polyhedron
  22503. */
  22504. static CreatePolyhedron(options: {
  22505. type?: number;
  22506. size?: number;
  22507. sizeX?: number;
  22508. sizeY?: number;
  22509. sizeZ?: number;
  22510. custom?: any;
  22511. faceUV?: Vector4[];
  22512. faceColors?: Color4[];
  22513. flat?: boolean;
  22514. sideOrientation?: number;
  22515. frontUVs?: Vector4;
  22516. backUVs?: Vector4;
  22517. }): VertexData;
  22518. /**
  22519. * Creates the VertexData for a TorusKnot
  22520. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22521. * * radius the radius of the torus knot, optional, default 2
  22522. * * tube the thickness of the tube, optional, default 0.5
  22523. * * radialSegments the number of sides on each tube segments, optional, default 32
  22524. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22525. * * p the number of windings around the z axis, optional, default 2
  22526. * * q the number of windings around the x axis, optional, default 3
  22527. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22528. * * 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)
  22529. * * 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)
  22530. * @returns the VertexData of the Torus Knot
  22531. */
  22532. static CreateTorusKnot(options: {
  22533. radius?: number;
  22534. tube?: number;
  22535. radialSegments?: number;
  22536. tubularSegments?: number;
  22537. p?: number;
  22538. q?: number;
  22539. sideOrientation?: number;
  22540. frontUVs?: Vector4;
  22541. backUVs?: Vector4;
  22542. }): VertexData;
  22543. /**
  22544. * Compute normals for given positions and indices
  22545. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22546. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22547. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22548. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22549. * * facetNormals : optional array of facet normals (vector3)
  22550. * * facetPositions : optional array of facet positions (vector3)
  22551. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22552. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22553. * * bInfo : optional bounding info, required for facetPartitioning computation
  22554. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22555. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22556. * * useRightHandedSystem: optional boolean to for right handed system computation
  22557. * * depthSort : optional boolean to enable the facet depth sort computation
  22558. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22559. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22560. */
  22561. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22562. facetNormals?: any;
  22563. facetPositions?: any;
  22564. facetPartitioning?: any;
  22565. ratio?: number;
  22566. bInfo?: any;
  22567. bbSize?: Vector3;
  22568. subDiv?: any;
  22569. useRightHandedSystem?: boolean;
  22570. depthSort?: boolean;
  22571. distanceTo?: Vector3;
  22572. depthSortedFacets?: any;
  22573. }): void;
  22574. /** @hidden */
  22575. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22576. /**
  22577. * Applies VertexData created from the imported parameters to the geometry
  22578. * @param parsedVertexData the parsed data from an imported file
  22579. * @param geometry the geometry to apply the VertexData to
  22580. */
  22581. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22582. }
  22583. }
  22584. declare module "babylonjs/Morph/morphTarget" {
  22585. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22586. import { Observable } from "babylonjs/Misc/observable";
  22587. import { Nullable, FloatArray } from "babylonjs/types";
  22588. import { Scene } from "babylonjs/scene";
  22589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22590. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22591. /**
  22592. * Defines a target to use with MorphTargetManager
  22593. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22594. */
  22595. export class MorphTarget implements IAnimatable {
  22596. /** defines the name of the target */
  22597. name: string;
  22598. /**
  22599. * Gets or sets the list of animations
  22600. */
  22601. animations: import("babylonjs/Animations/animation").Animation[];
  22602. private _scene;
  22603. private _positions;
  22604. private _normals;
  22605. private _tangents;
  22606. private _uvs;
  22607. private _influence;
  22608. /**
  22609. * Observable raised when the influence changes
  22610. */
  22611. onInfluenceChanged: Observable<boolean>;
  22612. /** @hidden */
  22613. _onDataLayoutChanged: Observable<void>;
  22614. /**
  22615. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22616. */
  22617. influence: number;
  22618. /**
  22619. * Gets or sets the id of the morph Target
  22620. */
  22621. id: string;
  22622. private _animationPropertiesOverride;
  22623. /**
  22624. * Gets or sets the animation properties override
  22625. */
  22626. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22627. /**
  22628. * Creates a new MorphTarget
  22629. * @param name defines the name of the target
  22630. * @param influence defines the influence to use
  22631. * @param scene defines the scene the morphtarget belongs to
  22632. */
  22633. constructor(
  22634. /** defines the name of the target */
  22635. name: string, influence?: number, scene?: Nullable<Scene>);
  22636. /**
  22637. * Gets a boolean defining if the target contains position data
  22638. */
  22639. readonly hasPositions: boolean;
  22640. /**
  22641. * Gets a boolean defining if the target contains normal data
  22642. */
  22643. readonly hasNormals: boolean;
  22644. /**
  22645. * Gets a boolean defining if the target contains tangent data
  22646. */
  22647. readonly hasTangents: boolean;
  22648. /**
  22649. * Gets a boolean defining if the target contains texture coordinates data
  22650. */
  22651. readonly hasUVs: boolean;
  22652. /**
  22653. * Affects position data to this target
  22654. * @param data defines the position data to use
  22655. */
  22656. setPositions(data: Nullable<FloatArray>): void;
  22657. /**
  22658. * Gets the position data stored in this target
  22659. * @returns a FloatArray containing the position data (or null if not present)
  22660. */
  22661. getPositions(): Nullable<FloatArray>;
  22662. /**
  22663. * Affects normal data to this target
  22664. * @param data defines the normal data to use
  22665. */
  22666. setNormals(data: Nullable<FloatArray>): void;
  22667. /**
  22668. * Gets the normal data stored in this target
  22669. * @returns a FloatArray containing the normal data (or null if not present)
  22670. */
  22671. getNormals(): Nullable<FloatArray>;
  22672. /**
  22673. * Affects tangent data to this target
  22674. * @param data defines the tangent data to use
  22675. */
  22676. setTangents(data: Nullable<FloatArray>): void;
  22677. /**
  22678. * Gets the tangent data stored in this target
  22679. * @returns a FloatArray containing the tangent data (or null if not present)
  22680. */
  22681. getTangents(): Nullable<FloatArray>;
  22682. /**
  22683. * Affects texture coordinates data to this target
  22684. * @param data defines the texture coordinates data to use
  22685. */
  22686. setUVs(data: Nullable<FloatArray>): void;
  22687. /**
  22688. * Gets the texture coordinates data stored in this target
  22689. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22690. */
  22691. getUVs(): Nullable<FloatArray>;
  22692. /**
  22693. * Serializes the current target into a Serialization object
  22694. * @returns the serialized object
  22695. */
  22696. serialize(): any;
  22697. /**
  22698. * Returns the string "MorphTarget"
  22699. * @returns "MorphTarget"
  22700. */
  22701. getClassName(): string;
  22702. /**
  22703. * Creates a new target from serialized data
  22704. * @param serializationObject defines the serialized data to use
  22705. * @returns a new MorphTarget
  22706. */
  22707. static Parse(serializationObject: any): MorphTarget;
  22708. /**
  22709. * Creates a MorphTarget from mesh data
  22710. * @param mesh defines the source mesh
  22711. * @param name defines the name to use for the new target
  22712. * @param influence defines the influence to attach to the target
  22713. * @returns a new MorphTarget
  22714. */
  22715. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22716. }
  22717. }
  22718. declare module "babylonjs/Morph/morphTargetManager" {
  22719. import { Nullable } from "babylonjs/types";
  22720. import { Scene } from "babylonjs/scene";
  22721. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22722. /**
  22723. * This class is used to deform meshes using morphing between different targets
  22724. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22725. */
  22726. export class MorphTargetManager {
  22727. private _targets;
  22728. private _targetInfluenceChangedObservers;
  22729. private _targetDataLayoutChangedObservers;
  22730. private _activeTargets;
  22731. private _scene;
  22732. private _influences;
  22733. private _supportsNormals;
  22734. private _supportsTangents;
  22735. private _supportsUVs;
  22736. private _vertexCount;
  22737. private _uniqueId;
  22738. private _tempInfluences;
  22739. /**
  22740. * Gets or sets a boolean indicating if normals must be morphed
  22741. */
  22742. enableNormalMorphing: boolean;
  22743. /**
  22744. * Gets or sets a boolean indicating if tangents must be morphed
  22745. */
  22746. enableTangentMorphing: boolean;
  22747. /**
  22748. * Gets or sets a boolean indicating if UV must be morphed
  22749. */
  22750. enableUVMorphing: boolean;
  22751. /**
  22752. * Creates a new MorphTargetManager
  22753. * @param scene defines the current scene
  22754. */
  22755. constructor(scene?: Nullable<Scene>);
  22756. /**
  22757. * Gets the unique ID of this manager
  22758. */
  22759. readonly uniqueId: number;
  22760. /**
  22761. * Gets the number of vertices handled by this manager
  22762. */
  22763. readonly vertexCount: number;
  22764. /**
  22765. * Gets a boolean indicating if this manager supports morphing of normals
  22766. */
  22767. readonly supportsNormals: boolean;
  22768. /**
  22769. * Gets a boolean indicating if this manager supports morphing of tangents
  22770. */
  22771. readonly supportsTangents: boolean;
  22772. /**
  22773. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22774. */
  22775. readonly supportsUVs: boolean;
  22776. /**
  22777. * Gets the number of targets stored in this manager
  22778. */
  22779. readonly numTargets: number;
  22780. /**
  22781. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22782. */
  22783. readonly numInfluencers: number;
  22784. /**
  22785. * Gets the list of influences (one per target)
  22786. */
  22787. readonly influences: Float32Array;
  22788. /**
  22789. * Gets the active target at specified index. An active target is a target with an influence > 0
  22790. * @param index defines the index to check
  22791. * @returns the requested target
  22792. */
  22793. getActiveTarget(index: number): MorphTarget;
  22794. /**
  22795. * Gets the target at specified index
  22796. * @param index defines the index to check
  22797. * @returns the requested target
  22798. */
  22799. getTarget(index: number): MorphTarget;
  22800. /**
  22801. * Add a new target to this manager
  22802. * @param target defines the target to add
  22803. */
  22804. addTarget(target: MorphTarget): void;
  22805. /**
  22806. * Removes a target from the manager
  22807. * @param target defines the target to remove
  22808. */
  22809. removeTarget(target: MorphTarget): void;
  22810. /**
  22811. * Serializes the current manager into a Serialization object
  22812. * @returns the serialized object
  22813. */
  22814. serialize(): any;
  22815. private _syncActiveTargets;
  22816. /**
  22817. * Syncrhonize the targets with all the meshes using this morph target manager
  22818. */
  22819. synchronize(): void;
  22820. /**
  22821. * Creates a new MorphTargetManager from serialized data
  22822. * @param serializationObject defines the serialized data
  22823. * @param scene defines the hosting scene
  22824. * @returns the new MorphTargetManager
  22825. */
  22826. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22827. }
  22828. }
  22829. declare module "babylonjs/Meshes/meshLODLevel" {
  22830. import { Mesh } from "babylonjs/Meshes/mesh";
  22831. import { Nullable } from "babylonjs/types";
  22832. /**
  22833. * Class used to represent a specific level of detail of a mesh
  22834. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22835. */
  22836. export class MeshLODLevel {
  22837. /** Defines the distance where this level should start being displayed */
  22838. distance: number;
  22839. /** Defines the mesh to use to render this level */
  22840. mesh: Nullable<Mesh>;
  22841. /**
  22842. * Creates a new LOD level
  22843. * @param distance defines the distance where this level should star being displayed
  22844. * @param mesh defines the mesh to use to render this level
  22845. */
  22846. constructor(
  22847. /** Defines the distance where this level should start being displayed */
  22848. distance: number,
  22849. /** Defines the mesh to use to render this level */
  22850. mesh: Nullable<Mesh>);
  22851. }
  22852. }
  22853. declare module "babylonjs/Meshes/groundMesh" {
  22854. import { Scene } from "babylonjs/scene";
  22855. import { Vector3 } from "babylonjs/Maths/math.vector";
  22856. import { Mesh } from "babylonjs/Meshes/mesh";
  22857. /**
  22858. * Mesh representing the gorund
  22859. */
  22860. export class GroundMesh extends Mesh {
  22861. /** If octree should be generated */
  22862. generateOctree: boolean;
  22863. private _heightQuads;
  22864. /** @hidden */
  22865. _subdivisionsX: number;
  22866. /** @hidden */
  22867. _subdivisionsY: number;
  22868. /** @hidden */
  22869. _width: number;
  22870. /** @hidden */
  22871. _height: number;
  22872. /** @hidden */
  22873. _minX: number;
  22874. /** @hidden */
  22875. _maxX: number;
  22876. /** @hidden */
  22877. _minZ: number;
  22878. /** @hidden */
  22879. _maxZ: number;
  22880. constructor(name: string, scene: Scene);
  22881. /**
  22882. * "GroundMesh"
  22883. * @returns "GroundMesh"
  22884. */
  22885. getClassName(): string;
  22886. /**
  22887. * The minimum of x and y subdivisions
  22888. */
  22889. readonly subdivisions: number;
  22890. /**
  22891. * X subdivisions
  22892. */
  22893. readonly subdivisionsX: number;
  22894. /**
  22895. * Y subdivisions
  22896. */
  22897. readonly subdivisionsY: number;
  22898. /**
  22899. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22900. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22901. * @param chunksCount the number of subdivisions for x and y
  22902. * @param octreeBlocksSize (Default: 32)
  22903. */
  22904. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22905. /**
  22906. * Returns a height (y) value in the Worl system :
  22907. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22908. * @param x x coordinate
  22909. * @param z z coordinate
  22910. * @returns the ground y position if (x, z) are outside the ground surface.
  22911. */
  22912. getHeightAtCoordinates(x: number, z: number): number;
  22913. /**
  22914. * Returns a normalized vector (Vector3) orthogonal to the ground
  22915. * at the ground coordinates (x, z) expressed in the World system.
  22916. * @param x x coordinate
  22917. * @param z z coordinate
  22918. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22919. */
  22920. getNormalAtCoordinates(x: number, z: number): Vector3;
  22921. /**
  22922. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22923. * at the ground coordinates (x, z) expressed in the World system.
  22924. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22925. * @param x x coordinate
  22926. * @param z z coordinate
  22927. * @param ref vector to store the result
  22928. * @returns the GroundMesh.
  22929. */
  22930. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22931. /**
  22932. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22933. * if the ground has been updated.
  22934. * This can be used in the render loop.
  22935. * @returns the GroundMesh.
  22936. */
  22937. updateCoordinateHeights(): GroundMesh;
  22938. private _getFacetAt;
  22939. private _initHeightQuads;
  22940. private _computeHeightQuads;
  22941. /**
  22942. * Serializes this ground mesh
  22943. * @param serializationObject object to write serialization to
  22944. */
  22945. serialize(serializationObject: any): void;
  22946. /**
  22947. * Parses a serialized ground mesh
  22948. * @param parsedMesh the serialized mesh
  22949. * @param scene the scene to create the ground mesh in
  22950. * @returns the created ground mesh
  22951. */
  22952. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22953. }
  22954. }
  22955. declare module "babylonjs/Physics/physicsJoint" {
  22956. import { Vector3 } from "babylonjs/Maths/math.vector";
  22957. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22958. /**
  22959. * Interface for Physics-Joint data
  22960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22961. */
  22962. export interface PhysicsJointData {
  22963. /**
  22964. * The main pivot of the joint
  22965. */
  22966. mainPivot?: Vector3;
  22967. /**
  22968. * The connected pivot of the joint
  22969. */
  22970. connectedPivot?: Vector3;
  22971. /**
  22972. * The main axis of the joint
  22973. */
  22974. mainAxis?: Vector3;
  22975. /**
  22976. * The connected axis of the joint
  22977. */
  22978. connectedAxis?: Vector3;
  22979. /**
  22980. * The collision of the joint
  22981. */
  22982. collision?: boolean;
  22983. /**
  22984. * Native Oimo/Cannon/Energy data
  22985. */
  22986. nativeParams?: any;
  22987. }
  22988. /**
  22989. * This is a holder class for the physics joint created by the physics plugin
  22990. * It holds a set of functions to control the underlying joint
  22991. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22992. */
  22993. export class PhysicsJoint {
  22994. /**
  22995. * The type of the physics joint
  22996. */
  22997. type: number;
  22998. /**
  22999. * The data for the physics joint
  23000. */
  23001. jointData: PhysicsJointData;
  23002. private _physicsJoint;
  23003. protected _physicsPlugin: IPhysicsEnginePlugin;
  23004. /**
  23005. * Initializes the physics joint
  23006. * @param type The type of the physics joint
  23007. * @param jointData The data for the physics joint
  23008. */
  23009. constructor(
  23010. /**
  23011. * The type of the physics joint
  23012. */
  23013. type: number,
  23014. /**
  23015. * The data for the physics joint
  23016. */
  23017. jointData: PhysicsJointData);
  23018. /**
  23019. * Gets the physics joint
  23020. */
  23021. /**
  23022. * Sets the physics joint
  23023. */
  23024. physicsJoint: any;
  23025. /**
  23026. * Sets the physics plugin
  23027. */
  23028. physicsPlugin: IPhysicsEnginePlugin;
  23029. /**
  23030. * Execute a function that is physics-plugin specific.
  23031. * @param {Function} func the function that will be executed.
  23032. * It accepts two parameters: the physics world and the physics joint
  23033. */
  23034. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23035. /**
  23036. * Distance-Joint type
  23037. */
  23038. static DistanceJoint: number;
  23039. /**
  23040. * Hinge-Joint type
  23041. */
  23042. static HingeJoint: number;
  23043. /**
  23044. * Ball-and-Socket joint type
  23045. */
  23046. static BallAndSocketJoint: number;
  23047. /**
  23048. * Wheel-Joint type
  23049. */
  23050. static WheelJoint: number;
  23051. /**
  23052. * Slider-Joint type
  23053. */
  23054. static SliderJoint: number;
  23055. /**
  23056. * Prismatic-Joint type
  23057. */
  23058. static PrismaticJoint: number;
  23059. /**
  23060. * Universal-Joint type
  23061. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23062. */
  23063. static UniversalJoint: number;
  23064. /**
  23065. * Hinge-Joint 2 type
  23066. */
  23067. static Hinge2Joint: number;
  23068. /**
  23069. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23070. */
  23071. static PointToPointJoint: number;
  23072. /**
  23073. * Spring-Joint type
  23074. */
  23075. static SpringJoint: number;
  23076. /**
  23077. * Lock-Joint type
  23078. */
  23079. static LockJoint: number;
  23080. }
  23081. /**
  23082. * A class representing a physics distance joint
  23083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23084. */
  23085. export class DistanceJoint extends PhysicsJoint {
  23086. /**
  23087. *
  23088. * @param jointData The data for the Distance-Joint
  23089. */
  23090. constructor(jointData: DistanceJointData);
  23091. /**
  23092. * Update the predefined distance.
  23093. * @param maxDistance The maximum preferred distance
  23094. * @param minDistance The minimum preferred distance
  23095. */
  23096. updateDistance(maxDistance: number, minDistance?: number): void;
  23097. }
  23098. /**
  23099. * Represents a Motor-Enabled Joint
  23100. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23101. */
  23102. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23103. /**
  23104. * Initializes the Motor-Enabled Joint
  23105. * @param type The type of the joint
  23106. * @param jointData The physica joint data for the joint
  23107. */
  23108. constructor(type: number, jointData: PhysicsJointData);
  23109. /**
  23110. * Set the motor values.
  23111. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23112. * @param force the force to apply
  23113. * @param maxForce max force for this motor.
  23114. */
  23115. setMotor(force?: number, maxForce?: number): void;
  23116. /**
  23117. * Set the motor's limits.
  23118. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23119. * @param upperLimit The upper limit of the motor
  23120. * @param lowerLimit The lower limit of the motor
  23121. */
  23122. setLimit(upperLimit: number, lowerLimit?: number): void;
  23123. }
  23124. /**
  23125. * This class represents a single physics Hinge-Joint
  23126. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23127. */
  23128. export class HingeJoint extends MotorEnabledJoint {
  23129. /**
  23130. * Initializes the Hinge-Joint
  23131. * @param jointData The joint data for the Hinge-Joint
  23132. */
  23133. constructor(jointData: PhysicsJointData);
  23134. /**
  23135. * Set the motor values.
  23136. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23137. * @param {number} force the force to apply
  23138. * @param {number} maxForce max force for this motor.
  23139. */
  23140. setMotor(force?: number, maxForce?: number): void;
  23141. /**
  23142. * Set the motor's limits.
  23143. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23144. * @param upperLimit The upper limit of the motor
  23145. * @param lowerLimit The lower limit of the motor
  23146. */
  23147. setLimit(upperLimit: number, lowerLimit?: number): void;
  23148. }
  23149. /**
  23150. * This class represents a dual hinge physics joint (same as wheel joint)
  23151. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23152. */
  23153. export class Hinge2Joint extends MotorEnabledJoint {
  23154. /**
  23155. * Initializes the Hinge2-Joint
  23156. * @param jointData The joint data for the Hinge2-Joint
  23157. */
  23158. constructor(jointData: PhysicsJointData);
  23159. /**
  23160. * Set the motor values.
  23161. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23162. * @param {number} targetSpeed the speed the motor is to reach
  23163. * @param {number} maxForce max force for this motor.
  23164. * @param {motorIndex} the motor's index, 0 or 1.
  23165. */
  23166. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23167. /**
  23168. * Set the motor limits.
  23169. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23170. * @param {number} upperLimit the upper limit
  23171. * @param {number} lowerLimit lower limit
  23172. * @param {motorIndex} the motor's index, 0 or 1.
  23173. */
  23174. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23175. }
  23176. /**
  23177. * Interface for a motor enabled joint
  23178. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23179. */
  23180. export interface IMotorEnabledJoint {
  23181. /**
  23182. * Physics joint
  23183. */
  23184. physicsJoint: any;
  23185. /**
  23186. * Sets the motor of the motor-enabled joint
  23187. * @param force The force of the motor
  23188. * @param maxForce The maximum force of the motor
  23189. * @param motorIndex The index of the motor
  23190. */
  23191. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23192. /**
  23193. * Sets the limit of the motor
  23194. * @param upperLimit The upper limit of the motor
  23195. * @param lowerLimit The lower limit of the motor
  23196. * @param motorIndex The index of the motor
  23197. */
  23198. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23199. }
  23200. /**
  23201. * Joint data for a Distance-Joint
  23202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23203. */
  23204. export interface DistanceJointData extends PhysicsJointData {
  23205. /**
  23206. * Max distance the 2 joint objects can be apart
  23207. */
  23208. maxDistance: number;
  23209. }
  23210. /**
  23211. * Joint data from a spring joint
  23212. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23213. */
  23214. export interface SpringJointData extends PhysicsJointData {
  23215. /**
  23216. * Length of the spring
  23217. */
  23218. length: number;
  23219. /**
  23220. * Stiffness of the spring
  23221. */
  23222. stiffness: number;
  23223. /**
  23224. * Damping of the spring
  23225. */
  23226. damping: number;
  23227. /** this callback will be called when applying the force to the impostors. */
  23228. forceApplicationCallback: () => void;
  23229. }
  23230. }
  23231. declare module "babylonjs/Physics/physicsRaycastResult" {
  23232. import { Vector3 } from "babylonjs/Maths/math.vector";
  23233. /**
  23234. * Holds the data for the raycast result
  23235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23236. */
  23237. export class PhysicsRaycastResult {
  23238. private _hasHit;
  23239. private _hitDistance;
  23240. private _hitNormalWorld;
  23241. private _hitPointWorld;
  23242. private _rayFromWorld;
  23243. private _rayToWorld;
  23244. /**
  23245. * Gets if there was a hit
  23246. */
  23247. readonly hasHit: boolean;
  23248. /**
  23249. * Gets the distance from the hit
  23250. */
  23251. readonly hitDistance: number;
  23252. /**
  23253. * Gets the hit normal/direction in the world
  23254. */
  23255. readonly hitNormalWorld: Vector3;
  23256. /**
  23257. * Gets the hit point in the world
  23258. */
  23259. readonly hitPointWorld: Vector3;
  23260. /**
  23261. * Gets the ray "start point" of the ray in the world
  23262. */
  23263. readonly rayFromWorld: Vector3;
  23264. /**
  23265. * Gets the ray "end point" of the ray in the world
  23266. */
  23267. readonly rayToWorld: Vector3;
  23268. /**
  23269. * Sets the hit data (normal & point in world space)
  23270. * @param hitNormalWorld defines the normal in world space
  23271. * @param hitPointWorld defines the point in world space
  23272. */
  23273. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23274. /**
  23275. * Sets the distance from the start point to the hit point
  23276. * @param distance
  23277. */
  23278. setHitDistance(distance: number): void;
  23279. /**
  23280. * Calculates the distance manually
  23281. */
  23282. calculateHitDistance(): void;
  23283. /**
  23284. * Resets all the values to default
  23285. * @param from The from point on world space
  23286. * @param to The to point on world space
  23287. */
  23288. reset(from?: Vector3, to?: Vector3): void;
  23289. }
  23290. /**
  23291. * Interface for the size containing width and height
  23292. */
  23293. interface IXYZ {
  23294. /**
  23295. * X
  23296. */
  23297. x: number;
  23298. /**
  23299. * Y
  23300. */
  23301. y: number;
  23302. /**
  23303. * Z
  23304. */
  23305. z: number;
  23306. }
  23307. }
  23308. declare module "babylonjs/Physics/IPhysicsEngine" {
  23309. import { Nullable } from "babylonjs/types";
  23310. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23312. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23313. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23314. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23315. /**
  23316. * Interface used to describe a physics joint
  23317. */
  23318. export interface PhysicsImpostorJoint {
  23319. /** Defines the main impostor to which the joint is linked */
  23320. mainImpostor: PhysicsImpostor;
  23321. /** Defines the impostor that is connected to the main impostor using this joint */
  23322. connectedImpostor: PhysicsImpostor;
  23323. /** Defines the joint itself */
  23324. joint: PhysicsJoint;
  23325. }
  23326. /** @hidden */
  23327. export interface IPhysicsEnginePlugin {
  23328. world: any;
  23329. name: string;
  23330. setGravity(gravity: Vector3): void;
  23331. setTimeStep(timeStep: number): void;
  23332. getTimeStep(): number;
  23333. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23334. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23335. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23336. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23337. removePhysicsBody(impostor: PhysicsImpostor): void;
  23338. generateJoint(joint: PhysicsImpostorJoint): void;
  23339. removeJoint(joint: PhysicsImpostorJoint): void;
  23340. isSupported(): boolean;
  23341. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23342. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23343. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23344. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23345. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23346. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23347. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23348. getBodyMass(impostor: PhysicsImpostor): number;
  23349. getBodyFriction(impostor: PhysicsImpostor): number;
  23350. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23351. getBodyRestitution(impostor: PhysicsImpostor): number;
  23352. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23353. getBodyPressure?(impostor: PhysicsImpostor): number;
  23354. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23355. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23356. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23357. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23358. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23359. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23360. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23361. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23362. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23363. sleepBody(impostor: PhysicsImpostor): void;
  23364. wakeUpBody(impostor: PhysicsImpostor): void;
  23365. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23366. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23367. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23368. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23369. getRadius(impostor: PhysicsImpostor): number;
  23370. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23371. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23372. dispose(): void;
  23373. }
  23374. /**
  23375. * Interface used to define a physics engine
  23376. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23377. */
  23378. export interface IPhysicsEngine {
  23379. /**
  23380. * Gets the gravity vector used by the simulation
  23381. */
  23382. gravity: Vector3;
  23383. /**
  23384. * Sets the gravity vector used by the simulation
  23385. * @param gravity defines the gravity vector to use
  23386. */
  23387. setGravity(gravity: Vector3): void;
  23388. /**
  23389. * Set the time step of the physics engine.
  23390. * Default is 1/60.
  23391. * To slow it down, enter 1/600 for example.
  23392. * To speed it up, 1/30
  23393. * @param newTimeStep the new timestep to apply to this world.
  23394. */
  23395. setTimeStep(newTimeStep: number): void;
  23396. /**
  23397. * Get the time step of the physics engine.
  23398. * @returns the current time step
  23399. */
  23400. getTimeStep(): number;
  23401. /**
  23402. * Release all resources
  23403. */
  23404. dispose(): void;
  23405. /**
  23406. * Gets the name of the current physics plugin
  23407. * @returns the name of the plugin
  23408. */
  23409. getPhysicsPluginName(): string;
  23410. /**
  23411. * Adding a new impostor for the impostor tracking.
  23412. * This will be done by the impostor itself.
  23413. * @param impostor the impostor to add
  23414. */
  23415. addImpostor(impostor: PhysicsImpostor): void;
  23416. /**
  23417. * Remove an impostor from the engine.
  23418. * This impostor and its mesh will not longer be updated by the physics engine.
  23419. * @param impostor the impostor to remove
  23420. */
  23421. removeImpostor(impostor: PhysicsImpostor): void;
  23422. /**
  23423. * Add a joint to the physics engine
  23424. * @param mainImpostor defines the main impostor to which the joint is added.
  23425. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23426. * @param joint defines the joint that will connect both impostors.
  23427. */
  23428. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23429. /**
  23430. * Removes a joint from the simulation
  23431. * @param mainImpostor defines the impostor used with the joint
  23432. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23433. * @param joint defines the joint to remove
  23434. */
  23435. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23436. /**
  23437. * Gets the current plugin used to run the simulation
  23438. * @returns current plugin
  23439. */
  23440. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23441. /**
  23442. * Gets the list of physic impostors
  23443. * @returns an array of PhysicsImpostor
  23444. */
  23445. getImpostors(): Array<PhysicsImpostor>;
  23446. /**
  23447. * Gets the impostor for a physics enabled object
  23448. * @param object defines the object impersonated by the impostor
  23449. * @returns the PhysicsImpostor or null if not found
  23450. */
  23451. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23452. /**
  23453. * Gets the impostor for a physics body object
  23454. * @param body defines physics body used by the impostor
  23455. * @returns the PhysicsImpostor or null if not found
  23456. */
  23457. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23458. /**
  23459. * Does a raycast in the physics world
  23460. * @param from when should the ray start?
  23461. * @param to when should the ray end?
  23462. * @returns PhysicsRaycastResult
  23463. */
  23464. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23465. /**
  23466. * Called by the scene. No need to call it.
  23467. * @param delta defines the timespam between frames
  23468. */
  23469. _step(delta: number): void;
  23470. }
  23471. }
  23472. declare module "babylonjs/Physics/physicsImpostor" {
  23473. import { Nullable, IndicesArray } from "babylonjs/types";
  23474. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23475. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23477. import { Scene } from "babylonjs/scene";
  23478. import { Bone } from "babylonjs/Bones/bone";
  23479. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23480. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23481. import { Space } from "babylonjs/Maths/math.axis";
  23482. /**
  23483. * The interface for the physics imposter parameters
  23484. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23485. */
  23486. export interface PhysicsImpostorParameters {
  23487. /**
  23488. * The mass of the physics imposter
  23489. */
  23490. mass: number;
  23491. /**
  23492. * The friction of the physics imposter
  23493. */
  23494. friction?: number;
  23495. /**
  23496. * The coefficient of restitution of the physics imposter
  23497. */
  23498. restitution?: number;
  23499. /**
  23500. * The native options of the physics imposter
  23501. */
  23502. nativeOptions?: any;
  23503. /**
  23504. * Specifies if the parent should be ignored
  23505. */
  23506. ignoreParent?: boolean;
  23507. /**
  23508. * Specifies if bi-directional transformations should be disabled
  23509. */
  23510. disableBidirectionalTransformation?: boolean;
  23511. /**
  23512. * The pressure inside the physics imposter, soft object only
  23513. */
  23514. pressure?: number;
  23515. /**
  23516. * The stiffness the physics imposter, soft object only
  23517. */
  23518. stiffness?: number;
  23519. /**
  23520. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23521. */
  23522. velocityIterations?: number;
  23523. /**
  23524. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23525. */
  23526. positionIterations?: number;
  23527. /**
  23528. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23529. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23530. * Add to fix multiple points
  23531. */
  23532. fixedPoints?: number;
  23533. /**
  23534. * The collision margin around a soft object
  23535. */
  23536. margin?: number;
  23537. /**
  23538. * The collision margin around a soft object
  23539. */
  23540. damping?: number;
  23541. /**
  23542. * The path for a rope based on an extrusion
  23543. */
  23544. path?: any;
  23545. /**
  23546. * The shape of an extrusion used for a rope based on an extrusion
  23547. */
  23548. shape?: any;
  23549. }
  23550. /**
  23551. * Interface for a physics-enabled object
  23552. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23553. */
  23554. export interface IPhysicsEnabledObject {
  23555. /**
  23556. * The position of the physics-enabled object
  23557. */
  23558. position: Vector3;
  23559. /**
  23560. * The rotation of the physics-enabled object
  23561. */
  23562. rotationQuaternion: Nullable<Quaternion>;
  23563. /**
  23564. * The scale of the physics-enabled object
  23565. */
  23566. scaling: Vector3;
  23567. /**
  23568. * The rotation of the physics-enabled object
  23569. */
  23570. rotation?: Vector3;
  23571. /**
  23572. * The parent of the physics-enabled object
  23573. */
  23574. parent?: any;
  23575. /**
  23576. * The bounding info of the physics-enabled object
  23577. * @returns The bounding info of the physics-enabled object
  23578. */
  23579. getBoundingInfo(): BoundingInfo;
  23580. /**
  23581. * Computes the world matrix
  23582. * @param force Specifies if the world matrix should be computed by force
  23583. * @returns A world matrix
  23584. */
  23585. computeWorldMatrix(force: boolean): Matrix;
  23586. /**
  23587. * Gets the world matrix
  23588. * @returns A world matrix
  23589. */
  23590. getWorldMatrix?(): Matrix;
  23591. /**
  23592. * Gets the child meshes
  23593. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23594. * @returns An array of abstract meshes
  23595. */
  23596. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23597. /**
  23598. * Gets the vertex data
  23599. * @param kind The type of vertex data
  23600. * @returns A nullable array of numbers, or a float32 array
  23601. */
  23602. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23603. /**
  23604. * Gets the indices from the mesh
  23605. * @returns A nullable array of index arrays
  23606. */
  23607. getIndices?(): Nullable<IndicesArray>;
  23608. /**
  23609. * Gets the scene from the mesh
  23610. * @returns the indices array or null
  23611. */
  23612. getScene?(): Scene;
  23613. /**
  23614. * Gets the absolute position from the mesh
  23615. * @returns the absolute position
  23616. */
  23617. getAbsolutePosition(): Vector3;
  23618. /**
  23619. * Gets the absolute pivot point from the mesh
  23620. * @returns the absolute pivot point
  23621. */
  23622. getAbsolutePivotPoint(): Vector3;
  23623. /**
  23624. * Rotates the mesh
  23625. * @param axis The axis of rotation
  23626. * @param amount The amount of rotation
  23627. * @param space The space of the rotation
  23628. * @returns The rotation transform node
  23629. */
  23630. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23631. /**
  23632. * Translates the mesh
  23633. * @param axis The axis of translation
  23634. * @param distance The distance of translation
  23635. * @param space The space of the translation
  23636. * @returns The transform node
  23637. */
  23638. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23639. /**
  23640. * Sets the absolute position of the mesh
  23641. * @param absolutePosition The absolute position of the mesh
  23642. * @returns The transform node
  23643. */
  23644. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23645. /**
  23646. * Gets the class name of the mesh
  23647. * @returns The class name
  23648. */
  23649. getClassName(): string;
  23650. }
  23651. /**
  23652. * Represents a physics imposter
  23653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23654. */
  23655. export class PhysicsImpostor {
  23656. /**
  23657. * The physics-enabled object used as the physics imposter
  23658. */
  23659. object: IPhysicsEnabledObject;
  23660. /**
  23661. * The type of the physics imposter
  23662. */
  23663. type: number;
  23664. private _options;
  23665. private _scene?;
  23666. /**
  23667. * The default object size of the imposter
  23668. */
  23669. static DEFAULT_OBJECT_SIZE: Vector3;
  23670. /**
  23671. * The identity quaternion of the imposter
  23672. */
  23673. static IDENTITY_QUATERNION: Quaternion;
  23674. /** @hidden */
  23675. _pluginData: any;
  23676. private _physicsEngine;
  23677. private _physicsBody;
  23678. private _bodyUpdateRequired;
  23679. private _onBeforePhysicsStepCallbacks;
  23680. private _onAfterPhysicsStepCallbacks;
  23681. /** @hidden */
  23682. _onPhysicsCollideCallbacks: Array<{
  23683. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23684. otherImpostors: Array<PhysicsImpostor>;
  23685. }>;
  23686. private _deltaPosition;
  23687. private _deltaRotation;
  23688. private _deltaRotationConjugated;
  23689. /** @hidden */
  23690. _isFromLine: boolean;
  23691. private _parent;
  23692. private _isDisposed;
  23693. private static _tmpVecs;
  23694. private static _tmpQuat;
  23695. /**
  23696. * Specifies if the physics imposter is disposed
  23697. */
  23698. readonly isDisposed: boolean;
  23699. /**
  23700. * Gets the mass of the physics imposter
  23701. */
  23702. mass: number;
  23703. /**
  23704. * Gets the coefficient of friction
  23705. */
  23706. /**
  23707. * Sets the coefficient of friction
  23708. */
  23709. friction: number;
  23710. /**
  23711. * Gets the coefficient of restitution
  23712. */
  23713. /**
  23714. * Sets the coefficient of restitution
  23715. */
  23716. restitution: number;
  23717. /**
  23718. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23719. */
  23720. /**
  23721. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23722. */
  23723. pressure: number;
  23724. /**
  23725. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23726. */
  23727. /**
  23728. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23729. */
  23730. stiffness: number;
  23731. /**
  23732. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23733. */
  23734. /**
  23735. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23736. */
  23737. velocityIterations: number;
  23738. /**
  23739. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23740. */
  23741. /**
  23742. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23743. */
  23744. positionIterations: number;
  23745. /**
  23746. * The unique id of the physics imposter
  23747. * set by the physics engine when adding this impostor to the array
  23748. */
  23749. uniqueId: number;
  23750. /**
  23751. * @hidden
  23752. */
  23753. soft: boolean;
  23754. /**
  23755. * @hidden
  23756. */
  23757. segments: number;
  23758. private _joints;
  23759. /**
  23760. * Initializes the physics imposter
  23761. * @param object The physics-enabled object used as the physics imposter
  23762. * @param type The type of the physics imposter
  23763. * @param _options The options for the physics imposter
  23764. * @param _scene The Babylon scene
  23765. */
  23766. constructor(
  23767. /**
  23768. * The physics-enabled object used as the physics imposter
  23769. */
  23770. object: IPhysicsEnabledObject,
  23771. /**
  23772. * The type of the physics imposter
  23773. */
  23774. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23775. /**
  23776. * This function will completly initialize this impostor.
  23777. * It will create a new body - but only if this mesh has no parent.
  23778. * If it has, this impostor will not be used other than to define the impostor
  23779. * of the child mesh.
  23780. * @hidden
  23781. */
  23782. _init(): void;
  23783. private _getPhysicsParent;
  23784. /**
  23785. * Should a new body be generated.
  23786. * @returns boolean specifying if body initialization is required
  23787. */
  23788. isBodyInitRequired(): boolean;
  23789. /**
  23790. * Sets the updated scaling
  23791. * @param updated Specifies if the scaling is updated
  23792. */
  23793. setScalingUpdated(): void;
  23794. /**
  23795. * Force a regeneration of this or the parent's impostor's body.
  23796. * Use under cautious - This will remove all joints already implemented.
  23797. */
  23798. forceUpdate(): void;
  23799. /**
  23800. * Gets the body that holds this impostor. Either its own, or its parent.
  23801. */
  23802. /**
  23803. * Set the physics body. Used mainly by the physics engine/plugin
  23804. */
  23805. physicsBody: any;
  23806. /**
  23807. * Get the parent of the physics imposter
  23808. * @returns Physics imposter or null
  23809. */
  23810. /**
  23811. * Sets the parent of the physics imposter
  23812. */
  23813. parent: Nullable<PhysicsImpostor>;
  23814. /**
  23815. * Resets the update flags
  23816. */
  23817. resetUpdateFlags(): void;
  23818. /**
  23819. * Gets the object extend size
  23820. * @returns the object extend size
  23821. */
  23822. getObjectExtendSize(): Vector3;
  23823. /**
  23824. * Gets the object center
  23825. * @returns The object center
  23826. */
  23827. getObjectCenter(): Vector3;
  23828. /**
  23829. * Get a specific parametes from the options parameter
  23830. * @param paramName The object parameter name
  23831. * @returns The object parameter
  23832. */
  23833. getParam(paramName: string): any;
  23834. /**
  23835. * Sets a specific parameter in the options given to the physics plugin
  23836. * @param paramName The parameter name
  23837. * @param value The value of the parameter
  23838. */
  23839. setParam(paramName: string, value: number): void;
  23840. /**
  23841. * Specifically change the body's mass option. Won't recreate the physics body object
  23842. * @param mass The mass of the physics imposter
  23843. */
  23844. setMass(mass: number): void;
  23845. /**
  23846. * Gets the linear velocity
  23847. * @returns linear velocity or null
  23848. */
  23849. getLinearVelocity(): Nullable<Vector3>;
  23850. /**
  23851. * Sets the linear velocity
  23852. * @param velocity linear velocity or null
  23853. */
  23854. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23855. /**
  23856. * Gets the angular velocity
  23857. * @returns angular velocity or null
  23858. */
  23859. getAngularVelocity(): Nullable<Vector3>;
  23860. /**
  23861. * Sets the angular velocity
  23862. * @param velocity The velocity or null
  23863. */
  23864. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23865. /**
  23866. * Execute a function with the physics plugin native code
  23867. * Provide a function the will have two variables - the world object and the physics body object
  23868. * @param func The function to execute with the physics plugin native code
  23869. */
  23870. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23871. /**
  23872. * Register a function that will be executed before the physics world is stepping forward
  23873. * @param func The function to execute before the physics world is stepped forward
  23874. */
  23875. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23876. /**
  23877. * Unregister a function that will be executed before the physics world is stepping forward
  23878. * @param func The function to execute before the physics world is stepped forward
  23879. */
  23880. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23881. /**
  23882. * Register a function that will be executed after the physics step
  23883. * @param func The function to execute after physics step
  23884. */
  23885. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23886. /**
  23887. * Unregisters a function that will be executed after the physics step
  23888. * @param func The function to execute after physics step
  23889. */
  23890. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23891. /**
  23892. * register a function that will be executed when this impostor collides against a different body
  23893. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23894. * @param func Callback that is executed on collision
  23895. */
  23896. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23897. /**
  23898. * Unregisters the physics imposter on contact
  23899. * @param collideAgainst The physics object to collide against
  23900. * @param func Callback to execute on collision
  23901. */
  23902. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23903. private _tmpQuat;
  23904. private _tmpQuat2;
  23905. /**
  23906. * Get the parent rotation
  23907. * @returns The parent rotation
  23908. */
  23909. getParentsRotation(): Quaternion;
  23910. /**
  23911. * this function is executed by the physics engine.
  23912. */
  23913. beforeStep: () => void;
  23914. /**
  23915. * this function is executed by the physics engine
  23916. */
  23917. afterStep: () => void;
  23918. /**
  23919. * Legacy collision detection event support
  23920. */
  23921. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23922. /**
  23923. * event and body object due to cannon's event-based architecture.
  23924. */
  23925. onCollide: (e: {
  23926. body: any;
  23927. }) => void;
  23928. /**
  23929. * Apply a force
  23930. * @param force The force to apply
  23931. * @param contactPoint The contact point for the force
  23932. * @returns The physics imposter
  23933. */
  23934. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23935. /**
  23936. * Apply an impulse
  23937. * @param force The impulse force
  23938. * @param contactPoint The contact point for the impulse force
  23939. * @returns The physics imposter
  23940. */
  23941. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23942. /**
  23943. * A help function to create a joint
  23944. * @param otherImpostor A physics imposter used to create a joint
  23945. * @param jointType The type of joint
  23946. * @param jointData The data for the joint
  23947. * @returns The physics imposter
  23948. */
  23949. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23950. /**
  23951. * Add a joint to this impostor with a different impostor
  23952. * @param otherImpostor A physics imposter used to add a joint
  23953. * @param joint The joint to add
  23954. * @returns The physics imposter
  23955. */
  23956. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23957. /**
  23958. * Add an anchor to a cloth impostor
  23959. * @param otherImpostor rigid impostor to anchor to
  23960. * @param width ratio across width from 0 to 1
  23961. * @param height ratio up height from 0 to 1
  23962. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23963. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23964. * @returns impostor the soft imposter
  23965. */
  23966. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23967. /**
  23968. * Add a hook to a rope impostor
  23969. * @param otherImpostor rigid impostor to anchor to
  23970. * @param length ratio across rope from 0 to 1
  23971. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23972. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23973. * @returns impostor the rope imposter
  23974. */
  23975. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23976. /**
  23977. * Will keep this body still, in a sleep mode.
  23978. * @returns the physics imposter
  23979. */
  23980. sleep(): PhysicsImpostor;
  23981. /**
  23982. * Wake the body up.
  23983. * @returns The physics imposter
  23984. */
  23985. wakeUp(): PhysicsImpostor;
  23986. /**
  23987. * Clones the physics imposter
  23988. * @param newObject The physics imposter clones to this physics-enabled object
  23989. * @returns A nullable physics imposter
  23990. */
  23991. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23992. /**
  23993. * Disposes the physics imposter
  23994. */
  23995. dispose(): void;
  23996. /**
  23997. * Sets the delta position
  23998. * @param position The delta position amount
  23999. */
  24000. setDeltaPosition(position: Vector3): void;
  24001. /**
  24002. * Sets the delta rotation
  24003. * @param rotation The delta rotation amount
  24004. */
  24005. setDeltaRotation(rotation: Quaternion): void;
  24006. /**
  24007. * Gets the box size of the physics imposter and stores the result in the input parameter
  24008. * @param result Stores the box size
  24009. * @returns The physics imposter
  24010. */
  24011. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24012. /**
  24013. * Gets the radius of the physics imposter
  24014. * @returns Radius of the physics imposter
  24015. */
  24016. getRadius(): number;
  24017. /**
  24018. * Sync a bone with this impostor
  24019. * @param bone The bone to sync to the impostor.
  24020. * @param boneMesh The mesh that the bone is influencing.
  24021. * @param jointPivot The pivot of the joint / bone in local space.
  24022. * @param distToJoint Optional distance from the impostor to the joint.
  24023. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24024. */
  24025. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24026. /**
  24027. * Sync impostor to a bone
  24028. * @param bone The bone that the impostor will be synced to.
  24029. * @param boneMesh The mesh that the bone is influencing.
  24030. * @param jointPivot The pivot of the joint / bone in local space.
  24031. * @param distToJoint Optional distance from the impostor to the joint.
  24032. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24033. * @param boneAxis Optional vector3 axis the bone is aligned with
  24034. */
  24035. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24036. /**
  24037. * No-Imposter type
  24038. */
  24039. static NoImpostor: number;
  24040. /**
  24041. * Sphere-Imposter type
  24042. */
  24043. static SphereImpostor: number;
  24044. /**
  24045. * Box-Imposter type
  24046. */
  24047. static BoxImpostor: number;
  24048. /**
  24049. * Plane-Imposter type
  24050. */
  24051. static PlaneImpostor: number;
  24052. /**
  24053. * Mesh-imposter type
  24054. */
  24055. static MeshImpostor: number;
  24056. /**
  24057. * Capsule-Impostor type (Ammo.js plugin only)
  24058. */
  24059. static CapsuleImpostor: number;
  24060. /**
  24061. * Cylinder-Imposter type
  24062. */
  24063. static CylinderImpostor: number;
  24064. /**
  24065. * Particle-Imposter type
  24066. */
  24067. static ParticleImpostor: number;
  24068. /**
  24069. * Heightmap-Imposter type
  24070. */
  24071. static HeightmapImpostor: number;
  24072. /**
  24073. * ConvexHull-Impostor type (Ammo.js plugin only)
  24074. */
  24075. static ConvexHullImpostor: number;
  24076. /**
  24077. * Rope-Imposter type
  24078. */
  24079. static RopeImpostor: number;
  24080. /**
  24081. * Cloth-Imposter type
  24082. */
  24083. static ClothImpostor: number;
  24084. /**
  24085. * Softbody-Imposter type
  24086. */
  24087. static SoftbodyImpostor: number;
  24088. }
  24089. }
  24090. declare module "babylonjs/Meshes/mesh" {
  24091. import { Observable } from "babylonjs/Misc/observable";
  24092. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24093. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24094. import { Camera } from "babylonjs/Cameras/camera";
  24095. import { Scene } from "babylonjs/scene";
  24096. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24097. import { Color4 } from "babylonjs/Maths/math.color";
  24098. import { Engine } from "babylonjs/Engines/engine";
  24099. import { Node } from "babylonjs/node";
  24100. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24101. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24102. import { Buffer } from "babylonjs/Meshes/buffer";
  24103. import { Geometry } from "babylonjs/Meshes/geometry";
  24104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24105. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24106. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24107. import { Effect } from "babylonjs/Materials/effect";
  24108. import { Material } from "babylonjs/Materials/material";
  24109. import { Skeleton } from "babylonjs/Bones/skeleton";
  24110. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24111. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24112. import { Path3D } from "babylonjs/Maths/math.path";
  24113. import { Plane } from "babylonjs/Maths/math.plane";
  24114. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24115. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24116. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24117. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24118. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24119. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24120. /**
  24121. * @hidden
  24122. **/
  24123. export class _CreationDataStorage {
  24124. closePath?: boolean;
  24125. closeArray?: boolean;
  24126. idx: number[];
  24127. dashSize: number;
  24128. gapSize: number;
  24129. path3D: Path3D;
  24130. pathArray: Vector3[][];
  24131. arc: number;
  24132. radius: number;
  24133. cap: number;
  24134. tessellation: number;
  24135. }
  24136. /**
  24137. * @hidden
  24138. **/
  24139. class _InstanceDataStorage {
  24140. visibleInstances: any;
  24141. batchCache: _InstancesBatch;
  24142. instancesBufferSize: number;
  24143. instancesBuffer: Nullable<Buffer>;
  24144. instancesData: Float32Array;
  24145. overridenInstanceCount: number;
  24146. isFrozen: boolean;
  24147. previousBatch: Nullable<_InstancesBatch>;
  24148. hardwareInstancedRendering: boolean;
  24149. sideOrientation: number;
  24150. }
  24151. /**
  24152. * @hidden
  24153. **/
  24154. export class _InstancesBatch {
  24155. mustReturn: boolean;
  24156. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24157. renderSelf: boolean[];
  24158. hardwareInstancedRendering: boolean[];
  24159. }
  24160. /**
  24161. * Class used to represent renderable models
  24162. */
  24163. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24164. /**
  24165. * Mesh side orientation : usually the external or front surface
  24166. */
  24167. static readonly FRONTSIDE: number;
  24168. /**
  24169. * Mesh side orientation : usually the internal or back surface
  24170. */
  24171. static readonly BACKSIDE: number;
  24172. /**
  24173. * Mesh side orientation : both internal and external or front and back surfaces
  24174. */
  24175. static readonly DOUBLESIDE: number;
  24176. /**
  24177. * Mesh side orientation : by default, `FRONTSIDE`
  24178. */
  24179. static readonly DEFAULTSIDE: number;
  24180. /**
  24181. * Mesh cap setting : no cap
  24182. */
  24183. static readonly NO_CAP: number;
  24184. /**
  24185. * Mesh cap setting : one cap at the beginning of the mesh
  24186. */
  24187. static readonly CAP_START: number;
  24188. /**
  24189. * Mesh cap setting : one cap at the end of the mesh
  24190. */
  24191. static readonly CAP_END: number;
  24192. /**
  24193. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24194. */
  24195. static readonly CAP_ALL: number;
  24196. /**
  24197. * Mesh pattern setting : no flip or rotate
  24198. */
  24199. static readonly NO_FLIP: number;
  24200. /**
  24201. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24202. */
  24203. static readonly FLIP_TILE: number;
  24204. /**
  24205. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24206. */
  24207. static readonly ROTATE_TILE: number;
  24208. /**
  24209. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24210. */
  24211. static readonly FLIP_ROW: number;
  24212. /**
  24213. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24214. */
  24215. static readonly ROTATE_ROW: number;
  24216. /**
  24217. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24218. */
  24219. static readonly FLIP_N_ROTATE_TILE: number;
  24220. /**
  24221. * Mesh pattern setting : rotate pattern and rotate
  24222. */
  24223. static readonly FLIP_N_ROTATE_ROW: number;
  24224. /**
  24225. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24226. */
  24227. static readonly CENTER: number;
  24228. /**
  24229. * Mesh tile positioning : part tiles on left
  24230. */
  24231. static readonly LEFT: number;
  24232. /**
  24233. * Mesh tile positioning : part tiles on right
  24234. */
  24235. static readonly RIGHT: number;
  24236. /**
  24237. * Mesh tile positioning : part tiles on top
  24238. */
  24239. static readonly TOP: number;
  24240. /**
  24241. * Mesh tile positioning : part tiles on bottom
  24242. */
  24243. static readonly BOTTOM: number;
  24244. /**
  24245. * Gets the default side orientation.
  24246. * @param orientation the orientation to value to attempt to get
  24247. * @returns the default orientation
  24248. * @hidden
  24249. */
  24250. static _GetDefaultSideOrientation(orientation?: number): number;
  24251. private _internalMeshDataInfo;
  24252. /**
  24253. * An event triggered before rendering the mesh
  24254. */
  24255. readonly onBeforeRenderObservable: Observable<Mesh>;
  24256. /**
  24257. * An event triggered before binding the mesh
  24258. */
  24259. readonly onBeforeBindObservable: Observable<Mesh>;
  24260. /**
  24261. * An event triggered after rendering the mesh
  24262. */
  24263. readonly onAfterRenderObservable: Observable<Mesh>;
  24264. /**
  24265. * An event triggered before drawing the mesh
  24266. */
  24267. readonly onBeforeDrawObservable: Observable<Mesh>;
  24268. private _onBeforeDrawObserver;
  24269. /**
  24270. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24271. */
  24272. onBeforeDraw: () => void;
  24273. readonly hasInstances: boolean;
  24274. /**
  24275. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24276. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24277. */
  24278. delayLoadState: number;
  24279. /**
  24280. * Gets the list of instances created from this mesh
  24281. * it is not supposed to be modified manually.
  24282. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24283. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24284. */
  24285. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24286. /**
  24287. * Gets the file containing delay loading data for this mesh
  24288. */
  24289. delayLoadingFile: string;
  24290. /** @hidden */
  24291. _binaryInfo: any;
  24292. /**
  24293. * User defined function used to change how LOD level selection is done
  24294. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24295. */
  24296. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24297. /**
  24298. * Gets or sets the morph target manager
  24299. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24300. */
  24301. morphTargetManager: Nullable<MorphTargetManager>;
  24302. /** @hidden */
  24303. _creationDataStorage: Nullable<_CreationDataStorage>;
  24304. /** @hidden */
  24305. _geometry: Nullable<Geometry>;
  24306. /** @hidden */
  24307. _delayInfo: Array<string>;
  24308. /** @hidden */
  24309. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24310. /** @hidden */
  24311. _instanceDataStorage: _InstanceDataStorage;
  24312. private _effectiveMaterial;
  24313. /** @hidden */
  24314. _shouldGenerateFlatShading: boolean;
  24315. /** @hidden */
  24316. _originalBuilderSideOrientation: number;
  24317. /**
  24318. * Use this property to change the original side orientation defined at construction time
  24319. */
  24320. overrideMaterialSideOrientation: Nullable<number>;
  24321. /**
  24322. * Gets the source mesh (the one used to clone this one from)
  24323. */
  24324. readonly source: Nullable<Mesh>;
  24325. /**
  24326. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24327. */
  24328. isUnIndexed: boolean;
  24329. /**
  24330. * @constructor
  24331. * @param name The value used by scene.getMeshByName() to do a lookup.
  24332. * @param scene The scene to add this mesh to.
  24333. * @param parent The parent of this mesh, if it has one
  24334. * @param source An optional Mesh from which geometry is shared, cloned.
  24335. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24336. * When false, achieved by calling a clone(), also passing False.
  24337. * This will make creation of children, recursive.
  24338. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24339. */
  24340. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24341. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24342. /**
  24343. * Gets the class name
  24344. * @returns the string "Mesh".
  24345. */
  24346. getClassName(): string;
  24347. /** @hidden */
  24348. readonly _isMesh: boolean;
  24349. /**
  24350. * Returns a description of this mesh
  24351. * @param fullDetails define if full details about this mesh must be used
  24352. * @returns a descriptive string representing this mesh
  24353. */
  24354. toString(fullDetails?: boolean): string;
  24355. /** @hidden */
  24356. _unBindEffect(): void;
  24357. /**
  24358. * Gets a boolean indicating if this mesh has LOD
  24359. */
  24360. readonly hasLODLevels: boolean;
  24361. /**
  24362. * Gets the list of MeshLODLevel associated with the current mesh
  24363. * @returns an array of MeshLODLevel
  24364. */
  24365. getLODLevels(): MeshLODLevel[];
  24366. private _sortLODLevels;
  24367. /**
  24368. * Add a mesh as LOD level triggered at the given distance.
  24369. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24370. * @param distance The distance from the center of the object to show this level
  24371. * @param mesh The mesh to be added as LOD level (can be null)
  24372. * @return This mesh (for chaining)
  24373. */
  24374. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24375. /**
  24376. * Returns the LOD level mesh at the passed distance or null if not found.
  24377. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24378. * @param distance The distance from the center of the object to show this level
  24379. * @returns a Mesh or `null`
  24380. */
  24381. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24382. /**
  24383. * Remove a mesh from the LOD array
  24384. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24385. * @param mesh defines the mesh to be removed
  24386. * @return This mesh (for chaining)
  24387. */
  24388. removeLODLevel(mesh: Mesh): Mesh;
  24389. /**
  24390. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24391. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24392. * @param camera defines the camera to use to compute distance
  24393. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24394. * @return This mesh (for chaining)
  24395. */
  24396. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24397. /**
  24398. * Gets the mesh internal Geometry object
  24399. */
  24400. readonly geometry: Nullable<Geometry>;
  24401. /**
  24402. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24403. * @returns the total number of vertices
  24404. */
  24405. getTotalVertices(): number;
  24406. /**
  24407. * Returns the content of an associated vertex buffer
  24408. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24409. * - VertexBuffer.PositionKind
  24410. * - VertexBuffer.UVKind
  24411. * - VertexBuffer.UV2Kind
  24412. * - VertexBuffer.UV3Kind
  24413. * - VertexBuffer.UV4Kind
  24414. * - VertexBuffer.UV5Kind
  24415. * - VertexBuffer.UV6Kind
  24416. * - VertexBuffer.ColorKind
  24417. * - VertexBuffer.MatricesIndicesKind
  24418. * - VertexBuffer.MatricesIndicesExtraKind
  24419. * - VertexBuffer.MatricesWeightsKind
  24420. * - VertexBuffer.MatricesWeightsExtraKind
  24421. * @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
  24422. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24423. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24424. */
  24425. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24426. /**
  24427. * Returns the mesh VertexBuffer object from the requested `kind`
  24428. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24429. * - VertexBuffer.PositionKind
  24430. * - VertexBuffer.NormalKind
  24431. * - VertexBuffer.UVKind
  24432. * - VertexBuffer.UV2Kind
  24433. * - VertexBuffer.UV3Kind
  24434. * - VertexBuffer.UV4Kind
  24435. * - VertexBuffer.UV5Kind
  24436. * - VertexBuffer.UV6Kind
  24437. * - VertexBuffer.ColorKind
  24438. * - VertexBuffer.MatricesIndicesKind
  24439. * - VertexBuffer.MatricesIndicesExtraKind
  24440. * - VertexBuffer.MatricesWeightsKind
  24441. * - VertexBuffer.MatricesWeightsExtraKind
  24442. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24443. */
  24444. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24445. /**
  24446. * Tests if a specific vertex buffer is associated with this mesh
  24447. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24448. * - VertexBuffer.PositionKind
  24449. * - VertexBuffer.NormalKind
  24450. * - VertexBuffer.UVKind
  24451. * - VertexBuffer.UV2Kind
  24452. * - VertexBuffer.UV3Kind
  24453. * - VertexBuffer.UV4Kind
  24454. * - VertexBuffer.UV5Kind
  24455. * - VertexBuffer.UV6Kind
  24456. * - VertexBuffer.ColorKind
  24457. * - VertexBuffer.MatricesIndicesKind
  24458. * - VertexBuffer.MatricesIndicesExtraKind
  24459. * - VertexBuffer.MatricesWeightsKind
  24460. * - VertexBuffer.MatricesWeightsExtraKind
  24461. * @returns a boolean
  24462. */
  24463. isVerticesDataPresent(kind: string): boolean;
  24464. /**
  24465. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24466. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24467. * - VertexBuffer.PositionKind
  24468. * - VertexBuffer.UVKind
  24469. * - VertexBuffer.UV2Kind
  24470. * - VertexBuffer.UV3Kind
  24471. * - VertexBuffer.UV4Kind
  24472. * - VertexBuffer.UV5Kind
  24473. * - VertexBuffer.UV6Kind
  24474. * - VertexBuffer.ColorKind
  24475. * - VertexBuffer.MatricesIndicesKind
  24476. * - VertexBuffer.MatricesIndicesExtraKind
  24477. * - VertexBuffer.MatricesWeightsKind
  24478. * - VertexBuffer.MatricesWeightsExtraKind
  24479. * @returns a boolean
  24480. */
  24481. isVertexBufferUpdatable(kind: string): boolean;
  24482. /**
  24483. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24484. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24485. * - VertexBuffer.PositionKind
  24486. * - VertexBuffer.NormalKind
  24487. * - VertexBuffer.UVKind
  24488. * - VertexBuffer.UV2Kind
  24489. * - VertexBuffer.UV3Kind
  24490. * - VertexBuffer.UV4Kind
  24491. * - VertexBuffer.UV5Kind
  24492. * - VertexBuffer.UV6Kind
  24493. * - VertexBuffer.ColorKind
  24494. * - VertexBuffer.MatricesIndicesKind
  24495. * - VertexBuffer.MatricesIndicesExtraKind
  24496. * - VertexBuffer.MatricesWeightsKind
  24497. * - VertexBuffer.MatricesWeightsExtraKind
  24498. * @returns an array of strings
  24499. */
  24500. getVerticesDataKinds(): string[];
  24501. /**
  24502. * Returns a positive integer : the total number of indices in this mesh geometry.
  24503. * @returns the numner of indices or zero if the mesh has no geometry.
  24504. */
  24505. getTotalIndices(): number;
  24506. /**
  24507. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24508. * @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.
  24509. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24510. * @returns the indices array or an empty array if the mesh has no geometry
  24511. */
  24512. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24513. readonly isBlocked: boolean;
  24514. /**
  24515. * Determine if the current mesh is ready to be rendered
  24516. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24517. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24518. * @returns true if all associated assets are ready (material, textures, shaders)
  24519. */
  24520. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24521. /**
  24522. * 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.
  24523. */
  24524. readonly areNormalsFrozen: boolean;
  24525. /**
  24526. * 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.
  24527. * @returns the current mesh
  24528. */
  24529. freezeNormals(): Mesh;
  24530. /**
  24531. * 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
  24532. * @returns the current mesh
  24533. */
  24534. unfreezeNormals(): Mesh;
  24535. /**
  24536. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24537. */
  24538. overridenInstanceCount: number;
  24539. /** @hidden */
  24540. _preActivate(): Mesh;
  24541. /** @hidden */
  24542. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24543. /** @hidden */
  24544. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24545. /**
  24546. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24547. * This means the mesh underlying bounding box and sphere are recomputed.
  24548. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24549. * @returns the current mesh
  24550. */
  24551. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24552. /** @hidden */
  24553. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24554. /**
  24555. * This function will subdivide the mesh into multiple submeshes
  24556. * @param count defines the expected number of submeshes
  24557. */
  24558. subdivide(count: number): void;
  24559. /**
  24560. * Copy a FloatArray into a specific associated vertex buffer
  24561. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24562. * - VertexBuffer.PositionKind
  24563. * - VertexBuffer.UVKind
  24564. * - VertexBuffer.UV2Kind
  24565. * - VertexBuffer.UV3Kind
  24566. * - VertexBuffer.UV4Kind
  24567. * - VertexBuffer.UV5Kind
  24568. * - VertexBuffer.UV6Kind
  24569. * - VertexBuffer.ColorKind
  24570. * - VertexBuffer.MatricesIndicesKind
  24571. * - VertexBuffer.MatricesIndicesExtraKind
  24572. * - VertexBuffer.MatricesWeightsKind
  24573. * - VertexBuffer.MatricesWeightsExtraKind
  24574. * @param data defines the data source
  24575. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24576. * @param stride defines the data stride size (can be null)
  24577. * @returns the current mesh
  24578. */
  24579. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24580. /**
  24581. * Flags an associated vertex buffer as updatable
  24582. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24583. * - VertexBuffer.PositionKind
  24584. * - VertexBuffer.UVKind
  24585. * - VertexBuffer.UV2Kind
  24586. * - VertexBuffer.UV3Kind
  24587. * - VertexBuffer.UV4Kind
  24588. * - VertexBuffer.UV5Kind
  24589. * - VertexBuffer.UV6Kind
  24590. * - VertexBuffer.ColorKind
  24591. * - VertexBuffer.MatricesIndicesKind
  24592. * - VertexBuffer.MatricesIndicesExtraKind
  24593. * - VertexBuffer.MatricesWeightsKind
  24594. * - VertexBuffer.MatricesWeightsExtraKind
  24595. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24596. */
  24597. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24598. /**
  24599. * Sets the mesh global Vertex Buffer
  24600. * @param buffer defines the buffer to use
  24601. * @returns the current mesh
  24602. */
  24603. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24604. /**
  24605. * Update a specific associated vertex buffer
  24606. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24607. * - VertexBuffer.PositionKind
  24608. * - VertexBuffer.UVKind
  24609. * - VertexBuffer.UV2Kind
  24610. * - VertexBuffer.UV3Kind
  24611. * - VertexBuffer.UV4Kind
  24612. * - VertexBuffer.UV5Kind
  24613. * - VertexBuffer.UV6Kind
  24614. * - VertexBuffer.ColorKind
  24615. * - VertexBuffer.MatricesIndicesKind
  24616. * - VertexBuffer.MatricesIndicesExtraKind
  24617. * - VertexBuffer.MatricesWeightsKind
  24618. * - VertexBuffer.MatricesWeightsExtraKind
  24619. * @param data defines the data source
  24620. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24621. * @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)
  24622. * @returns the current mesh
  24623. */
  24624. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24625. /**
  24626. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24627. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24628. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24629. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24630. * @returns the current mesh
  24631. */
  24632. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24633. /**
  24634. * Creates a un-shared specific occurence of the geometry for the mesh.
  24635. * @returns the current mesh
  24636. */
  24637. makeGeometryUnique(): Mesh;
  24638. /**
  24639. * Set the index buffer of this mesh
  24640. * @param indices defines the source data
  24641. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24642. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24643. * @returns the current mesh
  24644. */
  24645. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24646. /**
  24647. * Update the current index buffer
  24648. * @param indices defines the source data
  24649. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24650. * @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)
  24651. * @returns the current mesh
  24652. */
  24653. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24654. /**
  24655. * Invert the geometry to move from a right handed system to a left handed one.
  24656. * @returns the current mesh
  24657. */
  24658. toLeftHanded(): Mesh;
  24659. /** @hidden */
  24660. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24661. /** @hidden */
  24662. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24663. /**
  24664. * Registers for this mesh a javascript function called just before the rendering process
  24665. * @param func defines the function to call before rendering this mesh
  24666. * @returns the current mesh
  24667. */
  24668. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24669. /**
  24670. * Disposes a previously registered javascript function called before the rendering
  24671. * @param func defines the function to remove
  24672. * @returns the current mesh
  24673. */
  24674. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24675. /**
  24676. * Registers for this mesh a javascript function called just after the rendering is complete
  24677. * @param func defines the function to call after rendering this mesh
  24678. * @returns the current mesh
  24679. */
  24680. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24681. /**
  24682. * Disposes a previously registered javascript function called after the rendering.
  24683. * @param func defines the function to remove
  24684. * @returns the current mesh
  24685. */
  24686. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24687. /** @hidden */
  24688. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24689. /** @hidden */
  24690. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24691. /** @hidden */
  24692. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24693. /** @hidden */
  24694. _rebuild(): void;
  24695. /** @hidden */
  24696. _freeze(): void;
  24697. /** @hidden */
  24698. _unFreeze(): void;
  24699. /**
  24700. * 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
  24701. * @param subMesh defines the subMesh to render
  24702. * @param enableAlphaMode defines if alpha mode can be changed
  24703. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24704. * @returns the current mesh
  24705. */
  24706. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24707. private _onBeforeDraw;
  24708. /**
  24709. * Renormalize the mesh and patch it up if there are no weights
  24710. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24711. * However in the case of zero weights then we set just a single influence to 1.
  24712. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24713. */
  24714. cleanMatrixWeights(): void;
  24715. private normalizeSkinFourWeights;
  24716. private normalizeSkinWeightsAndExtra;
  24717. /**
  24718. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24719. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24720. * the user know there was an issue with importing the mesh
  24721. * @returns a validation object with skinned, valid and report string
  24722. */
  24723. validateSkinning(): {
  24724. skinned: boolean;
  24725. valid: boolean;
  24726. report: string;
  24727. };
  24728. /** @hidden */
  24729. _checkDelayState(): Mesh;
  24730. private _queueLoad;
  24731. /**
  24732. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24733. * A mesh is in the frustum if its bounding box intersects the frustum
  24734. * @param frustumPlanes defines the frustum to test
  24735. * @returns true if the mesh is in the frustum planes
  24736. */
  24737. isInFrustum(frustumPlanes: Plane[]): boolean;
  24738. /**
  24739. * Sets the mesh material by the material or multiMaterial `id` property
  24740. * @param id is a string identifying the material or the multiMaterial
  24741. * @returns the current mesh
  24742. */
  24743. setMaterialByID(id: string): Mesh;
  24744. /**
  24745. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24746. * @returns an array of IAnimatable
  24747. */
  24748. getAnimatables(): IAnimatable[];
  24749. /**
  24750. * Modifies the mesh geometry according to the passed transformation matrix.
  24751. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24752. * The mesh normals are modified using the same transformation.
  24753. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24754. * @param transform defines the transform matrix to use
  24755. * @see http://doc.babylonjs.com/resources/baking_transformations
  24756. * @returns the current mesh
  24757. */
  24758. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24759. /**
  24760. * Modifies the mesh geometry according to its own current World Matrix.
  24761. * The mesh World Matrix is then reset.
  24762. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24763. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24764. * @see http://doc.babylonjs.com/resources/baking_transformations
  24765. * @returns the current mesh
  24766. */
  24767. bakeCurrentTransformIntoVertices(): Mesh;
  24768. /** @hidden */
  24769. readonly _positions: Nullable<Vector3[]>;
  24770. /** @hidden */
  24771. _resetPointsArrayCache(): Mesh;
  24772. /** @hidden */
  24773. _generatePointsArray(): boolean;
  24774. /**
  24775. * Returns a new Mesh object generated from the current mesh properties.
  24776. * This method must not get confused with createInstance()
  24777. * @param name is a string, the name given to the new mesh
  24778. * @param newParent can be any Node object (default `null`)
  24779. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24780. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24781. * @returns a new mesh
  24782. */
  24783. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24784. /**
  24785. * Releases resources associated with this mesh.
  24786. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24787. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24788. */
  24789. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24790. /**
  24791. * Modifies the mesh geometry according to a displacement map.
  24792. * 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.
  24793. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24794. * @param url is a string, the URL from the image file is to be downloaded.
  24795. * @param minHeight is the lower limit of the displacement.
  24796. * @param maxHeight is the upper limit of the displacement.
  24797. * @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.
  24798. * @param uvOffset is an optional vector2 used to offset UV.
  24799. * @param uvScale is an optional vector2 used to scale UV.
  24800. * @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.
  24801. * @returns the Mesh.
  24802. */
  24803. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24804. /**
  24805. * Modifies the mesh geometry according to a displacementMap buffer.
  24806. * 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.
  24807. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24808. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24809. * @param heightMapWidth is the width of the buffer image.
  24810. * @param heightMapHeight is the height of the buffer image.
  24811. * @param minHeight is the lower limit of the displacement.
  24812. * @param maxHeight is the upper limit of the displacement.
  24813. * @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.
  24814. * @param uvOffset is an optional vector2 used to offset UV.
  24815. * @param uvScale is an optional vector2 used to scale UV.
  24816. * @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.
  24817. * @returns the Mesh.
  24818. */
  24819. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24820. /**
  24821. * Modify the mesh to get a flat shading rendering.
  24822. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24823. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24824. * @returns current mesh
  24825. */
  24826. convertToFlatShadedMesh(): Mesh;
  24827. /**
  24828. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24829. * In other words, more vertices, no more indices and a single bigger VBO.
  24830. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24831. * @returns current mesh
  24832. */
  24833. convertToUnIndexedMesh(): Mesh;
  24834. /**
  24835. * Inverses facet orientations.
  24836. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24837. * @param flipNormals will also inverts the normals
  24838. * @returns current mesh
  24839. */
  24840. flipFaces(flipNormals?: boolean): Mesh;
  24841. /**
  24842. * Increase the number of facets and hence vertices in a mesh
  24843. * Vertex normals are interpolated from existing vertex normals
  24844. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24845. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24846. */
  24847. increaseVertices(numberPerEdge: number): void;
  24848. /**
  24849. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24850. * This will undo any application of covertToFlatShadedMesh
  24851. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24852. */
  24853. forceSharedVertices(): void;
  24854. /** @hidden */
  24855. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24856. /** @hidden */
  24857. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24858. /**
  24859. * Creates a new InstancedMesh object from the mesh model.
  24860. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24861. * @param name defines the name of the new instance
  24862. * @returns a new InstancedMesh
  24863. */
  24864. createInstance(name: string): InstancedMesh;
  24865. /**
  24866. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24867. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24868. * @returns the current mesh
  24869. */
  24870. synchronizeInstances(): Mesh;
  24871. /**
  24872. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24873. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24874. * This should be used together with the simplification to avoid disappearing triangles.
  24875. * @param successCallback an optional success callback to be called after the optimization finished.
  24876. * @returns the current mesh
  24877. */
  24878. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24879. /**
  24880. * Serialize current mesh
  24881. * @param serializationObject defines the object which will receive the serialization data
  24882. */
  24883. serialize(serializationObject: any): void;
  24884. /** @hidden */
  24885. _syncGeometryWithMorphTargetManager(): void;
  24886. /** @hidden */
  24887. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24888. /**
  24889. * Returns a new Mesh object parsed from the source provided.
  24890. * @param parsedMesh is the source
  24891. * @param scene defines the hosting scene
  24892. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24893. * @returns a new Mesh
  24894. */
  24895. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24896. /**
  24897. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24898. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24899. * @param name defines the name of the mesh to create
  24900. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24901. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24902. * @param closePath creates a seam between the first and the last points of each path of the path array
  24903. * @param offset is taken in account only if the `pathArray` is containing a single path
  24904. * @param scene defines the hosting scene
  24905. * @param updatable defines if the mesh must be flagged as updatable
  24906. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24907. * @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)
  24908. * @returns a new Mesh
  24909. */
  24910. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24911. /**
  24912. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24913. * @param name defines the name of the mesh to create
  24914. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24915. * @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
  24916. * @param scene defines the hosting scene
  24917. * @param updatable defines if the mesh must be flagged as updatable
  24918. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24919. * @returns a new Mesh
  24920. */
  24921. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24922. /**
  24923. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24924. * @param name defines the name of the mesh to create
  24925. * @param size sets the size (float) of each box side (default 1)
  24926. * @param scene defines the hosting scene
  24927. * @param updatable defines if the mesh must be flagged as updatable
  24928. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24929. * @returns a new Mesh
  24930. */
  24931. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24932. /**
  24933. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24934. * @param name defines the name of the mesh to create
  24935. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24936. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24937. * @param scene defines the hosting scene
  24938. * @param updatable defines if the mesh must be flagged as updatable
  24939. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24940. * @returns a new Mesh
  24941. */
  24942. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24943. /**
  24944. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24945. * @param name defines the name of the mesh to create
  24946. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24947. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24948. * @param scene defines the hosting scene
  24949. * @returns a new Mesh
  24950. */
  24951. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24952. /**
  24953. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24954. * @param name defines the name of the mesh to create
  24955. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24956. * @param diameterTop set the top cap diameter (floats, default 1)
  24957. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24958. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24959. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24960. * @param scene defines the hosting scene
  24961. * @param updatable defines if the mesh must be flagged as updatable
  24962. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24963. * @returns a new Mesh
  24964. */
  24965. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24966. /**
  24967. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24968. * @param name defines the name of the mesh to create
  24969. * @param diameter sets the diameter size (float) of the torus (default 1)
  24970. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24971. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24972. * @param scene defines the hosting scene
  24973. * @param updatable defines if the mesh must be flagged as updatable
  24974. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24975. * @returns a new Mesh
  24976. */
  24977. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24978. /**
  24979. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24980. * @param name defines the name of the mesh to create
  24981. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24982. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24983. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24984. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24985. * @param p the number of windings on X axis (positive integers, default 2)
  24986. * @param q the number of windings on Y axis (positive integers, default 3)
  24987. * @param scene defines the hosting scene
  24988. * @param updatable defines if the mesh must be flagged as updatable
  24989. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24990. * @returns a new Mesh
  24991. */
  24992. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24993. /**
  24994. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24995. * @param name defines the name of the mesh to create
  24996. * @param points is an array successive Vector3
  24997. * @param scene defines the hosting scene
  24998. * @param updatable defines if the mesh must be flagged as updatable
  24999. * @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).
  25000. * @returns a new Mesh
  25001. */
  25002. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25003. /**
  25004. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25005. * @param name defines the name of the mesh to create
  25006. * @param points is an array successive Vector3
  25007. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25008. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25009. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25010. * @param scene defines the hosting scene
  25011. * @param updatable defines if the mesh must be flagged as updatable
  25012. * @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)
  25013. * @returns a new Mesh
  25014. */
  25015. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25016. /**
  25017. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25018. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25019. * 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.
  25020. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25021. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25022. * Remember you can only change the shape positions, not their number when updating a polygon.
  25023. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25024. * @param name defines the name of the mesh to create
  25025. * @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
  25026. * @param scene defines the hosting scene
  25027. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25028. * @param updatable defines if the mesh must be flagged as updatable
  25029. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25030. * @param earcutInjection can be used to inject your own earcut reference
  25031. * @returns a new Mesh
  25032. */
  25033. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25034. /**
  25035. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25036. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25037. * @param name defines the name of the mesh to create
  25038. * @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
  25039. * @param depth defines the height of extrusion
  25040. * @param scene defines the hosting scene
  25041. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25042. * @param updatable defines if the mesh must be flagged as updatable
  25043. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25044. * @param earcutInjection can be used to inject your own earcut reference
  25045. * @returns a new Mesh
  25046. */
  25047. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25048. /**
  25049. * Creates an extruded shape mesh.
  25050. * 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
  25051. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25052. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25053. * @param name defines the name of the mesh to create
  25054. * @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
  25055. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25056. * @param scale is the value to scale the shape
  25057. * @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
  25058. * @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
  25059. * @param scene defines the hosting scene
  25060. * @param updatable defines if the mesh must be flagged as updatable
  25061. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25062. * @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)
  25063. * @returns a new Mesh
  25064. */
  25065. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25066. /**
  25067. * Creates an custom extruded shape mesh.
  25068. * The custom extrusion is a parametric shape.
  25069. * It has no predefined shape. Its final shape will depend on the input parameters.
  25070. * Please consider using the same method from the MeshBuilder class instead
  25071. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25072. * @param name defines the name of the mesh to create
  25073. * @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
  25074. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25075. * @param scaleFunction is a custom Javascript function called on each path point
  25076. * @param rotationFunction is a custom Javascript function called on each path point
  25077. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25078. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25079. * @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
  25080. * @param scene defines the hosting scene
  25081. * @param updatable defines if the mesh must be flagged as updatable
  25082. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25083. * @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)
  25084. * @returns a new Mesh
  25085. */
  25086. 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;
  25087. /**
  25088. * Creates lathe mesh.
  25089. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25090. * Please consider using the same method from the MeshBuilder class instead
  25091. * @param name defines the name of the mesh to create
  25092. * @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
  25093. * @param radius is the radius value of the lathe
  25094. * @param tessellation is the side number of the lathe.
  25095. * @param scene defines the hosting scene
  25096. * @param updatable defines if the mesh must be flagged as updatable
  25097. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25098. * @returns a new Mesh
  25099. */
  25100. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25101. /**
  25102. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25103. * @param name defines the name of the mesh to create
  25104. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25105. * @param scene defines the hosting scene
  25106. * @param updatable defines if the mesh must be flagged as updatable
  25107. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25108. * @returns a new Mesh
  25109. */
  25110. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25111. /**
  25112. * Creates a ground mesh.
  25113. * Please consider using the same method from the MeshBuilder class instead
  25114. * @param name defines the name of the mesh to create
  25115. * @param width set the width of the ground
  25116. * @param height set the height of the ground
  25117. * @param subdivisions sets the number of subdivisions per side
  25118. * @param scene defines the hosting scene
  25119. * @param updatable defines if the mesh must be flagged as updatable
  25120. * @returns a new Mesh
  25121. */
  25122. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25123. /**
  25124. * Creates a tiled ground mesh.
  25125. * Please consider using the same method from the MeshBuilder class instead
  25126. * @param name defines the name of the mesh to create
  25127. * @param xmin set the ground minimum X coordinate
  25128. * @param zmin set the ground minimum Y coordinate
  25129. * @param xmax set the ground maximum X coordinate
  25130. * @param zmax set the ground maximum Z coordinate
  25131. * @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
  25132. * @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
  25133. * @param scene defines the hosting scene
  25134. * @param updatable defines if the mesh must be flagged as updatable
  25135. * @returns a new Mesh
  25136. */
  25137. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25138. w: number;
  25139. h: number;
  25140. }, precision: {
  25141. w: number;
  25142. h: number;
  25143. }, scene: Scene, updatable?: boolean): Mesh;
  25144. /**
  25145. * Creates a ground mesh from a height map.
  25146. * Please consider using the same method from the MeshBuilder class instead
  25147. * @see http://doc.babylonjs.com/babylon101/height_map
  25148. * @param name defines the name of the mesh to create
  25149. * @param url sets the URL of the height map image resource
  25150. * @param width set the ground width size
  25151. * @param height set the ground height size
  25152. * @param subdivisions sets the number of subdivision per side
  25153. * @param minHeight is the minimum altitude on the ground
  25154. * @param maxHeight is the maximum altitude on the ground
  25155. * @param scene defines the hosting scene
  25156. * @param updatable defines if the mesh must be flagged as updatable
  25157. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25158. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25159. * @returns a new Mesh
  25160. */
  25161. 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;
  25162. /**
  25163. * Creates a tube mesh.
  25164. * The tube is a parametric shape.
  25165. * It has no predefined shape. Its final shape will depend on the input parameters.
  25166. * Please consider using the same method from the MeshBuilder class instead
  25167. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25168. * @param name defines the name of the mesh to create
  25169. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25170. * @param radius sets the tube radius size
  25171. * @param tessellation is the number of sides on the tubular surface
  25172. * @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
  25173. * @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
  25174. * @param scene defines the hosting scene
  25175. * @param updatable defines if the mesh must be flagged as updatable
  25176. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25177. * @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)
  25178. * @returns a new Mesh
  25179. */
  25180. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25181. (i: number, distance: number): number;
  25182. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25183. /**
  25184. * Creates a polyhedron mesh.
  25185. * Please consider using the same method from the MeshBuilder class instead.
  25186. * * 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
  25187. * * The parameter `size` (positive float, default 1) sets the polygon size
  25188. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25189. * * 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`
  25190. * * 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
  25191. * * 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)`)
  25192. * * 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
  25193. * * 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
  25194. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25195. * * 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
  25196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25197. * @param name defines the name of the mesh to create
  25198. * @param options defines the options used to create the mesh
  25199. * @param scene defines the hosting scene
  25200. * @returns a new Mesh
  25201. */
  25202. static CreatePolyhedron(name: string, options: {
  25203. type?: number;
  25204. size?: number;
  25205. sizeX?: number;
  25206. sizeY?: number;
  25207. sizeZ?: number;
  25208. custom?: any;
  25209. faceUV?: Vector4[];
  25210. faceColors?: Color4[];
  25211. updatable?: boolean;
  25212. sideOrientation?: number;
  25213. }, scene: Scene): Mesh;
  25214. /**
  25215. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25216. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25217. * * 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`)
  25218. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25219. * * 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
  25220. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25221. * * 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
  25222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25223. * @param name defines the name of the mesh
  25224. * @param options defines the options used to create the mesh
  25225. * @param scene defines the hosting scene
  25226. * @returns a new Mesh
  25227. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25228. */
  25229. static CreateIcoSphere(name: string, options: {
  25230. radius?: number;
  25231. flat?: boolean;
  25232. subdivisions?: number;
  25233. sideOrientation?: number;
  25234. updatable?: boolean;
  25235. }, scene: Scene): Mesh;
  25236. /**
  25237. * Creates a decal mesh.
  25238. * Please consider using the same method from the MeshBuilder class instead.
  25239. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25240. * @param name defines the name of the mesh
  25241. * @param sourceMesh defines the mesh receiving the decal
  25242. * @param position sets the position of the decal in world coordinates
  25243. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25244. * @param size sets the decal scaling
  25245. * @param angle sets the angle to rotate the decal
  25246. * @returns a new Mesh
  25247. */
  25248. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25249. /**
  25250. * Prepare internal position array for software CPU skinning
  25251. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25252. */
  25253. setPositionsForCPUSkinning(): Float32Array;
  25254. /**
  25255. * Prepare internal normal array for software CPU skinning
  25256. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25257. */
  25258. setNormalsForCPUSkinning(): Float32Array;
  25259. /**
  25260. * Updates the vertex buffer by applying transformation from the bones
  25261. * @param skeleton defines the skeleton to apply to current mesh
  25262. * @returns the current mesh
  25263. */
  25264. applySkeleton(skeleton: Skeleton): Mesh;
  25265. /**
  25266. * 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
  25267. * @param meshes defines the list of meshes to scan
  25268. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25269. */
  25270. static MinMax(meshes: AbstractMesh[]): {
  25271. min: Vector3;
  25272. max: Vector3;
  25273. };
  25274. /**
  25275. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25276. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25277. * @returns a vector3
  25278. */
  25279. static Center(meshesOrMinMaxVector: {
  25280. min: Vector3;
  25281. max: Vector3;
  25282. } | AbstractMesh[]): Vector3;
  25283. /**
  25284. * Merge the array of meshes into a single mesh for performance reasons.
  25285. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25286. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25287. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25288. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25289. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25290. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25291. * @returns a new mesh
  25292. */
  25293. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25294. /** @hidden */
  25295. addInstance(instance: InstancedMesh): void;
  25296. /** @hidden */
  25297. removeInstance(instance: InstancedMesh): void;
  25298. }
  25299. }
  25300. declare module "babylonjs/Cameras/camera" {
  25301. import { SmartArray } from "babylonjs/Misc/smartArray";
  25302. import { Observable } from "babylonjs/Misc/observable";
  25303. import { Nullable } from "babylonjs/types";
  25304. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25305. import { Scene } from "babylonjs/scene";
  25306. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25307. import { Node } from "babylonjs/node";
  25308. import { Mesh } from "babylonjs/Meshes/mesh";
  25309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25310. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25311. import { Viewport } from "babylonjs/Maths/math.viewport";
  25312. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25313. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25314. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25315. import { Ray } from "babylonjs/Culling/ray";
  25316. /**
  25317. * This is the base class of all the camera used in the application.
  25318. * @see http://doc.babylonjs.com/features/cameras
  25319. */
  25320. export class Camera extends Node {
  25321. /** @hidden */
  25322. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25323. /**
  25324. * This is the default projection mode used by the cameras.
  25325. * It helps recreating a feeling of perspective and better appreciate depth.
  25326. * This is the best way to simulate real life cameras.
  25327. */
  25328. static readonly PERSPECTIVE_CAMERA: number;
  25329. /**
  25330. * This helps creating camera with an orthographic mode.
  25331. * 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.
  25332. */
  25333. static readonly ORTHOGRAPHIC_CAMERA: number;
  25334. /**
  25335. * This is the default FOV mode for perspective cameras.
  25336. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25337. */
  25338. static readonly FOVMODE_VERTICAL_FIXED: number;
  25339. /**
  25340. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25341. */
  25342. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25343. /**
  25344. * This specifies ther is no need for a camera rig.
  25345. * Basically only one eye is rendered corresponding to the camera.
  25346. */
  25347. static readonly RIG_MODE_NONE: number;
  25348. /**
  25349. * Simulates a camera Rig with one blue eye and one red eye.
  25350. * This can be use with 3d blue and red glasses.
  25351. */
  25352. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25353. /**
  25354. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25355. */
  25356. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25357. /**
  25358. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25359. */
  25360. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25361. /**
  25362. * Defines that both eyes of the camera will be rendered over under each other.
  25363. */
  25364. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25365. /**
  25366. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25367. */
  25368. static readonly RIG_MODE_VR: number;
  25369. /**
  25370. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25371. */
  25372. static readonly RIG_MODE_WEBVR: number;
  25373. /**
  25374. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25375. */
  25376. static readonly RIG_MODE_CUSTOM: number;
  25377. /**
  25378. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25379. */
  25380. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25381. /**
  25382. * Define the input manager associated with the camera.
  25383. */
  25384. inputs: CameraInputsManager<Camera>;
  25385. /** @hidden */
  25386. _position: Vector3;
  25387. /**
  25388. * Define the current local position of the camera in the scene
  25389. */
  25390. position: Vector3;
  25391. /**
  25392. * The vector the camera should consider as up.
  25393. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25394. */
  25395. upVector: Vector3;
  25396. /**
  25397. * Define the current limit on the left side for an orthographic camera
  25398. * In scene unit
  25399. */
  25400. orthoLeft: Nullable<number>;
  25401. /**
  25402. * Define the current limit on the right side for an orthographic camera
  25403. * In scene unit
  25404. */
  25405. orthoRight: Nullable<number>;
  25406. /**
  25407. * Define the current limit on the bottom side for an orthographic camera
  25408. * In scene unit
  25409. */
  25410. orthoBottom: Nullable<number>;
  25411. /**
  25412. * Define the current limit on the top side for an orthographic camera
  25413. * In scene unit
  25414. */
  25415. orthoTop: Nullable<number>;
  25416. /**
  25417. * Field Of View is set in Radians. (default is 0.8)
  25418. */
  25419. fov: number;
  25420. /**
  25421. * Define the minimum distance the camera can see from.
  25422. * This is important to note that the depth buffer are not infinite and the closer it starts
  25423. * the more your scene might encounter depth fighting issue.
  25424. */
  25425. minZ: number;
  25426. /**
  25427. * Define the maximum distance the camera can see to.
  25428. * This is important to note that the depth buffer are not infinite and the further it end
  25429. * the more your scene might encounter depth fighting issue.
  25430. */
  25431. maxZ: number;
  25432. /**
  25433. * Define the default inertia of the camera.
  25434. * This helps giving a smooth feeling to the camera movement.
  25435. */
  25436. inertia: number;
  25437. /**
  25438. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25439. */
  25440. mode: number;
  25441. /**
  25442. * Define wether the camera is intermediate.
  25443. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25444. */
  25445. isIntermediate: boolean;
  25446. /**
  25447. * Define the viewport of the camera.
  25448. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25449. */
  25450. viewport: Viewport;
  25451. /**
  25452. * Restricts the camera to viewing objects with the same layerMask.
  25453. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25454. */
  25455. layerMask: number;
  25456. /**
  25457. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25458. */
  25459. fovMode: number;
  25460. /**
  25461. * Rig mode of the camera.
  25462. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25463. * This is normally controlled byt the camera themselves as internal use.
  25464. */
  25465. cameraRigMode: number;
  25466. /**
  25467. * Defines the distance between both "eyes" in case of a RIG
  25468. */
  25469. interaxialDistance: number;
  25470. /**
  25471. * Defines if stereoscopic rendering is done side by side or over under.
  25472. */
  25473. isStereoscopicSideBySide: boolean;
  25474. /**
  25475. * 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
  25476. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25477. * else in the scene. (Eg. security camera)
  25478. *
  25479. * 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)
  25480. */
  25481. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25482. /**
  25483. * When set, the camera will render to this render target instead of the default canvas
  25484. *
  25485. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25486. */
  25487. outputRenderTarget: Nullable<RenderTargetTexture>;
  25488. /**
  25489. * Observable triggered when the camera view matrix has changed.
  25490. */
  25491. onViewMatrixChangedObservable: Observable<Camera>;
  25492. /**
  25493. * Observable triggered when the camera Projection matrix has changed.
  25494. */
  25495. onProjectionMatrixChangedObservable: Observable<Camera>;
  25496. /**
  25497. * Observable triggered when the inputs have been processed.
  25498. */
  25499. onAfterCheckInputsObservable: Observable<Camera>;
  25500. /**
  25501. * Observable triggered when reset has been called and applied to the camera.
  25502. */
  25503. onRestoreStateObservable: Observable<Camera>;
  25504. /** @hidden */
  25505. _cameraRigParams: any;
  25506. /** @hidden */
  25507. _rigCameras: Camera[];
  25508. /** @hidden */
  25509. _rigPostProcess: Nullable<PostProcess>;
  25510. protected _webvrViewMatrix: Matrix;
  25511. /** @hidden */
  25512. _skipRendering: boolean;
  25513. /** @hidden */
  25514. _projectionMatrix: Matrix;
  25515. /** @hidden */
  25516. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25517. /** @hidden */
  25518. _activeMeshes: SmartArray<AbstractMesh>;
  25519. protected _globalPosition: Vector3;
  25520. /** @hidden */
  25521. _computedViewMatrix: Matrix;
  25522. private _doNotComputeProjectionMatrix;
  25523. private _transformMatrix;
  25524. private _frustumPlanes;
  25525. private _refreshFrustumPlanes;
  25526. private _storedFov;
  25527. private _stateStored;
  25528. /**
  25529. * Instantiates a new camera object.
  25530. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25531. * @see http://doc.babylonjs.com/features/cameras
  25532. * @param name Defines the name of the camera in the scene
  25533. * @param position Defines the position of the camera
  25534. * @param scene Defines the scene the camera belongs too
  25535. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25536. */
  25537. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25538. /**
  25539. * Store current camera state (fov, position, etc..)
  25540. * @returns the camera
  25541. */
  25542. storeState(): Camera;
  25543. /**
  25544. * Restores the camera state values if it has been stored. You must call storeState() first
  25545. */
  25546. protected _restoreStateValues(): boolean;
  25547. /**
  25548. * Restored camera state. You must call storeState() first.
  25549. * @returns true if restored and false otherwise
  25550. */
  25551. restoreState(): boolean;
  25552. /**
  25553. * Gets the class name of the camera.
  25554. * @returns the class name
  25555. */
  25556. getClassName(): string;
  25557. /** @hidden */
  25558. readonly _isCamera: boolean;
  25559. /**
  25560. * Gets a string representation of the camera useful for debug purpose.
  25561. * @param fullDetails Defines that a more verboe level of logging is required
  25562. * @returns the string representation
  25563. */
  25564. toString(fullDetails?: boolean): string;
  25565. /**
  25566. * Gets the current world space position of the camera.
  25567. */
  25568. readonly globalPosition: Vector3;
  25569. /**
  25570. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25571. * @returns the active meshe list
  25572. */
  25573. getActiveMeshes(): SmartArray<AbstractMesh>;
  25574. /**
  25575. * Check wether a mesh is part of the current active mesh list of the camera
  25576. * @param mesh Defines the mesh to check
  25577. * @returns true if active, false otherwise
  25578. */
  25579. isActiveMesh(mesh: Mesh): boolean;
  25580. /**
  25581. * Is this camera ready to be used/rendered
  25582. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25583. * @return true if the camera is ready
  25584. */
  25585. isReady(completeCheck?: boolean): boolean;
  25586. /** @hidden */
  25587. _initCache(): void;
  25588. /** @hidden */
  25589. _updateCache(ignoreParentClass?: boolean): void;
  25590. /** @hidden */
  25591. _isSynchronized(): boolean;
  25592. /** @hidden */
  25593. _isSynchronizedViewMatrix(): boolean;
  25594. /** @hidden */
  25595. _isSynchronizedProjectionMatrix(): boolean;
  25596. /**
  25597. * Attach the input controls to a specific dom element to get the input from.
  25598. * @param element Defines the element the controls should be listened from
  25599. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25600. */
  25601. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25602. /**
  25603. * Detach the current controls from the specified dom element.
  25604. * @param element Defines the element to stop listening the inputs from
  25605. */
  25606. detachControl(element: HTMLElement): void;
  25607. /**
  25608. * Update the camera state according to the different inputs gathered during the frame.
  25609. */
  25610. update(): void;
  25611. /** @hidden */
  25612. _checkInputs(): void;
  25613. /** @hidden */
  25614. readonly rigCameras: Camera[];
  25615. /**
  25616. * Gets the post process used by the rig cameras
  25617. */
  25618. readonly rigPostProcess: Nullable<PostProcess>;
  25619. /**
  25620. * Internal, gets the first post proces.
  25621. * @returns the first post process to be run on this camera.
  25622. */
  25623. _getFirstPostProcess(): Nullable<PostProcess>;
  25624. private _cascadePostProcessesToRigCams;
  25625. /**
  25626. * Attach a post process to the camera.
  25627. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25628. * @param postProcess The post process to attach to the camera
  25629. * @param insertAt The position of the post process in case several of them are in use in the scene
  25630. * @returns the position the post process has been inserted at
  25631. */
  25632. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25633. /**
  25634. * Detach a post process to the camera.
  25635. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25636. * @param postProcess The post process to detach from the camera
  25637. */
  25638. detachPostProcess(postProcess: PostProcess): void;
  25639. /**
  25640. * Gets the current world matrix of the camera
  25641. */
  25642. getWorldMatrix(): Matrix;
  25643. /** @hidden */
  25644. _getViewMatrix(): Matrix;
  25645. /**
  25646. * Gets the current view matrix of the camera.
  25647. * @param force forces the camera to recompute the matrix without looking at the cached state
  25648. * @returns the view matrix
  25649. */
  25650. getViewMatrix(force?: boolean): Matrix;
  25651. /**
  25652. * Freeze the projection matrix.
  25653. * It will prevent the cache check of the camera projection compute and can speed up perf
  25654. * if no parameter of the camera are meant to change
  25655. * @param projection Defines manually a projection if necessary
  25656. */
  25657. freezeProjectionMatrix(projection?: Matrix): void;
  25658. /**
  25659. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25660. */
  25661. unfreezeProjectionMatrix(): void;
  25662. /**
  25663. * Gets the current projection matrix of the camera.
  25664. * @param force forces the camera to recompute the matrix without looking at the cached state
  25665. * @returns the projection matrix
  25666. */
  25667. getProjectionMatrix(force?: boolean): Matrix;
  25668. /**
  25669. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25670. * @returns a Matrix
  25671. */
  25672. getTransformationMatrix(): Matrix;
  25673. private _updateFrustumPlanes;
  25674. /**
  25675. * Checks if a cullable object (mesh...) is in the camera frustum
  25676. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25677. * @param target The object to check
  25678. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25679. * @returns true if the object is in frustum otherwise false
  25680. */
  25681. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25682. /**
  25683. * Checks if a cullable object (mesh...) is in the camera frustum
  25684. * Unlike isInFrustum this cheks the full bounding box
  25685. * @param target The object to check
  25686. * @returns true if the object is in frustum otherwise false
  25687. */
  25688. isCompletelyInFrustum(target: ICullable): boolean;
  25689. /**
  25690. * Gets a ray in the forward direction from the camera.
  25691. * @param length Defines the length of the ray to create
  25692. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25693. * @param origin Defines the start point of the ray which defaults to the camera position
  25694. * @returns the forward ray
  25695. */
  25696. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25697. /**
  25698. * Releases resources associated with this node.
  25699. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25700. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25701. */
  25702. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25703. /** @hidden */
  25704. _isLeftCamera: boolean;
  25705. /**
  25706. * Gets the left camera of a rig setup in case of Rigged Camera
  25707. */
  25708. readonly isLeftCamera: boolean;
  25709. /** @hidden */
  25710. _isRightCamera: boolean;
  25711. /**
  25712. * Gets the right camera of a rig setup in case of Rigged Camera
  25713. */
  25714. readonly isRightCamera: boolean;
  25715. /**
  25716. * Gets the left camera of a rig setup in case of Rigged Camera
  25717. */
  25718. readonly leftCamera: Nullable<FreeCamera>;
  25719. /**
  25720. * Gets the right camera of a rig setup in case of Rigged Camera
  25721. */
  25722. readonly rightCamera: Nullable<FreeCamera>;
  25723. /**
  25724. * Gets the left camera target of a rig setup in case of Rigged Camera
  25725. * @returns the target position
  25726. */
  25727. getLeftTarget(): Nullable<Vector3>;
  25728. /**
  25729. * Gets the right camera target of a rig setup in case of Rigged Camera
  25730. * @returns the target position
  25731. */
  25732. getRightTarget(): Nullable<Vector3>;
  25733. /**
  25734. * @hidden
  25735. */
  25736. setCameraRigMode(mode: number, rigParams: any): void;
  25737. /** @hidden */
  25738. static _setStereoscopicRigMode(camera: Camera): void;
  25739. /** @hidden */
  25740. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25741. /** @hidden */
  25742. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25743. /** @hidden */
  25744. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25745. /** @hidden */
  25746. _getVRProjectionMatrix(): Matrix;
  25747. protected _updateCameraRotationMatrix(): void;
  25748. protected _updateWebVRCameraRotationMatrix(): void;
  25749. /**
  25750. * This function MUST be overwritten by the different WebVR cameras available.
  25751. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25752. * @hidden
  25753. */
  25754. _getWebVRProjectionMatrix(): Matrix;
  25755. /**
  25756. * This function MUST be overwritten by the different WebVR cameras available.
  25757. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25758. * @hidden
  25759. */
  25760. _getWebVRViewMatrix(): Matrix;
  25761. /** @hidden */
  25762. setCameraRigParameter(name: string, value: any): void;
  25763. /**
  25764. * needs to be overridden by children so sub has required properties to be copied
  25765. * @hidden
  25766. */
  25767. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25768. /**
  25769. * May need to be overridden by children
  25770. * @hidden
  25771. */
  25772. _updateRigCameras(): void;
  25773. /** @hidden */
  25774. _setupInputs(): void;
  25775. /**
  25776. * Serialiaze the camera setup to a json represention
  25777. * @returns the JSON representation
  25778. */
  25779. serialize(): any;
  25780. /**
  25781. * Clones the current camera.
  25782. * @param name The cloned camera name
  25783. * @returns the cloned camera
  25784. */
  25785. clone(name: string): Camera;
  25786. /**
  25787. * Gets the direction of the camera relative to a given local axis.
  25788. * @param localAxis Defines the reference axis to provide a relative direction.
  25789. * @return the direction
  25790. */
  25791. getDirection(localAxis: Vector3): Vector3;
  25792. /**
  25793. * Returns the current camera absolute rotation
  25794. */
  25795. readonly absoluteRotation: Quaternion;
  25796. /**
  25797. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25798. * @param localAxis Defines the reference axis to provide a relative direction.
  25799. * @param result Defines the vector to store the result in
  25800. */
  25801. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25802. /**
  25803. * Gets a camera constructor for a given camera type
  25804. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25805. * @param name The name of the camera the result will be able to instantiate
  25806. * @param scene The scene the result will construct the camera in
  25807. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25808. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25809. * @returns a factory method to construc the camera
  25810. */
  25811. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25812. /**
  25813. * Compute the world matrix of the camera.
  25814. * @returns the camera workd matrix
  25815. */
  25816. computeWorldMatrix(): Matrix;
  25817. /**
  25818. * Parse a JSON and creates the camera from the parsed information
  25819. * @param parsedCamera The JSON to parse
  25820. * @param scene The scene to instantiate the camera in
  25821. * @returns the newly constructed camera
  25822. */
  25823. static Parse(parsedCamera: any, scene: Scene): Camera;
  25824. }
  25825. }
  25826. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25827. import { Nullable } from "babylonjs/types";
  25828. import { Scene } from "babylonjs/scene";
  25829. import { Vector4 } from "babylonjs/Maths/math.vector";
  25830. import { Mesh } from "babylonjs/Meshes/mesh";
  25831. /**
  25832. * Class containing static functions to help procedurally build meshes
  25833. */
  25834. export class DiscBuilder {
  25835. /**
  25836. * Creates a plane polygonal mesh. By default, this is a disc
  25837. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25838. * * 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
  25839. * * 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
  25840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25841. * * 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
  25842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25843. * @param name defines the name of the mesh
  25844. * @param options defines the options used to create the mesh
  25845. * @param scene defines the hosting scene
  25846. * @returns the plane polygonal mesh
  25847. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25848. */
  25849. static CreateDisc(name: string, options: {
  25850. radius?: number;
  25851. tessellation?: number;
  25852. arc?: number;
  25853. updatable?: boolean;
  25854. sideOrientation?: number;
  25855. frontUVs?: Vector4;
  25856. backUVs?: Vector4;
  25857. }, scene?: Nullable<Scene>): Mesh;
  25858. }
  25859. }
  25860. declare module "babylonjs/Particles/solidParticleSystem" {
  25861. import { Vector3 } from "babylonjs/Maths/math.vector";
  25862. import { Mesh } from "babylonjs/Meshes/mesh";
  25863. import { Scene, IDisposable } from "babylonjs/scene";
  25864. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25865. /**
  25866. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25867. *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.
  25868. * The SPS is also a particle system. It provides some methods to manage the particles.
  25869. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25870. *
  25871. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25872. */
  25873. export class SolidParticleSystem implements IDisposable {
  25874. /**
  25875. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25876. * Example : var p = SPS.particles[i];
  25877. */
  25878. particles: SolidParticle[];
  25879. /**
  25880. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25881. */
  25882. nbParticles: number;
  25883. /**
  25884. * If the particles must ever face the camera (default false). Useful for planar particles.
  25885. */
  25886. billboard: boolean;
  25887. /**
  25888. * Recompute normals when adding a shape
  25889. */
  25890. recomputeNormals: boolean;
  25891. /**
  25892. * This a counter ofr your own usage. It's not set by any SPS functions.
  25893. */
  25894. counter: number;
  25895. /**
  25896. * The SPS name. This name is also given to the underlying mesh.
  25897. */
  25898. name: string;
  25899. /**
  25900. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25901. */
  25902. mesh: Mesh;
  25903. /**
  25904. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25905. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25906. */
  25907. vars: any;
  25908. /**
  25909. * This array is populated when the SPS is set as 'pickable'.
  25910. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25911. * Each element of this array is an object `{idx: int, faceId: int}`.
  25912. * `idx` is the picked particle index in the `SPS.particles` array
  25913. * `faceId` is the picked face index counted within this particle.
  25914. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25915. */
  25916. pickedParticles: {
  25917. idx: number;
  25918. faceId: number;
  25919. }[];
  25920. /**
  25921. * This array is populated when `enableDepthSort` is set to true.
  25922. * Each element of this array is an instance of the class DepthSortedParticle.
  25923. */
  25924. depthSortedParticles: DepthSortedParticle[];
  25925. /**
  25926. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25927. * @hidden
  25928. */
  25929. _bSphereOnly: boolean;
  25930. /**
  25931. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25932. * @hidden
  25933. */
  25934. _bSphereRadiusFactor: number;
  25935. private _scene;
  25936. private _positions;
  25937. private _indices;
  25938. private _normals;
  25939. private _colors;
  25940. private _uvs;
  25941. private _indices32;
  25942. private _positions32;
  25943. private _normals32;
  25944. private _fixedNormal32;
  25945. private _colors32;
  25946. private _uvs32;
  25947. private _index;
  25948. private _updatable;
  25949. private _pickable;
  25950. private _isVisibilityBoxLocked;
  25951. private _alwaysVisible;
  25952. private _depthSort;
  25953. private _expandable;
  25954. private _shapeCounter;
  25955. private _copy;
  25956. private _color;
  25957. private _computeParticleColor;
  25958. private _computeParticleTexture;
  25959. private _computeParticleRotation;
  25960. private _computeParticleVertex;
  25961. private _computeBoundingBox;
  25962. private _depthSortParticles;
  25963. private _camera;
  25964. private _mustUnrotateFixedNormals;
  25965. private _particlesIntersect;
  25966. private _needs32Bits;
  25967. /**
  25968. * Creates a SPS (Solid Particle System) object.
  25969. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25970. * @param scene (Scene) is the scene in which the SPS is added.
  25971. * @param options defines the options of the sps e.g.
  25972. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25973. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25974. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25975. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  25976. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25977. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25978. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25979. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25980. */
  25981. constructor(name: string, scene: Scene, options?: {
  25982. updatable?: boolean;
  25983. isPickable?: boolean;
  25984. enableDepthSort?: boolean;
  25985. particleIntersection?: boolean;
  25986. boundingSphereOnly?: boolean;
  25987. bSphereRadiusFactor?: number;
  25988. expandable?: boolean;
  25989. });
  25990. /**
  25991. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25992. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25993. * @returns the created mesh
  25994. */
  25995. buildMesh(): Mesh;
  25996. /**
  25997. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25998. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25999. * Thus the particles generated from `digest()` have their property `position` set yet.
  26000. * @param mesh ( Mesh ) is the mesh to be digested
  26001. * @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
  26002. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26003. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26004. * @returns the current SPS
  26005. */
  26006. digest(mesh: Mesh, options?: {
  26007. facetNb?: number;
  26008. number?: number;
  26009. delta?: number;
  26010. }): SolidParticleSystem;
  26011. private _unrotateFixedNormals;
  26012. private _resetCopy;
  26013. private _meshBuilder;
  26014. private _posToShape;
  26015. private _uvsToShapeUV;
  26016. private _addParticle;
  26017. /**
  26018. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26019. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26020. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26021. * @param nb (positive integer) the number of particles to be created from this model
  26022. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26023. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26024. * @returns the number of shapes in the system
  26025. */
  26026. addShape(mesh: Mesh, nb: number, options?: {
  26027. positionFunction?: any;
  26028. vertexFunction?: any;
  26029. }): number;
  26030. private _rebuildParticle;
  26031. /**
  26032. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26033. * @returns the SPS.
  26034. */
  26035. rebuildMesh(): SolidParticleSystem;
  26036. /**
  26037. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26038. * This method calls `updateParticle()` for each particle of the SPS.
  26039. * For an animated SPS, it is usually called within the render loop.
  26040. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26041. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26042. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26043. * @returns the SPS.
  26044. */
  26045. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26046. /**
  26047. * Disposes the SPS.
  26048. */
  26049. dispose(): void;
  26050. /**
  26051. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26052. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26053. * @returns the SPS.
  26054. */
  26055. refreshVisibleSize(): SolidParticleSystem;
  26056. /**
  26057. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26058. * @param size the size (float) of the visibility box
  26059. * note : this doesn't lock the SPS mesh bounding box.
  26060. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26061. */
  26062. setVisibilityBox(size: number): void;
  26063. /**
  26064. * Gets whether the SPS as always visible or not
  26065. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26066. */
  26067. /**
  26068. * Sets the SPS as always visible or not
  26069. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26070. */
  26071. isAlwaysVisible: boolean;
  26072. /**
  26073. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26074. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26075. */
  26076. /**
  26077. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26078. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26079. */
  26080. isVisibilityBoxLocked: boolean;
  26081. /**
  26082. * Tells to `setParticles()` to compute the particle rotations or not.
  26083. * Default value : true. The SPS is faster when it's set to false.
  26084. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26085. */
  26086. /**
  26087. * Gets if `setParticles()` computes the particle rotations or not.
  26088. * Default value : true. The SPS is faster when it's set to false.
  26089. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26090. */
  26091. computeParticleRotation: boolean;
  26092. /**
  26093. * Tells to `setParticles()` to compute the particle colors or not.
  26094. * Default value : true. The SPS is faster when it's set to false.
  26095. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26096. */
  26097. /**
  26098. * Gets if `setParticles()` computes the particle colors or not.
  26099. * Default value : true. The SPS is faster when it's set to false.
  26100. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26101. */
  26102. computeParticleColor: boolean;
  26103. /**
  26104. * Gets if `setParticles()` computes the particle textures or not.
  26105. * Default value : true. The SPS is faster when it's set to false.
  26106. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26107. */
  26108. computeParticleTexture: boolean;
  26109. /**
  26110. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26111. * Default value : false. The SPS is faster when it's set to false.
  26112. * Note : the particle custom vertex positions aren't stored values.
  26113. */
  26114. /**
  26115. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26116. * Default value : false. The SPS is faster when it's set to false.
  26117. * Note : the particle custom vertex positions aren't stored values.
  26118. */
  26119. computeParticleVertex: boolean;
  26120. /**
  26121. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26122. */
  26123. /**
  26124. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26125. */
  26126. computeBoundingBox: boolean;
  26127. /**
  26128. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26129. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26130. * Default : `true`
  26131. */
  26132. /**
  26133. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26134. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26135. * Default : `true`
  26136. */
  26137. depthSortParticles: boolean;
  26138. /**
  26139. * Gets if the SPS is created as expandable at construction time.
  26140. * Default : `false`
  26141. */
  26142. readonly expandable: boolean;
  26143. /**
  26144. * This function does nothing. It may be overwritten to set all the particle first values.
  26145. * The SPS doesn't call this function, you may have to call it by your own.
  26146. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26147. */
  26148. initParticles(): void;
  26149. /**
  26150. * This function does nothing. It may be overwritten to recycle a particle.
  26151. * The SPS doesn't call this function, you may have to call it by your own.
  26152. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26153. * @param particle The particle to recycle
  26154. * @returns the recycled particle
  26155. */
  26156. recycleParticle(particle: SolidParticle): SolidParticle;
  26157. /**
  26158. * Updates a particle : this function should be overwritten by the user.
  26159. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26160. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26161. * @example : just set a particle position or velocity and recycle conditions
  26162. * @param particle The particle to update
  26163. * @returns the updated particle
  26164. */
  26165. updateParticle(particle: SolidParticle): SolidParticle;
  26166. /**
  26167. * Updates a vertex of a particle : it can be overwritten by the user.
  26168. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26169. * @param particle the current particle
  26170. * @param vertex the current index of the current particle
  26171. * @param pt the index of the current vertex in the particle shape
  26172. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26173. * @example : just set a vertex particle position
  26174. * @returns the updated vertex
  26175. */
  26176. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26177. /**
  26178. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26179. * This does nothing and may be overwritten by the user.
  26180. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26181. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26182. * @param update the boolean update value actually passed to setParticles()
  26183. */
  26184. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26185. /**
  26186. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26187. * This will be passed three parameters.
  26188. * This does nothing and may be overwritten by the user.
  26189. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26190. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26191. * @param update the boolean update value actually passed to setParticles()
  26192. */
  26193. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26194. }
  26195. }
  26196. declare module "babylonjs/Particles/solidParticle" {
  26197. import { Nullable } from "babylonjs/types";
  26198. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26199. import { Color4 } from "babylonjs/Maths/math.color";
  26200. import { Mesh } from "babylonjs/Meshes/mesh";
  26201. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26202. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26203. import { Plane } from "babylonjs/Maths/math.plane";
  26204. /**
  26205. * Represents one particle of a solid particle system.
  26206. */
  26207. export class SolidParticle {
  26208. /**
  26209. * particle global index
  26210. */
  26211. idx: number;
  26212. /**
  26213. * The color of the particle
  26214. */
  26215. color: Nullable<Color4>;
  26216. /**
  26217. * The world space position of the particle.
  26218. */
  26219. position: Vector3;
  26220. /**
  26221. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26222. */
  26223. rotation: Vector3;
  26224. /**
  26225. * The world space rotation quaternion of the particle.
  26226. */
  26227. rotationQuaternion: Nullable<Quaternion>;
  26228. /**
  26229. * The scaling of the particle.
  26230. */
  26231. scaling: Vector3;
  26232. /**
  26233. * The uvs of the particle.
  26234. */
  26235. uvs: Vector4;
  26236. /**
  26237. * The current speed of the particle.
  26238. */
  26239. velocity: Vector3;
  26240. /**
  26241. * The pivot point in the particle local space.
  26242. */
  26243. pivot: Vector3;
  26244. /**
  26245. * Must the particle be translated from its pivot point in its local space ?
  26246. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26247. * Default : false
  26248. */
  26249. translateFromPivot: boolean;
  26250. /**
  26251. * Is the particle active or not ?
  26252. */
  26253. alive: boolean;
  26254. /**
  26255. * Is the particle visible or not ?
  26256. */
  26257. isVisible: boolean;
  26258. /**
  26259. * Index of this particle in the global "positions" array (Internal use)
  26260. * @hidden
  26261. */
  26262. _pos: number;
  26263. /**
  26264. * @hidden Index of this particle in the global "indices" array (Internal use)
  26265. */
  26266. _ind: number;
  26267. /**
  26268. * @hidden ModelShape of this particle (Internal use)
  26269. */
  26270. _model: ModelShape;
  26271. /**
  26272. * ModelShape id of this particle
  26273. */
  26274. shapeId: number;
  26275. /**
  26276. * Index of the particle in its shape id
  26277. */
  26278. idxInShape: number;
  26279. /**
  26280. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26281. */
  26282. _modelBoundingInfo: BoundingInfo;
  26283. /**
  26284. * @hidden Particle BoundingInfo object (Internal use)
  26285. */
  26286. _boundingInfo: BoundingInfo;
  26287. /**
  26288. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26289. */
  26290. _sps: SolidParticleSystem;
  26291. /**
  26292. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26293. */
  26294. _stillInvisible: boolean;
  26295. /**
  26296. * @hidden Last computed particle rotation matrix
  26297. */
  26298. _rotationMatrix: number[];
  26299. /**
  26300. * Parent particle Id, if any.
  26301. * Default null.
  26302. */
  26303. parentId: Nullable<number>;
  26304. /**
  26305. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26306. * The possible values are :
  26307. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26308. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26309. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26310. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26311. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26312. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26313. * */
  26314. cullingStrategy: number;
  26315. /**
  26316. * @hidden Internal global position in the SPS.
  26317. */
  26318. _globalPosition: Vector3;
  26319. /**
  26320. * Creates a Solid Particle object.
  26321. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26322. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26323. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26324. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26325. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26326. * @param shapeId (integer) is the model shape identifier in the SPS.
  26327. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26328. * @param sps defines the sps it is associated to
  26329. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26330. */
  26331. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26332. /**
  26333. * Legacy support, changed scale to scaling
  26334. */
  26335. /**
  26336. * Legacy support, changed scale to scaling
  26337. */
  26338. scale: Vector3;
  26339. /**
  26340. * Legacy support, changed quaternion to rotationQuaternion
  26341. */
  26342. /**
  26343. * Legacy support, changed quaternion to rotationQuaternion
  26344. */
  26345. quaternion: Nullable<Quaternion>;
  26346. /**
  26347. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26348. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26349. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26350. * @returns true if it intersects
  26351. */
  26352. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26353. /**
  26354. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26355. * A particle is in the frustum if its bounding box intersects the frustum
  26356. * @param frustumPlanes defines the frustum to test
  26357. * @returns true if the particle is in the frustum planes
  26358. */
  26359. isInFrustum(frustumPlanes: Plane[]): boolean;
  26360. /**
  26361. * get the rotation matrix of the particle
  26362. * @hidden
  26363. */
  26364. getRotationMatrix(m: Matrix): void;
  26365. }
  26366. /**
  26367. * Represents the shape of the model used by one particle of a solid particle system.
  26368. * SPS internal tool, don't use it manually.
  26369. */
  26370. export class ModelShape {
  26371. /**
  26372. * The shape id
  26373. * @hidden
  26374. */
  26375. shapeID: number;
  26376. /**
  26377. * flat array of model positions (internal use)
  26378. * @hidden
  26379. */
  26380. _shape: Vector3[];
  26381. /**
  26382. * flat array of model UVs (internal use)
  26383. * @hidden
  26384. */
  26385. _shapeUV: number[];
  26386. /**
  26387. * length of the shape in the model indices array (internal use)
  26388. * @hidden
  26389. */
  26390. _indicesLength: number;
  26391. /**
  26392. * Custom position function (internal use)
  26393. * @hidden
  26394. */
  26395. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26396. /**
  26397. * Custom vertex function (internal use)
  26398. * @hidden
  26399. */
  26400. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26401. /**
  26402. * 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.
  26403. * SPS internal tool, don't use it manually.
  26404. * @hidden
  26405. */
  26406. 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>);
  26407. }
  26408. /**
  26409. * Represents a Depth Sorted Particle in the solid particle system.
  26410. */
  26411. export class DepthSortedParticle {
  26412. /**
  26413. * Index of the particle in the "indices" array
  26414. */
  26415. ind: number;
  26416. /**
  26417. * Length of the particle shape in the "indices" array
  26418. */
  26419. indicesLength: number;
  26420. /**
  26421. * Squared distance from the particle to the camera
  26422. */
  26423. sqDistance: number;
  26424. }
  26425. }
  26426. declare module "babylonjs/Collisions/meshCollisionData" {
  26427. import { Collider } from "babylonjs/Collisions/collider";
  26428. import { Vector3 } from "babylonjs/Maths/math.vector";
  26429. import { Nullable } from "babylonjs/types";
  26430. import { Observer } from "babylonjs/Misc/observable";
  26431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26432. /**
  26433. * @hidden
  26434. */
  26435. export class _MeshCollisionData {
  26436. _checkCollisions: boolean;
  26437. _collisionMask: number;
  26438. _collisionGroup: number;
  26439. _collider: Nullable<Collider>;
  26440. _oldPositionForCollisions: Vector3;
  26441. _diffPositionForCollisions: Vector3;
  26442. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26443. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26444. }
  26445. }
  26446. declare module "babylonjs/Meshes/abstractMesh" {
  26447. import { Observable } from "babylonjs/Misc/observable";
  26448. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26449. import { Camera } from "babylonjs/Cameras/camera";
  26450. import { Scene, IDisposable } from "babylonjs/scene";
  26451. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26452. import { Node } from "babylonjs/node";
  26453. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26454. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26455. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26456. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26457. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26458. import { Material } from "babylonjs/Materials/material";
  26459. import { Light } from "babylonjs/Lights/light";
  26460. import { Skeleton } from "babylonjs/Bones/skeleton";
  26461. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26462. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26463. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26464. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26465. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26466. import { Plane } from "babylonjs/Maths/math.plane";
  26467. import { Ray } from "babylonjs/Culling/ray";
  26468. import { Collider } from "babylonjs/Collisions/collider";
  26469. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26470. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26471. /** @hidden */
  26472. class _FacetDataStorage {
  26473. facetPositions: Vector3[];
  26474. facetNormals: Vector3[];
  26475. facetPartitioning: number[][];
  26476. facetNb: number;
  26477. partitioningSubdivisions: number;
  26478. partitioningBBoxRatio: number;
  26479. facetDataEnabled: boolean;
  26480. facetParameters: any;
  26481. bbSize: Vector3;
  26482. subDiv: {
  26483. max: number;
  26484. X: number;
  26485. Y: number;
  26486. Z: number;
  26487. };
  26488. facetDepthSort: boolean;
  26489. facetDepthSortEnabled: boolean;
  26490. depthSortedIndices: IndicesArray;
  26491. depthSortedFacets: {
  26492. ind: number;
  26493. sqDistance: number;
  26494. }[];
  26495. facetDepthSortFunction: (f1: {
  26496. ind: number;
  26497. sqDistance: number;
  26498. }, f2: {
  26499. ind: number;
  26500. sqDistance: number;
  26501. }) => number;
  26502. facetDepthSortFrom: Vector3;
  26503. facetDepthSortOrigin: Vector3;
  26504. invertedMatrix: Matrix;
  26505. }
  26506. /**
  26507. * @hidden
  26508. **/
  26509. class _InternalAbstractMeshDataInfo {
  26510. _hasVertexAlpha: boolean;
  26511. _useVertexColors: boolean;
  26512. _numBoneInfluencers: number;
  26513. _applyFog: boolean;
  26514. _receiveShadows: boolean;
  26515. _facetData: _FacetDataStorage;
  26516. _visibility: number;
  26517. _skeleton: Nullable<Skeleton>;
  26518. _layerMask: number;
  26519. _computeBonesUsingShaders: boolean;
  26520. _isActive: boolean;
  26521. _onlyForInstances: boolean;
  26522. _isActiveIntermediate: boolean;
  26523. _onlyForInstancesIntermediate: boolean;
  26524. }
  26525. /**
  26526. * Class used to store all common mesh properties
  26527. */
  26528. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26529. /** No occlusion */
  26530. static OCCLUSION_TYPE_NONE: number;
  26531. /** Occlusion set to optimisitic */
  26532. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26533. /** Occlusion set to strict */
  26534. static OCCLUSION_TYPE_STRICT: number;
  26535. /** Use an accurante occlusion algorithm */
  26536. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26537. /** Use a conservative occlusion algorithm */
  26538. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26539. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26540. * Test order :
  26541. * Is the bounding sphere outside the frustum ?
  26542. * If not, are the bounding box vertices outside the frustum ?
  26543. * It not, then the cullable object is in the frustum.
  26544. */
  26545. static readonly CULLINGSTRATEGY_STANDARD: number;
  26546. /** Culling strategy : Bounding Sphere Only.
  26547. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26548. * It's also less accurate than the standard because some not visible objects can still be selected.
  26549. * Test : is the bounding sphere outside the frustum ?
  26550. * If not, then the cullable object is in the frustum.
  26551. */
  26552. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26553. /** Culling strategy : Optimistic Inclusion.
  26554. * This in an inclusion test first, then the standard exclusion test.
  26555. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26556. * 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.
  26557. * Anyway, it's as accurate as the standard strategy.
  26558. * Test :
  26559. * Is the cullable object bounding sphere center in the frustum ?
  26560. * If not, apply the default culling strategy.
  26561. */
  26562. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26563. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26564. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26565. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26566. * 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.
  26567. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26568. * Test :
  26569. * Is the cullable object bounding sphere center in the frustum ?
  26570. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26571. */
  26572. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26573. /**
  26574. * No billboard
  26575. */
  26576. static readonly BILLBOARDMODE_NONE: number;
  26577. /** Billboard on X axis */
  26578. static readonly BILLBOARDMODE_X: number;
  26579. /** Billboard on Y axis */
  26580. static readonly BILLBOARDMODE_Y: number;
  26581. /** Billboard on Z axis */
  26582. static readonly BILLBOARDMODE_Z: number;
  26583. /** Billboard on all axes */
  26584. static readonly BILLBOARDMODE_ALL: number;
  26585. /** Billboard on using position instead of orientation */
  26586. static readonly BILLBOARDMODE_USE_POSITION: number;
  26587. /** @hidden */
  26588. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26589. /**
  26590. * The culling strategy to use to check whether the mesh must be rendered or not.
  26591. * This value can be changed at any time and will be used on the next render mesh selection.
  26592. * The possible values are :
  26593. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26594. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26595. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26596. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26597. * Please read each static variable documentation to get details about the culling process.
  26598. * */
  26599. cullingStrategy: number;
  26600. /**
  26601. * Gets the number of facets in the mesh
  26602. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26603. */
  26604. readonly facetNb: number;
  26605. /**
  26606. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26607. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26608. */
  26609. partitioningSubdivisions: number;
  26610. /**
  26611. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26612. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26613. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26614. */
  26615. partitioningBBoxRatio: number;
  26616. /**
  26617. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26618. * Works only for updatable meshes.
  26619. * Doesn't work with multi-materials
  26620. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26621. */
  26622. mustDepthSortFacets: boolean;
  26623. /**
  26624. * The location (Vector3) where the facet depth sort must be computed from.
  26625. * By default, the active camera position.
  26626. * Used only when facet depth sort is enabled
  26627. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26628. */
  26629. facetDepthSortFrom: Vector3;
  26630. /**
  26631. * gets a boolean indicating if facetData is enabled
  26632. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26633. */
  26634. readonly isFacetDataEnabled: boolean;
  26635. /** @hidden */
  26636. _updateNonUniformScalingState(value: boolean): boolean;
  26637. /**
  26638. * An event triggered when this mesh collides with another one
  26639. */
  26640. onCollideObservable: Observable<AbstractMesh>;
  26641. /** Set a function to call when this mesh collides with another one */
  26642. onCollide: () => void;
  26643. /**
  26644. * An event triggered when the collision's position changes
  26645. */
  26646. onCollisionPositionChangeObservable: Observable<Vector3>;
  26647. /** Set a function to call when the collision's position changes */
  26648. onCollisionPositionChange: () => void;
  26649. /**
  26650. * An event triggered when material is changed
  26651. */
  26652. onMaterialChangedObservable: Observable<AbstractMesh>;
  26653. /**
  26654. * Gets or sets the orientation for POV movement & rotation
  26655. */
  26656. definedFacingForward: boolean;
  26657. /** @hidden */
  26658. _occlusionQuery: Nullable<WebGLQuery>;
  26659. /** @hidden */
  26660. _renderingGroup: Nullable<RenderingGroup>;
  26661. /**
  26662. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26663. */
  26664. /**
  26665. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26666. */
  26667. visibility: number;
  26668. /** Gets or sets the alpha index used to sort transparent meshes
  26669. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26670. */
  26671. alphaIndex: number;
  26672. /**
  26673. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26674. */
  26675. isVisible: boolean;
  26676. /**
  26677. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26678. */
  26679. isPickable: boolean;
  26680. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26681. showSubMeshesBoundingBox: boolean;
  26682. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26683. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26684. */
  26685. isBlocker: boolean;
  26686. /**
  26687. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26688. */
  26689. enablePointerMoveEvents: boolean;
  26690. /**
  26691. * Specifies the rendering group id for this mesh (0 by default)
  26692. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26693. */
  26694. renderingGroupId: number;
  26695. private _material;
  26696. /** Gets or sets current material */
  26697. material: Nullable<Material>;
  26698. /**
  26699. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26700. * @see http://doc.babylonjs.com/babylon101/shadows
  26701. */
  26702. receiveShadows: boolean;
  26703. /** Defines color to use when rendering outline */
  26704. outlineColor: Color3;
  26705. /** Define width to use when rendering outline */
  26706. outlineWidth: number;
  26707. /** Defines color to use when rendering overlay */
  26708. overlayColor: Color3;
  26709. /** Defines alpha to use when rendering overlay */
  26710. overlayAlpha: number;
  26711. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26712. hasVertexAlpha: boolean;
  26713. /** 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) */
  26714. useVertexColors: boolean;
  26715. /**
  26716. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26717. */
  26718. computeBonesUsingShaders: boolean;
  26719. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26720. numBoneInfluencers: number;
  26721. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26722. applyFog: boolean;
  26723. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26724. useOctreeForRenderingSelection: boolean;
  26725. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26726. useOctreeForPicking: boolean;
  26727. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26728. useOctreeForCollisions: boolean;
  26729. /**
  26730. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26731. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26732. */
  26733. layerMask: number;
  26734. /**
  26735. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26736. */
  26737. alwaysSelectAsActiveMesh: boolean;
  26738. /**
  26739. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26740. */
  26741. doNotSyncBoundingInfo: boolean;
  26742. /**
  26743. * Gets or sets the current action manager
  26744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26745. */
  26746. actionManager: Nullable<AbstractActionManager>;
  26747. private _meshCollisionData;
  26748. /**
  26749. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26750. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26751. */
  26752. ellipsoid: Vector3;
  26753. /**
  26754. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26755. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26756. */
  26757. ellipsoidOffset: Vector3;
  26758. /**
  26759. * Gets or sets a collision mask used to mask collisions (default is -1).
  26760. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26761. */
  26762. collisionMask: number;
  26763. /**
  26764. * Gets or sets the current collision group mask (-1 by default).
  26765. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26766. */
  26767. collisionGroup: number;
  26768. /**
  26769. * Defines edge width used when edgesRenderer is enabled
  26770. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26771. */
  26772. edgesWidth: number;
  26773. /**
  26774. * Defines edge color used when edgesRenderer is enabled
  26775. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26776. */
  26777. edgesColor: Color4;
  26778. /** @hidden */
  26779. _edgesRenderer: Nullable<IEdgesRenderer>;
  26780. /** @hidden */
  26781. _masterMesh: Nullable<AbstractMesh>;
  26782. /** @hidden */
  26783. _boundingInfo: Nullable<BoundingInfo>;
  26784. /** @hidden */
  26785. _renderId: number;
  26786. /**
  26787. * Gets or sets the list of subMeshes
  26788. * @see http://doc.babylonjs.com/how_to/multi_materials
  26789. */
  26790. subMeshes: SubMesh[];
  26791. /** @hidden */
  26792. _intersectionsInProgress: AbstractMesh[];
  26793. /** @hidden */
  26794. _unIndexed: boolean;
  26795. /** @hidden */
  26796. _lightSources: Light[];
  26797. /** Gets the list of lights affecting that mesh */
  26798. readonly lightSources: Light[];
  26799. /** @hidden */
  26800. readonly _positions: Nullable<Vector3[]>;
  26801. /** @hidden */
  26802. _waitingData: {
  26803. lods: Nullable<any>;
  26804. actions: Nullable<any>;
  26805. freezeWorldMatrix: Nullable<boolean>;
  26806. };
  26807. /** @hidden */
  26808. _bonesTransformMatrices: Nullable<Float32Array>;
  26809. /** @hidden */
  26810. _transformMatrixTexture: Nullable<RawTexture>;
  26811. /**
  26812. * Gets or sets a skeleton to apply skining transformations
  26813. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26814. */
  26815. skeleton: Nullable<Skeleton>;
  26816. /**
  26817. * An event triggered when the mesh is rebuilt.
  26818. */
  26819. onRebuildObservable: Observable<AbstractMesh>;
  26820. /**
  26821. * Creates a new AbstractMesh
  26822. * @param name defines the name of the mesh
  26823. * @param scene defines the hosting scene
  26824. */
  26825. constructor(name: string, scene?: Nullable<Scene>);
  26826. /**
  26827. * Returns the string "AbstractMesh"
  26828. * @returns "AbstractMesh"
  26829. */
  26830. getClassName(): string;
  26831. /**
  26832. * Gets a string representation of the current mesh
  26833. * @param fullDetails defines a boolean indicating if full details must be included
  26834. * @returns a string representation of the current mesh
  26835. */
  26836. toString(fullDetails?: boolean): string;
  26837. /**
  26838. * @hidden
  26839. */
  26840. protected _getEffectiveParent(): Nullable<Node>;
  26841. /** @hidden */
  26842. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26843. /** @hidden */
  26844. _rebuild(): void;
  26845. /** @hidden */
  26846. _resyncLightSources(): void;
  26847. /** @hidden */
  26848. _resyncLighSource(light: Light): void;
  26849. /** @hidden */
  26850. _unBindEffect(): void;
  26851. /** @hidden */
  26852. _removeLightSource(light: Light, dispose: boolean): void;
  26853. private _markSubMeshesAsDirty;
  26854. /** @hidden */
  26855. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26856. /** @hidden */
  26857. _markSubMeshesAsAttributesDirty(): void;
  26858. /** @hidden */
  26859. _markSubMeshesAsMiscDirty(): void;
  26860. /**
  26861. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26862. */
  26863. scaling: Vector3;
  26864. /**
  26865. * Returns true if the mesh is blocked. Implemented by child classes
  26866. */
  26867. readonly isBlocked: boolean;
  26868. /**
  26869. * Returns the mesh itself by default. Implemented by child classes
  26870. * @param camera defines the camera to use to pick the right LOD level
  26871. * @returns the currentAbstractMesh
  26872. */
  26873. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26874. /**
  26875. * Returns 0 by default. Implemented by child classes
  26876. * @returns an integer
  26877. */
  26878. getTotalVertices(): number;
  26879. /**
  26880. * Returns a positive integer : the total number of indices in this mesh geometry.
  26881. * @returns the numner of indices or zero if the mesh has no geometry.
  26882. */
  26883. getTotalIndices(): number;
  26884. /**
  26885. * Returns null by default. Implemented by child classes
  26886. * @returns null
  26887. */
  26888. getIndices(): Nullable<IndicesArray>;
  26889. /**
  26890. * Returns the array of the requested vertex data kind. Implemented by child classes
  26891. * @param kind defines the vertex data kind to use
  26892. * @returns null
  26893. */
  26894. getVerticesData(kind: string): Nullable<FloatArray>;
  26895. /**
  26896. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26897. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26898. * Note that a new underlying VertexBuffer object is created each call.
  26899. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26900. * @param kind defines vertex data kind:
  26901. * * VertexBuffer.PositionKind
  26902. * * VertexBuffer.UVKind
  26903. * * VertexBuffer.UV2Kind
  26904. * * VertexBuffer.UV3Kind
  26905. * * VertexBuffer.UV4Kind
  26906. * * VertexBuffer.UV5Kind
  26907. * * VertexBuffer.UV6Kind
  26908. * * VertexBuffer.ColorKind
  26909. * * VertexBuffer.MatricesIndicesKind
  26910. * * VertexBuffer.MatricesIndicesExtraKind
  26911. * * VertexBuffer.MatricesWeightsKind
  26912. * * VertexBuffer.MatricesWeightsExtraKind
  26913. * @param data defines the data source
  26914. * @param updatable defines if the data must be flagged as updatable (or static)
  26915. * @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
  26916. * @returns the current mesh
  26917. */
  26918. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26919. /**
  26920. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26921. * If the mesh has no geometry, it is simply returned as it is.
  26922. * @param kind defines vertex data kind:
  26923. * * VertexBuffer.PositionKind
  26924. * * VertexBuffer.UVKind
  26925. * * VertexBuffer.UV2Kind
  26926. * * VertexBuffer.UV3Kind
  26927. * * VertexBuffer.UV4Kind
  26928. * * VertexBuffer.UV5Kind
  26929. * * VertexBuffer.UV6Kind
  26930. * * VertexBuffer.ColorKind
  26931. * * VertexBuffer.MatricesIndicesKind
  26932. * * VertexBuffer.MatricesIndicesExtraKind
  26933. * * VertexBuffer.MatricesWeightsKind
  26934. * * VertexBuffer.MatricesWeightsExtraKind
  26935. * @param data defines the data source
  26936. * @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
  26937. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26938. * @returns the current mesh
  26939. */
  26940. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26941. /**
  26942. * Sets the mesh indices,
  26943. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26944. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26945. * @param totalVertices Defines the total number of vertices
  26946. * @returns the current mesh
  26947. */
  26948. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26949. /**
  26950. * Gets a boolean indicating if specific vertex data is present
  26951. * @param kind defines the vertex data kind to use
  26952. * @returns true is data kind is present
  26953. */
  26954. isVerticesDataPresent(kind: string): boolean;
  26955. /**
  26956. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26957. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26958. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26959. * @returns a BoundingInfo
  26960. */
  26961. getBoundingInfo(): BoundingInfo;
  26962. /**
  26963. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26964. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26965. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26966. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26967. * @returns the current mesh
  26968. */
  26969. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26970. /**
  26971. * Overwrite the current bounding info
  26972. * @param boundingInfo defines the new bounding info
  26973. * @returns the current mesh
  26974. */
  26975. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26976. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26977. readonly useBones: boolean;
  26978. /** @hidden */
  26979. _preActivate(): void;
  26980. /** @hidden */
  26981. _preActivateForIntermediateRendering(renderId: number): void;
  26982. /** @hidden */
  26983. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26984. /** @hidden */
  26985. _postActivate(): void;
  26986. /** @hidden */
  26987. _freeze(): void;
  26988. /** @hidden */
  26989. _unFreeze(): void;
  26990. /**
  26991. * Gets the current world matrix
  26992. * @returns a Matrix
  26993. */
  26994. getWorldMatrix(): Matrix;
  26995. /** @hidden */
  26996. _getWorldMatrixDeterminant(): number;
  26997. /**
  26998. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26999. */
  27000. readonly isAnInstance: boolean;
  27001. /**
  27002. * Gets a boolean indicating if this mesh has instances
  27003. */
  27004. readonly hasInstances: boolean;
  27005. /**
  27006. * Perform relative position change from the point of view of behind the front of the mesh.
  27007. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27008. * Supports definition of mesh facing forward or backward
  27009. * @param amountRight defines the distance on the right axis
  27010. * @param amountUp defines the distance on the up axis
  27011. * @param amountForward defines the distance on the forward axis
  27012. * @returns the current mesh
  27013. */
  27014. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27015. /**
  27016. * Calculate relative position change from the point of view of behind the front of the mesh.
  27017. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27018. * Supports definition of mesh facing forward or backward
  27019. * @param amountRight defines the distance on the right axis
  27020. * @param amountUp defines the distance on the up axis
  27021. * @param amountForward defines the distance on the forward axis
  27022. * @returns the new displacement vector
  27023. */
  27024. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27025. /**
  27026. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27027. * Supports definition of mesh facing forward or backward
  27028. * @param flipBack defines the flip
  27029. * @param twirlClockwise defines the twirl
  27030. * @param tiltRight defines the tilt
  27031. * @returns the current mesh
  27032. */
  27033. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27034. /**
  27035. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27036. * Supports definition of mesh facing forward or backward.
  27037. * @param flipBack defines the flip
  27038. * @param twirlClockwise defines the twirl
  27039. * @param tiltRight defines the tilt
  27040. * @returns the new rotation vector
  27041. */
  27042. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27043. /**
  27044. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27045. * This means the mesh underlying bounding box and sphere are recomputed.
  27046. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27047. * @returns the current mesh
  27048. */
  27049. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27050. /** @hidden */
  27051. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27052. /** @hidden */
  27053. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27054. /** @hidden */
  27055. _updateBoundingInfo(): AbstractMesh;
  27056. /** @hidden */
  27057. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27058. /** @hidden */
  27059. protected _afterComputeWorldMatrix(): void;
  27060. /** @hidden */
  27061. readonly _effectiveMesh: AbstractMesh;
  27062. /**
  27063. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27064. * A mesh is in the frustum if its bounding box intersects the frustum
  27065. * @param frustumPlanes defines the frustum to test
  27066. * @returns true if the mesh is in the frustum planes
  27067. */
  27068. isInFrustum(frustumPlanes: Plane[]): boolean;
  27069. /**
  27070. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27071. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27072. * @param frustumPlanes defines the frustum to test
  27073. * @returns true if the mesh is completely in the frustum planes
  27074. */
  27075. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27076. /**
  27077. * True if the mesh intersects another mesh or a SolidParticle object
  27078. * @param mesh defines a target mesh or SolidParticle to test
  27079. * @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)
  27080. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27081. * @returns true if there is an intersection
  27082. */
  27083. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27084. /**
  27085. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27086. * @param point defines the point to test
  27087. * @returns true if there is an intersection
  27088. */
  27089. intersectsPoint(point: Vector3): boolean;
  27090. /**
  27091. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27092. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27093. */
  27094. checkCollisions: boolean;
  27095. /**
  27096. * Gets Collider object used to compute collisions (not physics)
  27097. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27098. */
  27099. readonly collider: Nullable<Collider>;
  27100. /**
  27101. * Move the mesh using collision engine
  27102. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27103. * @param displacement defines the requested displacement vector
  27104. * @returns the current mesh
  27105. */
  27106. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27107. private _onCollisionPositionChange;
  27108. /** @hidden */
  27109. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27110. /** @hidden */
  27111. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27112. /** @hidden */
  27113. _checkCollision(collider: Collider): AbstractMesh;
  27114. /** @hidden */
  27115. _generatePointsArray(): boolean;
  27116. /**
  27117. * Checks if the passed Ray intersects with the mesh
  27118. * @param ray defines the ray to use
  27119. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27120. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27121. * @returns the picking info
  27122. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27123. */
  27124. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27125. /**
  27126. * Clones the current mesh
  27127. * @param name defines the mesh name
  27128. * @param newParent defines the new mesh parent
  27129. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27130. * @returns the new mesh
  27131. */
  27132. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27133. /**
  27134. * Disposes all the submeshes of the current meshnp
  27135. * @returns the current mesh
  27136. */
  27137. releaseSubMeshes(): AbstractMesh;
  27138. /**
  27139. * Releases resources associated with this abstract mesh.
  27140. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27141. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27142. */
  27143. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27144. /**
  27145. * Adds the passed mesh as a child to the current mesh
  27146. * @param mesh defines the child mesh
  27147. * @returns the current mesh
  27148. */
  27149. addChild(mesh: AbstractMesh): AbstractMesh;
  27150. /**
  27151. * Removes the passed mesh from the current mesh children list
  27152. * @param mesh defines the child mesh
  27153. * @returns the current mesh
  27154. */
  27155. removeChild(mesh: AbstractMesh): AbstractMesh;
  27156. /** @hidden */
  27157. private _initFacetData;
  27158. /**
  27159. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27160. * This method can be called within the render loop.
  27161. * 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
  27162. * @returns the current mesh
  27163. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27164. */
  27165. updateFacetData(): AbstractMesh;
  27166. /**
  27167. * Returns the facetLocalNormals array.
  27168. * The normals are expressed in the mesh local spac
  27169. * @returns an array of Vector3
  27170. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27171. */
  27172. getFacetLocalNormals(): Vector3[];
  27173. /**
  27174. * Returns the facetLocalPositions array.
  27175. * The facet positions are expressed in the mesh local space
  27176. * @returns an array of Vector3
  27177. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27178. */
  27179. getFacetLocalPositions(): Vector3[];
  27180. /**
  27181. * Returns the facetLocalPartioning array
  27182. * @returns an array of array of numbers
  27183. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27184. */
  27185. getFacetLocalPartitioning(): number[][];
  27186. /**
  27187. * Returns the i-th facet position in the world system.
  27188. * This method allocates a new Vector3 per call
  27189. * @param i defines the facet index
  27190. * @returns a new Vector3
  27191. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27192. */
  27193. getFacetPosition(i: number): Vector3;
  27194. /**
  27195. * Sets the reference Vector3 with the i-th facet position in the world system
  27196. * @param i defines the facet index
  27197. * @param ref defines the target vector
  27198. * @returns the current mesh
  27199. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27200. */
  27201. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27202. /**
  27203. * Returns the i-th facet normal in the world system.
  27204. * This method allocates a new Vector3 per call
  27205. * @param i defines the facet index
  27206. * @returns a new Vector3
  27207. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27208. */
  27209. getFacetNormal(i: number): Vector3;
  27210. /**
  27211. * Sets the reference Vector3 with the i-th facet normal in the world system
  27212. * @param i defines the facet index
  27213. * @param ref defines the target vector
  27214. * @returns the current mesh
  27215. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27216. */
  27217. getFacetNormalToRef(i: number, ref: Vector3): this;
  27218. /**
  27219. * 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)
  27220. * @param x defines x coordinate
  27221. * @param y defines y coordinate
  27222. * @param z defines z coordinate
  27223. * @returns the array of facet indexes
  27224. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27225. */
  27226. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27227. /**
  27228. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27229. * @param projected sets as the (x,y,z) world projection on the facet
  27230. * @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
  27231. * @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
  27232. * @param x defines x coordinate
  27233. * @param y defines y coordinate
  27234. * @param z defines z coordinate
  27235. * @returns the face index if found (or null instead)
  27236. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27237. */
  27238. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27239. /**
  27240. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27241. * @param projected sets as the (x,y,z) local projection on the facet
  27242. * @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
  27243. * @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
  27244. * @param x defines x coordinate
  27245. * @param y defines y coordinate
  27246. * @param z defines z coordinate
  27247. * @returns the face index if found (or null instead)
  27248. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27249. */
  27250. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27251. /**
  27252. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27253. * @returns the parameters
  27254. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27255. */
  27256. getFacetDataParameters(): any;
  27257. /**
  27258. * Disables the feature FacetData and frees the related memory
  27259. * @returns the current mesh
  27260. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27261. */
  27262. disableFacetData(): AbstractMesh;
  27263. /**
  27264. * Updates the AbstractMesh indices array
  27265. * @param indices defines the data source
  27266. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27267. * @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)
  27268. * @returns the current mesh
  27269. */
  27270. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27271. /**
  27272. * Creates new normals data for the mesh
  27273. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27274. * @returns the current mesh
  27275. */
  27276. createNormals(updatable: boolean): AbstractMesh;
  27277. /**
  27278. * Align the mesh with a normal
  27279. * @param normal defines the normal to use
  27280. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27281. * @returns the current mesh
  27282. */
  27283. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27284. /** @hidden */
  27285. _checkOcclusionQuery(): boolean;
  27286. /**
  27287. * Disables the mesh edge rendering mode
  27288. * @returns the currentAbstractMesh
  27289. */
  27290. disableEdgesRendering(): AbstractMesh;
  27291. /**
  27292. * Enables the edge rendering mode on the mesh.
  27293. * This mode makes the mesh edges visible
  27294. * @param epsilon defines the maximal distance between two angles to detect a face
  27295. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27296. * @returns the currentAbstractMesh
  27297. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27298. */
  27299. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27300. }
  27301. }
  27302. declare module "babylonjs/Actions/actionEvent" {
  27303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27304. import { Nullable } from "babylonjs/types";
  27305. import { Sprite } from "babylonjs/Sprites/sprite";
  27306. import { Scene } from "babylonjs/scene";
  27307. import { Vector2 } from "babylonjs/Maths/math.vector";
  27308. /**
  27309. * Interface used to define ActionEvent
  27310. */
  27311. export interface IActionEvent {
  27312. /** The mesh or sprite that triggered the action */
  27313. source: any;
  27314. /** The X mouse cursor position at the time of the event */
  27315. pointerX: number;
  27316. /** The Y mouse cursor position at the time of the event */
  27317. pointerY: number;
  27318. /** The mesh that is currently pointed at (can be null) */
  27319. meshUnderPointer: Nullable<AbstractMesh>;
  27320. /** the original (browser) event that triggered the ActionEvent */
  27321. sourceEvent?: any;
  27322. /** additional data for the event */
  27323. additionalData?: any;
  27324. }
  27325. /**
  27326. * ActionEvent is the event being sent when an action is triggered.
  27327. */
  27328. export class ActionEvent implements IActionEvent {
  27329. /** The mesh or sprite that triggered the action */
  27330. source: any;
  27331. /** The X mouse cursor position at the time of the event */
  27332. pointerX: number;
  27333. /** The Y mouse cursor position at the time of the event */
  27334. pointerY: number;
  27335. /** The mesh that is currently pointed at (can be null) */
  27336. meshUnderPointer: Nullable<AbstractMesh>;
  27337. /** the original (browser) event that triggered the ActionEvent */
  27338. sourceEvent?: any;
  27339. /** additional data for the event */
  27340. additionalData?: any;
  27341. /**
  27342. * Creates a new ActionEvent
  27343. * @param source The mesh or sprite that triggered the action
  27344. * @param pointerX The X mouse cursor position at the time of the event
  27345. * @param pointerY The Y mouse cursor position at the time of the event
  27346. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27347. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27348. * @param additionalData additional data for the event
  27349. */
  27350. constructor(
  27351. /** The mesh or sprite that triggered the action */
  27352. source: any,
  27353. /** The X mouse cursor position at the time of the event */
  27354. pointerX: number,
  27355. /** The Y mouse cursor position at the time of the event */
  27356. pointerY: number,
  27357. /** The mesh that is currently pointed at (can be null) */
  27358. meshUnderPointer: Nullable<AbstractMesh>,
  27359. /** the original (browser) event that triggered the ActionEvent */
  27360. sourceEvent?: any,
  27361. /** additional data for the event */
  27362. additionalData?: any);
  27363. /**
  27364. * Helper function to auto-create an ActionEvent from a source mesh.
  27365. * @param source The source mesh that triggered the event
  27366. * @param evt The original (browser) event
  27367. * @param additionalData additional data for the event
  27368. * @returns the new ActionEvent
  27369. */
  27370. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27371. /**
  27372. * Helper function to auto-create an ActionEvent from a source sprite
  27373. * @param source The source sprite that triggered the event
  27374. * @param scene Scene associated with the sprite
  27375. * @param evt The original (browser) event
  27376. * @param additionalData additional data for the event
  27377. * @returns the new ActionEvent
  27378. */
  27379. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27380. /**
  27381. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27382. * @param scene the scene where the event occurred
  27383. * @param evt The original (browser) event
  27384. * @returns the new ActionEvent
  27385. */
  27386. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27387. /**
  27388. * Helper function to auto-create an ActionEvent from a primitive
  27389. * @param prim defines the target primitive
  27390. * @param pointerPos defines the pointer position
  27391. * @param evt The original (browser) event
  27392. * @param additionalData additional data for the event
  27393. * @returns the new ActionEvent
  27394. */
  27395. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27396. }
  27397. }
  27398. declare module "babylonjs/Actions/abstractActionManager" {
  27399. import { IDisposable } from "babylonjs/scene";
  27400. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27401. import { IAction } from "babylonjs/Actions/action";
  27402. import { Nullable } from "babylonjs/types";
  27403. /**
  27404. * Abstract class used to decouple action Manager from scene and meshes.
  27405. * Do not instantiate.
  27406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27407. */
  27408. export abstract class AbstractActionManager implements IDisposable {
  27409. /** Gets the list of active triggers */
  27410. static Triggers: {
  27411. [key: string]: number;
  27412. };
  27413. /** Gets the cursor to use when hovering items */
  27414. hoverCursor: string;
  27415. /** Gets the list of actions */
  27416. actions: IAction[];
  27417. /**
  27418. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27419. */
  27420. isRecursive: boolean;
  27421. /**
  27422. * Releases all associated resources
  27423. */
  27424. abstract dispose(): void;
  27425. /**
  27426. * Does this action manager has pointer triggers
  27427. */
  27428. abstract readonly hasPointerTriggers: boolean;
  27429. /**
  27430. * Does this action manager has pick triggers
  27431. */
  27432. abstract readonly hasPickTriggers: boolean;
  27433. /**
  27434. * Process a specific trigger
  27435. * @param trigger defines the trigger to process
  27436. * @param evt defines the event details to be processed
  27437. */
  27438. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27439. /**
  27440. * Does this action manager handles actions of any of the given triggers
  27441. * @param triggers defines the triggers to be tested
  27442. * @return a boolean indicating whether one (or more) of the triggers is handled
  27443. */
  27444. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27445. /**
  27446. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27447. * speed.
  27448. * @param triggerA defines the trigger to be tested
  27449. * @param triggerB defines the trigger to be tested
  27450. * @return a boolean indicating whether one (or more) of the triggers is handled
  27451. */
  27452. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27453. /**
  27454. * Does this action manager handles actions of a given trigger
  27455. * @param trigger defines the trigger to be tested
  27456. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27457. * @return whether the trigger is handled
  27458. */
  27459. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27460. /**
  27461. * Serialize this manager to a JSON object
  27462. * @param name defines the property name to store this manager
  27463. * @returns a JSON representation of this manager
  27464. */
  27465. abstract serialize(name: string): any;
  27466. /**
  27467. * Registers an action to this action manager
  27468. * @param action defines the action to be registered
  27469. * @return the action amended (prepared) after registration
  27470. */
  27471. abstract registerAction(action: IAction): Nullable<IAction>;
  27472. /**
  27473. * Unregisters an action to this action manager
  27474. * @param action defines the action to be unregistered
  27475. * @return a boolean indicating whether the action has been unregistered
  27476. */
  27477. abstract unregisterAction(action: IAction): Boolean;
  27478. /**
  27479. * Does exist one action manager with at least one trigger
  27480. **/
  27481. static readonly HasTriggers: boolean;
  27482. /**
  27483. * Does exist one action manager with at least one pick trigger
  27484. **/
  27485. static readonly HasPickTriggers: boolean;
  27486. /**
  27487. * Does exist one action manager that handles actions of a given trigger
  27488. * @param trigger defines the trigger to be tested
  27489. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27490. **/
  27491. static HasSpecificTrigger(trigger: number): boolean;
  27492. }
  27493. }
  27494. declare module "babylonjs/node" {
  27495. import { Scene } from "babylonjs/scene";
  27496. import { Nullable } from "babylonjs/types";
  27497. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27498. import { Engine } from "babylonjs/Engines/engine";
  27499. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27500. import { Observable } from "babylonjs/Misc/observable";
  27501. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27502. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27503. import { Animatable } from "babylonjs/Animations/animatable";
  27504. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27505. import { Animation } from "babylonjs/Animations/animation";
  27506. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27508. /**
  27509. * Defines how a node can be built from a string name.
  27510. */
  27511. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27512. /**
  27513. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27514. */
  27515. export class Node implements IBehaviorAware<Node> {
  27516. /** @hidden */
  27517. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27518. private static _NodeConstructors;
  27519. /**
  27520. * Add a new node constructor
  27521. * @param type defines the type name of the node to construct
  27522. * @param constructorFunc defines the constructor function
  27523. */
  27524. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27525. /**
  27526. * Returns a node constructor based on type name
  27527. * @param type defines the type name
  27528. * @param name defines the new node name
  27529. * @param scene defines the hosting scene
  27530. * @param options defines optional options to transmit to constructors
  27531. * @returns the new constructor or null
  27532. */
  27533. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27534. /**
  27535. * Gets or sets the name of the node
  27536. */
  27537. name: string;
  27538. /**
  27539. * Gets or sets the id of the node
  27540. */
  27541. id: string;
  27542. /**
  27543. * Gets or sets the unique id of the node
  27544. */
  27545. uniqueId: number;
  27546. /**
  27547. * Gets or sets a string used to store user defined state for the node
  27548. */
  27549. state: string;
  27550. /**
  27551. * Gets or sets an object used to store user defined information for the node
  27552. */
  27553. metadata: any;
  27554. /**
  27555. * For internal use only. Please do not use.
  27556. */
  27557. reservedDataStore: any;
  27558. /**
  27559. * List of inspectable custom properties (used by the Inspector)
  27560. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27561. */
  27562. inspectableCustomProperties: IInspectable[];
  27563. private _doNotSerialize;
  27564. /**
  27565. * Gets or sets a boolean used to define if the node must be serialized
  27566. */
  27567. doNotSerialize: boolean;
  27568. /** @hidden */
  27569. _isDisposed: boolean;
  27570. /**
  27571. * Gets a list of Animations associated with the node
  27572. */
  27573. animations: import("babylonjs/Animations/animation").Animation[];
  27574. protected _ranges: {
  27575. [name: string]: Nullable<AnimationRange>;
  27576. };
  27577. /**
  27578. * Callback raised when the node is ready to be used
  27579. */
  27580. onReady: Nullable<(node: Node) => void>;
  27581. private _isEnabled;
  27582. private _isParentEnabled;
  27583. private _isReady;
  27584. /** @hidden */
  27585. _currentRenderId: number;
  27586. private _parentUpdateId;
  27587. /** @hidden */
  27588. _childUpdateId: number;
  27589. /** @hidden */
  27590. _waitingParentId: Nullable<string>;
  27591. /** @hidden */
  27592. _scene: Scene;
  27593. /** @hidden */
  27594. _cache: any;
  27595. private _parentNode;
  27596. private _children;
  27597. /** @hidden */
  27598. _worldMatrix: Matrix;
  27599. /** @hidden */
  27600. _worldMatrixDeterminant: number;
  27601. /** @hidden */
  27602. _worldMatrixDeterminantIsDirty: boolean;
  27603. /** @hidden */
  27604. private _sceneRootNodesIndex;
  27605. /**
  27606. * Gets a boolean indicating if the node has been disposed
  27607. * @returns true if the node was disposed
  27608. */
  27609. isDisposed(): boolean;
  27610. /**
  27611. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27612. * @see https://doc.babylonjs.com/how_to/parenting
  27613. */
  27614. parent: Nullable<Node>;
  27615. private addToSceneRootNodes;
  27616. private removeFromSceneRootNodes;
  27617. private _animationPropertiesOverride;
  27618. /**
  27619. * Gets or sets the animation properties override
  27620. */
  27621. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27622. /**
  27623. * Gets a string idenfifying the name of the class
  27624. * @returns "Node" string
  27625. */
  27626. getClassName(): string;
  27627. /** @hidden */
  27628. readonly _isNode: boolean;
  27629. /**
  27630. * An event triggered when the mesh is disposed
  27631. */
  27632. onDisposeObservable: Observable<Node>;
  27633. private _onDisposeObserver;
  27634. /**
  27635. * Sets a callback that will be raised when the node will be disposed
  27636. */
  27637. onDispose: () => void;
  27638. /**
  27639. * Creates a new Node
  27640. * @param name the name and id to be given to this node
  27641. * @param scene the scene this node will be added to
  27642. * @param addToRootNodes the node will be added to scene.rootNodes
  27643. */
  27644. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27645. /**
  27646. * Gets the scene of the node
  27647. * @returns a scene
  27648. */
  27649. getScene(): Scene;
  27650. /**
  27651. * Gets the engine of the node
  27652. * @returns a Engine
  27653. */
  27654. getEngine(): Engine;
  27655. private _behaviors;
  27656. /**
  27657. * Attach a behavior to the node
  27658. * @see http://doc.babylonjs.com/features/behaviour
  27659. * @param behavior defines the behavior to attach
  27660. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27661. * @returns the current Node
  27662. */
  27663. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27664. /**
  27665. * Remove an attached behavior
  27666. * @see http://doc.babylonjs.com/features/behaviour
  27667. * @param behavior defines the behavior to attach
  27668. * @returns the current Node
  27669. */
  27670. removeBehavior(behavior: Behavior<Node>): Node;
  27671. /**
  27672. * Gets the list of attached behaviors
  27673. * @see http://doc.babylonjs.com/features/behaviour
  27674. */
  27675. readonly behaviors: Behavior<Node>[];
  27676. /**
  27677. * Gets an attached behavior by name
  27678. * @param name defines the name of the behavior to look for
  27679. * @see http://doc.babylonjs.com/features/behaviour
  27680. * @returns null if behavior was not found else the requested behavior
  27681. */
  27682. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27683. /**
  27684. * Returns the latest update of the World matrix
  27685. * @returns a Matrix
  27686. */
  27687. getWorldMatrix(): Matrix;
  27688. /** @hidden */
  27689. _getWorldMatrixDeterminant(): number;
  27690. /**
  27691. * Returns directly the latest state of the mesh World matrix.
  27692. * A Matrix is returned.
  27693. */
  27694. readonly worldMatrixFromCache: Matrix;
  27695. /** @hidden */
  27696. _initCache(): void;
  27697. /** @hidden */
  27698. updateCache(force?: boolean): void;
  27699. /** @hidden */
  27700. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27701. /** @hidden */
  27702. _updateCache(ignoreParentClass?: boolean): void;
  27703. /** @hidden */
  27704. _isSynchronized(): boolean;
  27705. /** @hidden */
  27706. _markSyncedWithParent(): void;
  27707. /** @hidden */
  27708. isSynchronizedWithParent(): boolean;
  27709. /** @hidden */
  27710. isSynchronized(): boolean;
  27711. /**
  27712. * Is this node ready to be used/rendered
  27713. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27714. * @return true if the node is ready
  27715. */
  27716. isReady(completeCheck?: boolean): boolean;
  27717. /**
  27718. * Is this node enabled?
  27719. * 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
  27720. * @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
  27721. * @return whether this node (and its parent) is enabled
  27722. */
  27723. isEnabled(checkAncestors?: boolean): boolean;
  27724. /** @hidden */
  27725. protected _syncParentEnabledState(): void;
  27726. /**
  27727. * Set the enabled state of this node
  27728. * @param value defines the new enabled state
  27729. */
  27730. setEnabled(value: boolean): void;
  27731. /**
  27732. * Is this node a descendant of the given node?
  27733. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27734. * @param ancestor defines the parent node to inspect
  27735. * @returns a boolean indicating if this node is a descendant of the given node
  27736. */
  27737. isDescendantOf(ancestor: Node): boolean;
  27738. /** @hidden */
  27739. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27740. /**
  27741. * Will return all nodes that have this node as ascendant
  27742. * @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
  27743. * @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
  27744. * @return all children nodes of all types
  27745. */
  27746. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27747. /**
  27748. * Get all child-meshes of this node
  27749. * @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)
  27750. * @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
  27751. * @returns an array of AbstractMesh
  27752. */
  27753. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27754. /**
  27755. * Get all direct children of this node
  27756. * @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
  27757. * @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)
  27758. * @returns an array of Node
  27759. */
  27760. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27761. /** @hidden */
  27762. _setReady(state: boolean): void;
  27763. /**
  27764. * Get an animation by name
  27765. * @param name defines the name of the animation to look for
  27766. * @returns null if not found else the requested animation
  27767. */
  27768. getAnimationByName(name: string): Nullable<Animation>;
  27769. /**
  27770. * Creates an animation range for this node
  27771. * @param name defines the name of the range
  27772. * @param from defines the starting key
  27773. * @param to defines the end key
  27774. */
  27775. createAnimationRange(name: string, from: number, to: number): void;
  27776. /**
  27777. * Delete a specific animation range
  27778. * @param name defines the name of the range to delete
  27779. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27780. */
  27781. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27782. /**
  27783. * Get an animation range by name
  27784. * @param name defines the name of the animation range to look for
  27785. * @returns null if not found else the requested animation range
  27786. */
  27787. getAnimationRange(name: string): Nullable<AnimationRange>;
  27788. /**
  27789. * Gets the list of all animation ranges defined on this node
  27790. * @returns an array
  27791. */
  27792. getAnimationRanges(): Nullable<AnimationRange>[];
  27793. /**
  27794. * Will start the animation sequence
  27795. * @param name defines the range frames for animation sequence
  27796. * @param loop defines if the animation should loop (false by default)
  27797. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27798. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27799. * @returns the object created for this animation. If range does not exist, it will return null
  27800. */
  27801. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27802. /**
  27803. * Serialize animation ranges into a JSON compatible object
  27804. * @returns serialization object
  27805. */
  27806. serializeAnimationRanges(): any;
  27807. /**
  27808. * Computes the world matrix of the node
  27809. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27810. * @returns the world matrix
  27811. */
  27812. computeWorldMatrix(force?: boolean): Matrix;
  27813. /**
  27814. * Releases resources associated with this node.
  27815. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27816. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27817. */
  27818. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27819. /**
  27820. * Parse animation range data from a serialization object and store them into a given node
  27821. * @param node defines where to store the animation ranges
  27822. * @param parsedNode defines the serialization object to read data from
  27823. * @param scene defines the hosting scene
  27824. */
  27825. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27826. /**
  27827. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27828. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27829. * @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
  27830. * @returns the new bounding vectors
  27831. */
  27832. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27833. min: Vector3;
  27834. max: Vector3;
  27835. };
  27836. }
  27837. }
  27838. declare module "babylonjs/Animations/animation" {
  27839. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27840. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27841. import { Color3 } from "babylonjs/Maths/math.color";
  27842. import { Nullable } from "babylonjs/types";
  27843. import { Scene } from "babylonjs/scene";
  27844. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27845. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27846. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27847. import { Node } from "babylonjs/node";
  27848. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27849. import { Size } from "babylonjs/Maths/math.size";
  27850. import { Animatable } from "babylonjs/Animations/animatable";
  27851. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27852. /**
  27853. * @hidden
  27854. */
  27855. export class _IAnimationState {
  27856. key: number;
  27857. repeatCount: number;
  27858. workValue?: any;
  27859. loopMode?: number;
  27860. offsetValue?: any;
  27861. highLimitValue?: any;
  27862. }
  27863. /**
  27864. * Class used to store any kind of animation
  27865. */
  27866. export class Animation {
  27867. /**Name of the animation */
  27868. name: string;
  27869. /**Property to animate */
  27870. targetProperty: string;
  27871. /**The frames per second of the animation */
  27872. framePerSecond: number;
  27873. /**The data type of the animation */
  27874. dataType: number;
  27875. /**The loop mode of the animation */
  27876. loopMode?: number | undefined;
  27877. /**Specifies if blending should be enabled */
  27878. enableBlending?: boolean | undefined;
  27879. /**
  27880. * Use matrix interpolation instead of using direct key value when animating matrices
  27881. */
  27882. static AllowMatricesInterpolation: boolean;
  27883. /**
  27884. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27885. */
  27886. static AllowMatrixDecomposeForInterpolation: boolean;
  27887. /**
  27888. * Stores the key frames of the animation
  27889. */
  27890. private _keys;
  27891. /**
  27892. * Stores the easing function of the animation
  27893. */
  27894. private _easingFunction;
  27895. /**
  27896. * @hidden Internal use only
  27897. */
  27898. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27899. /**
  27900. * The set of event that will be linked to this animation
  27901. */
  27902. private _events;
  27903. /**
  27904. * Stores an array of target property paths
  27905. */
  27906. targetPropertyPath: string[];
  27907. /**
  27908. * Stores the blending speed of the animation
  27909. */
  27910. blendingSpeed: number;
  27911. /**
  27912. * Stores the animation ranges for the animation
  27913. */
  27914. private _ranges;
  27915. /**
  27916. * @hidden Internal use
  27917. */
  27918. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27919. /**
  27920. * Sets up an animation
  27921. * @param property The property to animate
  27922. * @param animationType The animation type to apply
  27923. * @param framePerSecond The frames per second of the animation
  27924. * @param easingFunction The easing function used in the animation
  27925. * @returns The created animation
  27926. */
  27927. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27928. /**
  27929. * Create and start an animation on a node
  27930. * @param name defines the name of the global animation that will be run on all nodes
  27931. * @param node defines the root node where the animation will take place
  27932. * @param targetProperty defines property to animate
  27933. * @param framePerSecond defines the number of frame per second yo use
  27934. * @param totalFrame defines the number of frames in total
  27935. * @param from defines the initial value
  27936. * @param to defines the final value
  27937. * @param loopMode defines which loop mode you want to use (off by default)
  27938. * @param easingFunction defines the easing function to use (linear by default)
  27939. * @param onAnimationEnd defines the callback to call when animation end
  27940. * @returns the animatable created for this animation
  27941. */
  27942. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27943. /**
  27944. * Create and start an animation on a node and its descendants
  27945. * @param name defines the name of the global animation that will be run on all nodes
  27946. * @param node defines the root node where the animation will take place
  27947. * @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
  27948. * @param targetProperty defines property to animate
  27949. * @param framePerSecond defines the number of frame per second to use
  27950. * @param totalFrame defines the number of frames in total
  27951. * @param from defines the initial value
  27952. * @param to defines the final value
  27953. * @param loopMode defines which loop mode you want to use (off by default)
  27954. * @param easingFunction defines the easing function to use (linear by default)
  27955. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27956. * @returns the list of animatables created for all nodes
  27957. * @example https://www.babylonjs-playground.com/#MH0VLI
  27958. */
  27959. 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[]>;
  27960. /**
  27961. * Creates a new animation, merges it with the existing animations and starts it
  27962. * @param name Name of the animation
  27963. * @param node Node which contains the scene that begins the animations
  27964. * @param targetProperty Specifies which property to animate
  27965. * @param framePerSecond The frames per second of the animation
  27966. * @param totalFrame The total number of frames
  27967. * @param from The frame at the beginning of the animation
  27968. * @param to The frame at the end of the animation
  27969. * @param loopMode Specifies the loop mode of the animation
  27970. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27971. * @param onAnimationEnd Callback to run once the animation is complete
  27972. * @returns Nullable animation
  27973. */
  27974. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27975. /**
  27976. * Transition property of an host to the target Value
  27977. * @param property The property to transition
  27978. * @param targetValue The target Value of the property
  27979. * @param host The object where the property to animate belongs
  27980. * @param scene Scene used to run the animation
  27981. * @param frameRate Framerate (in frame/s) to use
  27982. * @param transition The transition type we want to use
  27983. * @param duration The duration of the animation, in milliseconds
  27984. * @param onAnimationEnd Callback trigger at the end of the animation
  27985. * @returns Nullable animation
  27986. */
  27987. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27988. /**
  27989. * Return the array of runtime animations currently using this animation
  27990. */
  27991. readonly runtimeAnimations: RuntimeAnimation[];
  27992. /**
  27993. * Specifies if any of the runtime animations are currently running
  27994. */
  27995. readonly hasRunningRuntimeAnimations: boolean;
  27996. /**
  27997. * Initializes the animation
  27998. * @param name Name of the animation
  27999. * @param targetProperty Property to animate
  28000. * @param framePerSecond The frames per second of the animation
  28001. * @param dataType The data type of the animation
  28002. * @param loopMode The loop mode of the animation
  28003. * @param enableBlending Specifies if blending should be enabled
  28004. */
  28005. constructor(
  28006. /**Name of the animation */
  28007. name: string,
  28008. /**Property to animate */
  28009. targetProperty: string,
  28010. /**The frames per second of the animation */
  28011. framePerSecond: number,
  28012. /**The data type of the animation */
  28013. dataType: number,
  28014. /**The loop mode of the animation */
  28015. loopMode?: number | undefined,
  28016. /**Specifies if blending should be enabled */
  28017. enableBlending?: boolean | undefined);
  28018. /**
  28019. * Converts the animation to a string
  28020. * @param fullDetails support for multiple levels of logging within scene loading
  28021. * @returns String form of the animation
  28022. */
  28023. toString(fullDetails?: boolean): string;
  28024. /**
  28025. * Add an event to this animation
  28026. * @param event Event to add
  28027. */
  28028. addEvent(event: AnimationEvent): void;
  28029. /**
  28030. * Remove all events found at the given frame
  28031. * @param frame The frame to remove events from
  28032. */
  28033. removeEvents(frame: number): void;
  28034. /**
  28035. * Retrieves all the events from the animation
  28036. * @returns Events from the animation
  28037. */
  28038. getEvents(): AnimationEvent[];
  28039. /**
  28040. * Creates an animation range
  28041. * @param name Name of the animation range
  28042. * @param from Starting frame of the animation range
  28043. * @param to Ending frame of the animation
  28044. */
  28045. createRange(name: string, from: number, to: number): void;
  28046. /**
  28047. * Deletes an animation range by name
  28048. * @param name Name of the animation range to delete
  28049. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28050. */
  28051. deleteRange(name: string, deleteFrames?: boolean): void;
  28052. /**
  28053. * Gets the animation range by name, or null if not defined
  28054. * @param name Name of the animation range
  28055. * @returns Nullable animation range
  28056. */
  28057. getRange(name: string): Nullable<AnimationRange>;
  28058. /**
  28059. * Gets the key frames from the animation
  28060. * @returns The key frames of the animation
  28061. */
  28062. getKeys(): Array<IAnimationKey>;
  28063. /**
  28064. * Gets the highest frame rate of the animation
  28065. * @returns Highest frame rate of the animation
  28066. */
  28067. getHighestFrame(): number;
  28068. /**
  28069. * Gets the easing function of the animation
  28070. * @returns Easing function of the animation
  28071. */
  28072. getEasingFunction(): IEasingFunction;
  28073. /**
  28074. * Sets the easing function of the animation
  28075. * @param easingFunction A custom mathematical formula for animation
  28076. */
  28077. setEasingFunction(easingFunction: EasingFunction): void;
  28078. /**
  28079. * Interpolates a scalar linearly
  28080. * @param startValue Start value of the animation curve
  28081. * @param endValue End value of the animation curve
  28082. * @param gradient Scalar amount to interpolate
  28083. * @returns Interpolated scalar value
  28084. */
  28085. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28086. /**
  28087. * Interpolates a scalar cubically
  28088. * @param startValue Start value of the animation curve
  28089. * @param outTangent End tangent of the animation
  28090. * @param endValue End value of the animation curve
  28091. * @param inTangent Start tangent of the animation curve
  28092. * @param gradient Scalar amount to interpolate
  28093. * @returns Interpolated scalar value
  28094. */
  28095. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28096. /**
  28097. * Interpolates a quaternion using a spherical linear interpolation
  28098. * @param startValue Start value of the animation curve
  28099. * @param endValue End value of the animation curve
  28100. * @param gradient Scalar amount to interpolate
  28101. * @returns Interpolated quaternion value
  28102. */
  28103. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28104. /**
  28105. * Interpolates a quaternion cubically
  28106. * @param startValue Start value of the animation curve
  28107. * @param outTangent End tangent of the animation curve
  28108. * @param endValue End value of the animation curve
  28109. * @param inTangent Start tangent of the animation curve
  28110. * @param gradient Scalar amount to interpolate
  28111. * @returns Interpolated quaternion value
  28112. */
  28113. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28114. /**
  28115. * Interpolates a Vector3 linearl
  28116. * @param startValue Start value of the animation curve
  28117. * @param endValue End value of the animation curve
  28118. * @param gradient Scalar amount to interpolate
  28119. * @returns Interpolated scalar value
  28120. */
  28121. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28122. /**
  28123. * Interpolates a Vector3 cubically
  28124. * @param startValue Start value of the animation curve
  28125. * @param outTangent End tangent of the animation
  28126. * @param endValue End value of the animation curve
  28127. * @param inTangent Start tangent of the animation curve
  28128. * @param gradient Scalar amount to interpolate
  28129. * @returns InterpolatedVector3 value
  28130. */
  28131. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28132. /**
  28133. * Interpolates a Vector2 linearly
  28134. * @param startValue Start value of the animation curve
  28135. * @param endValue End value of the animation curve
  28136. * @param gradient Scalar amount to interpolate
  28137. * @returns Interpolated Vector2 value
  28138. */
  28139. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28140. /**
  28141. * Interpolates a Vector2 cubically
  28142. * @param startValue Start value of the animation curve
  28143. * @param outTangent End tangent of the animation
  28144. * @param endValue End value of the animation curve
  28145. * @param inTangent Start tangent of the animation curve
  28146. * @param gradient Scalar amount to interpolate
  28147. * @returns Interpolated Vector2 value
  28148. */
  28149. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28150. /**
  28151. * Interpolates a size linearly
  28152. * @param startValue Start value of the animation curve
  28153. * @param endValue End value of the animation curve
  28154. * @param gradient Scalar amount to interpolate
  28155. * @returns Interpolated Size value
  28156. */
  28157. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28158. /**
  28159. * Interpolates a Color3 linearly
  28160. * @param startValue Start value of the animation curve
  28161. * @param endValue End value of the animation curve
  28162. * @param gradient Scalar amount to interpolate
  28163. * @returns Interpolated Color3 value
  28164. */
  28165. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28166. /**
  28167. * @hidden Internal use only
  28168. */
  28169. _getKeyValue(value: any): any;
  28170. /**
  28171. * @hidden Internal use only
  28172. */
  28173. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28174. /**
  28175. * Defines the function to use to interpolate matrices
  28176. * @param startValue defines the start matrix
  28177. * @param endValue defines the end matrix
  28178. * @param gradient defines the gradient between both matrices
  28179. * @param result defines an optional target matrix where to store the interpolation
  28180. * @returns the interpolated matrix
  28181. */
  28182. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28183. /**
  28184. * Makes a copy of the animation
  28185. * @returns Cloned animation
  28186. */
  28187. clone(): Animation;
  28188. /**
  28189. * Sets the key frames of the animation
  28190. * @param values The animation key frames to set
  28191. */
  28192. setKeys(values: Array<IAnimationKey>): void;
  28193. /**
  28194. * Serializes the animation to an object
  28195. * @returns Serialized object
  28196. */
  28197. serialize(): any;
  28198. /**
  28199. * Float animation type
  28200. */
  28201. private static _ANIMATIONTYPE_FLOAT;
  28202. /**
  28203. * Vector3 animation type
  28204. */
  28205. private static _ANIMATIONTYPE_VECTOR3;
  28206. /**
  28207. * Quaternion animation type
  28208. */
  28209. private static _ANIMATIONTYPE_QUATERNION;
  28210. /**
  28211. * Matrix animation type
  28212. */
  28213. private static _ANIMATIONTYPE_MATRIX;
  28214. /**
  28215. * Color3 animation type
  28216. */
  28217. private static _ANIMATIONTYPE_COLOR3;
  28218. /**
  28219. * Vector2 animation type
  28220. */
  28221. private static _ANIMATIONTYPE_VECTOR2;
  28222. /**
  28223. * Size animation type
  28224. */
  28225. private static _ANIMATIONTYPE_SIZE;
  28226. /**
  28227. * Relative Loop Mode
  28228. */
  28229. private static _ANIMATIONLOOPMODE_RELATIVE;
  28230. /**
  28231. * Cycle Loop Mode
  28232. */
  28233. private static _ANIMATIONLOOPMODE_CYCLE;
  28234. /**
  28235. * Constant Loop Mode
  28236. */
  28237. private static _ANIMATIONLOOPMODE_CONSTANT;
  28238. /**
  28239. * Get the float animation type
  28240. */
  28241. static readonly ANIMATIONTYPE_FLOAT: number;
  28242. /**
  28243. * Get the Vector3 animation type
  28244. */
  28245. static readonly ANIMATIONTYPE_VECTOR3: number;
  28246. /**
  28247. * Get the Vector2 animation type
  28248. */
  28249. static readonly ANIMATIONTYPE_VECTOR2: number;
  28250. /**
  28251. * Get the Size animation type
  28252. */
  28253. static readonly ANIMATIONTYPE_SIZE: number;
  28254. /**
  28255. * Get the Quaternion animation type
  28256. */
  28257. static readonly ANIMATIONTYPE_QUATERNION: number;
  28258. /**
  28259. * Get the Matrix animation type
  28260. */
  28261. static readonly ANIMATIONTYPE_MATRIX: number;
  28262. /**
  28263. * Get the Color3 animation type
  28264. */
  28265. static readonly ANIMATIONTYPE_COLOR3: number;
  28266. /**
  28267. * Get the Relative Loop Mode
  28268. */
  28269. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28270. /**
  28271. * Get the Cycle Loop Mode
  28272. */
  28273. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28274. /**
  28275. * Get the Constant Loop Mode
  28276. */
  28277. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28278. /** @hidden */
  28279. static _UniversalLerp(left: any, right: any, amount: number): any;
  28280. /**
  28281. * Parses an animation object and creates an animation
  28282. * @param parsedAnimation Parsed animation object
  28283. * @returns Animation object
  28284. */
  28285. static Parse(parsedAnimation: any): Animation;
  28286. /**
  28287. * Appends the serialized animations from the source animations
  28288. * @param source Source containing the animations
  28289. * @param destination Target to store the animations
  28290. */
  28291. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28292. }
  28293. }
  28294. declare module "babylonjs/Animations/animatable.interface" {
  28295. import { Nullable } from "babylonjs/types";
  28296. import { Animation } from "babylonjs/Animations/animation";
  28297. /**
  28298. * Interface containing an array of animations
  28299. */
  28300. export interface IAnimatable {
  28301. /**
  28302. * Array of animations
  28303. */
  28304. animations: Nullable<Array<Animation>>;
  28305. }
  28306. }
  28307. declare module "babylonjs/Materials/fresnelParameters" {
  28308. import { Color3 } from "babylonjs/Maths/math.color";
  28309. /**
  28310. * This represents all the required information to add a fresnel effect on a material:
  28311. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28312. */
  28313. export class FresnelParameters {
  28314. private _isEnabled;
  28315. /**
  28316. * Define if the fresnel effect is enable or not.
  28317. */
  28318. isEnabled: boolean;
  28319. /**
  28320. * Define the color used on edges (grazing angle)
  28321. */
  28322. leftColor: Color3;
  28323. /**
  28324. * Define the color used on center
  28325. */
  28326. rightColor: Color3;
  28327. /**
  28328. * Define bias applied to computed fresnel term
  28329. */
  28330. bias: number;
  28331. /**
  28332. * Defined the power exponent applied to fresnel term
  28333. */
  28334. power: number;
  28335. /**
  28336. * Clones the current fresnel and its valuues
  28337. * @returns a clone fresnel configuration
  28338. */
  28339. clone(): FresnelParameters;
  28340. /**
  28341. * Serializes the current fresnel parameters to a JSON representation.
  28342. * @return the JSON serialization
  28343. */
  28344. serialize(): any;
  28345. /**
  28346. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28347. * @param parsedFresnelParameters Define the JSON representation
  28348. * @returns the parsed parameters
  28349. */
  28350. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28351. }
  28352. }
  28353. declare module "babylonjs/Misc/decorators" {
  28354. import { Nullable } from "babylonjs/types";
  28355. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28356. import { Scene } from "babylonjs/scene";
  28357. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28358. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28359. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28360. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28361. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28362. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28363. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28364. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28365. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28366. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28367. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28368. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28369. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28370. /**
  28371. * Decorator used to define property that can be serialized as reference to a camera
  28372. * @param sourceName defines the name of the property to decorate
  28373. */
  28374. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28375. /**
  28376. * Class used to help serialization objects
  28377. */
  28378. export class SerializationHelper {
  28379. /** @hidden */
  28380. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28381. /** @hidden */
  28382. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28383. /** @hidden */
  28384. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28385. /** @hidden */
  28386. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28387. /**
  28388. * Appends the serialized animations from the source animations
  28389. * @param source Source containing the animations
  28390. * @param destination Target to store the animations
  28391. */
  28392. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28393. /**
  28394. * Static function used to serialized a specific entity
  28395. * @param entity defines the entity to serialize
  28396. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28397. * @returns a JSON compatible object representing the serialization of the entity
  28398. */
  28399. static Serialize<T>(entity: T, serializationObject?: any): any;
  28400. /**
  28401. * Creates a new entity from a serialization data object
  28402. * @param creationFunction defines a function used to instanciated the new entity
  28403. * @param source defines the source serialization data
  28404. * @param scene defines the hosting scene
  28405. * @param rootUrl defines the root url for resources
  28406. * @returns a new entity
  28407. */
  28408. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28409. /**
  28410. * Clones an object
  28411. * @param creationFunction defines the function used to instanciate the new object
  28412. * @param source defines the source object
  28413. * @returns the cloned object
  28414. */
  28415. static Clone<T>(creationFunction: () => T, source: T): T;
  28416. /**
  28417. * Instanciates a new object based on a source one (some data will be shared between both object)
  28418. * @param creationFunction defines the function used to instanciate the new object
  28419. * @param source defines the source object
  28420. * @returns the new object
  28421. */
  28422. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28423. }
  28424. }
  28425. declare module "babylonjs/Misc/guid" {
  28426. /**
  28427. * Class used to manipulate GUIDs
  28428. */
  28429. export class GUID {
  28430. /**
  28431. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28432. * Be aware Math.random() could cause collisions, but:
  28433. * "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"
  28434. * @returns a pseudo random id
  28435. */
  28436. static RandomId(): string;
  28437. }
  28438. }
  28439. declare module "babylonjs/Materials/Textures/baseTexture" {
  28440. import { Observable } from "babylonjs/Misc/observable";
  28441. import { Nullable } from "babylonjs/types";
  28442. import { Scene } from "babylonjs/scene";
  28443. import { Matrix } from "babylonjs/Maths/math.vector";
  28444. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28445. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28446. import { ISize } from "babylonjs/Maths/math.size";
  28447. /**
  28448. * Base class of all the textures in babylon.
  28449. * It groups all the common properties the materials, post process, lights... might need
  28450. * in order to make a correct use of the texture.
  28451. */
  28452. export class BaseTexture implements IAnimatable {
  28453. /**
  28454. * Default anisotropic filtering level for the application.
  28455. * It is set to 4 as a good tradeoff between perf and quality.
  28456. */
  28457. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28458. /**
  28459. * Gets or sets the unique id of the texture
  28460. */
  28461. uniqueId: number;
  28462. /**
  28463. * Define the name of the texture.
  28464. */
  28465. name: string;
  28466. /**
  28467. * Gets or sets an object used to store user defined information.
  28468. */
  28469. metadata: any;
  28470. /**
  28471. * For internal use only. Please do not use.
  28472. */
  28473. reservedDataStore: any;
  28474. private _hasAlpha;
  28475. /**
  28476. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28477. */
  28478. hasAlpha: boolean;
  28479. /**
  28480. * Defines if the alpha value should be determined via the rgb values.
  28481. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28482. */
  28483. getAlphaFromRGB: boolean;
  28484. /**
  28485. * Intensity or strength of the texture.
  28486. * It is commonly used by materials to fine tune the intensity of the texture
  28487. */
  28488. level: number;
  28489. /**
  28490. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28491. * This is part of the texture as textures usually maps to one uv set.
  28492. */
  28493. coordinatesIndex: number;
  28494. private _coordinatesMode;
  28495. /**
  28496. * How a texture is mapped.
  28497. *
  28498. * | Value | Type | Description |
  28499. * | ----- | ----------------------------------- | ----------- |
  28500. * | 0 | EXPLICIT_MODE | |
  28501. * | 1 | SPHERICAL_MODE | |
  28502. * | 2 | PLANAR_MODE | |
  28503. * | 3 | CUBIC_MODE | |
  28504. * | 4 | PROJECTION_MODE | |
  28505. * | 5 | SKYBOX_MODE | |
  28506. * | 6 | INVCUBIC_MODE | |
  28507. * | 7 | EQUIRECTANGULAR_MODE | |
  28508. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28509. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28510. */
  28511. coordinatesMode: number;
  28512. /**
  28513. * | Value | Type | Description |
  28514. * | ----- | ------------------ | ----------- |
  28515. * | 0 | CLAMP_ADDRESSMODE | |
  28516. * | 1 | WRAP_ADDRESSMODE | |
  28517. * | 2 | MIRROR_ADDRESSMODE | |
  28518. */
  28519. wrapU: number;
  28520. /**
  28521. * | Value | Type | Description |
  28522. * | ----- | ------------------ | ----------- |
  28523. * | 0 | CLAMP_ADDRESSMODE | |
  28524. * | 1 | WRAP_ADDRESSMODE | |
  28525. * | 2 | MIRROR_ADDRESSMODE | |
  28526. */
  28527. wrapV: number;
  28528. /**
  28529. * | Value | Type | Description |
  28530. * | ----- | ------------------ | ----------- |
  28531. * | 0 | CLAMP_ADDRESSMODE | |
  28532. * | 1 | WRAP_ADDRESSMODE | |
  28533. * | 2 | MIRROR_ADDRESSMODE | |
  28534. */
  28535. wrapR: number;
  28536. /**
  28537. * With compliant hardware and browser (supporting anisotropic filtering)
  28538. * this defines the level of anisotropic filtering in the texture.
  28539. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28540. */
  28541. anisotropicFilteringLevel: number;
  28542. /**
  28543. * Define if the texture is a cube texture or if false a 2d texture.
  28544. */
  28545. isCube: boolean;
  28546. /**
  28547. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28548. */
  28549. is3D: boolean;
  28550. /**
  28551. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28552. * HDR texture are usually stored in linear space.
  28553. * This only impacts the PBR and Background materials
  28554. */
  28555. gammaSpace: boolean;
  28556. /**
  28557. * Gets or sets whether or not the texture contains RGBD data.
  28558. */
  28559. isRGBD: boolean;
  28560. /**
  28561. * Is Z inverted in the texture (useful in a cube texture).
  28562. */
  28563. invertZ: boolean;
  28564. /**
  28565. * Are mip maps generated for this texture or not.
  28566. */
  28567. readonly noMipmap: boolean;
  28568. /**
  28569. * @hidden
  28570. */
  28571. lodLevelInAlpha: boolean;
  28572. /**
  28573. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28574. */
  28575. lodGenerationOffset: number;
  28576. /**
  28577. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28578. */
  28579. lodGenerationScale: number;
  28580. /**
  28581. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28582. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28583. * average roughness values.
  28584. */
  28585. linearSpecularLOD: boolean;
  28586. /**
  28587. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28588. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28589. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28590. */
  28591. irradianceTexture: Nullable<BaseTexture>;
  28592. /**
  28593. * Define if the texture is a render target.
  28594. */
  28595. isRenderTarget: boolean;
  28596. /**
  28597. * Define the unique id of the texture in the scene.
  28598. */
  28599. readonly uid: string;
  28600. /**
  28601. * Return a string representation of the texture.
  28602. * @returns the texture as a string
  28603. */
  28604. toString(): string;
  28605. /**
  28606. * Get the class name of the texture.
  28607. * @returns "BaseTexture"
  28608. */
  28609. getClassName(): string;
  28610. /**
  28611. * Define the list of animation attached to the texture.
  28612. */
  28613. animations: import("babylonjs/Animations/animation").Animation[];
  28614. /**
  28615. * An event triggered when the texture is disposed.
  28616. */
  28617. onDisposeObservable: Observable<BaseTexture>;
  28618. private _onDisposeObserver;
  28619. /**
  28620. * Callback triggered when the texture has been disposed.
  28621. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28622. */
  28623. onDispose: () => void;
  28624. /**
  28625. * Define the current state of the loading sequence when in delayed load mode.
  28626. */
  28627. delayLoadState: number;
  28628. private _scene;
  28629. /** @hidden */
  28630. _texture: Nullable<InternalTexture>;
  28631. private _uid;
  28632. /**
  28633. * Define if the texture is preventinga material to render or not.
  28634. * If not and the texture is not ready, the engine will use a default black texture instead.
  28635. */
  28636. readonly isBlocking: boolean;
  28637. /**
  28638. * Instantiates a new BaseTexture.
  28639. * Base class of all the textures in babylon.
  28640. * It groups all the common properties the materials, post process, lights... might need
  28641. * in order to make a correct use of the texture.
  28642. * @param scene Define the scene the texture blongs to
  28643. */
  28644. constructor(scene: Nullable<Scene>);
  28645. /**
  28646. * Get the scene the texture belongs to.
  28647. * @returns the scene or null if undefined
  28648. */
  28649. getScene(): Nullable<Scene>;
  28650. /**
  28651. * Get the texture transform matrix used to offset tile the texture for istance.
  28652. * @returns the transformation matrix
  28653. */
  28654. getTextureMatrix(): Matrix;
  28655. /**
  28656. * Get the texture reflection matrix used to rotate/transform the reflection.
  28657. * @returns the reflection matrix
  28658. */
  28659. getReflectionTextureMatrix(): Matrix;
  28660. /**
  28661. * Get the underlying lower level texture from Babylon.
  28662. * @returns the insternal texture
  28663. */
  28664. getInternalTexture(): Nullable<InternalTexture>;
  28665. /**
  28666. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28667. * @returns true if ready or not blocking
  28668. */
  28669. isReadyOrNotBlocking(): boolean;
  28670. /**
  28671. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28672. * @returns true if fully ready
  28673. */
  28674. isReady(): boolean;
  28675. private _cachedSize;
  28676. /**
  28677. * Get the size of the texture.
  28678. * @returns the texture size.
  28679. */
  28680. getSize(): ISize;
  28681. /**
  28682. * Get the base size of the texture.
  28683. * It can be different from the size if the texture has been resized for POT for instance
  28684. * @returns the base size
  28685. */
  28686. getBaseSize(): ISize;
  28687. /**
  28688. * Update the sampling mode of the texture.
  28689. * Default is Trilinear mode.
  28690. *
  28691. * | Value | Type | Description |
  28692. * | ----- | ------------------ | ----------- |
  28693. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28694. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28695. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28696. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28697. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28698. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28699. * | 7 | NEAREST_LINEAR | |
  28700. * | 8 | NEAREST_NEAREST | |
  28701. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28702. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28703. * | 11 | LINEAR_LINEAR | |
  28704. * | 12 | LINEAR_NEAREST | |
  28705. *
  28706. * > _mag_: magnification filter (close to the viewer)
  28707. * > _min_: minification filter (far from the viewer)
  28708. * > _mip_: filter used between mip map levels
  28709. *@param samplingMode Define the new sampling mode of the texture
  28710. */
  28711. updateSamplingMode(samplingMode: number): void;
  28712. /**
  28713. * Scales the texture if is `canRescale()`
  28714. * @param ratio the resize factor we want to use to rescale
  28715. */
  28716. scale(ratio: number): void;
  28717. /**
  28718. * Get if the texture can rescale.
  28719. */
  28720. readonly canRescale: boolean;
  28721. /** @hidden */
  28722. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28723. /** @hidden */
  28724. _rebuild(): void;
  28725. /**
  28726. * Triggers the load sequence in delayed load mode.
  28727. */
  28728. delayLoad(): void;
  28729. /**
  28730. * Clones the texture.
  28731. * @returns the cloned texture
  28732. */
  28733. clone(): Nullable<BaseTexture>;
  28734. /**
  28735. * Get the texture underlying type (INT, FLOAT...)
  28736. */
  28737. readonly textureType: number;
  28738. /**
  28739. * Get the texture underlying format (RGB, RGBA...)
  28740. */
  28741. readonly textureFormat: number;
  28742. /**
  28743. * Indicates that textures need to be re-calculated for all materials
  28744. */
  28745. protected _markAllSubMeshesAsTexturesDirty(): void;
  28746. /**
  28747. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28748. * This will returns an RGBA array buffer containing either in values (0-255) or
  28749. * float values (0-1) depending of the underlying buffer type.
  28750. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28751. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28752. * @param buffer defines a user defined buffer to fill with data (can be null)
  28753. * @returns The Array buffer containing the pixels data.
  28754. */
  28755. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28756. /**
  28757. * Release and destroy the underlying lower level texture aka internalTexture.
  28758. */
  28759. releaseInternalTexture(): void;
  28760. /** @hidden */
  28761. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28762. /** @hidden */
  28763. readonly _lodTextureMid: Nullable<BaseTexture>;
  28764. /** @hidden */
  28765. readonly _lodTextureLow: Nullable<BaseTexture>;
  28766. /**
  28767. * Dispose the texture and release its associated resources.
  28768. */
  28769. dispose(): void;
  28770. /**
  28771. * Serialize the texture into a JSON representation that can be parsed later on.
  28772. * @returns the JSON representation of the texture
  28773. */
  28774. serialize(): any;
  28775. /**
  28776. * Helper function to be called back once a list of texture contains only ready textures.
  28777. * @param textures Define the list of textures to wait for
  28778. * @param callback Define the callback triggered once the entire list will be ready
  28779. */
  28780. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28781. }
  28782. }
  28783. declare module "babylonjs/Materials/effect" {
  28784. import { Observable } from "babylonjs/Misc/observable";
  28785. import { Nullable } from "babylonjs/types";
  28786. import { IDisposable } from "babylonjs/scene";
  28787. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28788. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28789. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28790. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  28791. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  28792. import { Engine } from "babylonjs/Engines/engine";
  28793. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28794. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28795. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28796. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28797. /**
  28798. * Options to be used when creating an effect.
  28799. */
  28800. export interface IEffectCreationOptions {
  28801. /**
  28802. * Atrributes that will be used in the shader.
  28803. */
  28804. attributes: string[];
  28805. /**
  28806. * Uniform varible names that will be set in the shader.
  28807. */
  28808. uniformsNames: string[];
  28809. /**
  28810. * Uniform buffer varible names that will be set in the shader.
  28811. */
  28812. uniformBuffersNames: string[];
  28813. /**
  28814. * Sampler texture variable names that will be set in the shader.
  28815. */
  28816. samplers: string[];
  28817. /**
  28818. * Define statements that will be set in the shader.
  28819. */
  28820. defines: any;
  28821. /**
  28822. * Possible fallbacks for this effect to improve performance when needed.
  28823. */
  28824. fallbacks: Nullable<IEffectFallbacks>;
  28825. /**
  28826. * Callback that will be called when the shader is compiled.
  28827. */
  28828. onCompiled: Nullable<(effect: Effect) => void>;
  28829. /**
  28830. * Callback that will be called if an error occurs during shader compilation.
  28831. */
  28832. onError: Nullable<(effect: Effect, errors: string) => void>;
  28833. /**
  28834. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28835. */
  28836. indexParameters?: any;
  28837. /**
  28838. * Max number of lights that can be used in the shader.
  28839. */
  28840. maxSimultaneousLights?: number;
  28841. /**
  28842. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28843. */
  28844. transformFeedbackVaryings?: Nullable<string[]>;
  28845. }
  28846. /**
  28847. * Effect containing vertex and fragment shader that can be executed on an object.
  28848. */
  28849. export class Effect implements IDisposable {
  28850. /**
  28851. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28852. */
  28853. static ShadersRepository: string;
  28854. /**
  28855. * Name of the effect.
  28856. */
  28857. name: any;
  28858. /**
  28859. * String container all the define statements that should be set on the shader.
  28860. */
  28861. defines: string;
  28862. /**
  28863. * Callback that will be called when the shader is compiled.
  28864. */
  28865. onCompiled: Nullable<(effect: Effect) => void>;
  28866. /**
  28867. * Callback that will be called if an error occurs during shader compilation.
  28868. */
  28869. onError: Nullable<(effect: Effect, errors: string) => void>;
  28870. /**
  28871. * Callback that will be called when effect is bound.
  28872. */
  28873. onBind: Nullable<(effect: Effect) => void>;
  28874. /**
  28875. * Unique ID of the effect.
  28876. */
  28877. uniqueId: number;
  28878. /**
  28879. * Observable that will be called when the shader is compiled.
  28880. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28881. */
  28882. onCompileObservable: Observable<Effect>;
  28883. /**
  28884. * Observable that will be called if an error occurs during shader compilation.
  28885. */
  28886. onErrorObservable: Observable<Effect>;
  28887. /** @hidden */
  28888. _onBindObservable: Nullable<Observable<Effect>>;
  28889. /**
  28890. * Observable that will be called when effect is bound.
  28891. */
  28892. readonly onBindObservable: Observable<Effect>;
  28893. /** @hidden */
  28894. _bonesComputationForcedToCPU: boolean;
  28895. private static _uniqueIdSeed;
  28896. private _engine;
  28897. private _uniformBuffersNames;
  28898. private _uniformsNames;
  28899. private _samplerList;
  28900. private _samplers;
  28901. private _isReady;
  28902. private _compilationError;
  28903. private _allFallbacksProcessed;
  28904. private _attributesNames;
  28905. private _attributes;
  28906. private _uniforms;
  28907. /**
  28908. * Key for the effect.
  28909. * @hidden
  28910. */
  28911. _key: string;
  28912. private _indexParameters;
  28913. private _fallbacks;
  28914. private _vertexSourceCode;
  28915. private _fragmentSourceCode;
  28916. private _vertexSourceCodeOverride;
  28917. private _fragmentSourceCodeOverride;
  28918. private _transformFeedbackVaryings;
  28919. /**
  28920. * Compiled shader to webGL program.
  28921. * @hidden
  28922. */
  28923. _pipelineContext: Nullable<IPipelineContext>;
  28924. private _valueCache;
  28925. private static _baseCache;
  28926. /**
  28927. * Instantiates an effect.
  28928. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28929. * @param baseName Name of the effect.
  28930. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28931. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28932. * @param samplers List of sampler variables that will be passed to the shader.
  28933. * @param engine Engine to be used to render the effect
  28934. * @param defines Define statements to be added to the shader.
  28935. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28936. * @param onCompiled Callback that will be called when the shader is compiled.
  28937. * @param onError Callback that will be called if an error occurs during shader compilation.
  28938. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28939. */
  28940. 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);
  28941. private _useFinalCode;
  28942. /**
  28943. * Unique key for this effect
  28944. */
  28945. readonly key: string;
  28946. /**
  28947. * If the effect has been compiled and prepared.
  28948. * @returns if the effect is compiled and prepared.
  28949. */
  28950. isReady(): boolean;
  28951. private _isReadyInternal;
  28952. /**
  28953. * The engine the effect was initialized with.
  28954. * @returns the engine.
  28955. */
  28956. getEngine(): Engine;
  28957. /**
  28958. * The pipeline context for this effect
  28959. * @returns the associated pipeline context
  28960. */
  28961. getPipelineContext(): Nullable<IPipelineContext>;
  28962. /**
  28963. * The set of names of attribute variables for the shader.
  28964. * @returns An array of attribute names.
  28965. */
  28966. getAttributesNames(): string[];
  28967. /**
  28968. * Returns the attribute at the given index.
  28969. * @param index The index of the attribute.
  28970. * @returns The location of the attribute.
  28971. */
  28972. getAttributeLocation(index: number): number;
  28973. /**
  28974. * Returns the attribute based on the name of the variable.
  28975. * @param name of the attribute to look up.
  28976. * @returns the attribute location.
  28977. */
  28978. getAttributeLocationByName(name: string): number;
  28979. /**
  28980. * The number of attributes.
  28981. * @returns the numnber of attributes.
  28982. */
  28983. getAttributesCount(): number;
  28984. /**
  28985. * Gets the index of a uniform variable.
  28986. * @param uniformName of the uniform to look up.
  28987. * @returns the index.
  28988. */
  28989. getUniformIndex(uniformName: string): number;
  28990. /**
  28991. * Returns the attribute based on the name of the variable.
  28992. * @param uniformName of the uniform to look up.
  28993. * @returns the location of the uniform.
  28994. */
  28995. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28996. /**
  28997. * Returns an array of sampler variable names
  28998. * @returns The array of sampler variable neames.
  28999. */
  29000. getSamplers(): string[];
  29001. /**
  29002. * The error from the last compilation.
  29003. * @returns the error string.
  29004. */
  29005. getCompilationError(): string;
  29006. /**
  29007. * Gets a boolean indicating that all fallbacks were used during compilation
  29008. * @returns true if all fallbacks were used
  29009. */
  29010. allFallbacksProcessed(): boolean;
  29011. /**
  29012. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29013. * @param func The callback to be used.
  29014. */
  29015. executeWhenCompiled(func: (effect: Effect) => void): void;
  29016. private _checkIsReady;
  29017. private _loadShader;
  29018. /**
  29019. * Recompiles the webGL program
  29020. * @param vertexSourceCode The source code for the vertex shader.
  29021. * @param fragmentSourceCode The source code for the fragment shader.
  29022. * @param onCompiled Callback called when completed.
  29023. * @param onError Callback called on error.
  29024. * @hidden
  29025. */
  29026. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29027. /**
  29028. * Prepares the effect
  29029. * @hidden
  29030. */
  29031. _prepareEffect(): void;
  29032. private _processCompilationErrors;
  29033. /**
  29034. * Checks if the effect is supported. (Must be called after compilation)
  29035. */
  29036. readonly isSupported: boolean;
  29037. /**
  29038. * Binds a texture to the engine to be used as output of the shader.
  29039. * @param channel Name of the output variable.
  29040. * @param texture Texture to bind.
  29041. * @hidden
  29042. */
  29043. _bindTexture(channel: string, texture: InternalTexture): void;
  29044. /**
  29045. * Sets a texture on the engine to be used in the shader.
  29046. * @param channel Name of the sampler variable.
  29047. * @param texture Texture to set.
  29048. */
  29049. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29050. /**
  29051. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29052. * @param channel Name of the sampler variable.
  29053. * @param texture Texture to set.
  29054. */
  29055. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29056. /**
  29057. * Sets an array of textures on the engine to be used in the shader.
  29058. * @param channel Name of the variable.
  29059. * @param textures Textures to set.
  29060. */
  29061. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29062. /**
  29063. * 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)
  29064. * @param channel Name of the sampler variable.
  29065. * @param postProcess Post process to get the input texture from.
  29066. */
  29067. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29068. /**
  29069. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29070. * 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)
  29071. * @param channel Name of the sampler variable.
  29072. * @param postProcess Post process to get the output texture from.
  29073. */
  29074. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29075. /** @hidden */
  29076. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29077. /** @hidden */
  29078. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29079. /** @hidden */
  29080. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29081. /** @hidden */
  29082. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29083. /**
  29084. * Binds a buffer to a uniform.
  29085. * @param buffer Buffer to bind.
  29086. * @param name Name of the uniform variable to bind to.
  29087. */
  29088. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29089. /**
  29090. * Binds block to a uniform.
  29091. * @param blockName Name of the block to bind.
  29092. * @param index Index to bind.
  29093. */
  29094. bindUniformBlock(blockName: string, index: number): void;
  29095. /**
  29096. * Sets an interger value on a uniform variable.
  29097. * @param uniformName Name of the variable.
  29098. * @param value Value to be set.
  29099. * @returns this effect.
  29100. */
  29101. setInt(uniformName: string, value: number): Effect;
  29102. /**
  29103. * Sets an int array on a uniform variable.
  29104. * @param uniformName Name of the variable.
  29105. * @param array array to be set.
  29106. * @returns this effect.
  29107. */
  29108. setIntArray(uniformName: string, array: Int32Array): Effect;
  29109. /**
  29110. * 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)
  29111. * @param uniformName Name of the variable.
  29112. * @param array array to be set.
  29113. * @returns this effect.
  29114. */
  29115. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29116. /**
  29117. * 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)
  29118. * @param uniformName Name of the variable.
  29119. * @param array array to be set.
  29120. * @returns this effect.
  29121. */
  29122. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29123. /**
  29124. * 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)
  29125. * @param uniformName Name of the variable.
  29126. * @param array array to be set.
  29127. * @returns this effect.
  29128. */
  29129. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29130. /**
  29131. * Sets an float array on a uniform variable.
  29132. * @param uniformName Name of the variable.
  29133. * @param array array to be set.
  29134. * @returns this effect.
  29135. */
  29136. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29137. /**
  29138. * 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)
  29139. * @param uniformName Name of the variable.
  29140. * @param array array to be set.
  29141. * @returns this effect.
  29142. */
  29143. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29144. /**
  29145. * 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)
  29146. * @param uniformName Name of the variable.
  29147. * @param array array to be set.
  29148. * @returns this effect.
  29149. */
  29150. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29151. /**
  29152. * 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)
  29153. * @param uniformName Name of the variable.
  29154. * @param array array to be set.
  29155. * @returns this effect.
  29156. */
  29157. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29158. /**
  29159. * Sets an array on a uniform variable.
  29160. * @param uniformName Name of the variable.
  29161. * @param array array to be set.
  29162. * @returns this effect.
  29163. */
  29164. setArray(uniformName: string, array: number[]): Effect;
  29165. /**
  29166. * 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)
  29167. * @param uniformName Name of the variable.
  29168. * @param array array to be set.
  29169. * @returns this effect.
  29170. */
  29171. setArray2(uniformName: string, array: number[]): Effect;
  29172. /**
  29173. * 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)
  29174. * @param uniformName Name of the variable.
  29175. * @param array array to be set.
  29176. * @returns this effect.
  29177. */
  29178. setArray3(uniformName: string, array: number[]): Effect;
  29179. /**
  29180. * 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)
  29181. * @param uniformName Name of the variable.
  29182. * @param array array to be set.
  29183. * @returns this effect.
  29184. */
  29185. setArray4(uniformName: string, array: number[]): Effect;
  29186. /**
  29187. * Sets matrices on a uniform variable.
  29188. * @param uniformName Name of the variable.
  29189. * @param matrices matrices to be set.
  29190. * @returns this effect.
  29191. */
  29192. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29193. /**
  29194. * Sets matrix on a uniform variable.
  29195. * @param uniformName Name of the variable.
  29196. * @param matrix matrix to be set.
  29197. * @returns this effect.
  29198. */
  29199. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29200. /**
  29201. * 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)
  29202. * @param uniformName Name of the variable.
  29203. * @param matrix matrix to be set.
  29204. * @returns this effect.
  29205. */
  29206. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29207. /**
  29208. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29209. * @param uniformName Name of the variable.
  29210. * @param matrix matrix to be set.
  29211. * @returns this effect.
  29212. */
  29213. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29214. /**
  29215. * Sets a float on a uniform variable.
  29216. * @param uniformName Name of the variable.
  29217. * @param value value to be set.
  29218. * @returns this effect.
  29219. */
  29220. setFloat(uniformName: string, value: number): Effect;
  29221. /**
  29222. * Sets a boolean on a uniform variable.
  29223. * @param uniformName Name of the variable.
  29224. * @param bool value to be set.
  29225. * @returns this effect.
  29226. */
  29227. setBool(uniformName: string, bool: boolean): Effect;
  29228. /**
  29229. * Sets a Vector2 on a uniform variable.
  29230. * @param uniformName Name of the variable.
  29231. * @param vector2 vector2 to be set.
  29232. * @returns this effect.
  29233. */
  29234. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29235. /**
  29236. * Sets a float2 on a uniform variable.
  29237. * @param uniformName Name of the variable.
  29238. * @param x First float in float2.
  29239. * @param y Second float in float2.
  29240. * @returns this effect.
  29241. */
  29242. setFloat2(uniformName: string, x: number, y: number): Effect;
  29243. /**
  29244. * Sets a Vector3 on a uniform variable.
  29245. * @param uniformName Name of the variable.
  29246. * @param vector3 Value to be set.
  29247. * @returns this effect.
  29248. */
  29249. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29250. /**
  29251. * Sets a float3 on a uniform variable.
  29252. * @param uniformName Name of the variable.
  29253. * @param x First float in float3.
  29254. * @param y Second float in float3.
  29255. * @param z Third float in float3.
  29256. * @returns this effect.
  29257. */
  29258. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29259. /**
  29260. * Sets a Vector4 on a uniform variable.
  29261. * @param uniformName Name of the variable.
  29262. * @param vector4 Value to be set.
  29263. * @returns this effect.
  29264. */
  29265. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29266. /**
  29267. * Sets a float4 on a uniform variable.
  29268. * @param uniformName Name of the variable.
  29269. * @param x First float in float4.
  29270. * @param y Second float in float4.
  29271. * @param z Third float in float4.
  29272. * @param w Fourth float in float4.
  29273. * @returns this effect.
  29274. */
  29275. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29276. /**
  29277. * Sets a Color3 on a uniform variable.
  29278. * @param uniformName Name of the variable.
  29279. * @param color3 Value to be set.
  29280. * @returns this effect.
  29281. */
  29282. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29283. /**
  29284. * Sets a Color4 on a uniform variable.
  29285. * @param uniformName Name of the variable.
  29286. * @param color3 Value to be set.
  29287. * @param alpha Alpha value to be set.
  29288. * @returns this effect.
  29289. */
  29290. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29291. /**
  29292. * Sets a Color4 on a uniform variable
  29293. * @param uniformName defines the name of the variable
  29294. * @param color4 defines the value to be set
  29295. * @returns this effect.
  29296. */
  29297. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29298. /** Release all associated resources */
  29299. dispose(): void;
  29300. /**
  29301. * This function will add a new shader to the shader store
  29302. * @param name the name of the shader
  29303. * @param pixelShader optional pixel shader content
  29304. * @param vertexShader optional vertex shader content
  29305. */
  29306. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29307. /**
  29308. * Store of each shader (The can be looked up using effect.key)
  29309. */
  29310. static ShadersStore: {
  29311. [key: string]: string;
  29312. };
  29313. /**
  29314. * Store of each included file for a shader (The can be looked up using effect.key)
  29315. */
  29316. static IncludesShadersStore: {
  29317. [key: string]: string;
  29318. };
  29319. /**
  29320. * Resets the cache of effects.
  29321. */
  29322. static ResetCache(): void;
  29323. }
  29324. }
  29325. declare module "babylonjs/Engines/engineCapabilities" {
  29326. import { Nullable } from "babylonjs/types";
  29327. /**
  29328. * Class used to describe the capabilities of the engine relatively to the current browser
  29329. */
  29330. export class EngineCapabilities {
  29331. /** Maximum textures units per fragment shader */
  29332. maxTexturesImageUnits: number;
  29333. /** Maximum texture units per vertex shader */
  29334. maxVertexTextureImageUnits: number;
  29335. /** Maximum textures units in the entire pipeline */
  29336. maxCombinedTexturesImageUnits: number;
  29337. /** Maximum texture size */
  29338. maxTextureSize: number;
  29339. /** Maximum cube texture size */
  29340. maxCubemapTextureSize: number;
  29341. /** Maximum render texture size */
  29342. maxRenderTextureSize: number;
  29343. /** Maximum number of vertex attributes */
  29344. maxVertexAttribs: number;
  29345. /** Maximum number of varyings */
  29346. maxVaryingVectors: number;
  29347. /** Maximum number of uniforms per vertex shader */
  29348. maxVertexUniformVectors: number;
  29349. /** Maximum number of uniforms per fragment shader */
  29350. maxFragmentUniformVectors: number;
  29351. /** Defines if standard derivates (dx/dy) are supported */
  29352. standardDerivatives: boolean;
  29353. /** Defines if s3tc texture compression is supported */
  29354. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29355. /** Defines if pvrtc texture compression is supported */
  29356. pvrtc: any;
  29357. /** Defines if etc1 texture compression is supported */
  29358. etc1: any;
  29359. /** Defines if etc2 texture compression is supported */
  29360. etc2: any;
  29361. /** Defines if astc texture compression is supported */
  29362. astc: any;
  29363. /** Defines if float textures are supported */
  29364. textureFloat: boolean;
  29365. /** Defines if vertex array objects are supported */
  29366. vertexArrayObject: boolean;
  29367. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29368. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29369. /** Gets the maximum level of anisotropy supported */
  29370. maxAnisotropy: number;
  29371. /** Defines if instancing is supported */
  29372. instancedArrays: boolean;
  29373. /** Defines if 32 bits indices are supported */
  29374. uintIndices: boolean;
  29375. /** Defines if high precision shaders are supported */
  29376. highPrecisionShaderSupported: boolean;
  29377. /** Defines if depth reading in the fragment shader is supported */
  29378. fragmentDepthSupported: boolean;
  29379. /** Defines if float texture linear filtering is supported*/
  29380. textureFloatLinearFiltering: boolean;
  29381. /** Defines if rendering to float textures is supported */
  29382. textureFloatRender: boolean;
  29383. /** Defines if half float textures are supported*/
  29384. textureHalfFloat: boolean;
  29385. /** Defines if half float texture linear filtering is supported*/
  29386. textureHalfFloatLinearFiltering: boolean;
  29387. /** Defines if rendering to half float textures is supported */
  29388. textureHalfFloatRender: boolean;
  29389. /** Defines if textureLOD shader command is supported */
  29390. textureLOD: boolean;
  29391. /** Defines if draw buffers extension is supported */
  29392. drawBuffersExtension: boolean;
  29393. /** Defines if depth textures are supported */
  29394. depthTextureExtension: boolean;
  29395. /** Defines if float color buffer are supported */
  29396. colorBufferFloat: boolean;
  29397. /** Gets disjoint timer query extension (null if not supported) */
  29398. timerQuery: EXT_disjoint_timer_query;
  29399. /** Defines if timestamp can be used with timer query */
  29400. canUseTimestampForTimerQuery: boolean;
  29401. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29402. multiview: any;
  29403. /** Function used to let the system compiles shaders in background */
  29404. parallelShaderCompile: {
  29405. COMPLETION_STATUS_KHR: number;
  29406. };
  29407. /** Max number of texture samples for MSAA */
  29408. maxMSAASamples: number;
  29409. /** Defines if the blend min max extension is supported */
  29410. blendMinMax: boolean;
  29411. }
  29412. }
  29413. declare module "babylonjs/States/depthCullingState" {
  29414. import { Nullable } from "babylonjs/types";
  29415. /**
  29416. * @hidden
  29417. **/
  29418. export class DepthCullingState {
  29419. private _isDepthTestDirty;
  29420. private _isDepthMaskDirty;
  29421. private _isDepthFuncDirty;
  29422. private _isCullFaceDirty;
  29423. private _isCullDirty;
  29424. private _isZOffsetDirty;
  29425. private _isFrontFaceDirty;
  29426. private _depthTest;
  29427. private _depthMask;
  29428. private _depthFunc;
  29429. private _cull;
  29430. private _cullFace;
  29431. private _zOffset;
  29432. private _frontFace;
  29433. /**
  29434. * Initializes the state.
  29435. */
  29436. constructor();
  29437. readonly isDirty: boolean;
  29438. zOffset: number;
  29439. cullFace: Nullable<number>;
  29440. cull: Nullable<boolean>;
  29441. depthFunc: Nullable<number>;
  29442. depthMask: boolean;
  29443. depthTest: boolean;
  29444. frontFace: Nullable<number>;
  29445. reset(): void;
  29446. apply(gl: WebGLRenderingContext): void;
  29447. }
  29448. }
  29449. declare module "babylonjs/States/stencilState" {
  29450. /**
  29451. * @hidden
  29452. **/
  29453. export class StencilState {
  29454. /** 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 */
  29455. static readonly ALWAYS: number;
  29456. /** Passed to stencilOperation to specify that stencil value must be kept */
  29457. static readonly KEEP: number;
  29458. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29459. static readonly REPLACE: number;
  29460. private _isStencilTestDirty;
  29461. private _isStencilMaskDirty;
  29462. private _isStencilFuncDirty;
  29463. private _isStencilOpDirty;
  29464. private _stencilTest;
  29465. private _stencilMask;
  29466. private _stencilFunc;
  29467. private _stencilFuncRef;
  29468. private _stencilFuncMask;
  29469. private _stencilOpStencilFail;
  29470. private _stencilOpDepthFail;
  29471. private _stencilOpStencilDepthPass;
  29472. readonly isDirty: boolean;
  29473. stencilFunc: number;
  29474. stencilFuncRef: number;
  29475. stencilFuncMask: number;
  29476. stencilOpStencilFail: number;
  29477. stencilOpDepthFail: number;
  29478. stencilOpStencilDepthPass: number;
  29479. stencilMask: number;
  29480. stencilTest: boolean;
  29481. constructor();
  29482. reset(): void;
  29483. apply(gl: WebGLRenderingContext): void;
  29484. }
  29485. }
  29486. declare module "babylonjs/States/alphaCullingState" {
  29487. /**
  29488. * @hidden
  29489. **/
  29490. export class AlphaState {
  29491. private _isAlphaBlendDirty;
  29492. private _isBlendFunctionParametersDirty;
  29493. private _isBlendEquationParametersDirty;
  29494. private _isBlendConstantsDirty;
  29495. private _alphaBlend;
  29496. private _blendFunctionParameters;
  29497. private _blendEquationParameters;
  29498. private _blendConstants;
  29499. /**
  29500. * Initializes the state.
  29501. */
  29502. constructor();
  29503. readonly isDirty: boolean;
  29504. alphaBlend: boolean;
  29505. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29506. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29507. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29508. reset(): void;
  29509. apply(gl: WebGLRenderingContext): void;
  29510. }
  29511. }
  29512. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29513. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29514. /** @hidden */
  29515. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29516. attributeProcessor(attribute: string): string;
  29517. varyingProcessor(varying: string, isFragment: boolean): string;
  29518. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29519. }
  29520. }
  29521. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29522. /**
  29523. * Interface for attribute information associated with buffer instanciation
  29524. */
  29525. export class InstancingAttributeInfo {
  29526. /**
  29527. * Index/offset of the attribute in the vertex shader
  29528. */
  29529. index: number;
  29530. /**
  29531. * size of the attribute, 1, 2, 3 or 4
  29532. */
  29533. attributeSize: number;
  29534. /**
  29535. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29536. * default is FLOAT
  29537. */
  29538. attribyteType: number;
  29539. /**
  29540. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29541. */
  29542. normalized: boolean;
  29543. /**
  29544. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29545. */
  29546. offset: number;
  29547. /**
  29548. * Name of the GLSL attribute, for debugging purpose only
  29549. */
  29550. attributeName: string;
  29551. }
  29552. }
  29553. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29554. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29555. import { Nullable } from "babylonjs/types";
  29556. module "babylonjs/Engines/thinEngine" {
  29557. interface ThinEngine {
  29558. /**
  29559. * Update a video texture
  29560. * @param texture defines the texture to update
  29561. * @param video defines the video element to use
  29562. * @param invertY defines if data must be stored with Y axis inverted
  29563. */
  29564. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29565. }
  29566. }
  29567. }
  29568. declare module "babylonjs/Materials/Textures/videoTexture" {
  29569. import { Observable } from "babylonjs/Misc/observable";
  29570. import { Nullable } from "babylonjs/types";
  29571. import { Scene } from "babylonjs/scene";
  29572. import { Texture } from "babylonjs/Materials/Textures/texture";
  29573. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29574. /**
  29575. * Settings for finer control over video usage
  29576. */
  29577. export interface VideoTextureSettings {
  29578. /**
  29579. * Applies `autoplay` to video, if specified
  29580. */
  29581. autoPlay?: boolean;
  29582. /**
  29583. * Applies `loop` to video, if specified
  29584. */
  29585. loop?: boolean;
  29586. /**
  29587. * Automatically updates internal texture from video at every frame in the render loop
  29588. */
  29589. autoUpdateTexture: boolean;
  29590. /**
  29591. * Image src displayed during the video loading or until the user interacts with the video.
  29592. */
  29593. poster?: string;
  29594. }
  29595. /**
  29596. * If you want to display a video in your scene, this is the special texture for that.
  29597. * This special texture works similar to other textures, with the exception of a few parameters.
  29598. * @see https://doc.babylonjs.com/how_to/video_texture
  29599. */
  29600. export class VideoTexture extends Texture {
  29601. /**
  29602. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29603. */
  29604. readonly autoUpdateTexture: boolean;
  29605. /**
  29606. * The video instance used by the texture internally
  29607. */
  29608. readonly video: HTMLVideoElement;
  29609. private _onUserActionRequestedObservable;
  29610. /**
  29611. * Event triggerd when a dom action is required by the user to play the video.
  29612. * This happens due to recent changes in browser policies preventing video to auto start.
  29613. */
  29614. readonly onUserActionRequestedObservable: Observable<Texture>;
  29615. private _generateMipMaps;
  29616. private _engine;
  29617. private _stillImageCaptured;
  29618. private _displayingPosterTexture;
  29619. private _settings;
  29620. private _createInternalTextureOnEvent;
  29621. private _frameId;
  29622. /**
  29623. * Creates a video texture.
  29624. * If you want to display a video in your scene, this is the special texture for that.
  29625. * This special texture works similar to other textures, with the exception of a few parameters.
  29626. * @see https://doc.babylonjs.com/how_to/video_texture
  29627. * @param name optional name, will detect from video source, if not defined
  29628. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29629. * @param scene is obviously the current scene.
  29630. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29631. * @param invertY is false by default but can be used to invert video on Y axis
  29632. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29633. * @param settings allows finer control over video usage
  29634. */
  29635. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29636. private _getName;
  29637. private _getVideo;
  29638. private _createInternalTexture;
  29639. private reset;
  29640. /**
  29641. * @hidden Internal method to initiate `update`.
  29642. */
  29643. _rebuild(): void;
  29644. /**
  29645. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29646. */
  29647. update(): void;
  29648. /**
  29649. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29650. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29651. */
  29652. updateTexture(isVisible: boolean): void;
  29653. protected _updateInternalTexture: () => void;
  29654. /**
  29655. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29656. * @param url New url.
  29657. */
  29658. updateURL(url: string): void;
  29659. /**
  29660. * Dispose the texture and release its associated resources.
  29661. */
  29662. dispose(): void;
  29663. /**
  29664. * Creates a video texture straight from a stream.
  29665. * @param scene Define the scene the texture should be created in
  29666. * @param stream Define the stream the texture should be created from
  29667. * @returns The created video texture as a promise
  29668. */
  29669. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29670. /**
  29671. * Creates a video texture straight from your WebCam video feed.
  29672. * @param scene Define the scene the texture should be created in
  29673. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29674. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29675. * @returns The created video texture as a promise
  29676. */
  29677. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29678. minWidth: number;
  29679. maxWidth: number;
  29680. minHeight: number;
  29681. maxHeight: number;
  29682. deviceId: string;
  29683. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29684. /**
  29685. * Creates a video texture straight from your WebCam video feed.
  29686. * @param scene Define the scene the texture should be created in
  29687. * @param onReady Define a callback to triggered once the texture will be ready
  29688. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29689. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29690. */
  29691. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29692. minWidth: number;
  29693. maxWidth: number;
  29694. minHeight: number;
  29695. maxHeight: number;
  29696. deviceId: string;
  29697. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29698. }
  29699. }
  29700. declare module "babylonjs/Engines/thinEngine" {
  29701. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  29702. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  29703. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29704. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29705. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  29706. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  29707. import { Observable } from "babylonjs/Misc/observable";
  29708. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  29709. import { StencilState } from "babylonjs/States/stencilState";
  29710. import { AlphaState } from "babylonjs/States/alphaCullingState";
  29711. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29712. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  29713. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29714. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  29715. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29716. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  29717. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29718. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  29719. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  29720. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29721. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  29722. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29723. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  29724. /**
  29725. * Defines the interface used by objects working like Scene
  29726. * @hidden
  29727. */
  29728. interface ISceneLike {
  29729. _addPendingData(data: any): void;
  29730. _removePendingData(data: any): void;
  29731. offlineProvider: IOfflineProvider;
  29732. }
  29733. /** Interface defining initialization parameters for Engine class */
  29734. export interface EngineOptions extends WebGLContextAttributes {
  29735. /**
  29736. * Defines if the engine should no exceed a specified device ratio
  29737. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29738. */
  29739. limitDeviceRatio?: number;
  29740. /**
  29741. * Defines if webvr should be enabled automatically
  29742. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29743. */
  29744. autoEnableWebVR?: boolean;
  29745. /**
  29746. * Defines if webgl2 should be turned off even if supported
  29747. * @see http://doc.babylonjs.com/features/webgl2
  29748. */
  29749. disableWebGL2Support?: boolean;
  29750. /**
  29751. * Defines if webaudio should be initialized as well
  29752. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29753. */
  29754. audioEngine?: boolean;
  29755. /**
  29756. * Defines if animations should run using a deterministic lock step
  29757. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29758. */
  29759. deterministicLockstep?: boolean;
  29760. /** Defines the maximum steps to use with deterministic lock step mode */
  29761. lockstepMaxSteps?: number;
  29762. /**
  29763. * Defines that engine should ignore context lost events
  29764. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29765. */
  29766. doNotHandleContextLost?: boolean;
  29767. /**
  29768. * Defines that engine should ignore modifying touch action attribute and style
  29769. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29770. */
  29771. doNotHandleTouchAction?: boolean;
  29772. /**
  29773. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29774. */
  29775. useHighPrecisionFloats?: boolean;
  29776. }
  29777. /**
  29778. * The base engine class (root of all engines)
  29779. */
  29780. export class ThinEngine {
  29781. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29782. static ExceptionList: ({
  29783. key: string;
  29784. capture: string;
  29785. captureConstraint: number;
  29786. targets: string[];
  29787. } | {
  29788. key: string;
  29789. capture: null;
  29790. captureConstraint: null;
  29791. targets: string[];
  29792. })[];
  29793. /** @hidden */
  29794. static _TextureLoaders: IInternalTextureLoader[];
  29795. /**
  29796. * Returns the current npm package of the sdk
  29797. */
  29798. static readonly NpmPackage: string;
  29799. /**
  29800. * Returns the current version of the framework
  29801. */
  29802. static readonly Version: string;
  29803. /**
  29804. * Returns a string describing the current engine
  29805. */
  29806. readonly description: string;
  29807. /**
  29808. * Gets or sets the epsilon value used by collision engine
  29809. */
  29810. static CollisionsEpsilon: number;
  29811. /**
  29812. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29813. */
  29814. static ShadersRepository: string;
  29815. /** @hidden */
  29816. _shaderProcessor: IShaderProcessor;
  29817. /**
  29818. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29819. */
  29820. forcePOTTextures: boolean;
  29821. /**
  29822. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29823. */
  29824. isFullscreen: boolean;
  29825. /**
  29826. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29827. */
  29828. cullBackFaces: boolean;
  29829. /**
  29830. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29831. */
  29832. renderEvenInBackground: boolean;
  29833. /**
  29834. * Gets or sets a boolean indicating that cache can be kept between frames
  29835. */
  29836. preventCacheWipeBetweenFrames: boolean;
  29837. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29838. validateShaderPrograms: boolean;
  29839. /**
  29840. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29841. */
  29842. disableUniformBuffers: boolean;
  29843. /** @hidden */
  29844. _uniformBuffers: UniformBuffer[];
  29845. /**
  29846. * Gets a boolean indicating that the engine supports uniform buffers
  29847. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29848. */
  29849. readonly supportsUniformBuffers: boolean;
  29850. /** @hidden */
  29851. _gl: WebGLRenderingContext;
  29852. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29853. protected _windowIsBackground: boolean;
  29854. protected _webGLVersion: number;
  29855. protected _highPrecisionShadersAllowed: boolean;
  29856. /** @hidden */
  29857. readonly _shouldUseHighPrecisionShader: boolean;
  29858. /**
  29859. * Gets a boolean indicating that only power of 2 textures are supported
  29860. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29861. */
  29862. readonly needPOTTextures: boolean;
  29863. /** @hidden */
  29864. _badOS: boolean;
  29865. /** @hidden */
  29866. _badDesktopOS: boolean;
  29867. private _hardwareScalingLevel;
  29868. /** @hidden */
  29869. _caps: EngineCapabilities;
  29870. private _isStencilEnable;
  29871. protected _colorWrite: boolean;
  29872. private _glVersion;
  29873. private _glRenderer;
  29874. private _glVendor;
  29875. /** @hidden */
  29876. _videoTextureSupported: boolean;
  29877. protected _renderingQueueLaunched: boolean;
  29878. protected _activeRenderLoops: (() => void)[];
  29879. /**
  29880. * Observable signaled when a context lost event is raised
  29881. */
  29882. onContextLostObservable: Observable<ThinEngine>;
  29883. /**
  29884. * Observable signaled when a context restored event is raised
  29885. */
  29886. onContextRestoredObservable: Observable<ThinEngine>;
  29887. private _onContextLost;
  29888. private _onContextRestored;
  29889. protected _contextWasLost: boolean;
  29890. /** @hidden */
  29891. _doNotHandleContextLost: boolean;
  29892. /**
  29893. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29894. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29895. */
  29896. doNotHandleContextLost: boolean;
  29897. /**
  29898. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29899. */
  29900. disableVertexArrayObjects: boolean;
  29901. /** @hidden */
  29902. protected _depthCullingState: DepthCullingState;
  29903. /** @hidden */
  29904. protected _stencilState: StencilState;
  29905. /** @hidden */
  29906. protected _alphaState: AlphaState;
  29907. /** @hidden */
  29908. _internalTexturesCache: InternalTexture[];
  29909. /** @hidden */
  29910. protected _activeChannel: number;
  29911. private _currentTextureChannel;
  29912. /** @hidden */
  29913. protected _boundTexturesCache: {
  29914. [key: string]: Nullable<InternalTexture>;
  29915. };
  29916. /** @hidden */
  29917. protected _currentEffect: Nullable<Effect>;
  29918. /** @hidden */
  29919. protected _currentProgram: Nullable<WebGLProgram>;
  29920. private _compiledEffects;
  29921. private _vertexAttribArraysEnabled;
  29922. /** @hidden */
  29923. protected _cachedViewport: Nullable<IViewportLike>;
  29924. private _cachedVertexArrayObject;
  29925. /** @hidden */
  29926. protected _cachedVertexBuffers: any;
  29927. /** @hidden */
  29928. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29929. /** @hidden */
  29930. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29931. /** @hidden */
  29932. _currentRenderTarget: Nullable<InternalTexture>;
  29933. private _uintIndicesCurrentlySet;
  29934. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  29935. /** @hidden */
  29936. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29937. private _currentBufferPointers;
  29938. private _currentInstanceLocations;
  29939. private _currentInstanceBuffers;
  29940. private _textureUnits;
  29941. /** @hidden */
  29942. _workingCanvas: Nullable<HTMLCanvasElement>;
  29943. /** @hidden */
  29944. _workingContext: Nullable<CanvasRenderingContext2D>;
  29945. /** @hidden */
  29946. _bindedRenderFunction: any;
  29947. private _vaoRecordInProgress;
  29948. private _mustWipeVertexAttributes;
  29949. private _emptyTexture;
  29950. private _emptyCubeTexture;
  29951. private _emptyTexture3D;
  29952. /** @hidden */
  29953. _frameHandler: number;
  29954. private _nextFreeTextureSlots;
  29955. private _maxSimultaneousTextures;
  29956. private _activeRequests;
  29957. protected _texturesSupported: string[];
  29958. /** @hidden */
  29959. _textureFormatInUse: Nullable<string>;
  29960. protected readonly _supportsHardwareTextureRescaling: boolean;
  29961. /**
  29962. * Gets the list of texture formats supported
  29963. */
  29964. readonly texturesSupported: Array<string>;
  29965. /**
  29966. * Gets the list of texture formats in use
  29967. */
  29968. readonly textureFormatInUse: Nullable<string>;
  29969. /**
  29970. * Gets the current viewport
  29971. */
  29972. readonly currentViewport: Nullable<IViewportLike>;
  29973. /**
  29974. * Gets the default empty texture
  29975. */
  29976. readonly emptyTexture: InternalTexture;
  29977. /**
  29978. * Gets the default empty 3D texture
  29979. */
  29980. readonly emptyTexture3D: InternalTexture;
  29981. /**
  29982. * Gets the default empty cube texture
  29983. */
  29984. readonly emptyCubeTexture: InternalTexture;
  29985. /**
  29986. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29987. */
  29988. readonly premultipliedAlpha: boolean;
  29989. /**
  29990. * Observable event triggered before each texture is initialized
  29991. */
  29992. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  29993. /**
  29994. * Creates a new engine
  29995. * @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
  29996. * @param antialias defines enable antialiasing (default: false)
  29997. * @param options defines further options to be sent to the getContext() function
  29998. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29999. */
  30000. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30001. private _rebuildInternalTextures;
  30002. private _rebuildEffects;
  30003. /**
  30004. * Gets a boolean indicating if all created effects are ready
  30005. * @returns true if all effects are ready
  30006. */
  30007. areAllEffectsReady(): boolean;
  30008. protected _rebuildBuffers(): void;
  30009. private _initGLContext;
  30010. /**
  30011. * Gets version of the current webGL context
  30012. */
  30013. readonly webGLVersion: number;
  30014. /**
  30015. * Gets a string idenfifying the name of the class
  30016. * @returns "Engine" string
  30017. */
  30018. getClassName(): string;
  30019. /**
  30020. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30021. */
  30022. readonly isStencilEnable: boolean;
  30023. /** @hidden */
  30024. _prepareWorkingCanvas(): void;
  30025. /**
  30026. * Reset the texture cache to empty state
  30027. */
  30028. resetTextureCache(): void;
  30029. /**
  30030. * Gets an object containing information about the current webGL context
  30031. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30032. */
  30033. getGlInfo(): {
  30034. vendor: string;
  30035. renderer: string;
  30036. version: string;
  30037. };
  30038. /**
  30039. * Defines the hardware scaling level.
  30040. * By default the hardware scaling level is computed from the window device ratio.
  30041. * 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.
  30042. * @param level defines the level to use
  30043. */
  30044. setHardwareScalingLevel(level: number): void;
  30045. /**
  30046. * Gets the current hardware scaling level.
  30047. * By default the hardware scaling level is computed from the window device ratio.
  30048. * 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.
  30049. * @returns a number indicating the current hardware scaling level
  30050. */
  30051. getHardwareScalingLevel(): number;
  30052. /**
  30053. * Gets the list of loaded textures
  30054. * @returns an array containing all loaded textures
  30055. */
  30056. getLoadedTexturesCache(): InternalTexture[];
  30057. /**
  30058. * Gets the object containing all engine capabilities
  30059. * @returns the EngineCapabilities object
  30060. */
  30061. getCaps(): EngineCapabilities;
  30062. /**
  30063. * stop executing a render loop function and remove it from the execution array
  30064. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30065. */
  30066. stopRenderLoop(renderFunction?: () => void): void;
  30067. /** @hidden */
  30068. _renderLoop(): void;
  30069. /**
  30070. * Gets the HTML canvas attached with the current webGL context
  30071. * @returns a HTML canvas
  30072. */
  30073. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30074. /**
  30075. * Gets host window
  30076. * @returns the host window object
  30077. */
  30078. getHostWindow(): Window;
  30079. /**
  30080. * Gets the current render width
  30081. * @param useScreen defines if screen size must be used (or the current render target if any)
  30082. * @returns a number defining the current render width
  30083. */
  30084. getRenderWidth(useScreen?: boolean): number;
  30085. /**
  30086. * Gets the current render height
  30087. * @param useScreen defines if screen size must be used (or the current render target if any)
  30088. * @returns a number defining the current render height
  30089. */
  30090. getRenderHeight(useScreen?: boolean): number;
  30091. /**
  30092. * Can be used to override the current requestAnimationFrame requester.
  30093. * @hidden
  30094. */
  30095. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30096. /**
  30097. * Register and execute a render loop. The engine can have more than one render function
  30098. * @param renderFunction defines the function to continuously execute
  30099. */
  30100. runRenderLoop(renderFunction: () => void): void;
  30101. /**
  30102. * Clear the current render buffer or the current render target (if any is set up)
  30103. * @param color defines the color to use
  30104. * @param backBuffer defines if the back buffer must be cleared
  30105. * @param depth defines if the depth buffer must be cleared
  30106. * @param stencil defines if the stencil buffer must be cleared
  30107. */
  30108. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30109. private _viewportCached;
  30110. /** @hidden */
  30111. _viewport(x: number, y: number, width: number, height: number): void;
  30112. /**
  30113. * Set the WebGL's viewport
  30114. * @param viewport defines the viewport element to be used
  30115. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30116. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30117. */
  30118. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30119. /**
  30120. * Begin a new frame
  30121. */
  30122. beginFrame(): void;
  30123. /**
  30124. * Enf the current frame
  30125. */
  30126. endFrame(): void;
  30127. /**
  30128. * Resize the view according to the canvas' size
  30129. */
  30130. resize(): void;
  30131. /**
  30132. * Force a specific size of the canvas
  30133. * @param width defines the new canvas' width
  30134. * @param height defines the new canvas' height
  30135. */
  30136. setSize(width: number, height: number): void;
  30137. /**
  30138. * Binds the frame buffer to the specified texture.
  30139. * @param texture The texture to render to or null for the default canvas
  30140. * @param faceIndex The face of the texture to render to in case of cube texture
  30141. * @param requiredWidth The width of the target to render to
  30142. * @param requiredHeight The height of the target to render to
  30143. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30144. * @param depthStencilTexture The depth stencil texture to use to render
  30145. * @param lodLevel defines le lod level to bind to the frame buffer
  30146. */
  30147. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30148. /** @hidden */
  30149. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30150. /**
  30151. * Unbind the current render target texture from the webGL context
  30152. * @param texture defines the render target texture to unbind
  30153. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30154. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30155. */
  30156. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30157. /**
  30158. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30159. */
  30160. flushFramebuffer(): void;
  30161. /**
  30162. * Unbind the current render target and bind the default framebuffer
  30163. */
  30164. restoreDefaultFramebuffer(): void;
  30165. private _resetVertexBufferBinding;
  30166. /**
  30167. * Creates a vertex buffer
  30168. * @param data the data for the vertex buffer
  30169. * @returns the new WebGL static buffer
  30170. */
  30171. createVertexBuffer(data: DataArray): DataBuffer;
  30172. private _createVertexBuffer;
  30173. /**
  30174. * Creates a dynamic vertex buffer
  30175. * @param data the data for the dynamic vertex buffer
  30176. * @returns the new WebGL dynamic buffer
  30177. */
  30178. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30179. /**
  30180. * Updates a dynamic vertex buffer.
  30181. * @param vertexBuffer the vertex buffer to update
  30182. * @param data the data used to update the vertex buffer
  30183. * @param byteOffset the byte offset of the data
  30184. * @param byteLength the byte length of the data
  30185. */
  30186. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30187. protected _resetIndexBufferBinding(): void;
  30188. /**
  30189. * Creates a new index buffer
  30190. * @param indices defines the content of the index buffer
  30191. * @param updatable defines if the index buffer must be updatable
  30192. * @returns a new webGL buffer
  30193. */
  30194. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30195. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30196. /**
  30197. * Bind a webGL buffer to the webGL context
  30198. * @param buffer defines the buffer to bind
  30199. */
  30200. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30201. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30202. private bindBuffer;
  30203. /**
  30204. * update the bound buffer with the given data
  30205. * @param data defines the data to update
  30206. */
  30207. updateArrayBuffer(data: Float32Array): void;
  30208. private _vertexAttribPointer;
  30209. private _bindIndexBufferWithCache;
  30210. private _bindVertexBuffersAttributes;
  30211. /**
  30212. * Records a vertex array object
  30213. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30214. * @param vertexBuffers defines the list of vertex buffers to store
  30215. * @param indexBuffer defines the index buffer to store
  30216. * @param effect defines the effect to store
  30217. * @returns the new vertex array object
  30218. */
  30219. recordVertexArrayObject(vertexBuffers: {
  30220. [key: string]: VertexBuffer;
  30221. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30222. /**
  30223. * Bind a specific vertex array object
  30224. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30225. * @param vertexArrayObject defines the vertex array object to bind
  30226. * @param indexBuffer defines the index buffer to bind
  30227. */
  30228. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30229. /**
  30230. * Bind webGl buffers directly to the webGL context
  30231. * @param vertexBuffer defines the vertex buffer to bind
  30232. * @param indexBuffer defines the index buffer to bind
  30233. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30234. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30235. * @param effect defines the effect associated with the vertex buffer
  30236. */
  30237. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30238. private _unbindVertexArrayObject;
  30239. /**
  30240. * Bind a list of vertex buffers to the webGL context
  30241. * @param vertexBuffers defines the list of vertex buffers to bind
  30242. * @param indexBuffer defines the index buffer to bind
  30243. * @param effect defines the effect associated with the vertex buffers
  30244. */
  30245. bindBuffers(vertexBuffers: {
  30246. [key: string]: Nullable<VertexBuffer>;
  30247. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30248. /**
  30249. * Unbind all instance attributes
  30250. */
  30251. unbindInstanceAttributes(): void;
  30252. /**
  30253. * Release and free the memory of a vertex array object
  30254. * @param vao defines the vertex array object to delete
  30255. */
  30256. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30257. /** @hidden */
  30258. _releaseBuffer(buffer: DataBuffer): boolean;
  30259. protected _deleteBuffer(buffer: DataBuffer): void;
  30260. /**
  30261. * Creates a webGL buffer to use with instanciation
  30262. * @param capacity defines the size of the buffer
  30263. * @returns the webGL buffer
  30264. */
  30265. createInstancesBuffer(capacity: number): DataBuffer;
  30266. /**
  30267. * Delete a webGL buffer used with instanciation
  30268. * @param buffer defines the webGL buffer to delete
  30269. */
  30270. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30271. /**
  30272. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30273. * @param instancesBuffer defines the webGL buffer to update and bind
  30274. * @param data defines the data to store in the buffer
  30275. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30276. */
  30277. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30278. /**
  30279. * Apply all cached states (depth, culling, stencil and alpha)
  30280. */
  30281. applyStates(): void;
  30282. /**
  30283. * Send a draw order
  30284. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30285. * @param indexStart defines the starting index
  30286. * @param indexCount defines the number of index to draw
  30287. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30288. */
  30289. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30290. /**
  30291. * Draw a list of points
  30292. * @param verticesStart defines the index of first vertex to draw
  30293. * @param verticesCount defines the count of vertices to draw
  30294. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30295. */
  30296. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30297. /**
  30298. * Draw a list of unindexed primitives
  30299. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30300. * @param verticesStart defines the index of first vertex to draw
  30301. * @param verticesCount defines the count of vertices to draw
  30302. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30303. */
  30304. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30305. /**
  30306. * Draw a list of indexed primitives
  30307. * @param fillMode defines the primitive to use
  30308. * @param indexStart defines the starting index
  30309. * @param indexCount defines the number of index to draw
  30310. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30311. */
  30312. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30313. /**
  30314. * Draw a list of unindexed primitives
  30315. * @param fillMode defines the primitive to use
  30316. * @param verticesStart defines the index of first vertex to draw
  30317. * @param verticesCount defines the count of vertices to draw
  30318. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30319. */
  30320. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30321. private _drawMode;
  30322. /** @hidden */
  30323. protected _reportDrawCall(): void;
  30324. /** @hidden */
  30325. _releaseEffect(effect: Effect): void;
  30326. /** @hidden */
  30327. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30328. /**
  30329. * Create a new effect (used to store vertex/fragment shaders)
  30330. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30331. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30332. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30333. * @param samplers defines an array of string used to represent textures
  30334. * @param defines defines the string containing the defines to use to compile the shaders
  30335. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30336. * @param onCompiled defines a function to call when the effect creation is successful
  30337. * @param onError defines a function to call when the effect creation has failed
  30338. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30339. * @returns the new Effect
  30340. */
  30341. 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;
  30342. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30343. private _compileShader;
  30344. private _compileRawShader;
  30345. /**
  30346. * Directly creates a webGL program
  30347. * @param pipelineContext defines the pipeline context to attach to
  30348. * @param vertexCode defines the vertex shader code to use
  30349. * @param fragmentCode defines the fragment shader code to use
  30350. * @param context defines the webGL context to use (if not set, the current one will be used)
  30351. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30352. * @returns the new webGL program
  30353. */
  30354. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30355. /**
  30356. * Creates a webGL program
  30357. * @param pipelineContext defines the pipeline context to attach to
  30358. * @param vertexCode defines the vertex shader code to use
  30359. * @param fragmentCode defines the fragment shader code to use
  30360. * @param defines defines the string containing the defines to use to compile the shaders
  30361. * @param context defines the webGL context to use (if not set, the current one will be used)
  30362. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30363. * @returns the new webGL program
  30364. */
  30365. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30366. /**
  30367. * Creates a new pipeline context
  30368. * @returns the new pipeline
  30369. */
  30370. createPipelineContext(): IPipelineContext;
  30371. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30372. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30373. /** @hidden */
  30374. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30375. /** @hidden */
  30376. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30377. /** @hidden */
  30378. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30379. /**
  30380. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30381. * @param pipelineContext defines the pipeline context to use
  30382. * @param uniformsNames defines the list of uniform names
  30383. * @returns an array of webGL uniform locations
  30384. */
  30385. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30386. /**
  30387. * Gets the lsit of active attributes for a given webGL program
  30388. * @param pipelineContext defines the pipeline context to use
  30389. * @param attributesNames defines the list of attribute names to get
  30390. * @returns an array of indices indicating the offset of each attribute
  30391. */
  30392. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30393. /**
  30394. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30395. * @param effect defines the effect to activate
  30396. */
  30397. enableEffect(effect: Nullable<Effect>): void;
  30398. /**
  30399. * Set the value of an uniform to an array of int32
  30400. * @param uniform defines the webGL uniform location where to store the value
  30401. * @param array defines the array of int32 to store
  30402. */
  30403. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30404. /**
  30405. * Set the value of an uniform to an array of int32 (stored as vec2)
  30406. * @param uniform defines the webGL uniform location where to store the value
  30407. * @param array defines the array of int32 to store
  30408. */
  30409. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30410. /**
  30411. * Set the value of an uniform to an array of int32 (stored as vec3)
  30412. * @param uniform defines the webGL uniform location where to store the value
  30413. * @param array defines the array of int32 to store
  30414. */
  30415. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30416. /**
  30417. * Set the value of an uniform to an array of int32 (stored as vec4)
  30418. * @param uniform defines the webGL uniform location where to store the value
  30419. * @param array defines the array of int32 to store
  30420. */
  30421. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30422. /**
  30423. * Set the value of an uniform to an array of float32
  30424. * @param uniform defines the webGL uniform location where to store the value
  30425. * @param array defines the array of float32 to store
  30426. */
  30427. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30428. /**
  30429. * Set the value of an uniform to an array of float32 (stored as vec2)
  30430. * @param uniform defines the webGL uniform location where to store the value
  30431. * @param array defines the array of float32 to store
  30432. */
  30433. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30434. /**
  30435. * Set the value of an uniform to an array of float32 (stored as vec3)
  30436. * @param uniform defines the webGL uniform location where to store the value
  30437. * @param array defines the array of float32 to store
  30438. */
  30439. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30440. /**
  30441. * Set the value of an uniform to an array of float32 (stored as vec4)
  30442. * @param uniform defines the webGL uniform location where to store the value
  30443. * @param array defines the array of float32 to store
  30444. */
  30445. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30446. /**
  30447. * Set the value of an uniform to an array of number
  30448. * @param uniform defines the webGL uniform location where to store the value
  30449. * @param array defines the array of number to store
  30450. */
  30451. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30452. /**
  30453. * Set the value of an uniform to an array of number (stored as vec2)
  30454. * @param uniform defines the webGL uniform location where to store the value
  30455. * @param array defines the array of number to store
  30456. */
  30457. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30458. /**
  30459. * Set the value of an uniform to an array of number (stored as vec3)
  30460. * @param uniform defines the webGL uniform location where to store the value
  30461. * @param array defines the array of number to store
  30462. */
  30463. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30464. /**
  30465. * Set the value of an uniform to an array of number (stored as vec4)
  30466. * @param uniform defines the webGL uniform location where to store the value
  30467. * @param array defines the array of number to store
  30468. */
  30469. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30470. /**
  30471. * Set the value of an uniform to an array of float32 (stored as matrices)
  30472. * @param uniform defines the webGL uniform location where to store the value
  30473. * @param matrices defines the array of float32 to store
  30474. */
  30475. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30476. /**
  30477. * Set the value of an uniform to a matrix (3x3)
  30478. * @param uniform defines the webGL uniform location where to store the value
  30479. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30480. */
  30481. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30482. /**
  30483. * Set the value of an uniform to a matrix (2x2)
  30484. * @param uniform defines the webGL uniform location where to store the value
  30485. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30486. */
  30487. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30488. /**
  30489. * Set the value of an uniform to a number (int)
  30490. * @param uniform defines the webGL uniform location where to store the value
  30491. * @param value defines the int number to store
  30492. */
  30493. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30494. /**
  30495. * Set the value of an uniform to a number (float)
  30496. * @param uniform defines the webGL uniform location where to store the value
  30497. * @param value defines the float number to store
  30498. */
  30499. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30500. /**
  30501. * Set the value of an uniform to a vec2
  30502. * @param uniform defines the webGL uniform location where to store the value
  30503. * @param x defines the 1st component of the value
  30504. * @param y defines the 2nd component of the value
  30505. */
  30506. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30507. /**
  30508. * Set the value of an uniform to a vec3
  30509. * @param uniform defines the webGL uniform location where to store the value
  30510. * @param x defines the 1st component of the value
  30511. * @param y defines the 2nd component of the value
  30512. * @param z defines the 3rd component of the value
  30513. */
  30514. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30515. /**
  30516. * Set the value of an uniform to a boolean
  30517. * @param uniform defines the webGL uniform location where to store the value
  30518. * @param bool defines the boolean to store
  30519. */
  30520. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30521. /**
  30522. * Set the value of an uniform to a vec4
  30523. * @param uniform defines the webGL uniform location where to store the value
  30524. * @param x defines the 1st component of the value
  30525. * @param y defines the 2nd component of the value
  30526. * @param z defines the 3rd component of the value
  30527. * @param w defines the 4th component of the value
  30528. */
  30529. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30530. /**
  30531. * Sets a Color4 on a uniform variable
  30532. * @param uniform defines the uniform location
  30533. * @param color4 defines the value to be set
  30534. */
  30535. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30536. /**
  30537. * Gets the depth culling state manager
  30538. */
  30539. readonly depthCullingState: DepthCullingState;
  30540. /**
  30541. * Gets the alpha state manager
  30542. */
  30543. readonly alphaState: AlphaState;
  30544. /**
  30545. * Gets the stencil state manager
  30546. */
  30547. readonly stencilState: StencilState;
  30548. /**
  30549. * Clears the list of texture accessible through engine.
  30550. * This can help preventing texture load conflict due to name collision.
  30551. */
  30552. clearInternalTexturesCache(): void;
  30553. /**
  30554. * Force the entire cache to be cleared
  30555. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30556. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30557. */
  30558. wipeCaches(bruteForce?: boolean): void;
  30559. /** @hidden */
  30560. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30561. min: number;
  30562. mag: number;
  30563. };
  30564. /** @hidden */
  30565. _createTexture(): WebGLTexture;
  30566. /**
  30567. * Usually called from Texture.ts.
  30568. * Passed information to create a WebGLTexture
  30569. * @param urlArg defines a value which contains one of the following:
  30570. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30571. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30572. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30573. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30574. * @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)
  30575. * @param scene needed for loading to the correct scene
  30576. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30577. * @param onLoad optional callback to be called upon successful completion
  30578. * @param onError optional callback to be called upon failure
  30579. * @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
  30580. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30581. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30582. * @param forcedExtension defines the extension to use to pick the right loader
  30583. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30584. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30585. */
  30586. 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;
  30587. /**
  30588. * @hidden
  30589. */
  30590. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30591. /**
  30592. * Creates a raw texture
  30593. * @param data defines the data to store in the texture
  30594. * @param width defines the width of the texture
  30595. * @param height defines the height of the texture
  30596. * @param format defines the format of the data
  30597. * @param generateMipMaps defines if the engine should generate the mip levels
  30598. * @param invertY defines if data must be stored with Y axis inverted
  30599. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30600. * @param compression defines the compression used (null by default)
  30601. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30602. * @returns the raw texture inside an InternalTexture
  30603. */
  30604. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30605. /**
  30606. * Creates a new raw cube texture
  30607. * @param data defines the array of data to use to create each face
  30608. * @param size defines the size of the textures
  30609. * @param format defines the format of the data
  30610. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30611. * @param generateMipMaps defines if the engine should generate the mip levels
  30612. * @param invertY defines if data must be stored with Y axis inverted
  30613. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30614. * @param compression defines the compression used (null by default)
  30615. * @returns the cube texture as an InternalTexture
  30616. */
  30617. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30618. /**
  30619. * Creates a new raw 3D texture
  30620. * @param data defines the data used to create the texture
  30621. * @param width defines the width of the texture
  30622. * @param height defines the height of the texture
  30623. * @param depth defines the depth of the texture
  30624. * @param format defines the format of the texture
  30625. * @param generateMipMaps defines if the engine must generate mip levels
  30626. * @param invertY defines if data must be stored with Y axis inverted
  30627. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30628. * @param compression defines the compressed used (can be null)
  30629. * @param textureType defines the compressed used (can be null)
  30630. * @returns a new raw 3D texture (stored in an InternalTexture)
  30631. */
  30632. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30633. private _unpackFlipYCached;
  30634. /**
  30635. * In case you are sharing the context with other applications, it might
  30636. * be interested to not cache the unpack flip y state to ensure a consistent
  30637. * value would be set.
  30638. */
  30639. enableUnpackFlipYCached: boolean;
  30640. /** @hidden */
  30641. _unpackFlipY(value: boolean): void;
  30642. /** @hidden */
  30643. _getUnpackAlignement(): number;
  30644. /**
  30645. * Update the sampling mode of a given texture
  30646. * @param samplingMode defines the required sampling mode
  30647. * @param texture defines the texture to update
  30648. */
  30649. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30650. /**
  30651. * Updates a depth texture Comparison Mode and Function.
  30652. * If the comparison Function is equal to 0, the mode will be set to none.
  30653. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30654. * @param texture The texture to set the comparison function for
  30655. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30656. */
  30657. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30658. /** @hidden */
  30659. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30660. width: number;
  30661. height: number;
  30662. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30663. /**
  30664. * Creates a depth stencil texture.
  30665. * This is only available in WebGL 2 or with the depth texture extension available.
  30666. * @param size The size of face edge in the texture.
  30667. * @param options The options defining the texture.
  30668. * @returns The texture
  30669. */
  30670. createDepthStencilTexture(size: number | {
  30671. width: number;
  30672. height: number;
  30673. }, options: DepthTextureCreationOptions): InternalTexture;
  30674. /**
  30675. * Creates a depth stencil texture.
  30676. * This is only available in WebGL 2 or with the depth texture extension available.
  30677. * @param size The size of face edge in the texture.
  30678. * @param options The options defining the texture.
  30679. * @returns The texture
  30680. */
  30681. private _createDepthStencilTexture;
  30682. /** @hidden */
  30683. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30684. /** @hidden */
  30685. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30686. /** @hidden */
  30687. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30688. /** @hidden */
  30689. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  30690. /**
  30691. * @hidden
  30692. */
  30693. _setCubeMapTextureParams(loadMipmap: boolean): void;
  30694. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30695. private _prepareWebGLTexture;
  30696. /** @hidden */
  30697. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30698. /** @hidden */
  30699. _releaseFramebufferObjects(texture: InternalTexture): void;
  30700. /** @hidden */
  30701. _releaseTexture(texture: InternalTexture): void;
  30702. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30703. protected _setProgram(program: WebGLProgram): void;
  30704. protected _boundUniforms: {
  30705. [key: number]: WebGLUniformLocation;
  30706. };
  30707. /**
  30708. * Binds an effect to the webGL context
  30709. * @param effect defines the effect to bind
  30710. */
  30711. bindSamplers(effect: Effect): void;
  30712. private _activateCurrentTexture;
  30713. /** @hidden */
  30714. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30715. /** @hidden */
  30716. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30717. /**
  30718. * Unbind all textures from the webGL context
  30719. */
  30720. unbindAllTextures(): void;
  30721. /**
  30722. * Sets a texture to the according uniform.
  30723. * @param channel The texture channel
  30724. * @param uniform The uniform to set
  30725. * @param texture The texture to apply
  30726. */
  30727. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30728. private _bindSamplerUniformToChannel;
  30729. private _getTextureWrapMode;
  30730. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30731. /**
  30732. * Sets an array of texture to the webGL context
  30733. * @param channel defines the channel where the texture array must be set
  30734. * @param uniform defines the associated uniform location
  30735. * @param textures defines the array of textures to bind
  30736. */
  30737. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30738. /** @hidden */
  30739. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30740. private _setTextureParameterFloat;
  30741. private _setTextureParameterInteger;
  30742. /**
  30743. * Unbind all vertex attributes from the webGL context
  30744. */
  30745. unbindAllAttributes(): void;
  30746. /**
  30747. * 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
  30748. */
  30749. releaseEffects(): void;
  30750. /**
  30751. * Dispose and release all associated resources
  30752. */
  30753. dispose(): void;
  30754. /**
  30755. * Attach a new callback raised when context lost event is fired
  30756. * @param callback defines the callback to call
  30757. */
  30758. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30759. /**
  30760. * Attach a new callback raised when context restored event is fired
  30761. * @param callback defines the callback to call
  30762. */
  30763. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30764. /**
  30765. * Get the current error code of the webGL context
  30766. * @returns the error code
  30767. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30768. */
  30769. getError(): number;
  30770. private _canRenderToFloatFramebuffer;
  30771. private _canRenderToHalfFloatFramebuffer;
  30772. private _canRenderToFramebuffer;
  30773. /** @hidden */
  30774. _getWebGLTextureType(type: number): number;
  30775. /** @hidden */
  30776. _getInternalFormat(format: number): number;
  30777. /** @hidden */
  30778. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30779. /** @hidden */
  30780. _getRGBAMultiSampleBufferFormat(type: number): number;
  30781. /** @hidden */
  30782. _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;
  30783. /**
  30784. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30785. * @returns true if the engine can be created
  30786. * @ignorenaming
  30787. */
  30788. static isSupported(): boolean;
  30789. /**
  30790. * Find the next highest power of two.
  30791. * @param x Number to start search from.
  30792. * @return Next highest power of two.
  30793. */
  30794. static CeilingPOT(x: number): number;
  30795. /**
  30796. * Find the next lowest power of two.
  30797. * @param x Number to start search from.
  30798. * @return Next lowest power of two.
  30799. */
  30800. static FloorPOT(x: number): number;
  30801. /**
  30802. * Find the nearest power of two.
  30803. * @param x Number to start search from.
  30804. * @return Next nearest power of two.
  30805. */
  30806. static NearestPOT(x: number): number;
  30807. /**
  30808. * Get the closest exponent of two
  30809. * @param value defines the value to approximate
  30810. * @param max defines the maximum value to return
  30811. * @param mode defines how to define the closest value
  30812. * @returns closest exponent of two of the given value
  30813. */
  30814. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30815. /**
  30816. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30817. * @param func - the function to be called
  30818. * @param requester - the object that will request the next frame. Falls back to window.
  30819. * @returns frame number
  30820. */
  30821. static QueueNewFrame(func: () => void, requester?: any): number;
  30822. }
  30823. }
  30824. declare module "babylonjs/Maths/sphericalPolynomial" {
  30825. import { Vector3 } from "babylonjs/Maths/math.vector";
  30826. import { Color3 } from "babylonjs/Maths/math.color";
  30827. /**
  30828. * Class representing spherical harmonics coefficients to the 3rd degree
  30829. */
  30830. export class SphericalHarmonics {
  30831. /**
  30832. * Defines whether or not the harmonics have been prescaled for rendering.
  30833. */
  30834. preScaled: boolean;
  30835. /**
  30836. * The l0,0 coefficients of the spherical harmonics
  30837. */
  30838. l00: Vector3;
  30839. /**
  30840. * The l1,-1 coefficients of the spherical harmonics
  30841. */
  30842. l1_1: Vector3;
  30843. /**
  30844. * The l1,0 coefficients of the spherical harmonics
  30845. */
  30846. l10: Vector3;
  30847. /**
  30848. * The l1,1 coefficients of the spherical harmonics
  30849. */
  30850. l11: Vector3;
  30851. /**
  30852. * The l2,-2 coefficients of the spherical harmonics
  30853. */
  30854. l2_2: Vector3;
  30855. /**
  30856. * The l2,-1 coefficients of the spherical harmonics
  30857. */
  30858. l2_1: Vector3;
  30859. /**
  30860. * The l2,0 coefficients of the spherical harmonics
  30861. */
  30862. l20: Vector3;
  30863. /**
  30864. * The l2,1 coefficients of the spherical harmonics
  30865. */
  30866. l21: Vector3;
  30867. /**
  30868. * The l2,2 coefficients of the spherical harmonics
  30869. */
  30870. l22: Vector3;
  30871. /**
  30872. * Adds a light to the spherical harmonics
  30873. * @param direction the direction of the light
  30874. * @param color the color of the light
  30875. * @param deltaSolidAngle the delta solid angle of the light
  30876. */
  30877. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30878. /**
  30879. * Scales the spherical harmonics by the given amount
  30880. * @param scale the amount to scale
  30881. */
  30882. scaleInPlace(scale: number): void;
  30883. /**
  30884. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30885. *
  30886. * ```
  30887. * E_lm = A_l * L_lm
  30888. * ```
  30889. *
  30890. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30891. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30892. * the scaling factors are given in equation 9.
  30893. */
  30894. convertIncidentRadianceToIrradiance(): void;
  30895. /**
  30896. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30897. *
  30898. * ```
  30899. * L = (1/pi) * E * rho
  30900. * ```
  30901. *
  30902. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  30903. */
  30904. convertIrradianceToLambertianRadiance(): void;
  30905. /**
  30906. * Integrates the reconstruction coefficients directly in to the SH preventing further
  30907. * required operations at run time.
  30908. *
  30909. * This is simply done by scaling back the SH with Ylm constants parameter.
  30910. * The trigonometric part being applied by the shader at run time.
  30911. */
  30912. preScaleForRendering(): void;
  30913. /**
  30914. * Constructs a spherical harmonics from an array.
  30915. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  30916. * @returns the spherical harmonics
  30917. */
  30918. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  30919. /**
  30920. * Gets the spherical harmonics from polynomial
  30921. * @param polynomial the spherical polynomial
  30922. * @returns the spherical harmonics
  30923. */
  30924. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  30925. }
  30926. /**
  30927. * Class representing spherical polynomial coefficients to the 3rd degree
  30928. */
  30929. export class SphericalPolynomial {
  30930. private _harmonics;
  30931. /**
  30932. * The spherical harmonics used to create the polynomials.
  30933. */
  30934. readonly preScaledHarmonics: SphericalHarmonics;
  30935. /**
  30936. * The x coefficients of the spherical polynomial
  30937. */
  30938. x: Vector3;
  30939. /**
  30940. * The y coefficients of the spherical polynomial
  30941. */
  30942. y: Vector3;
  30943. /**
  30944. * The z coefficients of the spherical polynomial
  30945. */
  30946. z: Vector3;
  30947. /**
  30948. * The xx coefficients of the spherical polynomial
  30949. */
  30950. xx: Vector3;
  30951. /**
  30952. * The yy coefficients of the spherical polynomial
  30953. */
  30954. yy: Vector3;
  30955. /**
  30956. * The zz coefficients of the spherical polynomial
  30957. */
  30958. zz: Vector3;
  30959. /**
  30960. * The xy coefficients of the spherical polynomial
  30961. */
  30962. xy: Vector3;
  30963. /**
  30964. * The yz coefficients of the spherical polynomial
  30965. */
  30966. yz: Vector3;
  30967. /**
  30968. * The zx coefficients of the spherical polynomial
  30969. */
  30970. zx: Vector3;
  30971. /**
  30972. * Adds an ambient color to the spherical polynomial
  30973. * @param color the color to add
  30974. */
  30975. addAmbient(color: Color3): void;
  30976. /**
  30977. * Scales the spherical polynomial by the given amount
  30978. * @param scale the amount to scale
  30979. */
  30980. scaleInPlace(scale: number): void;
  30981. /**
  30982. * Gets the spherical polynomial from harmonics
  30983. * @param harmonics the spherical harmonics
  30984. * @returns the spherical polynomial
  30985. */
  30986. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  30987. /**
  30988. * Constructs a spherical polynomial from an array.
  30989. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  30990. * @returns the spherical polynomial
  30991. */
  30992. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  30993. }
  30994. }
  30995. declare module "babylonjs/Materials/Textures/internalTexture" {
  30996. import { Observable } from "babylonjs/Misc/observable";
  30997. import { Nullable, int } from "babylonjs/types";
  30998. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30999. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31000. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31001. /**
  31002. * Defines the source of the internal texture
  31003. */
  31004. export enum InternalTextureSource {
  31005. /**
  31006. * The source of the texture data is unknown
  31007. */
  31008. Unknown = 0,
  31009. /**
  31010. * Texture data comes from an URL
  31011. */
  31012. Url = 1,
  31013. /**
  31014. * Texture data is only used for temporary storage
  31015. */
  31016. Temp = 2,
  31017. /**
  31018. * Texture data comes from raw data (ArrayBuffer)
  31019. */
  31020. Raw = 3,
  31021. /**
  31022. * Texture content is dynamic (video or dynamic texture)
  31023. */
  31024. Dynamic = 4,
  31025. /**
  31026. * Texture content is generated by rendering to it
  31027. */
  31028. RenderTarget = 5,
  31029. /**
  31030. * Texture content is part of a multi render target process
  31031. */
  31032. MultiRenderTarget = 6,
  31033. /**
  31034. * Texture data comes from a cube data file
  31035. */
  31036. Cube = 7,
  31037. /**
  31038. * Texture data comes from a raw cube data
  31039. */
  31040. CubeRaw = 8,
  31041. /**
  31042. * Texture data come from a prefiltered cube data file
  31043. */
  31044. CubePrefiltered = 9,
  31045. /**
  31046. * Texture content is raw 3D data
  31047. */
  31048. Raw3D = 10,
  31049. /**
  31050. * Texture content is a depth texture
  31051. */
  31052. Depth = 11,
  31053. /**
  31054. * Texture data comes from a raw cube data encoded with RGBD
  31055. */
  31056. CubeRawRGBD = 12
  31057. }
  31058. /**
  31059. * Class used to store data associated with WebGL texture data for the engine
  31060. * This class should not be used directly
  31061. */
  31062. export class InternalTexture {
  31063. /** @hidden */
  31064. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31065. /**
  31066. * Defines if the texture is ready
  31067. */
  31068. isReady: boolean;
  31069. /**
  31070. * Defines if the texture is a cube texture
  31071. */
  31072. isCube: boolean;
  31073. /**
  31074. * Defines if the texture contains 3D data
  31075. */
  31076. is3D: boolean;
  31077. /**
  31078. * Defines if the texture contains multiview data
  31079. */
  31080. isMultiview: boolean;
  31081. /**
  31082. * Gets the URL used to load this texture
  31083. */
  31084. url: string;
  31085. /**
  31086. * Gets the sampling mode of the texture
  31087. */
  31088. samplingMode: number;
  31089. /**
  31090. * Gets a boolean indicating if the texture needs mipmaps generation
  31091. */
  31092. generateMipMaps: boolean;
  31093. /**
  31094. * Gets the number of samples used by the texture (WebGL2+ only)
  31095. */
  31096. samples: number;
  31097. /**
  31098. * Gets the type of the texture (int, float...)
  31099. */
  31100. type: number;
  31101. /**
  31102. * Gets the format of the texture (RGB, RGBA...)
  31103. */
  31104. format: number;
  31105. /**
  31106. * Observable called when the texture is loaded
  31107. */
  31108. onLoadedObservable: Observable<InternalTexture>;
  31109. /**
  31110. * Gets the width of the texture
  31111. */
  31112. width: number;
  31113. /**
  31114. * Gets the height of the texture
  31115. */
  31116. height: number;
  31117. /**
  31118. * Gets the depth of the texture
  31119. */
  31120. depth: number;
  31121. /**
  31122. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31123. */
  31124. baseWidth: number;
  31125. /**
  31126. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31127. */
  31128. baseHeight: number;
  31129. /**
  31130. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31131. */
  31132. baseDepth: number;
  31133. /**
  31134. * Gets a boolean indicating if the texture is inverted on Y axis
  31135. */
  31136. invertY: boolean;
  31137. /** @hidden */
  31138. _invertVScale: boolean;
  31139. /** @hidden */
  31140. _associatedChannel: number;
  31141. /** @hidden */
  31142. _source: InternalTextureSource;
  31143. /** @hidden */
  31144. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  31145. /** @hidden */
  31146. _bufferView: Nullable<ArrayBufferView>;
  31147. /** @hidden */
  31148. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31149. /** @hidden */
  31150. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31151. /** @hidden */
  31152. _size: number;
  31153. /** @hidden */
  31154. _extension: string;
  31155. /** @hidden */
  31156. _files: Nullable<string[]>;
  31157. /** @hidden */
  31158. _workingCanvas: Nullable<HTMLCanvasElement>;
  31159. /** @hidden */
  31160. _workingContext: Nullable<CanvasRenderingContext2D>;
  31161. /** @hidden */
  31162. _framebuffer: Nullable<WebGLFramebuffer>;
  31163. /** @hidden */
  31164. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31165. /** @hidden */
  31166. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31167. /** @hidden */
  31168. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31169. /** @hidden */
  31170. _attachments: Nullable<number[]>;
  31171. /** @hidden */
  31172. _cachedCoordinatesMode: Nullable<number>;
  31173. /** @hidden */
  31174. _cachedWrapU: Nullable<number>;
  31175. /** @hidden */
  31176. _cachedWrapV: Nullable<number>;
  31177. /** @hidden */
  31178. _cachedWrapR: Nullable<number>;
  31179. /** @hidden */
  31180. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31181. /** @hidden */
  31182. _isDisabled: boolean;
  31183. /** @hidden */
  31184. _compression: Nullable<string>;
  31185. /** @hidden */
  31186. _generateStencilBuffer: boolean;
  31187. /** @hidden */
  31188. _generateDepthBuffer: boolean;
  31189. /** @hidden */
  31190. _comparisonFunction: number;
  31191. /** @hidden */
  31192. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31193. /** @hidden */
  31194. _lodGenerationScale: number;
  31195. /** @hidden */
  31196. _lodGenerationOffset: number;
  31197. /** @hidden */
  31198. _colorTextureArray: Nullable<WebGLTexture>;
  31199. /** @hidden */
  31200. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31201. /** @hidden */
  31202. _lodTextureHigh: Nullable<BaseTexture>;
  31203. /** @hidden */
  31204. _lodTextureMid: Nullable<BaseTexture>;
  31205. /** @hidden */
  31206. _lodTextureLow: Nullable<BaseTexture>;
  31207. /** @hidden */
  31208. _isRGBD: boolean;
  31209. /** @hidden */
  31210. _linearSpecularLOD: boolean;
  31211. /** @hidden */
  31212. _irradianceTexture: Nullable<BaseTexture>;
  31213. /** @hidden */
  31214. _webGLTexture: Nullable<WebGLTexture>;
  31215. /** @hidden */
  31216. _references: number;
  31217. private _engine;
  31218. /**
  31219. * Gets the Engine the texture belongs to.
  31220. * @returns The babylon engine
  31221. */
  31222. getEngine(): ThinEngine;
  31223. /**
  31224. * Gets the data source type of the texture
  31225. */
  31226. readonly source: InternalTextureSource;
  31227. /**
  31228. * Creates a new InternalTexture
  31229. * @param engine defines the engine to use
  31230. * @param source defines the type of data that will be used
  31231. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31232. */
  31233. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31234. /**
  31235. * Increments the number of references (ie. the number of Texture that point to it)
  31236. */
  31237. incrementReferences(): void;
  31238. /**
  31239. * Change the size of the texture (not the size of the content)
  31240. * @param width defines the new width
  31241. * @param height defines the new height
  31242. * @param depth defines the new depth (1 by default)
  31243. */
  31244. updateSize(width: int, height: int, depth?: int): void;
  31245. /** @hidden */
  31246. _rebuild(): void;
  31247. /** @hidden */
  31248. _swapAndDie(target: InternalTexture): void;
  31249. /**
  31250. * Dispose the current allocated resources
  31251. */
  31252. dispose(): void;
  31253. }
  31254. }
  31255. declare module "babylonjs/Audio/analyser" {
  31256. import { Scene } from "babylonjs/scene";
  31257. /**
  31258. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31260. */
  31261. export class Analyser {
  31262. /**
  31263. * Gets or sets the smoothing
  31264. * @ignorenaming
  31265. */
  31266. SMOOTHING: number;
  31267. /**
  31268. * Gets or sets the FFT table size
  31269. * @ignorenaming
  31270. */
  31271. FFT_SIZE: number;
  31272. /**
  31273. * Gets or sets the bar graph amplitude
  31274. * @ignorenaming
  31275. */
  31276. BARGRAPHAMPLITUDE: number;
  31277. /**
  31278. * Gets or sets the position of the debug canvas
  31279. * @ignorenaming
  31280. */
  31281. DEBUGCANVASPOS: {
  31282. x: number;
  31283. y: number;
  31284. };
  31285. /**
  31286. * Gets or sets the debug canvas size
  31287. * @ignorenaming
  31288. */
  31289. DEBUGCANVASSIZE: {
  31290. width: number;
  31291. height: number;
  31292. };
  31293. private _byteFreqs;
  31294. private _byteTime;
  31295. private _floatFreqs;
  31296. private _webAudioAnalyser;
  31297. private _debugCanvas;
  31298. private _debugCanvasContext;
  31299. private _scene;
  31300. private _registerFunc;
  31301. private _audioEngine;
  31302. /**
  31303. * Creates a new analyser
  31304. * @param scene defines hosting scene
  31305. */
  31306. constructor(scene: Scene);
  31307. /**
  31308. * Get the number of data values you will have to play with for the visualization
  31309. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31310. * @returns a number
  31311. */
  31312. getFrequencyBinCount(): number;
  31313. /**
  31314. * Gets the current frequency data as a byte array
  31315. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31316. * @returns a Uint8Array
  31317. */
  31318. getByteFrequencyData(): Uint8Array;
  31319. /**
  31320. * Gets the current waveform as a byte array
  31321. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31322. * @returns a Uint8Array
  31323. */
  31324. getByteTimeDomainData(): Uint8Array;
  31325. /**
  31326. * Gets the current frequency data as a float array
  31327. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31328. * @returns a Float32Array
  31329. */
  31330. getFloatFrequencyData(): Float32Array;
  31331. /**
  31332. * Renders the debug canvas
  31333. */
  31334. drawDebugCanvas(): void;
  31335. /**
  31336. * Stops rendering the debug canvas and removes it
  31337. */
  31338. stopDebugCanvas(): void;
  31339. /**
  31340. * Connects two audio nodes
  31341. * @param inputAudioNode defines first node to connect
  31342. * @param outputAudioNode defines second node to connect
  31343. */
  31344. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31345. /**
  31346. * Releases all associated resources
  31347. */
  31348. dispose(): void;
  31349. }
  31350. }
  31351. declare module "babylonjs/Audio/audioEngine" {
  31352. import { IDisposable } from "babylonjs/scene";
  31353. import { Analyser } from "babylonjs/Audio/analyser";
  31354. import { Nullable } from "babylonjs/types";
  31355. import { Observable } from "babylonjs/Misc/observable";
  31356. /**
  31357. * This represents an audio engine and it is responsible
  31358. * to play, synchronize and analyse sounds throughout the application.
  31359. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31360. */
  31361. export interface IAudioEngine extends IDisposable {
  31362. /**
  31363. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31364. */
  31365. readonly canUseWebAudio: boolean;
  31366. /**
  31367. * Gets the current AudioContext if available.
  31368. */
  31369. readonly audioContext: Nullable<AudioContext>;
  31370. /**
  31371. * The master gain node defines the global audio volume of your audio engine.
  31372. */
  31373. readonly masterGain: GainNode;
  31374. /**
  31375. * Gets whether or not mp3 are supported by your browser.
  31376. */
  31377. readonly isMP3supported: boolean;
  31378. /**
  31379. * Gets whether or not ogg are supported by your browser.
  31380. */
  31381. readonly isOGGsupported: boolean;
  31382. /**
  31383. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31384. * @ignoreNaming
  31385. */
  31386. WarnedWebAudioUnsupported: boolean;
  31387. /**
  31388. * Defines if the audio engine relies on a custom unlocked button.
  31389. * In this case, the embedded button will not be displayed.
  31390. */
  31391. useCustomUnlockedButton: boolean;
  31392. /**
  31393. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31394. */
  31395. readonly unlocked: boolean;
  31396. /**
  31397. * Event raised when audio has been unlocked on the browser.
  31398. */
  31399. onAudioUnlockedObservable: Observable<AudioEngine>;
  31400. /**
  31401. * Event raised when audio has been locked on the browser.
  31402. */
  31403. onAudioLockedObservable: Observable<AudioEngine>;
  31404. /**
  31405. * Flags the audio engine in Locked state.
  31406. * This happens due to new browser policies preventing audio to autoplay.
  31407. */
  31408. lock(): void;
  31409. /**
  31410. * Unlocks the audio engine once a user action has been done on the dom.
  31411. * This is helpful to resume play once browser policies have been satisfied.
  31412. */
  31413. unlock(): void;
  31414. }
  31415. /**
  31416. * This represents the default audio engine used in babylon.
  31417. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31418. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31419. */
  31420. export class AudioEngine implements IAudioEngine {
  31421. private _audioContext;
  31422. private _audioContextInitialized;
  31423. private _muteButton;
  31424. private _hostElement;
  31425. /**
  31426. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31427. */
  31428. canUseWebAudio: boolean;
  31429. /**
  31430. * The master gain node defines the global audio volume of your audio engine.
  31431. */
  31432. masterGain: GainNode;
  31433. /**
  31434. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31435. * @ignoreNaming
  31436. */
  31437. WarnedWebAudioUnsupported: boolean;
  31438. /**
  31439. * Gets whether or not mp3 are supported by your browser.
  31440. */
  31441. isMP3supported: boolean;
  31442. /**
  31443. * Gets whether or not ogg are supported by your browser.
  31444. */
  31445. isOGGsupported: boolean;
  31446. /**
  31447. * Gets whether audio has been unlocked on the device.
  31448. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31449. * a user interaction has happened.
  31450. */
  31451. unlocked: boolean;
  31452. /**
  31453. * Defines if the audio engine relies on a custom unlocked button.
  31454. * In this case, the embedded button will not be displayed.
  31455. */
  31456. useCustomUnlockedButton: boolean;
  31457. /**
  31458. * Event raised when audio has been unlocked on the browser.
  31459. */
  31460. onAudioUnlockedObservable: Observable<AudioEngine>;
  31461. /**
  31462. * Event raised when audio has been locked on the browser.
  31463. */
  31464. onAudioLockedObservable: Observable<AudioEngine>;
  31465. /**
  31466. * Gets the current AudioContext if available.
  31467. */
  31468. readonly audioContext: Nullable<AudioContext>;
  31469. private _connectedAnalyser;
  31470. /**
  31471. * Instantiates a new audio engine.
  31472. *
  31473. * There should be only one per page as some browsers restrict the number
  31474. * of audio contexts you can create.
  31475. * @param hostElement defines the host element where to display the mute icon if necessary
  31476. */
  31477. constructor(hostElement?: Nullable<HTMLElement>);
  31478. /**
  31479. * Flags the audio engine in Locked state.
  31480. * This happens due to new browser policies preventing audio to autoplay.
  31481. */
  31482. lock(): void;
  31483. /**
  31484. * Unlocks the audio engine once a user action has been done on the dom.
  31485. * This is helpful to resume play once browser policies have been satisfied.
  31486. */
  31487. unlock(): void;
  31488. private _resumeAudioContext;
  31489. private _initializeAudioContext;
  31490. private _tryToRun;
  31491. private _triggerRunningState;
  31492. private _triggerSuspendedState;
  31493. private _displayMuteButton;
  31494. private _moveButtonToTopLeft;
  31495. private _onResize;
  31496. private _hideMuteButton;
  31497. /**
  31498. * Destroy and release the resources associated with the audio ccontext.
  31499. */
  31500. dispose(): void;
  31501. /**
  31502. * Gets the global volume sets on the master gain.
  31503. * @returns the global volume if set or -1 otherwise
  31504. */
  31505. getGlobalVolume(): number;
  31506. /**
  31507. * Sets the global volume of your experience (sets on the master gain).
  31508. * @param newVolume Defines the new global volume of the application
  31509. */
  31510. setGlobalVolume(newVolume: number): void;
  31511. /**
  31512. * Connect the audio engine to an audio analyser allowing some amazing
  31513. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31514. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31515. * @param analyser The analyser to connect to the engine
  31516. */
  31517. connectToAnalyser(analyser: Analyser): void;
  31518. }
  31519. }
  31520. declare module "babylonjs/Loading/loadingScreen" {
  31521. /**
  31522. * Interface used to present a loading screen while loading a scene
  31523. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31524. */
  31525. export interface ILoadingScreen {
  31526. /**
  31527. * Function called to display the loading screen
  31528. */
  31529. displayLoadingUI: () => void;
  31530. /**
  31531. * Function called to hide the loading screen
  31532. */
  31533. hideLoadingUI: () => void;
  31534. /**
  31535. * Gets or sets the color to use for the background
  31536. */
  31537. loadingUIBackgroundColor: string;
  31538. /**
  31539. * Gets or sets the text to display while loading
  31540. */
  31541. loadingUIText: string;
  31542. }
  31543. /**
  31544. * Class used for the default loading screen
  31545. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31546. */
  31547. export class DefaultLoadingScreen implements ILoadingScreen {
  31548. private _renderingCanvas;
  31549. private _loadingText;
  31550. private _loadingDivBackgroundColor;
  31551. private _loadingDiv;
  31552. private _loadingTextDiv;
  31553. /** Gets or sets the logo url to use for the default loading screen */
  31554. static DefaultLogoUrl: string;
  31555. /** Gets or sets the spinner url to use for the default loading screen */
  31556. static DefaultSpinnerUrl: string;
  31557. /**
  31558. * Creates a new default loading screen
  31559. * @param _renderingCanvas defines the canvas used to render the scene
  31560. * @param _loadingText defines the default text to display
  31561. * @param _loadingDivBackgroundColor defines the default background color
  31562. */
  31563. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31564. /**
  31565. * Function called to display the loading screen
  31566. */
  31567. displayLoadingUI(): void;
  31568. /**
  31569. * Function called to hide the loading screen
  31570. */
  31571. hideLoadingUI(): void;
  31572. /**
  31573. * Gets or sets the text to display while loading
  31574. */
  31575. loadingUIText: string;
  31576. /**
  31577. * Gets or sets the color to use for the background
  31578. */
  31579. loadingUIBackgroundColor: string;
  31580. private _resizeLoadingUI;
  31581. }
  31582. }
  31583. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31584. /**
  31585. * Interface for any object that can request an animation frame
  31586. */
  31587. export interface ICustomAnimationFrameRequester {
  31588. /**
  31589. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31590. */
  31591. renderFunction?: Function;
  31592. /**
  31593. * Called to request the next frame to render to
  31594. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31595. */
  31596. requestAnimationFrame: Function;
  31597. /**
  31598. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31599. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31600. */
  31601. requestID?: number;
  31602. }
  31603. }
  31604. declare module "babylonjs/Misc/performanceMonitor" {
  31605. /**
  31606. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31607. */
  31608. export class PerformanceMonitor {
  31609. private _enabled;
  31610. private _rollingFrameTime;
  31611. private _lastFrameTimeMs;
  31612. /**
  31613. * constructor
  31614. * @param frameSampleSize The number of samples required to saturate the sliding window
  31615. */
  31616. constructor(frameSampleSize?: number);
  31617. /**
  31618. * Samples current frame
  31619. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31620. */
  31621. sampleFrame(timeMs?: number): void;
  31622. /**
  31623. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31624. */
  31625. readonly averageFrameTime: number;
  31626. /**
  31627. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31628. */
  31629. readonly averageFrameTimeVariance: number;
  31630. /**
  31631. * Returns the frame time of the most recent frame
  31632. */
  31633. readonly instantaneousFrameTime: number;
  31634. /**
  31635. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31636. */
  31637. readonly averageFPS: number;
  31638. /**
  31639. * Returns the average framerate in frames per second using the most recent frame time
  31640. */
  31641. readonly instantaneousFPS: number;
  31642. /**
  31643. * Returns true if enough samples have been taken to completely fill the sliding window
  31644. */
  31645. readonly isSaturated: boolean;
  31646. /**
  31647. * Enables contributions to the sliding window sample set
  31648. */
  31649. enable(): void;
  31650. /**
  31651. * Disables contributions to the sliding window sample set
  31652. * Samples will not be interpolated over the disabled period
  31653. */
  31654. disable(): void;
  31655. /**
  31656. * Returns true if sampling is enabled
  31657. */
  31658. readonly isEnabled: boolean;
  31659. /**
  31660. * Resets performance monitor
  31661. */
  31662. reset(): void;
  31663. }
  31664. /**
  31665. * RollingAverage
  31666. *
  31667. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31668. */
  31669. export class RollingAverage {
  31670. /**
  31671. * Current average
  31672. */
  31673. average: number;
  31674. /**
  31675. * Current variance
  31676. */
  31677. variance: number;
  31678. protected _samples: Array<number>;
  31679. protected _sampleCount: number;
  31680. protected _pos: number;
  31681. protected _m2: number;
  31682. /**
  31683. * constructor
  31684. * @param length The number of samples required to saturate the sliding window
  31685. */
  31686. constructor(length: number);
  31687. /**
  31688. * Adds a sample to the sample set
  31689. * @param v The sample value
  31690. */
  31691. add(v: number): void;
  31692. /**
  31693. * Returns previously added values or null if outside of history or outside the sliding window domain
  31694. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31695. * @return Value previously recorded with add() or null if outside of range
  31696. */
  31697. history(i: number): number;
  31698. /**
  31699. * Returns true if enough samples have been taken to completely fill the sliding window
  31700. * @return true if sample-set saturated
  31701. */
  31702. isSaturated(): boolean;
  31703. /**
  31704. * Resets the rolling average (equivalent to 0 samples taken so far)
  31705. */
  31706. reset(): void;
  31707. /**
  31708. * Wraps a value around the sample range boundaries
  31709. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31710. * @return Wrapped position in sample range
  31711. */
  31712. protected _wrapPosition(i: number): number;
  31713. }
  31714. }
  31715. declare module "babylonjs/Misc/perfCounter" {
  31716. /**
  31717. * This class is used to track a performance counter which is number based.
  31718. * The user has access to many properties which give statistics of different nature.
  31719. *
  31720. * The implementer can track two kinds of Performance Counter: time and count.
  31721. * 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.
  31722. * 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.
  31723. */
  31724. export class PerfCounter {
  31725. /**
  31726. * Gets or sets a global boolean to turn on and off all the counters
  31727. */
  31728. static Enabled: boolean;
  31729. /**
  31730. * Returns the smallest value ever
  31731. */
  31732. readonly min: number;
  31733. /**
  31734. * Returns the biggest value ever
  31735. */
  31736. readonly max: number;
  31737. /**
  31738. * Returns the average value since the performance counter is running
  31739. */
  31740. readonly average: number;
  31741. /**
  31742. * Returns the average value of the last second the counter was monitored
  31743. */
  31744. readonly lastSecAverage: number;
  31745. /**
  31746. * Returns the current value
  31747. */
  31748. readonly current: number;
  31749. /**
  31750. * Gets the accumulated total
  31751. */
  31752. readonly total: number;
  31753. /**
  31754. * Gets the total value count
  31755. */
  31756. readonly count: number;
  31757. /**
  31758. * Creates a new counter
  31759. */
  31760. constructor();
  31761. /**
  31762. * Call this method to start monitoring a new frame.
  31763. * 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.
  31764. */
  31765. fetchNewFrame(): void;
  31766. /**
  31767. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31768. * @param newCount the count value to add to the monitored count
  31769. * @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.
  31770. */
  31771. addCount(newCount: number, fetchResult: boolean): void;
  31772. /**
  31773. * Start monitoring this performance counter
  31774. */
  31775. beginMonitoring(): void;
  31776. /**
  31777. * Compute the time lapsed since the previous beginMonitoring() call.
  31778. * @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
  31779. */
  31780. endMonitoring(newFrame?: boolean): void;
  31781. private _fetchResult;
  31782. private _startMonitoringTime;
  31783. private _min;
  31784. private _max;
  31785. private _average;
  31786. private _current;
  31787. private _totalValueCount;
  31788. private _totalAccumulated;
  31789. private _lastSecAverage;
  31790. private _lastSecAccumulated;
  31791. private _lastSecTime;
  31792. private _lastSecValueCount;
  31793. }
  31794. }
  31795. declare module "babylonjs/Engines/engine" {
  31796. import { Observable } from "babylonjs/Misc/observable";
  31797. import { Nullable, IndicesArray } from "babylonjs/types";
  31798. import { Scene } from "babylonjs/scene";
  31799. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31800. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31801. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31802. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31803. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31804. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31805. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31806. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31807. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31808. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31809. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31810. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31811. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  31812. import { Material } from "babylonjs/Materials/material";
  31813. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31814. /**
  31815. * Defines the interface used by display changed events
  31816. */
  31817. export interface IDisplayChangedEventArgs {
  31818. /** Gets the vrDisplay object (if any) */
  31819. vrDisplay: Nullable<any>;
  31820. /** Gets a boolean indicating if webVR is supported */
  31821. vrSupported: boolean;
  31822. }
  31823. /**
  31824. * Defines the interface used by objects containing a viewport (like a camera)
  31825. */
  31826. interface IViewportOwnerLike {
  31827. /**
  31828. * Gets or sets the viewport
  31829. */
  31830. viewport: IViewportLike;
  31831. }
  31832. /**
  31833. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31834. */
  31835. export class Engine extends ThinEngine {
  31836. /** Defines that alpha blending is disabled */
  31837. static readonly ALPHA_DISABLE: number;
  31838. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31839. static readonly ALPHA_ADD: number;
  31840. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31841. static readonly ALPHA_COMBINE: number;
  31842. /** Defines that alpha blending to DEST - SRC * DEST */
  31843. static readonly ALPHA_SUBTRACT: number;
  31844. /** Defines that alpha blending to SRC * DEST */
  31845. static readonly ALPHA_MULTIPLY: number;
  31846. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31847. static readonly ALPHA_MAXIMIZED: number;
  31848. /** Defines that alpha blending to SRC + DEST */
  31849. static readonly ALPHA_ONEONE: number;
  31850. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31851. static readonly ALPHA_PREMULTIPLIED: number;
  31852. /**
  31853. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31854. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31855. */
  31856. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31857. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31858. static readonly ALPHA_INTERPOLATE: number;
  31859. /**
  31860. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31861. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31862. */
  31863. static readonly ALPHA_SCREENMODE: number;
  31864. /** Defines that the ressource is not delayed*/
  31865. static readonly DELAYLOADSTATE_NONE: number;
  31866. /** Defines that the ressource was successfully delay loaded */
  31867. static readonly DELAYLOADSTATE_LOADED: number;
  31868. /** Defines that the ressource is currently delay loading */
  31869. static readonly DELAYLOADSTATE_LOADING: number;
  31870. /** Defines that the ressource is delayed and has not started loading */
  31871. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31872. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31873. static readonly NEVER: number;
  31874. /** 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 */
  31875. static readonly ALWAYS: number;
  31876. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31877. static readonly LESS: number;
  31878. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31879. static readonly EQUAL: number;
  31880. /** 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 */
  31881. static readonly LEQUAL: number;
  31882. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31883. static readonly GREATER: number;
  31884. /** 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 */
  31885. static readonly GEQUAL: number;
  31886. /** 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 */
  31887. static readonly NOTEQUAL: number;
  31888. /** Passed to stencilOperation to specify that stencil value must be kept */
  31889. static readonly KEEP: number;
  31890. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31891. static readonly REPLACE: number;
  31892. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31893. static readonly INCR: number;
  31894. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31895. static readonly DECR: number;
  31896. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31897. static readonly INVERT: number;
  31898. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31899. static readonly INCR_WRAP: number;
  31900. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31901. static readonly DECR_WRAP: number;
  31902. /** Texture is not repeating outside of 0..1 UVs */
  31903. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31904. /** Texture is repeating outside of 0..1 UVs */
  31905. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31906. /** Texture is repeating and mirrored */
  31907. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31908. /** ALPHA */
  31909. static readonly TEXTUREFORMAT_ALPHA: number;
  31910. /** LUMINANCE */
  31911. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31912. /** LUMINANCE_ALPHA */
  31913. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31914. /** RGB */
  31915. static readonly TEXTUREFORMAT_RGB: number;
  31916. /** RGBA */
  31917. static readonly TEXTUREFORMAT_RGBA: number;
  31918. /** RED */
  31919. static readonly TEXTUREFORMAT_RED: number;
  31920. /** RED (2nd reference) */
  31921. static readonly TEXTUREFORMAT_R: number;
  31922. /** RG */
  31923. static readonly TEXTUREFORMAT_RG: number;
  31924. /** RED_INTEGER */
  31925. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31926. /** RED_INTEGER (2nd reference) */
  31927. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31928. /** RG_INTEGER */
  31929. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31930. /** RGB_INTEGER */
  31931. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31932. /** RGBA_INTEGER */
  31933. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31934. /** UNSIGNED_BYTE */
  31935. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31936. /** UNSIGNED_BYTE (2nd reference) */
  31937. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31938. /** FLOAT */
  31939. static readonly TEXTURETYPE_FLOAT: number;
  31940. /** HALF_FLOAT */
  31941. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31942. /** BYTE */
  31943. static readonly TEXTURETYPE_BYTE: number;
  31944. /** SHORT */
  31945. static readonly TEXTURETYPE_SHORT: number;
  31946. /** UNSIGNED_SHORT */
  31947. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31948. /** INT */
  31949. static readonly TEXTURETYPE_INT: number;
  31950. /** UNSIGNED_INT */
  31951. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31952. /** UNSIGNED_SHORT_4_4_4_4 */
  31953. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31954. /** UNSIGNED_SHORT_5_5_5_1 */
  31955. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31956. /** UNSIGNED_SHORT_5_6_5 */
  31957. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31958. /** UNSIGNED_INT_2_10_10_10_REV */
  31959. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31960. /** UNSIGNED_INT_24_8 */
  31961. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31962. /** UNSIGNED_INT_10F_11F_11F_REV */
  31963. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31964. /** UNSIGNED_INT_5_9_9_9_REV */
  31965. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31966. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31967. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31968. /** nearest is mag = nearest and min = nearest and mip = linear */
  31969. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31970. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31971. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31972. /** Trilinear is mag = linear and min = linear and mip = linear */
  31973. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31974. /** nearest is mag = nearest and min = nearest and mip = linear */
  31975. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31976. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31977. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31978. /** Trilinear is mag = linear and min = linear and mip = linear */
  31979. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31980. /** mag = nearest and min = nearest and mip = nearest */
  31981. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31982. /** mag = nearest and min = linear and mip = nearest */
  31983. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31984. /** mag = nearest and min = linear and mip = linear */
  31985. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31986. /** mag = nearest and min = linear and mip = none */
  31987. static readonly TEXTURE_NEAREST_LINEAR: number;
  31988. /** mag = nearest and min = nearest and mip = none */
  31989. static readonly TEXTURE_NEAREST_NEAREST: number;
  31990. /** mag = linear and min = nearest and mip = nearest */
  31991. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31992. /** mag = linear and min = nearest and mip = linear */
  31993. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31994. /** mag = linear and min = linear and mip = none */
  31995. static readonly TEXTURE_LINEAR_LINEAR: number;
  31996. /** mag = linear and min = nearest and mip = none */
  31997. static readonly TEXTURE_LINEAR_NEAREST: number;
  31998. /** Explicit coordinates mode */
  31999. static readonly TEXTURE_EXPLICIT_MODE: number;
  32000. /** Spherical coordinates mode */
  32001. static readonly TEXTURE_SPHERICAL_MODE: number;
  32002. /** Planar coordinates mode */
  32003. static readonly TEXTURE_PLANAR_MODE: number;
  32004. /** Cubic coordinates mode */
  32005. static readonly TEXTURE_CUBIC_MODE: number;
  32006. /** Projection coordinates mode */
  32007. static readonly TEXTURE_PROJECTION_MODE: number;
  32008. /** Skybox coordinates mode */
  32009. static readonly TEXTURE_SKYBOX_MODE: number;
  32010. /** Inverse Cubic coordinates mode */
  32011. static readonly TEXTURE_INVCUBIC_MODE: number;
  32012. /** Equirectangular coordinates mode */
  32013. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32014. /** Equirectangular Fixed coordinates mode */
  32015. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32016. /** Equirectangular Fixed Mirrored coordinates mode */
  32017. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32018. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32019. static readonly SCALEMODE_FLOOR: number;
  32020. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32021. static readonly SCALEMODE_NEAREST: number;
  32022. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32023. static readonly SCALEMODE_CEILING: number;
  32024. /**
  32025. * Returns the current npm package of the sdk
  32026. */
  32027. static readonly NpmPackage: string;
  32028. /**
  32029. * Returns the current version of the framework
  32030. */
  32031. static readonly Version: string;
  32032. /** Gets the list of created engines */
  32033. static readonly Instances: Engine[];
  32034. /**
  32035. * Gets the latest created engine
  32036. */
  32037. static readonly LastCreatedEngine: Nullable<Engine>;
  32038. /**
  32039. * Gets the latest created scene
  32040. */
  32041. static readonly LastCreatedScene: Nullable<Scene>;
  32042. /**
  32043. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32044. * @param flag defines which part of the materials must be marked as dirty
  32045. * @param predicate defines a predicate used to filter which materials should be affected
  32046. */
  32047. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32048. /**
  32049. * Method called to create the default loading screen.
  32050. * This can be overriden in your own app.
  32051. * @param canvas The rendering canvas element
  32052. * @returns The loading screen
  32053. */
  32054. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32055. /**
  32056. * Method called to create the default rescale post process on each engine.
  32057. */
  32058. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32059. /**
  32060. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32061. **/
  32062. enableOfflineSupport: boolean;
  32063. /**
  32064. * 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)
  32065. **/
  32066. disableManifestCheck: boolean;
  32067. /**
  32068. * Gets the list of created scenes
  32069. */
  32070. scenes: Scene[];
  32071. /**
  32072. * Event raised when a new scene is created
  32073. */
  32074. onNewSceneAddedObservable: Observable<Scene>;
  32075. /**
  32076. * Gets the list of created postprocesses
  32077. */
  32078. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32079. /**
  32080. * Gets a boolean indicating if the pointer is currently locked
  32081. */
  32082. isPointerLock: boolean;
  32083. /**
  32084. * Observable event triggered each time the rendering canvas is resized
  32085. */
  32086. onResizeObservable: Observable<Engine>;
  32087. /**
  32088. * Observable event triggered each time the canvas loses focus
  32089. */
  32090. onCanvasBlurObservable: Observable<Engine>;
  32091. /**
  32092. * Observable event triggered each time the canvas gains focus
  32093. */
  32094. onCanvasFocusObservable: Observable<Engine>;
  32095. /**
  32096. * Observable event triggered each time the canvas receives pointerout event
  32097. */
  32098. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32099. /**
  32100. * Observable raised when the engine begins a new frame
  32101. */
  32102. onBeginFrameObservable: Observable<Engine>;
  32103. /**
  32104. * If set, will be used to request the next animation frame for the render loop
  32105. */
  32106. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32107. /**
  32108. * Observable raised when the engine ends the current frame
  32109. */
  32110. onEndFrameObservable: Observable<Engine>;
  32111. /**
  32112. * Observable raised when the engine is about to compile a shader
  32113. */
  32114. onBeforeShaderCompilationObservable: Observable<Engine>;
  32115. /**
  32116. * Observable raised when the engine has jsut compiled a shader
  32117. */
  32118. onAfterShaderCompilationObservable: Observable<Engine>;
  32119. /**
  32120. * Gets the audio engine
  32121. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32122. * @ignorenaming
  32123. */
  32124. static audioEngine: IAudioEngine;
  32125. /**
  32126. * Default AudioEngine factory responsible of creating the Audio Engine.
  32127. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32128. */
  32129. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32130. /**
  32131. * Default offline support factory responsible of creating a tool used to store data locally.
  32132. * By default, this will create a Database object if the workload has been embedded.
  32133. */
  32134. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32135. private _loadingScreen;
  32136. private _pointerLockRequested;
  32137. private _dummyFramebuffer;
  32138. private _rescalePostProcess;
  32139. /** @hidden */
  32140. protected _alphaMode: number;
  32141. /** @hidden */
  32142. protected _alphaEquation: number;
  32143. private _deterministicLockstep;
  32144. private _lockstepMaxSteps;
  32145. protected readonly _supportsHardwareTextureRescaling: boolean;
  32146. private _fps;
  32147. private _deltaTime;
  32148. /** @hidden */
  32149. _drawCalls: PerfCounter;
  32150. /**
  32151. * Turn this value on if you want to pause FPS computation when in background
  32152. */
  32153. disablePerformanceMonitorInBackground: boolean;
  32154. private _performanceMonitor;
  32155. /**
  32156. * Gets the performance monitor attached to this engine
  32157. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32158. */
  32159. readonly performanceMonitor: PerformanceMonitor;
  32160. private _onFocus;
  32161. private _onBlur;
  32162. private _onCanvasPointerOut;
  32163. private _onCanvasBlur;
  32164. private _onCanvasFocus;
  32165. private _onFullscreenChange;
  32166. private _onPointerLockChange;
  32167. /**
  32168. * Creates a new engine
  32169. * @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
  32170. * @param antialias defines enable antialiasing (default: false)
  32171. * @param options defines further options to be sent to the getContext() function
  32172. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32173. */
  32174. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32175. /**
  32176. * Gets current aspect ratio
  32177. * @param viewportOwner defines the camera to use to get the aspect ratio
  32178. * @param useScreen defines if screen size must be used (or the current render target if any)
  32179. * @returns a number defining the aspect ratio
  32180. */
  32181. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32182. /**
  32183. * Gets current screen aspect ratio
  32184. * @returns a number defining the aspect ratio
  32185. */
  32186. getScreenAspectRatio(): number;
  32187. /**
  32188. * Gets host document
  32189. * @returns the host document object
  32190. */
  32191. getHostDocument(): Document;
  32192. /**
  32193. * Gets the client rect of the HTML canvas attached with the current webGL context
  32194. * @returns a client rectanglee
  32195. */
  32196. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32197. /**
  32198. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32199. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32200. * @returns true if engine is in deterministic lock step mode
  32201. */
  32202. isDeterministicLockStep(): boolean;
  32203. /**
  32204. * Gets the max steps when engine is running in deterministic lock step
  32205. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32206. * @returns the max steps
  32207. */
  32208. getLockstepMaxSteps(): number;
  32209. /**
  32210. * Force the mipmap generation for the given render target texture
  32211. * @param texture defines the render target texture to use
  32212. */
  32213. generateMipMapsForCubemap(texture: InternalTexture): void;
  32214. /** States */
  32215. /**
  32216. * Set various states to the webGL context
  32217. * @param culling defines backface culling state
  32218. * @param zOffset defines the value to apply to zOffset (0 by default)
  32219. * @param force defines if states must be applied even if cache is up to date
  32220. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32221. */
  32222. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32223. /**
  32224. * Set the z offset to apply to current rendering
  32225. * @param value defines the offset to apply
  32226. */
  32227. setZOffset(value: number): void;
  32228. /**
  32229. * Gets the current value of the zOffset
  32230. * @returns the current zOffset state
  32231. */
  32232. getZOffset(): number;
  32233. /**
  32234. * Enable or disable depth buffering
  32235. * @param enable defines the state to set
  32236. */
  32237. setDepthBuffer(enable: boolean): void;
  32238. /**
  32239. * Gets a boolean indicating if depth writing is enabled
  32240. * @returns the current depth writing state
  32241. */
  32242. getDepthWrite(): boolean;
  32243. /**
  32244. * Enable or disable depth writing
  32245. * @param enable defines the state to set
  32246. */
  32247. setDepthWrite(enable: boolean): void;
  32248. /**
  32249. * Enable or disable color writing
  32250. * @param enable defines the state to set
  32251. */
  32252. setColorWrite(enable: boolean): void;
  32253. /**
  32254. * Gets a boolean indicating if color writing is enabled
  32255. * @returns the current color writing state
  32256. */
  32257. getColorWrite(): boolean;
  32258. /**
  32259. * Sets alpha constants used by some alpha blending modes
  32260. * @param r defines the red component
  32261. * @param g defines the green component
  32262. * @param b defines the blue component
  32263. * @param a defines the alpha component
  32264. */
  32265. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32266. /**
  32267. * Sets the current alpha mode
  32268. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32269. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32270. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32271. */
  32272. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32273. /**
  32274. * Gets the current alpha mode
  32275. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32276. * @returns the current alpha mode
  32277. */
  32278. getAlphaMode(): number;
  32279. /**
  32280. * Sets the current alpha equation
  32281. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32282. */
  32283. setAlphaEquation(equation: number): void;
  32284. /**
  32285. * Gets the current alpha equation.
  32286. * @returns the current alpha equation
  32287. */
  32288. getAlphaEquation(): number;
  32289. /**
  32290. * Gets a boolean indicating if stencil buffer is enabled
  32291. * @returns the current stencil buffer state
  32292. */
  32293. getStencilBuffer(): boolean;
  32294. /**
  32295. * Enable or disable the stencil buffer
  32296. * @param enable defines if the stencil buffer must be enabled or disabled
  32297. */
  32298. setStencilBuffer(enable: boolean): void;
  32299. /**
  32300. * Gets the current stencil mask
  32301. * @returns a number defining the new stencil mask to use
  32302. */
  32303. getStencilMask(): number;
  32304. /**
  32305. * Sets the current stencil mask
  32306. * @param mask defines the new stencil mask to use
  32307. */
  32308. setStencilMask(mask: number): void;
  32309. /**
  32310. * Gets the current stencil function
  32311. * @returns a number defining the stencil function to use
  32312. */
  32313. getStencilFunction(): number;
  32314. /**
  32315. * Gets the current stencil reference value
  32316. * @returns a number defining the stencil reference value to use
  32317. */
  32318. getStencilFunctionReference(): number;
  32319. /**
  32320. * Gets the current stencil mask
  32321. * @returns a number defining the stencil mask to use
  32322. */
  32323. getStencilFunctionMask(): number;
  32324. /**
  32325. * Sets the current stencil function
  32326. * @param stencilFunc defines the new stencil function to use
  32327. */
  32328. setStencilFunction(stencilFunc: number): void;
  32329. /**
  32330. * Sets the current stencil reference
  32331. * @param reference defines the new stencil reference to use
  32332. */
  32333. setStencilFunctionReference(reference: number): void;
  32334. /**
  32335. * Sets the current stencil mask
  32336. * @param mask defines the new stencil mask to use
  32337. */
  32338. setStencilFunctionMask(mask: number): void;
  32339. /**
  32340. * Gets the current stencil operation when stencil fails
  32341. * @returns a number defining stencil operation to use when stencil fails
  32342. */
  32343. getStencilOperationFail(): number;
  32344. /**
  32345. * Gets the current stencil operation when depth fails
  32346. * @returns a number defining stencil operation to use when depth fails
  32347. */
  32348. getStencilOperationDepthFail(): number;
  32349. /**
  32350. * Gets the current stencil operation when stencil passes
  32351. * @returns a number defining stencil operation to use when stencil passes
  32352. */
  32353. getStencilOperationPass(): number;
  32354. /**
  32355. * Sets the stencil operation to use when stencil fails
  32356. * @param operation defines the stencil operation to use when stencil fails
  32357. */
  32358. setStencilOperationFail(operation: number): void;
  32359. /**
  32360. * Sets the stencil operation to use when depth fails
  32361. * @param operation defines the stencil operation to use when depth fails
  32362. */
  32363. setStencilOperationDepthFail(operation: number): void;
  32364. /**
  32365. * Sets the stencil operation to use when stencil passes
  32366. * @param operation defines the stencil operation to use when stencil passes
  32367. */
  32368. setStencilOperationPass(operation: number): void;
  32369. /**
  32370. * Sets a boolean indicating if the dithering state is enabled or disabled
  32371. * @param value defines the dithering state
  32372. */
  32373. setDitheringState(value: boolean): void;
  32374. /**
  32375. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32376. * @param value defines the rasterizer state
  32377. */
  32378. setRasterizerState(value: boolean): void;
  32379. /**
  32380. * Gets the current depth function
  32381. * @returns a number defining the depth function
  32382. */
  32383. getDepthFunction(): Nullable<number>;
  32384. /**
  32385. * Sets the current depth function
  32386. * @param depthFunc defines the function to use
  32387. */
  32388. setDepthFunction(depthFunc: number): void;
  32389. /**
  32390. * Sets the current depth function to GREATER
  32391. */
  32392. setDepthFunctionToGreater(): void;
  32393. /**
  32394. * Sets the current depth function to GEQUAL
  32395. */
  32396. setDepthFunctionToGreaterOrEqual(): void;
  32397. /**
  32398. * Sets the current depth function to LESS
  32399. */
  32400. setDepthFunctionToLess(): void;
  32401. /**
  32402. * Sets the current depth function to LEQUAL
  32403. */
  32404. setDepthFunctionToLessOrEqual(): void;
  32405. private _cachedStencilBuffer;
  32406. private _cachedStencilFunction;
  32407. private _cachedStencilMask;
  32408. private _cachedStencilOperationPass;
  32409. private _cachedStencilOperationFail;
  32410. private _cachedStencilOperationDepthFail;
  32411. private _cachedStencilReference;
  32412. /**
  32413. * Caches the the state of the stencil buffer
  32414. */
  32415. cacheStencilState(): void;
  32416. /**
  32417. * Restores the state of the stencil buffer
  32418. */
  32419. restoreStencilState(): void;
  32420. /**
  32421. * Directly set the WebGL Viewport
  32422. * @param x defines the x coordinate of the viewport (in screen space)
  32423. * @param y defines the y coordinate of the viewport (in screen space)
  32424. * @param width defines the width of the viewport (in screen space)
  32425. * @param height defines the height of the viewport (in screen space)
  32426. * @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
  32427. */
  32428. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32429. /**
  32430. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32431. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32432. * @param y defines the y-coordinate of the corner of the clear rectangle
  32433. * @param width defines the width of the clear rectangle
  32434. * @param height defines the height of the clear rectangle
  32435. * @param clearColor defines the clear color
  32436. */
  32437. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32438. /**
  32439. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32440. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32441. * @param y defines the y-coordinate of the corner of the clear rectangle
  32442. * @param width defines the width of the clear rectangle
  32443. * @param height defines the height of the clear rectangle
  32444. */
  32445. enableScissor(x: number, y: number, width: number, height: number): void;
  32446. /**
  32447. * Disable previously set scissor test rectangle
  32448. */
  32449. disableScissor(): void;
  32450. protected _reportDrawCall(): void;
  32451. /**
  32452. * Initializes a webVR display and starts listening to display change events
  32453. * The onVRDisplayChangedObservable will be notified upon these changes
  32454. * @returns The onVRDisplayChangedObservable
  32455. */
  32456. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32457. /** @hidden */
  32458. _prepareVRComponent(): void;
  32459. /** @hidden */
  32460. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32461. /** @hidden */
  32462. _submitVRFrame(): void;
  32463. /**
  32464. * Call this function to leave webVR mode
  32465. * Will do nothing if webVR is not supported or if there is no webVR device
  32466. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32467. */
  32468. disableVR(): void;
  32469. /**
  32470. * Gets a boolean indicating that the system is in VR mode and is presenting
  32471. * @returns true if VR mode is engaged
  32472. */
  32473. isVRPresenting(): boolean;
  32474. /** @hidden */
  32475. _requestVRFrame(): void;
  32476. /** @hidden */
  32477. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32478. /**
  32479. * Gets the source code of the vertex shader associated with a specific webGL program
  32480. * @param program defines the program to use
  32481. * @returns a string containing the source code of the vertex shader associated with the program
  32482. */
  32483. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32484. /**
  32485. * Gets the source code of the fragment shader associated with a specific webGL program
  32486. * @param program defines the program to use
  32487. * @returns a string containing the source code of the fragment shader associated with the program
  32488. */
  32489. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32490. /**
  32491. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32492. * @param x defines the x coordinate of the rectangle where pixels must be read
  32493. * @param y defines the y coordinate of the rectangle where pixels must be read
  32494. * @param width defines the width of the rectangle where pixels must be read
  32495. * @param height defines the height of the rectangle where pixels must be read
  32496. * @returns a Uint8Array containing RGBA colors
  32497. */
  32498. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32499. /**
  32500. * Sets a depth stencil texture from a render target to the according uniform.
  32501. * @param channel The texture channel
  32502. * @param uniform The uniform to set
  32503. * @param texture The render target texture containing the depth stencil texture to apply
  32504. */
  32505. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32506. /**
  32507. * Sets a texture to the webGL context from a postprocess
  32508. * @param channel defines the channel to use
  32509. * @param postProcess defines the source postprocess
  32510. */
  32511. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32512. /**
  32513. * Binds the output of the passed in post process to the texture channel specified
  32514. * @param channel The channel the texture should be bound to
  32515. * @param postProcess The post process which's output should be bound
  32516. */
  32517. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32518. /** @hidden */
  32519. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32520. protected _rebuildBuffers(): void;
  32521. _renderLoop(): void;
  32522. /**
  32523. * Toggle full screen mode
  32524. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32525. */
  32526. switchFullscreen(requestPointerLock: boolean): void;
  32527. /**
  32528. * Enters full screen mode
  32529. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32530. */
  32531. enterFullscreen(requestPointerLock: boolean): void;
  32532. /**
  32533. * Exits full screen mode
  32534. */
  32535. exitFullscreen(): void;
  32536. /**
  32537. * Enters Pointerlock mode
  32538. */
  32539. enterPointerlock(): void;
  32540. /**
  32541. * Exits Pointerlock mode
  32542. */
  32543. exitPointerlock(): void;
  32544. /**
  32545. * Begin a new frame
  32546. */
  32547. beginFrame(): void;
  32548. /**
  32549. * Enf the current frame
  32550. */
  32551. endFrame(): void;
  32552. resize(): void;
  32553. /**
  32554. * Set the compressed texture format to use, based on the formats you have, and the formats
  32555. * supported by the hardware / browser.
  32556. *
  32557. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32558. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32559. * to API arguments needed to compressed textures. This puts the burden on the container
  32560. * generator to house the arcane code for determining these for current & future formats.
  32561. *
  32562. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32563. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32564. *
  32565. * Note: The result of this call is not taken into account when a texture is base64.
  32566. *
  32567. * @param formatsAvailable defines the list of those format families you have created
  32568. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32569. *
  32570. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32571. * @returns The extension selected.
  32572. */
  32573. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32574. /**
  32575. * Force a specific size of the canvas
  32576. * @param width defines the new canvas' width
  32577. * @param height defines the new canvas' height
  32578. */
  32579. setSize(width: number, height: number): void;
  32580. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32581. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32582. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32583. _releaseTexture(texture: InternalTexture): void;
  32584. /**
  32585. * @hidden
  32586. * Rescales a texture
  32587. * @param source input texutre
  32588. * @param destination destination texture
  32589. * @param scene scene to use to render the resize
  32590. * @param internalFormat format to use when resizing
  32591. * @param onComplete callback to be called when resize has completed
  32592. */
  32593. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32594. /**
  32595. * Gets the current framerate
  32596. * @returns a number representing the framerate
  32597. */
  32598. getFps(): number;
  32599. /**
  32600. * Gets the time spent between current and previous frame
  32601. * @returns a number representing the delta time in ms
  32602. */
  32603. getDeltaTime(): number;
  32604. private _measureFps;
  32605. /**
  32606. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32607. * @param renderTarget The render target to set the frame buffer for
  32608. */
  32609. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32610. /**
  32611. * Update a dynamic index buffer
  32612. * @param indexBuffer defines the target index buffer
  32613. * @param indices defines the data to update
  32614. * @param offset defines the offset in the target index buffer where update should start
  32615. */
  32616. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32617. /**
  32618. * Updates the sample count of a render target texture
  32619. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32620. * @param texture defines the texture to update
  32621. * @param samples defines the sample count to set
  32622. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32623. */
  32624. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32625. /** @hidden */
  32626. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32627. dispose(): void;
  32628. private _disableTouchAction;
  32629. /**
  32630. * Display the loading screen
  32631. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32632. */
  32633. displayLoadingUI(): void;
  32634. /**
  32635. * Hide the loading screen
  32636. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32637. */
  32638. hideLoadingUI(): void;
  32639. /**
  32640. * Gets the current loading screen object
  32641. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32642. */
  32643. /**
  32644. * Sets the current loading screen object
  32645. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32646. */
  32647. loadingScreen: ILoadingScreen;
  32648. /**
  32649. * Sets the current loading screen text
  32650. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32651. */
  32652. loadingUIText: string;
  32653. /**
  32654. * Sets the current loading screen background color
  32655. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32656. */
  32657. loadingUIBackgroundColor: string;
  32658. /** Pointerlock and fullscreen */
  32659. /**
  32660. * Ask the browser to promote the current element to pointerlock mode
  32661. * @param element defines the DOM element to promote
  32662. */
  32663. static _RequestPointerlock(element: HTMLElement): void;
  32664. /**
  32665. * Asks the browser to exit pointerlock mode
  32666. */
  32667. static _ExitPointerlock(): void;
  32668. /**
  32669. * Ask the browser to promote the current element to fullscreen rendering mode
  32670. * @param element defines the DOM element to promote
  32671. */
  32672. static _RequestFullscreen(element: HTMLElement): void;
  32673. /**
  32674. * Asks the browser to exit fullscreen mode
  32675. */
  32676. static _ExitFullscreen(): void;
  32677. }
  32678. }
  32679. declare module "babylonjs/Engines/engineStore" {
  32680. import { Nullable } from "babylonjs/types";
  32681. import { Engine } from "babylonjs/Engines/engine";
  32682. import { Scene } from "babylonjs/scene";
  32683. /**
  32684. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32685. * during the life time of the application.
  32686. */
  32687. export class EngineStore {
  32688. /** Gets the list of created engines */
  32689. static Instances: import("babylonjs/Engines/engine").Engine[];
  32690. /** @hidden */
  32691. static _LastCreatedScene: Nullable<Scene>;
  32692. /**
  32693. * Gets the latest created engine
  32694. */
  32695. static readonly LastCreatedEngine: Nullable<Engine>;
  32696. /**
  32697. * Gets the latest created scene
  32698. */
  32699. static readonly LastCreatedScene: Nullable<Scene>;
  32700. /**
  32701. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32702. * @ignorenaming
  32703. */
  32704. static UseFallbackTexture: boolean;
  32705. /**
  32706. * Texture content used if a texture cannot loaded
  32707. * @ignorenaming
  32708. */
  32709. static FallbackTexture: string;
  32710. }
  32711. }
  32712. declare module "babylonjs/Misc/promise" {
  32713. /**
  32714. * Helper class that provides a small promise polyfill
  32715. */
  32716. export class PromisePolyfill {
  32717. /**
  32718. * Static function used to check if the polyfill is required
  32719. * If this is the case then the function will inject the polyfill to window.Promise
  32720. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32721. */
  32722. static Apply(force?: boolean): void;
  32723. }
  32724. }
  32725. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32726. /**
  32727. * Interface for screenshot methods with describe argument called `size` as object with options
  32728. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32729. */
  32730. export interface IScreenshotSize {
  32731. /**
  32732. * number in pixels for canvas height
  32733. */
  32734. height?: number;
  32735. /**
  32736. * multiplier allowing render at a higher or lower resolution
  32737. * If value is defined then height and width will be ignored and taken from camera
  32738. */
  32739. precision?: number;
  32740. /**
  32741. * number in pixels for canvas width
  32742. */
  32743. width?: number;
  32744. }
  32745. }
  32746. declare module "babylonjs/Misc/tools" {
  32747. import { Nullable, float } from "babylonjs/types";
  32748. import { DomManagement } from "babylonjs/Misc/domManagement";
  32749. import { WebRequest } from "babylonjs/Misc/webRequest";
  32750. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32751. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32752. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32753. import { Camera } from "babylonjs/Cameras/camera";
  32754. import { Engine } from "babylonjs/Engines/engine";
  32755. interface IColor4Like {
  32756. r: float;
  32757. g: float;
  32758. b: float;
  32759. a: float;
  32760. }
  32761. /**
  32762. * Class containing a set of static utilities functions
  32763. */
  32764. export class Tools {
  32765. /**
  32766. * Gets or sets the base URL to use to load assets
  32767. */
  32768. static BaseUrl: string;
  32769. /**
  32770. * Enable/Disable Custom HTTP Request Headers globally.
  32771. * default = false
  32772. * @see CustomRequestHeaders
  32773. */
  32774. static UseCustomRequestHeaders: boolean;
  32775. /**
  32776. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32777. * i.e. when loading files, where the server/service expects an Authorization header
  32778. */
  32779. static CustomRequestHeaders: {
  32780. [key: string]: string;
  32781. };
  32782. /**
  32783. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32784. */
  32785. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32786. /**
  32787. * Default behaviour for cors in the application.
  32788. * It can be a string if the expected behavior is identical in the entire app.
  32789. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32790. */
  32791. static CorsBehavior: string | ((url: string | string[]) => string);
  32792. /**
  32793. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32794. * @ignorenaming
  32795. */
  32796. static UseFallbackTexture: boolean;
  32797. /**
  32798. * Use this object to register external classes like custom textures or material
  32799. * to allow the laoders to instantiate them
  32800. */
  32801. static RegisteredExternalClasses: {
  32802. [key: string]: Object;
  32803. };
  32804. /**
  32805. * Texture content used if a texture cannot loaded
  32806. * @ignorenaming
  32807. */
  32808. static fallbackTexture: string;
  32809. /**
  32810. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32811. * @param u defines the coordinate on X axis
  32812. * @param v defines the coordinate on Y axis
  32813. * @param width defines the width of the source data
  32814. * @param height defines the height of the source data
  32815. * @param pixels defines the source byte array
  32816. * @param color defines the output color
  32817. */
  32818. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32819. /**
  32820. * Interpolates between a and b via alpha
  32821. * @param a The lower value (returned when alpha = 0)
  32822. * @param b The upper value (returned when alpha = 1)
  32823. * @param alpha The interpolation-factor
  32824. * @return The mixed value
  32825. */
  32826. static Mix(a: number, b: number, alpha: number): number;
  32827. /**
  32828. * Tries to instantiate a new object from a given class name
  32829. * @param className defines the class name to instantiate
  32830. * @returns the new object or null if the system was not able to do the instantiation
  32831. */
  32832. static Instantiate(className: string): any;
  32833. /**
  32834. * Provides a slice function that will work even on IE
  32835. * @param data defines the array to slice
  32836. * @param start defines the start of the data (optional)
  32837. * @param end defines the end of the data (optional)
  32838. * @returns the new sliced array
  32839. */
  32840. static Slice<T>(data: T, start?: number, end?: number): T;
  32841. /**
  32842. * Polyfill for setImmediate
  32843. * @param action defines the action to execute after the current execution block
  32844. */
  32845. static SetImmediate(action: () => void): void;
  32846. /**
  32847. * Function indicating if a number is an exponent of 2
  32848. * @param value defines the value to test
  32849. * @returns true if the value is an exponent of 2
  32850. */
  32851. static IsExponentOfTwo(value: number): boolean;
  32852. private static _tmpFloatArray;
  32853. /**
  32854. * Returns the nearest 32-bit single precision float representation of a Number
  32855. * @param value A Number. If the parameter is of a different type, it will get converted
  32856. * to a number or to NaN if it cannot be converted
  32857. * @returns number
  32858. */
  32859. static FloatRound(value: number): number;
  32860. /**
  32861. * Extracts the filename from a path
  32862. * @param path defines the path to use
  32863. * @returns the filename
  32864. */
  32865. static GetFilename(path: string): string;
  32866. /**
  32867. * Extracts the "folder" part of a path (everything before the filename).
  32868. * @param uri The URI to extract the info from
  32869. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32870. * @returns The "folder" part of the path
  32871. */
  32872. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32873. /**
  32874. * Extracts text content from a DOM element hierarchy
  32875. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32876. */
  32877. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32878. /**
  32879. * Convert an angle in radians to degrees
  32880. * @param angle defines the angle to convert
  32881. * @returns the angle in degrees
  32882. */
  32883. static ToDegrees(angle: number): number;
  32884. /**
  32885. * Convert an angle in degrees to radians
  32886. * @param angle defines the angle to convert
  32887. * @returns the angle in radians
  32888. */
  32889. static ToRadians(angle: number): number;
  32890. /**
  32891. * Encode a buffer to a base64 string
  32892. * @param buffer defines the buffer to encode
  32893. * @returns the encoded string
  32894. */
  32895. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32896. /**
  32897. * Returns an array if obj is not an array
  32898. * @param obj defines the object to evaluate as an array
  32899. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32900. * @returns either obj directly if obj is an array or a new array containing obj
  32901. */
  32902. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32903. /**
  32904. * Gets the pointer prefix to use
  32905. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32906. */
  32907. static GetPointerPrefix(): string;
  32908. /**
  32909. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32910. * @param url define the url we are trying
  32911. * @param element define the dom element where to configure the cors policy
  32912. */
  32913. static SetCorsBehavior(url: string | string[], element: {
  32914. crossOrigin: string | null;
  32915. }): void;
  32916. /**
  32917. * Removes unwanted characters from an url
  32918. * @param url defines the url to clean
  32919. * @returns the cleaned url
  32920. */
  32921. static CleanUrl(url: string): string;
  32922. /**
  32923. * Gets or sets a function used to pre-process url before using them to load assets
  32924. */
  32925. static PreprocessUrl: (url: string) => string;
  32926. /**
  32927. * Loads an image as an HTMLImageElement.
  32928. * @param input url string, ArrayBuffer, or Blob to load
  32929. * @param onLoad callback called when the image successfully loads
  32930. * @param onError callback called when the image fails to load
  32931. * @param offlineProvider offline provider for caching
  32932. * @returns the HTMLImageElement of the loaded image
  32933. */
  32934. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32935. /**
  32936. * Loads a file
  32937. * @param url url string, ArrayBuffer, or Blob to load
  32938. * @param onSuccess callback called when the file successfully loads
  32939. * @param onProgress callback called while file is loading (if the server supports this mode)
  32940. * @param offlineProvider defines the offline provider for caching
  32941. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32942. * @param onError callback called when the file fails to load
  32943. * @returns a file request object
  32944. */
  32945. 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;
  32946. /**
  32947. * Loads a file from a url
  32948. * @param url the file url to load
  32949. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32950. */
  32951. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32952. /**
  32953. * Load a script (identified by an url). When the url returns, the
  32954. * content of this file is added into a new script element, attached to the DOM (body element)
  32955. * @param scriptUrl defines the url of the script to laod
  32956. * @param onSuccess defines the callback called when the script is loaded
  32957. * @param onError defines the callback to call if an error occurs
  32958. * @param scriptId defines the id of the script element
  32959. */
  32960. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32961. /**
  32962. * Load an asynchronous script (identified by an url). When the url returns, the
  32963. * content of this file is added into a new script element, attached to the DOM (body element)
  32964. * @param scriptUrl defines the url of the script to laod
  32965. * @param scriptId defines the id of the script element
  32966. * @returns a promise request object
  32967. */
  32968. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32969. /**
  32970. * Loads a file from a blob
  32971. * @param fileToLoad defines the blob to use
  32972. * @param callback defines the callback to call when data is loaded
  32973. * @param progressCallback defines the callback to call during loading process
  32974. * @returns a file request object
  32975. */
  32976. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32977. /**
  32978. * Loads a file
  32979. * @param fileToLoad defines the file to load
  32980. * @param callback defines the callback to call when data is loaded
  32981. * @param progressCallBack defines the callback to call during loading process
  32982. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32983. * @returns a file request object
  32984. */
  32985. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32986. /**
  32987. * Creates a data url from a given string content
  32988. * @param content defines the content to convert
  32989. * @returns the new data url link
  32990. */
  32991. static FileAsURL(content: string): string;
  32992. /**
  32993. * Format the given number to a specific decimal format
  32994. * @param value defines the number to format
  32995. * @param decimals defines the number of decimals to use
  32996. * @returns the formatted string
  32997. */
  32998. static Format(value: number, decimals?: number): string;
  32999. /**
  33000. * Tries to copy an object by duplicating every property
  33001. * @param source defines the source object
  33002. * @param destination defines the target object
  33003. * @param doNotCopyList defines a list of properties to avoid
  33004. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33005. */
  33006. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33007. /**
  33008. * Gets a boolean indicating if the given object has no own property
  33009. * @param obj defines the object to test
  33010. * @returns true if object has no own property
  33011. */
  33012. static IsEmpty(obj: any): boolean;
  33013. /**
  33014. * Function used to register events at window level
  33015. * @param windowElement defines the Window object to use
  33016. * @param events defines the events to register
  33017. */
  33018. static RegisterTopRootEvents(windowElement: Window, events: {
  33019. name: string;
  33020. handler: Nullable<(e: FocusEvent) => any>;
  33021. }[]): void;
  33022. /**
  33023. * Function used to unregister events from window level
  33024. * @param windowElement defines the Window object to use
  33025. * @param events defines the events to unregister
  33026. */
  33027. static UnregisterTopRootEvents(windowElement: Window, events: {
  33028. name: string;
  33029. handler: Nullable<(e: FocusEvent) => any>;
  33030. }[]): void;
  33031. /**
  33032. * @ignore
  33033. */
  33034. static _ScreenshotCanvas: HTMLCanvasElement;
  33035. /**
  33036. * Dumps the current bound framebuffer
  33037. * @param width defines the rendering width
  33038. * @param height defines the rendering height
  33039. * @param engine defines the hosting engine
  33040. * @param successCallback defines the callback triggered once the data are available
  33041. * @param mimeType defines the mime type of the result
  33042. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33043. */
  33044. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33045. /**
  33046. * Converts the canvas data to blob.
  33047. * This acts as a polyfill for browsers not supporting the to blob function.
  33048. * @param canvas Defines the canvas to extract the data from
  33049. * @param successCallback Defines the callback triggered once the data are available
  33050. * @param mimeType Defines the mime type of the result
  33051. */
  33052. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33053. /**
  33054. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33055. * @param successCallback defines the callback triggered once the data are available
  33056. * @param mimeType defines the mime type of the result
  33057. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33058. */
  33059. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33060. /**
  33061. * Downloads a blob in the browser
  33062. * @param blob defines the blob to download
  33063. * @param fileName defines the name of the downloaded file
  33064. */
  33065. static Download(blob: Blob, fileName: string): void;
  33066. /**
  33067. * Captures a screenshot of the current rendering
  33068. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33069. * @param engine defines the rendering engine
  33070. * @param camera defines the source camera
  33071. * @param size This parameter can be set to a single number or to an object with the
  33072. * following (optional) properties: precision, width, height. If a single number is passed,
  33073. * it will be used for both width and height. If an object is passed, the screenshot size
  33074. * will be derived from the parameters. The precision property is a multiplier allowing
  33075. * rendering at a higher or lower resolution
  33076. * @param successCallback defines the callback receives a single parameter which contains the
  33077. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33078. * src parameter of an <img> to display it
  33079. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33080. * Check your browser for supported MIME types
  33081. */
  33082. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33083. /**
  33084. * Captures a screenshot of the current rendering
  33085. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33086. * @param engine defines the rendering engine
  33087. * @param camera defines the source camera
  33088. * @param size This parameter can be set to a single number or to an object with the
  33089. * following (optional) properties: precision, width, height. If a single number is passed,
  33090. * it will be used for both width and height. If an object is passed, the screenshot size
  33091. * will be derived from the parameters. The precision property is a multiplier allowing
  33092. * rendering at a higher or lower resolution
  33093. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33094. * Check your browser for supported MIME types
  33095. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33096. * to the src parameter of an <img> to display it
  33097. */
  33098. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33099. /**
  33100. * Generates an image screenshot from the specified camera.
  33101. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33102. * @param engine The engine to use for rendering
  33103. * @param camera The camera to use for rendering
  33104. * @param size This parameter can be set to a single number or to an object with the
  33105. * following (optional) properties: precision, width, height. If a single number is passed,
  33106. * it will be used for both width and height. If an object is passed, the screenshot size
  33107. * will be derived from the parameters. The precision property is a multiplier allowing
  33108. * rendering at a higher or lower resolution
  33109. * @param successCallback The callback receives a single parameter which contains the
  33110. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33111. * src parameter of an <img> to display it
  33112. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33113. * Check your browser for supported MIME types
  33114. * @param samples Texture samples (default: 1)
  33115. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33116. * @param fileName A name for for the downloaded file.
  33117. */
  33118. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33119. /**
  33120. * Generates an image screenshot from the specified camera.
  33121. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33122. * @param engine The engine to use for rendering
  33123. * @param camera The camera to use for rendering
  33124. * @param size This parameter can be set to a single number or to an object with the
  33125. * following (optional) properties: precision, width, height. If a single number is passed,
  33126. * it will be used for both width and height. If an object is passed, the screenshot size
  33127. * will be derived from the parameters. The precision property is a multiplier allowing
  33128. * rendering at a higher or lower resolution
  33129. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33130. * Check your browser for supported MIME types
  33131. * @param samples Texture samples (default: 1)
  33132. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33133. * @param fileName A name for for the downloaded file.
  33134. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33135. * to the src parameter of an <img> to display it
  33136. */
  33137. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33138. /**
  33139. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33140. * Be aware Math.random() could cause collisions, but:
  33141. * "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"
  33142. * @returns a pseudo random id
  33143. */
  33144. static RandomId(): string;
  33145. /**
  33146. * Test if the given uri is a base64 string
  33147. * @param uri The uri to test
  33148. * @return True if the uri is a base64 string or false otherwise
  33149. */
  33150. static IsBase64(uri: string): boolean;
  33151. /**
  33152. * Decode the given base64 uri.
  33153. * @param uri The uri to decode
  33154. * @return The decoded base64 data.
  33155. */
  33156. static DecodeBase64(uri: string): ArrayBuffer;
  33157. /**
  33158. * Gets the absolute url.
  33159. * @param url the input url
  33160. * @return the absolute url
  33161. */
  33162. static GetAbsoluteUrl(url: string): string;
  33163. /**
  33164. * No log
  33165. */
  33166. static readonly NoneLogLevel: number;
  33167. /**
  33168. * Only message logs
  33169. */
  33170. static readonly MessageLogLevel: number;
  33171. /**
  33172. * Only warning logs
  33173. */
  33174. static readonly WarningLogLevel: number;
  33175. /**
  33176. * Only error logs
  33177. */
  33178. static readonly ErrorLogLevel: number;
  33179. /**
  33180. * All logs
  33181. */
  33182. static readonly AllLogLevel: number;
  33183. /**
  33184. * Gets a value indicating the number of loading errors
  33185. * @ignorenaming
  33186. */
  33187. static readonly errorsCount: number;
  33188. /**
  33189. * Callback called when a new log is added
  33190. */
  33191. static OnNewCacheEntry: (entry: string) => void;
  33192. /**
  33193. * Log a message to the console
  33194. * @param message defines the message to log
  33195. */
  33196. static Log(message: string): void;
  33197. /**
  33198. * Write a warning message to the console
  33199. * @param message defines the message to log
  33200. */
  33201. static Warn(message: string): void;
  33202. /**
  33203. * Write an error message to the console
  33204. * @param message defines the message to log
  33205. */
  33206. static Error(message: string): void;
  33207. /**
  33208. * Gets current log cache (list of logs)
  33209. */
  33210. static readonly LogCache: string;
  33211. /**
  33212. * Clears the log cache
  33213. */
  33214. static ClearLogCache(): void;
  33215. /**
  33216. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33217. */
  33218. static LogLevels: number;
  33219. /**
  33220. * Checks if the window object exists
  33221. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33222. */
  33223. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33224. /**
  33225. * No performance log
  33226. */
  33227. static readonly PerformanceNoneLogLevel: number;
  33228. /**
  33229. * Use user marks to log performance
  33230. */
  33231. static readonly PerformanceUserMarkLogLevel: number;
  33232. /**
  33233. * Log performance to the console
  33234. */
  33235. static readonly PerformanceConsoleLogLevel: number;
  33236. private static _performance;
  33237. /**
  33238. * Sets the current performance log level
  33239. */
  33240. static PerformanceLogLevel: number;
  33241. private static _StartPerformanceCounterDisabled;
  33242. private static _EndPerformanceCounterDisabled;
  33243. private static _StartUserMark;
  33244. private static _EndUserMark;
  33245. private static _StartPerformanceConsole;
  33246. private static _EndPerformanceConsole;
  33247. /**
  33248. * Starts a performance counter
  33249. */
  33250. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33251. /**
  33252. * Ends a specific performance coutner
  33253. */
  33254. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33255. /**
  33256. * Gets either window.performance.now() if supported or Date.now() else
  33257. */
  33258. static readonly Now: number;
  33259. /**
  33260. * This method will return the name of the class used to create the instance of the given object.
  33261. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33262. * @param object the object to get the class name from
  33263. * @param isType defines if the object is actually a type
  33264. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33265. */
  33266. static GetClassName(object: any, isType?: boolean): string;
  33267. /**
  33268. * Gets the first element of an array satisfying a given predicate
  33269. * @param array defines the array to browse
  33270. * @param predicate defines the predicate to use
  33271. * @returns null if not found or the element
  33272. */
  33273. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33274. /**
  33275. * This method will return the name of the full name of the class, including its owning module (if any).
  33276. * 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).
  33277. * @param object the object to get the class name from
  33278. * @param isType defines if the object is actually a type
  33279. * @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.
  33280. * @ignorenaming
  33281. */
  33282. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33283. /**
  33284. * Returns a promise that resolves after the given amount of time.
  33285. * @param delay Number of milliseconds to delay
  33286. * @returns Promise that resolves after the given amount of time
  33287. */
  33288. static DelayAsync(delay: number): Promise<void>;
  33289. }
  33290. /**
  33291. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33292. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33293. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33294. * @param name The name of the class, case should be preserved
  33295. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33296. */
  33297. export function className(name: string, module?: string): (target: Object) => void;
  33298. /**
  33299. * An implementation of a loop for asynchronous functions.
  33300. */
  33301. export class AsyncLoop {
  33302. /**
  33303. * Defines the number of iterations for the loop
  33304. */
  33305. iterations: number;
  33306. /**
  33307. * Defines the current index of the loop.
  33308. */
  33309. index: number;
  33310. private _done;
  33311. private _fn;
  33312. private _successCallback;
  33313. /**
  33314. * Constructor.
  33315. * @param iterations the number of iterations.
  33316. * @param func the function to run each iteration
  33317. * @param successCallback the callback that will be called upon succesful execution
  33318. * @param offset starting offset.
  33319. */
  33320. constructor(
  33321. /**
  33322. * Defines the number of iterations for the loop
  33323. */
  33324. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33325. /**
  33326. * Execute the next iteration. Must be called after the last iteration was finished.
  33327. */
  33328. executeNext(): void;
  33329. /**
  33330. * Break the loop and run the success callback.
  33331. */
  33332. breakLoop(): void;
  33333. /**
  33334. * Create and run an async loop.
  33335. * @param iterations the number of iterations.
  33336. * @param fn the function to run each iteration
  33337. * @param successCallback the callback that will be called upon succesful execution
  33338. * @param offset starting offset.
  33339. * @returns the created async loop object
  33340. */
  33341. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33342. /**
  33343. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33344. * @param iterations total number of iterations
  33345. * @param syncedIterations number of synchronous iterations in each async iteration.
  33346. * @param fn the function to call each iteration.
  33347. * @param callback a success call back that will be called when iterating stops.
  33348. * @param breakFunction a break condition (optional)
  33349. * @param timeout timeout settings for the setTimeout function. default - 0.
  33350. * @returns the created async loop object
  33351. */
  33352. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33353. }
  33354. }
  33355. declare module "babylonjs/Misc/stringDictionary" {
  33356. import { Nullable } from "babylonjs/types";
  33357. /**
  33358. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33359. * The underlying implementation relies on an associative array to ensure the best performances.
  33360. * The value can be anything including 'null' but except 'undefined'
  33361. */
  33362. export class StringDictionary<T> {
  33363. /**
  33364. * This will clear this dictionary and copy the content from the 'source' one.
  33365. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33366. * @param source the dictionary to take the content from and copy to this dictionary
  33367. */
  33368. copyFrom(source: StringDictionary<T>): void;
  33369. /**
  33370. * Get a value based from its key
  33371. * @param key the given key to get the matching value from
  33372. * @return the value if found, otherwise undefined is returned
  33373. */
  33374. get(key: string): T | undefined;
  33375. /**
  33376. * Get a value from its key or add it if it doesn't exist.
  33377. * This method will ensure you that a given key/data will be present in the dictionary.
  33378. * @param key the given key to get the matching value from
  33379. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33380. * The factory will only be invoked if there's no data for the given key.
  33381. * @return the value corresponding to the key.
  33382. */
  33383. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33384. /**
  33385. * Get a value from its key if present in the dictionary otherwise add it
  33386. * @param key the key to get the value from
  33387. * @param val if there's no such key/value pair in the dictionary add it with this value
  33388. * @return the value corresponding to the key
  33389. */
  33390. getOrAdd(key: string, val: T): T;
  33391. /**
  33392. * Check if there's a given key in the dictionary
  33393. * @param key the key to check for
  33394. * @return true if the key is present, false otherwise
  33395. */
  33396. contains(key: string): boolean;
  33397. /**
  33398. * Add a new key and its corresponding value
  33399. * @param key the key to add
  33400. * @param value the value corresponding to the key
  33401. * @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
  33402. */
  33403. add(key: string, value: T): boolean;
  33404. /**
  33405. * Update a specific value associated to a key
  33406. * @param key defines the key to use
  33407. * @param value defines the value to store
  33408. * @returns true if the value was updated (or false if the key was not found)
  33409. */
  33410. set(key: string, value: T): boolean;
  33411. /**
  33412. * Get the element of the given key and remove it from the dictionary
  33413. * @param key defines the key to search
  33414. * @returns the value associated with the key or null if not found
  33415. */
  33416. getAndRemove(key: string): Nullable<T>;
  33417. /**
  33418. * Remove a key/value from the dictionary.
  33419. * @param key the key to remove
  33420. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33421. */
  33422. remove(key: string): boolean;
  33423. /**
  33424. * Clear the whole content of the dictionary
  33425. */
  33426. clear(): void;
  33427. /**
  33428. * Gets the current count
  33429. */
  33430. readonly count: number;
  33431. /**
  33432. * Execute a callback on each key/val of the dictionary.
  33433. * Note that you can remove any element in this dictionary in the callback implementation
  33434. * @param callback the callback to execute on a given key/value pair
  33435. */
  33436. forEach(callback: (key: string, val: T) => void): void;
  33437. /**
  33438. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33439. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33440. * Note that you can remove any element in this dictionary in the callback implementation
  33441. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33442. * @returns the first item
  33443. */
  33444. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33445. private _count;
  33446. private _data;
  33447. }
  33448. }
  33449. declare module "babylonjs/Collisions/collisionCoordinator" {
  33450. import { Nullable } from "babylonjs/types";
  33451. import { Scene } from "babylonjs/scene";
  33452. import { Vector3 } from "babylonjs/Maths/math.vector";
  33453. import { Collider } from "babylonjs/Collisions/collider";
  33454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33455. /** @hidden */
  33456. export interface ICollisionCoordinator {
  33457. createCollider(): Collider;
  33458. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33459. init(scene: Scene): void;
  33460. }
  33461. /** @hidden */
  33462. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33463. private _scene;
  33464. private _scaledPosition;
  33465. private _scaledVelocity;
  33466. private _finalPosition;
  33467. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33468. createCollider(): Collider;
  33469. init(scene: Scene): void;
  33470. private _collideWithWorld;
  33471. }
  33472. }
  33473. declare module "babylonjs/Inputs/scene.inputManager" {
  33474. import { Nullable } from "babylonjs/types";
  33475. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33476. import { Vector2 } from "babylonjs/Maths/math.vector";
  33477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33478. import { Scene } from "babylonjs/scene";
  33479. /**
  33480. * Class used to manage all inputs for the scene.
  33481. */
  33482. export class InputManager {
  33483. /** The distance in pixel that you have to move to prevent some events */
  33484. static DragMovementThreshold: number;
  33485. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33486. static LongPressDelay: number;
  33487. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33488. static DoubleClickDelay: number;
  33489. /** If you need to check double click without raising a single click at first click, enable this flag */
  33490. static ExclusiveDoubleClickMode: boolean;
  33491. private _wheelEventName;
  33492. private _onPointerMove;
  33493. private _onPointerDown;
  33494. private _onPointerUp;
  33495. private _initClickEvent;
  33496. private _initActionManager;
  33497. private _delayedSimpleClick;
  33498. private _delayedSimpleClickTimeout;
  33499. private _previousDelayedSimpleClickTimeout;
  33500. private _meshPickProceed;
  33501. private _previousButtonPressed;
  33502. private _currentPickResult;
  33503. private _previousPickResult;
  33504. private _totalPointersPressed;
  33505. private _doubleClickOccured;
  33506. private _pointerOverMesh;
  33507. private _pickedDownMesh;
  33508. private _pickedUpMesh;
  33509. private _pointerX;
  33510. private _pointerY;
  33511. private _unTranslatedPointerX;
  33512. private _unTranslatedPointerY;
  33513. private _startingPointerPosition;
  33514. private _previousStartingPointerPosition;
  33515. private _startingPointerTime;
  33516. private _previousStartingPointerTime;
  33517. private _pointerCaptures;
  33518. private _onKeyDown;
  33519. private _onKeyUp;
  33520. private _onCanvasFocusObserver;
  33521. private _onCanvasBlurObserver;
  33522. private _scene;
  33523. /**
  33524. * Creates a new InputManager
  33525. * @param scene defines the hosting scene
  33526. */
  33527. constructor(scene: Scene);
  33528. /**
  33529. * Gets the mesh that is currently under the pointer
  33530. */
  33531. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33532. /**
  33533. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33534. */
  33535. readonly unTranslatedPointer: Vector2;
  33536. /**
  33537. * Gets or sets the current on-screen X position of the pointer
  33538. */
  33539. pointerX: number;
  33540. /**
  33541. * Gets or sets the current on-screen Y position of the pointer
  33542. */
  33543. pointerY: number;
  33544. private _updatePointerPosition;
  33545. private _processPointerMove;
  33546. private _setRayOnPointerInfo;
  33547. private _checkPrePointerObservable;
  33548. /**
  33549. * Use this method to simulate a pointer move on a mesh
  33550. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33551. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33552. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33553. */
  33554. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33555. /**
  33556. * Use this method to simulate a pointer down on a mesh
  33557. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33558. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33559. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33560. */
  33561. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33562. private _processPointerDown;
  33563. /** @hidden */
  33564. _isPointerSwiping(): boolean;
  33565. /**
  33566. * Use this method to simulate a pointer up on a mesh
  33567. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33568. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33569. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33570. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33571. */
  33572. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33573. private _processPointerUp;
  33574. /**
  33575. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33576. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33577. * @returns true if the pointer was captured
  33578. */
  33579. isPointerCaptured(pointerId?: number): boolean;
  33580. /**
  33581. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33582. * @param attachUp defines if you want to attach events to pointerup
  33583. * @param attachDown defines if you want to attach events to pointerdown
  33584. * @param attachMove defines if you want to attach events to pointermove
  33585. */
  33586. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33587. /**
  33588. * Detaches all event handlers
  33589. */
  33590. detachControl(): void;
  33591. /**
  33592. * Force the value of meshUnderPointer
  33593. * @param mesh defines the mesh to use
  33594. */
  33595. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33596. /**
  33597. * Gets the mesh under the pointer
  33598. * @returns a Mesh or null if no mesh is under the pointer
  33599. */
  33600. getPointerOverMesh(): Nullable<AbstractMesh>;
  33601. }
  33602. }
  33603. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33604. /**
  33605. * Helper class used to generate session unique ID
  33606. */
  33607. export class UniqueIdGenerator {
  33608. private static _UniqueIdCounter;
  33609. /**
  33610. * Gets an unique (relatively to the current scene) Id
  33611. */
  33612. static readonly UniqueId: number;
  33613. }
  33614. }
  33615. declare module "babylonjs/Animations/animationGroup" {
  33616. import { Animatable } from "babylonjs/Animations/animatable";
  33617. import { Animation } from "babylonjs/Animations/animation";
  33618. import { Scene, IDisposable } from "babylonjs/scene";
  33619. import { Observable } from "babylonjs/Misc/observable";
  33620. import { Nullable } from "babylonjs/types";
  33621. import "babylonjs/Animations/animatable";
  33622. /**
  33623. * This class defines the direct association between an animation and a target
  33624. */
  33625. export class TargetedAnimation {
  33626. /**
  33627. * Animation to perform
  33628. */
  33629. animation: Animation;
  33630. /**
  33631. * Target to animate
  33632. */
  33633. target: any;
  33634. /**
  33635. * Serialize the object
  33636. * @returns the JSON object representing the current entity
  33637. */
  33638. serialize(): any;
  33639. }
  33640. /**
  33641. * Use this class to create coordinated animations on multiple targets
  33642. */
  33643. export class AnimationGroup implements IDisposable {
  33644. /** The name of the animation group */
  33645. name: string;
  33646. private _scene;
  33647. private _targetedAnimations;
  33648. private _animatables;
  33649. private _from;
  33650. private _to;
  33651. private _isStarted;
  33652. private _isPaused;
  33653. private _speedRatio;
  33654. private _loopAnimation;
  33655. /**
  33656. * Gets or sets the unique id of the node
  33657. */
  33658. uniqueId: number;
  33659. /**
  33660. * This observable will notify when one animation have ended
  33661. */
  33662. onAnimationEndObservable: Observable<TargetedAnimation>;
  33663. /**
  33664. * Observer raised when one animation loops
  33665. */
  33666. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33667. /**
  33668. * This observable will notify when all animations have ended.
  33669. */
  33670. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33671. /**
  33672. * This observable will notify when all animations have paused.
  33673. */
  33674. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33675. /**
  33676. * This observable will notify when all animations are playing.
  33677. */
  33678. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33679. /**
  33680. * Gets the first frame
  33681. */
  33682. readonly from: number;
  33683. /**
  33684. * Gets the last frame
  33685. */
  33686. readonly to: number;
  33687. /**
  33688. * Define if the animations are started
  33689. */
  33690. readonly isStarted: boolean;
  33691. /**
  33692. * Gets a value indicating that the current group is playing
  33693. */
  33694. readonly isPlaying: boolean;
  33695. /**
  33696. * Gets or sets the speed ratio to use for all animations
  33697. */
  33698. /**
  33699. * Gets or sets the speed ratio to use for all animations
  33700. */
  33701. speedRatio: number;
  33702. /**
  33703. * Gets or sets if all animations should loop or not
  33704. */
  33705. loopAnimation: boolean;
  33706. /**
  33707. * Gets the targeted animations for this animation group
  33708. */
  33709. readonly targetedAnimations: Array<TargetedAnimation>;
  33710. /**
  33711. * returning the list of animatables controlled by this animation group.
  33712. */
  33713. readonly animatables: Array<Animatable>;
  33714. /**
  33715. * Instantiates a new Animation Group.
  33716. * This helps managing several animations at once.
  33717. * @see http://doc.babylonjs.com/how_to/group
  33718. * @param name Defines the name of the group
  33719. * @param scene Defines the scene the group belongs to
  33720. */
  33721. constructor(
  33722. /** The name of the animation group */
  33723. name: string, scene?: Nullable<Scene>);
  33724. /**
  33725. * Add an animation (with its target) in the group
  33726. * @param animation defines the animation we want to add
  33727. * @param target defines the target of the animation
  33728. * @returns the TargetedAnimation object
  33729. */
  33730. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33731. /**
  33732. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33733. * It can add constant keys at begin or end
  33734. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33735. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33736. * @returns the animation group
  33737. */
  33738. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33739. /**
  33740. * Start all animations on given targets
  33741. * @param loop defines if animations must loop
  33742. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33743. * @param from defines the from key (optional)
  33744. * @param to defines the to key (optional)
  33745. * @returns the current animation group
  33746. */
  33747. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33748. /**
  33749. * Pause all animations
  33750. * @returns the animation group
  33751. */
  33752. pause(): AnimationGroup;
  33753. /**
  33754. * Play all animations to initial state
  33755. * This function will start() the animations if they were not started or will restart() them if they were paused
  33756. * @param loop defines if animations must loop
  33757. * @returns the animation group
  33758. */
  33759. play(loop?: boolean): AnimationGroup;
  33760. /**
  33761. * Reset all animations to initial state
  33762. * @returns the animation group
  33763. */
  33764. reset(): AnimationGroup;
  33765. /**
  33766. * Restart animations from key 0
  33767. * @returns the animation group
  33768. */
  33769. restart(): AnimationGroup;
  33770. /**
  33771. * Stop all animations
  33772. * @returns the animation group
  33773. */
  33774. stop(): AnimationGroup;
  33775. /**
  33776. * Set animation weight for all animatables
  33777. * @param weight defines the weight to use
  33778. * @return the animationGroup
  33779. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33780. */
  33781. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33782. /**
  33783. * Synchronize and normalize all animatables with a source animatable
  33784. * @param root defines the root animatable to synchronize with
  33785. * @return the animationGroup
  33786. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33787. */
  33788. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33789. /**
  33790. * Goes to a specific frame in this animation group
  33791. * @param frame the frame number to go to
  33792. * @return the animationGroup
  33793. */
  33794. goToFrame(frame: number): AnimationGroup;
  33795. /**
  33796. * Dispose all associated resources
  33797. */
  33798. dispose(): void;
  33799. private _checkAnimationGroupEnded;
  33800. /**
  33801. * Clone the current animation group and returns a copy
  33802. * @param newName defines the name of the new group
  33803. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33804. * @returns the new aniamtion group
  33805. */
  33806. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33807. /**
  33808. * Serializes the animationGroup to an object
  33809. * @returns Serialized object
  33810. */
  33811. serialize(): any;
  33812. /**
  33813. * Returns a new AnimationGroup object parsed from the source provided.
  33814. * @param parsedAnimationGroup defines the source
  33815. * @param scene defines the scene that will receive the animationGroup
  33816. * @returns a new AnimationGroup
  33817. */
  33818. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33819. /**
  33820. * Returns the string "AnimationGroup"
  33821. * @returns "AnimationGroup"
  33822. */
  33823. getClassName(): string;
  33824. /**
  33825. * Creates a detailled string about the object
  33826. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33827. * @returns a string representing the object
  33828. */
  33829. toString(fullDetails?: boolean): string;
  33830. }
  33831. }
  33832. declare module "babylonjs/scene" {
  33833. import { Nullable } from "babylonjs/types";
  33834. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33835. import { Observable } from "babylonjs/Misc/observable";
  33836. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33837. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33838. import { Geometry } from "babylonjs/Meshes/geometry";
  33839. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33840. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33842. import { Mesh } from "babylonjs/Meshes/mesh";
  33843. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33844. import { Bone } from "babylonjs/Bones/bone";
  33845. import { Skeleton } from "babylonjs/Bones/skeleton";
  33846. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33847. import { Camera } from "babylonjs/Cameras/camera";
  33848. import { AbstractScene } from "babylonjs/abstractScene";
  33849. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33850. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33851. import { Material } from "babylonjs/Materials/material";
  33852. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33853. import { Effect } from "babylonjs/Materials/effect";
  33854. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33855. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33856. import { Light } from "babylonjs/Lights/light";
  33857. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33858. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33859. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33860. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33861. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33862. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33863. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33864. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33865. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33866. import { Engine } from "babylonjs/Engines/engine";
  33867. import { Node } from "babylonjs/node";
  33868. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33869. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33870. import { WebRequest } from "babylonjs/Misc/webRequest";
  33871. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33872. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33873. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33874. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33875. import { Plane } from "babylonjs/Maths/math.plane";
  33876. import { Ray } from "babylonjs/Culling/ray";
  33877. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33878. import { Animation } from "babylonjs/Animations/animation";
  33879. import { Animatable } from "babylonjs/Animations/animatable";
  33880. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33881. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33882. import { Collider } from "babylonjs/Collisions/collider";
  33883. /**
  33884. * Define an interface for all classes that will hold resources
  33885. */
  33886. export interface IDisposable {
  33887. /**
  33888. * Releases all held resources
  33889. */
  33890. dispose(): void;
  33891. }
  33892. /** Interface defining initialization parameters for Scene class */
  33893. export interface SceneOptions {
  33894. /**
  33895. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33896. * It will improve performance when the number of geometries becomes important.
  33897. */
  33898. useGeometryUniqueIdsMap?: boolean;
  33899. /**
  33900. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33901. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33902. */
  33903. useMaterialMeshMap?: boolean;
  33904. /**
  33905. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33906. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33907. */
  33908. useClonedMeshhMap?: boolean;
  33909. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33910. virtual?: boolean;
  33911. }
  33912. /**
  33913. * Represents a scene to be rendered by the engine.
  33914. * @see http://doc.babylonjs.com/features/scene
  33915. */
  33916. export class Scene extends AbstractScene implements IAnimatable {
  33917. /** The fog is deactivated */
  33918. static readonly FOGMODE_NONE: number;
  33919. /** The fog density is following an exponential function */
  33920. static readonly FOGMODE_EXP: number;
  33921. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33922. static readonly FOGMODE_EXP2: number;
  33923. /** The fog density is following a linear function. */
  33924. static readonly FOGMODE_LINEAR: number;
  33925. /**
  33926. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33927. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33928. */
  33929. static MinDeltaTime: number;
  33930. /**
  33931. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33932. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33933. */
  33934. static MaxDeltaTime: number;
  33935. /**
  33936. * Factory used to create the default material.
  33937. * @param name The name of the material to create
  33938. * @param scene The scene to create the material for
  33939. * @returns The default material
  33940. */
  33941. static DefaultMaterialFactory(scene: Scene): Material;
  33942. /**
  33943. * Factory used to create the a collision coordinator.
  33944. * @returns The collision coordinator
  33945. */
  33946. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33947. /** @hidden */
  33948. _inputManager: InputManager;
  33949. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33950. cameraToUseForPointers: Nullable<Camera>;
  33951. /** @hidden */
  33952. readonly _isScene: boolean;
  33953. /**
  33954. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33955. */
  33956. autoClear: boolean;
  33957. /**
  33958. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33959. */
  33960. autoClearDepthAndStencil: boolean;
  33961. /**
  33962. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33963. */
  33964. clearColor: Color4;
  33965. /**
  33966. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33967. */
  33968. ambientColor: Color3;
  33969. /**
  33970. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33971. * It should only be one of the following (if not the default embedded one):
  33972. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33973. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33974. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33975. * The material properties need to be setup according to the type of texture in use.
  33976. */
  33977. environmentBRDFTexture: BaseTexture;
  33978. /** @hidden */
  33979. protected _environmentTexture: Nullable<BaseTexture>;
  33980. /**
  33981. * Texture used in all pbr material as the reflection texture.
  33982. * As in the majority of the scene they are the same (exception for multi room and so on),
  33983. * this is easier to reference from here than from all the materials.
  33984. */
  33985. /**
  33986. * Texture used in all pbr material as the reflection texture.
  33987. * As in the majority of the scene they are the same (exception for multi room and so on),
  33988. * this is easier to set here than in all the materials.
  33989. */
  33990. environmentTexture: Nullable<BaseTexture>;
  33991. /** @hidden */
  33992. protected _environmentIntensity: number;
  33993. /**
  33994. * Intensity of the environment in all pbr material.
  33995. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33996. * As in the majority of the scene they are the same (exception for multi room and so on),
  33997. * this is easier to reference from here than from all the materials.
  33998. */
  33999. /**
  34000. * Intensity of the environment in all pbr material.
  34001. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34002. * As in the majority of the scene they are the same (exception for multi room and so on),
  34003. * this is easier to set here than in all the materials.
  34004. */
  34005. environmentIntensity: number;
  34006. /** @hidden */
  34007. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34008. /**
  34009. * Default image processing configuration used either in the rendering
  34010. * Forward main pass or through the imageProcessingPostProcess if present.
  34011. * As in the majority of the scene they are the same (exception for multi camera),
  34012. * this is easier to reference from here than from all the materials and post process.
  34013. *
  34014. * No setter as we it is a shared configuration, you can set the values instead.
  34015. */
  34016. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34017. private _forceWireframe;
  34018. /**
  34019. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34020. */
  34021. forceWireframe: boolean;
  34022. private _forcePointsCloud;
  34023. /**
  34024. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34025. */
  34026. forcePointsCloud: boolean;
  34027. /**
  34028. * Gets or sets the active clipplane 1
  34029. */
  34030. clipPlane: Nullable<Plane>;
  34031. /**
  34032. * Gets or sets the active clipplane 2
  34033. */
  34034. clipPlane2: Nullable<Plane>;
  34035. /**
  34036. * Gets or sets the active clipplane 3
  34037. */
  34038. clipPlane3: Nullable<Plane>;
  34039. /**
  34040. * Gets or sets the active clipplane 4
  34041. */
  34042. clipPlane4: Nullable<Plane>;
  34043. /**
  34044. * Gets or sets a boolean indicating if animations are enabled
  34045. */
  34046. animationsEnabled: boolean;
  34047. private _animationPropertiesOverride;
  34048. /**
  34049. * Gets or sets the animation properties override
  34050. */
  34051. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34052. /**
  34053. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34054. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34055. */
  34056. useConstantAnimationDeltaTime: boolean;
  34057. /**
  34058. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34059. * Please note that it requires to run a ray cast through the scene on every frame
  34060. */
  34061. constantlyUpdateMeshUnderPointer: boolean;
  34062. /**
  34063. * Defines the HTML cursor to use when hovering over interactive elements
  34064. */
  34065. hoverCursor: string;
  34066. /**
  34067. * Defines the HTML default cursor to use (empty by default)
  34068. */
  34069. defaultCursor: string;
  34070. /**
  34071. * This is used to call preventDefault() on pointer down
  34072. * in order to block unwanted artifacts like system double clicks
  34073. */
  34074. preventDefaultOnPointerDown: boolean;
  34075. /**
  34076. * This is used to call preventDefault() on pointer up
  34077. * in order to block unwanted artifacts like system double clicks
  34078. */
  34079. preventDefaultOnPointerUp: boolean;
  34080. /**
  34081. * Gets or sets user defined metadata
  34082. */
  34083. metadata: any;
  34084. /**
  34085. * For internal use only. Please do not use.
  34086. */
  34087. reservedDataStore: any;
  34088. /**
  34089. * Gets the name of the plugin used to load this scene (null by default)
  34090. */
  34091. loadingPluginName: string;
  34092. /**
  34093. * Use this array to add regular expressions used to disable offline support for specific urls
  34094. */
  34095. disableOfflineSupportExceptionRules: RegExp[];
  34096. /**
  34097. * An event triggered when the scene is disposed.
  34098. */
  34099. onDisposeObservable: Observable<Scene>;
  34100. private _onDisposeObserver;
  34101. /** Sets a function to be executed when this scene is disposed. */
  34102. onDispose: () => void;
  34103. /**
  34104. * An event triggered before rendering the scene (right after animations and physics)
  34105. */
  34106. onBeforeRenderObservable: Observable<Scene>;
  34107. private _onBeforeRenderObserver;
  34108. /** Sets a function to be executed before rendering this scene */
  34109. beforeRender: Nullable<() => void>;
  34110. /**
  34111. * An event triggered after rendering the scene
  34112. */
  34113. onAfterRenderObservable: Observable<Scene>;
  34114. /**
  34115. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34116. */
  34117. onAfterRenderCameraObservable: Observable<Camera>;
  34118. private _onAfterRenderObserver;
  34119. /** Sets a function to be executed after rendering this scene */
  34120. afterRender: Nullable<() => void>;
  34121. /**
  34122. * An event triggered before animating the scene
  34123. */
  34124. onBeforeAnimationsObservable: Observable<Scene>;
  34125. /**
  34126. * An event triggered after animations processing
  34127. */
  34128. onAfterAnimationsObservable: Observable<Scene>;
  34129. /**
  34130. * An event triggered before draw calls are ready to be sent
  34131. */
  34132. onBeforeDrawPhaseObservable: Observable<Scene>;
  34133. /**
  34134. * An event triggered after draw calls have been sent
  34135. */
  34136. onAfterDrawPhaseObservable: Observable<Scene>;
  34137. /**
  34138. * An event triggered when the scene is ready
  34139. */
  34140. onReadyObservable: Observable<Scene>;
  34141. /**
  34142. * An event triggered before rendering a camera
  34143. */
  34144. onBeforeCameraRenderObservable: Observable<Camera>;
  34145. private _onBeforeCameraRenderObserver;
  34146. /** Sets a function to be executed before rendering a camera*/
  34147. beforeCameraRender: () => void;
  34148. /**
  34149. * An event triggered after rendering a camera
  34150. */
  34151. onAfterCameraRenderObservable: Observable<Camera>;
  34152. private _onAfterCameraRenderObserver;
  34153. /** Sets a function to be executed after rendering a camera*/
  34154. afterCameraRender: () => void;
  34155. /**
  34156. * An event triggered when active meshes evaluation is about to start
  34157. */
  34158. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34159. /**
  34160. * An event triggered when active meshes evaluation is done
  34161. */
  34162. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34163. /**
  34164. * An event triggered when particles rendering is about to start
  34165. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34166. */
  34167. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34168. /**
  34169. * An event triggered when particles rendering is done
  34170. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34171. */
  34172. onAfterParticlesRenderingObservable: Observable<Scene>;
  34173. /**
  34174. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34175. */
  34176. onDataLoadedObservable: Observable<Scene>;
  34177. /**
  34178. * An event triggered when a camera is created
  34179. */
  34180. onNewCameraAddedObservable: Observable<Camera>;
  34181. /**
  34182. * An event triggered when a camera is removed
  34183. */
  34184. onCameraRemovedObservable: Observable<Camera>;
  34185. /**
  34186. * An event triggered when a light is created
  34187. */
  34188. onNewLightAddedObservable: Observable<Light>;
  34189. /**
  34190. * An event triggered when a light is removed
  34191. */
  34192. onLightRemovedObservable: Observable<Light>;
  34193. /**
  34194. * An event triggered when a geometry is created
  34195. */
  34196. onNewGeometryAddedObservable: Observable<Geometry>;
  34197. /**
  34198. * An event triggered when a geometry is removed
  34199. */
  34200. onGeometryRemovedObservable: Observable<Geometry>;
  34201. /**
  34202. * An event triggered when a transform node is created
  34203. */
  34204. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34205. /**
  34206. * An event triggered when a transform node is removed
  34207. */
  34208. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34209. /**
  34210. * An event triggered when a mesh is created
  34211. */
  34212. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34213. /**
  34214. * An event triggered when a mesh is removed
  34215. */
  34216. onMeshRemovedObservable: Observable<AbstractMesh>;
  34217. /**
  34218. * An event triggered when a skeleton is created
  34219. */
  34220. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34221. /**
  34222. * An event triggered when a skeleton is removed
  34223. */
  34224. onSkeletonRemovedObservable: Observable<Skeleton>;
  34225. /**
  34226. * An event triggered when a material is created
  34227. */
  34228. onNewMaterialAddedObservable: Observable<Material>;
  34229. /**
  34230. * An event triggered when a material is removed
  34231. */
  34232. onMaterialRemovedObservable: Observable<Material>;
  34233. /**
  34234. * An event triggered when a texture is created
  34235. */
  34236. onNewTextureAddedObservable: Observable<BaseTexture>;
  34237. /**
  34238. * An event triggered when a texture is removed
  34239. */
  34240. onTextureRemovedObservable: Observable<BaseTexture>;
  34241. /**
  34242. * An event triggered when render targets are about to be rendered
  34243. * Can happen multiple times per frame.
  34244. */
  34245. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34246. /**
  34247. * An event triggered when render targets were rendered.
  34248. * Can happen multiple times per frame.
  34249. */
  34250. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34251. /**
  34252. * An event triggered before calculating deterministic simulation step
  34253. */
  34254. onBeforeStepObservable: Observable<Scene>;
  34255. /**
  34256. * An event triggered after calculating deterministic simulation step
  34257. */
  34258. onAfterStepObservable: Observable<Scene>;
  34259. /**
  34260. * An event triggered when the activeCamera property is updated
  34261. */
  34262. onActiveCameraChanged: Observable<Scene>;
  34263. /**
  34264. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34265. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34266. * 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)
  34267. */
  34268. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34269. /**
  34270. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34271. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34272. * 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)
  34273. */
  34274. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34275. /**
  34276. * This Observable will when a mesh has been imported into the scene.
  34277. */
  34278. onMeshImportedObservable: Observable<AbstractMesh>;
  34279. /**
  34280. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34281. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34282. */
  34283. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34284. /** @hidden */
  34285. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34286. /**
  34287. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34288. */
  34289. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34290. /**
  34291. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34292. */
  34293. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34294. /**
  34295. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34296. */
  34297. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34298. /** Callback called when a pointer move is detected */
  34299. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34300. /** Callback called when a pointer down is detected */
  34301. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34302. /** Callback called when a pointer up is detected */
  34303. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34304. /** Callback called when a pointer pick is detected */
  34305. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34306. /**
  34307. * 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).
  34308. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34309. */
  34310. onPrePointerObservable: Observable<PointerInfoPre>;
  34311. /**
  34312. * Observable event triggered each time an input event is received from the rendering canvas
  34313. */
  34314. onPointerObservable: Observable<PointerInfo>;
  34315. /**
  34316. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34317. */
  34318. readonly unTranslatedPointer: Vector2;
  34319. /**
  34320. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34321. */
  34322. static DragMovementThreshold: number;
  34323. /**
  34324. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34325. */
  34326. static LongPressDelay: number;
  34327. /**
  34328. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34329. */
  34330. static DoubleClickDelay: number;
  34331. /** If you need to check double click without raising a single click at first click, enable this flag */
  34332. static ExclusiveDoubleClickMode: boolean;
  34333. /** @hidden */
  34334. _mirroredCameraPosition: Nullable<Vector3>;
  34335. /**
  34336. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34337. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34338. */
  34339. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34340. /**
  34341. * Observable event triggered each time an keyboard event is received from the hosting window
  34342. */
  34343. onKeyboardObservable: Observable<KeyboardInfo>;
  34344. private _useRightHandedSystem;
  34345. /**
  34346. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34347. */
  34348. useRightHandedSystem: boolean;
  34349. private _timeAccumulator;
  34350. private _currentStepId;
  34351. private _currentInternalStep;
  34352. /**
  34353. * Sets the step Id used by deterministic lock step
  34354. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34355. * @param newStepId defines the step Id
  34356. */
  34357. setStepId(newStepId: number): void;
  34358. /**
  34359. * Gets the step Id used by deterministic lock step
  34360. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34361. * @returns the step Id
  34362. */
  34363. getStepId(): number;
  34364. /**
  34365. * Gets the internal step used by deterministic lock step
  34366. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34367. * @returns the internal step
  34368. */
  34369. getInternalStep(): number;
  34370. private _fogEnabled;
  34371. /**
  34372. * Gets or sets a boolean indicating if fog is enabled on this scene
  34373. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34374. * (Default is true)
  34375. */
  34376. fogEnabled: boolean;
  34377. private _fogMode;
  34378. /**
  34379. * Gets or sets the fog mode to use
  34380. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34381. * | mode | value |
  34382. * | --- | --- |
  34383. * | FOGMODE_NONE | 0 |
  34384. * | FOGMODE_EXP | 1 |
  34385. * | FOGMODE_EXP2 | 2 |
  34386. * | FOGMODE_LINEAR | 3 |
  34387. */
  34388. fogMode: number;
  34389. /**
  34390. * Gets or sets the fog color to use
  34391. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34392. * (Default is Color3(0.2, 0.2, 0.3))
  34393. */
  34394. fogColor: Color3;
  34395. /**
  34396. * Gets or sets the fog density to use
  34397. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34398. * (Default is 0.1)
  34399. */
  34400. fogDensity: number;
  34401. /**
  34402. * Gets or sets the fog start distance to use
  34403. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34404. * (Default is 0)
  34405. */
  34406. fogStart: number;
  34407. /**
  34408. * Gets or sets the fog end distance to use
  34409. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34410. * (Default is 1000)
  34411. */
  34412. fogEnd: number;
  34413. private _shadowsEnabled;
  34414. /**
  34415. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34416. */
  34417. shadowsEnabled: boolean;
  34418. private _lightsEnabled;
  34419. /**
  34420. * Gets or sets a boolean indicating if lights are enabled on this scene
  34421. */
  34422. lightsEnabled: boolean;
  34423. /** All of the active cameras added to this scene. */
  34424. activeCameras: Camera[];
  34425. /** @hidden */
  34426. _activeCamera: Nullable<Camera>;
  34427. /** Gets or sets the current active camera */
  34428. activeCamera: Nullable<Camera>;
  34429. private _defaultMaterial;
  34430. /** The default material used on meshes when no material is affected */
  34431. /** The default material used on meshes when no material is affected */
  34432. defaultMaterial: Material;
  34433. private _texturesEnabled;
  34434. /**
  34435. * Gets or sets a boolean indicating if textures are enabled on this scene
  34436. */
  34437. texturesEnabled: boolean;
  34438. /**
  34439. * Gets or sets a boolean indicating if particles are enabled on this scene
  34440. */
  34441. particlesEnabled: boolean;
  34442. /**
  34443. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34444. */
  34445. spritesEnabled: boolean;
  34446. private _skeletonsEnabled;
  34447. /**
  34448. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34449. */
  34450. skeletonsEnabled: boolean;
  34451. /**
  34452. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34453. */
  34454. lensFlaresEnabled: boolean;
  34455. /**
  34456. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34457. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34458. */
  34459. collisionsEnabled: boolean;
  34460. private _collisionCoordinator;
  34461. /** @hidden */
  34462. readonly collisionCoordinator: ICollisionCoordinator;
  34463. /**
  34464. * Defines the gravity applied to this scene (used only for collisions)
  34465. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34466. */
  34467. gravity: Vector3;
  34468. /**
  34469. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34470. */
  34471. postProcessesEnabled: boolean;
  34472. /**
  34473. * The list of postprocesses added to the scene
  34474. */
  34475. postProcesses: PostProcess[];
  34476. /**
  34477. * Gets the current postprocess manager
  34478. */
  34479. postProcessManager: PostProcessManager;
  34480. /**
  34481. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34482. */
  34483. renderTargetsEnabled: boolean;
  34484. /**
  34485. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34486. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34487. */
  34488. dumpNextRenderTargets: boolean;
  34489. /**
  34490. * The list of user defined render targets added to the scene
  34491. */
  34492. customRenderTargets: RenderTargetTexture[];
  34493. /**
  34494. * Defines if texture loading must be delayed
  34495. * If true, textures will only be loaded when they need to be rendered
  34496. */
  34497. useDelayedTextureLoading: boolean;
  34498. /**
  34499. * Gets the list of meshes imported to the scene through SceneLoader
  34500. */
  34501. importedMeshesFiles: String[];
  34502. /**
  34503. * Gets or sets a boolean indicating if probes are enabled on this scene
  34504. */
  34505. probesEnabled: boolean;
  34506. /**
  34507. * Gets or sets the current offline provider to use to store scene data
  34508. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34509. */
  34510. offlineProvider: IOfflineProvider;
  34511. /**
  34512. * Gets or sets the action manager associated with the scene
  34513. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34514. */
  34515. actionManager: AbstractActionManager;
  34516. private _meshesForIntersections;
  34517. /**
  34518. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34519. */
  34520. proceduralTexturesEnabled: boolean;
  34521. private _engine;
  34522. private _totalVertices;
  34523. /** @hidden */
  34524. _activeIndices: PerfCounter;
  34525. /** @hidden */
  34526. _activeParticles: PerfCounter;
  34527. /** @hidden */
  34528. _activeBones: PerfCounter;
  34529. private _animationRatio;
  34530. /** @hidden */
  34531. _animationTimeLast: number;
  34532. /** @hidden */
  34533. _animationTime: number;
  34534. /**
  34535. * Gets or sets a general scale for animation speed
  34536. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34537. */
  34538. animationTimeScale: number;
  34539. /** @hidden */
  34540. _cachedMaterial: Nullable<Material>;
  34541. /** @hidden */
  34542. _cachedEffect: Nullable<Effect>;
  34543. /** @hidden */
  34544. _cachedVisibility: Nullable<number>;
  34545. private _renderId;
  34546. private _frameId;
  34547. private _executeWhenReadyTimeoutId;
  34548. private _intermediateRendering;
  34549. private _viewUpdateFlag;
  34550. private _projectionUpdateFlag;
  34551. /** @hidden */
  34552. _toBeDisposed: Nullable<IDisposable>[];
  34553. private _activeRequests;
  34554. /** @hidden */
  34555. _pendingData: any[];
  34556. private _isDisposed;
  34557. /**
  34558. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34559. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34560. */
  34561. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34562. private _activeMeshes;
  34563. private _processedMaterials;
  34564. private _renderTargets;
  34565. /** @hidden */
  34566. _activeParticleSystems: SmartArray<IParticleSystem>;
  34567. private _activeSkeletons;
  34568. private _softwareSkinnedMeshes;
  34569. private _renderingManager;
  34570. /** @hidden */
  34571. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34572. private _transformMatrix;
  34573. private _sceneUbo;
  34574. /** @hidden */
  34575. _viewMatrix: Matrix;
  34576. private _projectionMatrix;
  34577. /** @hidden */
  34578. _forcedViewPosition: Nullable<Vector3>;
  34579. /** @hidden */
  34580. _frustumPlanes: Plane[];
  34581. /**
  34582. * Gets the list of frustum planes (built from the active camera)
  34583. */
  34584. readonly frustumPlanes: Plane[];
  34585. /**
  34586. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34587. * This is useful if there are more lights that the maximum simulteanous authorized
  34588. */
  34589. requireLightSorting: boolean;
  34590. /** @hidden */
  34591. readonly useMaterialMeshMap: boolean;
  34592. /** @hidden */
  34593. readonly useClonedMeshhMap: boolean;
  34594. private _externalData;
  34595. private _uid;
  34596. /**
  34597. * @hidden
  34598. * Backing store of defined scene components.
  34599. */
  34600. _components: ISceneComponent[];
  34601. /**
  34602. * @hidden
  34603. * Backing store of defined scene components.
  34604. */
  34605. _serializableComponents: ISceneSerializableComponent[];
  34606. /**
  34607. * List of components to register on the next registration step.
  34608. */
  34609. private _transientComponents;
  34610. /**
  34611. * Registers the transient components if needed.
  34612. */
  34613. private _registerTransientComponents;
  34614. /**
  34615. * @hidden
  34616. * Add a component to the scene.
  34617. * Note that the ccomponent could be registered on th next frame if this is called after
  34618. * the register component stage.
  34619. * @param component Defines the component to add to the scene
  34620. */
  34621. _addComponent(component: ISceneComponent): void;
  34622. /**
  34623. * @hidden
  34624. * Gets a component from the scene.
  34625. * @param name defines the name of the component to retrieve
  34626. * @returns the component or null if not present
  34627. */
  34628. _getComponent(name: string): Nullable<ISceneComponent>;
  34629. /**
  34630. * @hidden
  34631. * Defines the actions happening before camera updates.
  34632. */
  34633. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34634. /**
  34635. * @hidden
  34636. * Defines the actions happening before clear the canvas.
  34637. */
  34638. _beforeClearStage: Stage<SimpleStageAction>;
  34639. /**
  34640. * @hidden
  34641. * Defines the actions when collecting render targets for the frame.
  34642. */
  34643. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34644. /**
  34645. * @hidden
  34646. * Defines the actions happening for one camera in the frame.
  34647. */
  34648. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34649. /**
  34650. * @hidden
  34651. * Defines the actions happening during the per mesh ready checks.
  34652. */
  34653. _isReadyForMeshStage: Stage<MeshStageAction>;
  34654. /**
  34655. * @hidden
  34656. * Defines the actions happening before evaluate active mesh checks.
  34657. */
  34658. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34659. /**
  34660. * @hidden
  34661. * Defines the actions happening during the evaluate sub mesh checks.
  34662. */
  34663. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34664. /**
  34665. * @hidden
  34666. * Defines the actions happening during the active mesh stage.
  34667. */
  34668. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34669. /**
  34670. * @hidden
  34671. * Defines the actions happening during the per camera render target step.
  34672. */
  34673. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34674. /**
  34675. * @hidden
  34676. * Defines the actions happening just before the active camera is drawing.
  34677. */
  34678. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34679. /**
  34680. * @hidden
  34681. * Defines the actions happening just before a render target is drawing.
  34682. */
  34683. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34684. /**
  34685. * @hidden
  34686. * Defines the actions happening just before a rendering group is drawing.
  34687. */
  34688. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34689. /**
  34690. * @hidden
  34691. * Defines the actions happening just before a mesh is drawing.
  34692. */
  34693. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34694. /**
  34695. * @hidden
  34696. * Defines the actions happening just after a mesh has been drawn.
  34697. */
  34698. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34699. /**
  34700. * @hidden
  34701. * Defines the actions happening just after a rendering group has been drawn.
  34702. */
  34703. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34704. /**
  34705. * @hidden
  34706. * Defines the actions happening just after the active camera has been drawn.
  34707. */
  34708. _afterCameraDrawStage: Stage<CameraStageAction>;
  34709. /**
  34710. * @hidden
  34711. * Defines the actions happening just after a render target has been drawn.
  34712. */
  34713. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34714. /**
  34715. * @hidden
  34716. * Defines the actions happening just after rendering all cameras and computing intersections.
  34717. */
  34718. _afterRenderStage: Stage<SimpleStageAction>;
  34719. /**
  34720. * @hidden
  34721. * Defines the actions happening when a pointer move event happens.
  34722. */
  34723. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34724. /**
  34725. * @hidden
  34726. * Defines the actions happening when a pointer down event happens.
  34727. */
  34728. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34729. /**
  34730. * @hidden
  34731. * Defines the actions happening when a pointer up event happens.
  34732. */
  34733. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34734. /**
  34735. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34736. */
  34737. private geometriesByUniqueId;
  34738. /**
  34739. * Creates a new Scene
  34740. * @param engine defines the engine to use to render this scene
  34741. * @param options defines the scene options
  34742. */
  34743. constructor(engine: Engine, options?: SceneOptions);
  34744. /**
  34745. * Gets a string idenfifying the name of the class
  34746. * @returns "Scene" string
  34747. */
  34748. getClassName(): string;
  34749. private _defaultMeshCandidates;
  34750. /**
  34751. * @hidden
  34752. */
  34753. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34754. private _defaultSubMeshCandidates;
  34755. /**
  34756. * @hidden
  34757. */
  34758. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34759. /**
  34760. * Sets the default candidate providers for the scene.
  34761. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34762. * and getCollidingSubMeshCandidates to their default function
  34763. */
  34764. setDefaultCandidateProviders(): void;
  34765. /**
  34766. * Gets the mesh that is currently under the pointer
  34767. */
  34768. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34769. /**
  34770. * Gets or sets the current on-screen X position of the pointer
  34771. */
  34772. pointerX: number;
  34773. /**
  34774. * Gets or sets the current on-screen Y position of the pointer
  34775. */
  34776. pointerY: number;
  34777. /**
  34778. * Gets the cached material (ie. the latest rendered one)
  34779. * @returns the cached material
  34780. */
  34781. getCachedMaterial(): Nullable<Material>;
  34782. /**
  34783. * Gets the cached effect (ie. the latest rendered one)
  34784. * @returns the cached effect
  34785. */
  34786. getCachedEffect(): Nullable<Effect>;
  34787. /**
  34788. * Gets the cached visibility state (ie. the latest rendered one)
  34789. * @returns the cached visibility state
  34790. */
  34791. getCachedVisibility(): Nullable<number>;
  34792. /**
  34793. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34794. * @param material defines the current material
  34795. * @param effect defines the current effect
  34796. * @param visibility defines the current visibility state
  34797. * @returns true if one parameter is not cached
  34798. */
  34799. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34800. /**
  34801. * Gets the engine associated with the scene
  34802. * @returns an Engine
  34803. */
  34804. getEngine(): Engine;
  34805. /**
  34806. * Gets the total number of vertices rendered per frame
  34807. * @returns the total number of vertices rendered per frame
  34808. */
  34809. getTotalVertices(): number;
  34810. /**
  34811. * Gets the performance counter for total vertices
  34812. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34813. */
  34814. readonly totalVerticesPerfCounter: PerfCounter;
  34815. /**
  34816. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34817. * @returns the total number of active indices rendered per frame
  34818. */
  34819. getActiveIndices(): number;
  34820. /**
  34821. * Gets the performance counter for active indices
  34822. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34823. */
  34824. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34825. /**
  34826. * Gets the total number of active particles rendered per frame
  34827. * @returns the total number of active particles rendered per frame
  34828. */
  34829. getActiveParticles(): number;
  34830. /**
  34831. * Gets the performance counter for active particles
  34832. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34833. */
  34834. readonly activeParticlesPerfCounter: PerfCounter;
  34835. /**
  34836. * Gets the total number of active bones rendered per frame
  34837. * @returns the total number of active bones rendered per frame
  34838. */
  34839. getActiveBones(): number;
  34840. /**
  34841. * Gets the performance counter for active bones
  34842. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34843. */
  34844. readonly activeBonesPerfCounter: PerfCounter;
  34845. /**
  34846. * Gets the array of active meshes
  34847. * @returns an array of AbstractMesh
  34848. */
  34849. getActiveMeshes(): SmartArray<AbstractMesh>;
  34850. /**
  34851. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34852. * @returns a number
  34853. */
  34854. getAnimationRatio(): number;
  34855. /**
  34856. * Gets an unique Id for the current render phase
  34857. * @returns a number
  34858. */
  34859. getRenderId(): number;
  34860. /**
  34861. * Gets an unique Id for the current frame
  34862. * @returns a number
  34863. */
  34864. getFrameId(): number;
  34865. /** Call this function if you want to manually increment the render Id*/
  34866. incrementRenderId(): void;
  34867. private _createUbo;
  34868. /**
  34869. * Use this method to simulate a pointer move on a mesh
  34870. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34871. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34872. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34873. * @returns the current scene
  34874. */
  34875. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34876. /**
  34877. * Use this method to simulate a pointer down on a mesh
  34878. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34879. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34880. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34881. * @returns the current scene
  34882. */
  34883. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34884. /**
  34885. * Use this method to simulate a pointer up on a mesh
  34886. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34887. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34888. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34889. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34890. * @returns the current scene
  34891. */
  34892. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34893. /**
  34894. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34895. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34896. * @returns true if the pointer was captured
  34897. */
  34898. isPointerCaptured(pointerId?: number): boolean;
  34899. /**
  34900. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34901. * @param attachUp defines if you want to attach events to pointerup
  34902. * @param attachDown defines if you want to attach events to pointerdown
  34903. * @param attachMove defines if you want to attach events to pointermove
  34904. */
  34905. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34906. /** Detaches all event handlers*/
  34907. detachControl(): void;
  34908. /**
  34909. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34910. * Delay loaded resources are not taking in account
  34911. * @return true if all required resources are ready
  34912. */
  34913. isReady(): boolean;
  34914. /** Resets all cached information relative to material (including effect and visibility) */
  34915. resetCachedMaterial(): void;
  34916. /**
  34917. * Registers a function to be called before every frame render
  34918. * @param func defines the function to register
  34919. */
  34920. registerBeforeRender(func: () => void): void;
  34921. /**
  34922. * Unregisters a function called before every frame render
  34923. * @param func defines the function to unregister
  34924. */
  34925. unregisterBeforeRender(func: () => void): void;
  34926. /**
  34927. * Registers a function to be called after every frame render
  34928. * @param func defines the function to register
  34929. */
  34930. registerAfterRender(func: () => void): void;
  34931. /**
  34932. * Unregisters a function called after every frame render
  34933. * @param func defines the function to unregister
  34934. */
  34935. unregisterAfterRender(func: () => void): void;
  34936. private _executeOnceBeforeRender;
  34937. /**
  34938. * The provided function will run before render once and will be disposed afterwards.
  34939. * A timeout delay can be provided so that the function will be executed in N ms.
  34940. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34941. * @param func The function to be executed.
  34942. * @param timeout optional delay in ms
  34943. */
  34944. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34945. /** @hidden */
  34946. _addPendingData(data: any): void;
  34947. /** @hidden */
  34948. _removePendingData(data: any): void;
  34949. /**
  34950. * Returns the number of items waiting to be loaded
  34951. * @returns the number of items waiting to be loaded
  34952. */
  34953. getWaitingItemsCount(): number;
  34954. /**
  34955. * Returns a boolean indicating if the scene is still loading data
  34956. */
  34957. readonly isLoading: boolean;
  34958. /**
  34959. * Registers a function to be executed when the scene is ready
  34960. * @param {Function} func - the function to be executed
  34961. */
  34962. executeWhenReady(func: () => void): void;
  34963. /**
  34964. * Returns a promise that resolves when the scene is ready
  34965. * @returns A promise that resolves when the scene is ready
  34966. */
  34967. whenReadyAsync(): Promise<void>;
  34968. /** @hidden */
  34969. _checkIsReady(): void;
  34970. /**
  34971. * Gets all animatable attached to the scene
  34972. */
  34973. readonly animatables: Animatable[];
  34974. /**
  34975. * Resets the last animation time frame.
  34976. * Useful to override when animations start running when loading a scene for the first time.
  34977. */
  34978. resetLastAnimationTimeFrame(): void;
  34979. /**
  34980. * Gets the current view matrix
  34981. * @returns a Matrix
  34982. */
  34983. getViewMatrix(): Matrix;
  34984. /**
  34985. * Gets the current projection matrix
  34986. * @returns a Matrix
  34987. */
  34988. getProjectionMatrix(): Matrix;
  34989. /**
  34990. * Gets the current transform matrix
  34991. * @returns a Matrix made of View * Projection
  34992. */
  34993. getTransformMatrix(): Matrix;
  34994. /**
  34995. * Sets the current transform matrix
  34996. * @param viewL defines the View matrix to use
  34997. * @param projectionL defines the Projection matrix to use
  34998. * @param viewR defines the right View matrix to use (if provided)
  34999. * @param projectionR defines the right Projection matrix to use (if provided)
  35000. */
  35001. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35002. /**
  35003. * Gets the uniform buffer used to store scene data
  35004. * @returns a UniformBuffer
  35005. */
  35006. getSceneUniformBuffer(): UniformBuffer;
  35007. /**
  35008. * Gets an unique (relatively to the current scene) Id
  35009. * @returns an unique number for the scene
  35010. */
  35011. getUniqueId(): number;
  35012. /**
  35013. * Add a mesh to the list of scene's meshes
  35014. * @param newMesh defines the mesh to add
  35015. * @param recursive if all child meshes should also be added to the scene
  35016. */
  35017. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35018. /**
  35019. * Remove a mesh for the list of scene's meshes
  35020. * @param toRemove defines the mesh to remove
  35021. * @param recursive if all child meshes should also be removed from the scene
  35022. * @returns the index where the mesh was in the mesh list
  35023. */
  35024. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35025. /**
  35026. * Add a transform node to the list of scene's transform nodes
  35027. * @param newTransformNode defines the transform node to add
  35028. */
  35029. addTransformNode(newTransformNode: TransformNode): void;
  35030. /**
  35031. * Remove a transform node for the list of scene's transform nodes
  35032. * @param toRemove defines the transform node to remove
  35033. * @returns the index where the transform node was in the transform node list
  35034. */
  35035. removeTransformNode(toRemove: TransformNode): number;
  35036. /**
  35037. * Remove a skeleton for the list of scene's skeletons
  35038. * @param toRemove defines the skeleton to remove
  35039. * @returns the index where the skeleton was in the skeleton list
  35040. */
  35041. removeSkeleton(toRemove: Skeleton): number;
  35042. /**
  35043. * Remove a morph target for the list of scene's morph targets
  35044. * @param toRemove defines the morph target to remove
  35045. * @returns the index where the morph target was in the morph target list
  35046. */
  35047. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35048. /**
  35049. * Remove a light for the list of scene's lights
  35050. * @param toRemove defines the light to remove
  35051. * @returns the index where the light was in the light list
  35052. */
  35053. removeLight(toRemove: Light): number;
  35054. /**
  35055. * Remove a camera for the list of scene's cameras
  35056. * @param toRemove defines the camera to remove
  35057. * @returns the index where the camera was in the camera list
  35058. */
  35059. removeCamera(toRemove: Camera): number;
  35060. /**
  35061. * Remove a particle system for the list of scene's particle systems
  35062. * @param toRemove defines the particle system to remove
  35063. * @returns the index where the particle system was in the particle system list
  35064. */
  35065. removeParticleSystem(toRemove: IParticleSystem): number;
  35066. /**
  35067. * Remove a animation for the list of scene's animations
  35068. * @param toRemove defines the animation to remove
  35069. * @returns the index where the animation was in the animation list
  35070. */
  35071. removeAnimation(toRemove: Animation): number;
  35072. /**
  35073. * Will stop the animation of the given target
  35074. * @param target - the target
  35075. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35076. * @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)
  35077. */
  35078. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35079. /**
  35080. * Removes the given animation group from this scene.
  35081. * @param toRemove The animation group to remove
  35082. * @returns The index of the removed animation group
  35083. */
  35084. removeAnimationGroup(toRemove: AnimationGroup): number;
  35085. /**
  35086. * Removes the given multi-material from this scene.
  35087. * @param toRemove The multi-material to remove
  35088. * @returns The index of the removed multi-material
  35089. */
  35090. removeMultiMaterial(toRemove: MultiMaterial): number;
  35091. /**
  35092. * Removes the given material from this scene.
  35093. * @param toRemove The material to remove
  35094. * @returns The index of the removed material
  35095. */
  35096. removeMaterial(toRemove: Material): number;
  35097. /**
  35098. * Removes the given action manager from this scene.
  35099. * @param toRemove The action manager to remove
  35100. * @returns The index of the removed action manager
  35101. */
  35102. removeActionManager(toRemove: AbstractActionManager): number;
  35103. /**
  35104. * Removes the given texture from this scene.
  35105. * @param toRemove The texture to remove
  35106. * @returns The index of the removed texture
  35107. */
  35108. removeTexture(toRemove: BaseTexture): number;
  35109. /**
  35110. * Adds the given light to this scene
  35111. * @param newLight The light to add
  35112. */
  35113. addLight(newLight: Light): void;
  35114. /**
  35115. * Sorts the list list based on light priorities
  35116. */
  35117. sortLightsByPriority(): void;
  35118. /**
  35119. * Adds the given camera to this scene
  35120. * @param newCamera The camera to add
  35121. */
  35122. addCamera(newCamera: Camera): void;
  35123. /**
  35124. * Adds the given skeleton to this scene
  35125. * @param newSkeleton The skeleton to add
  35126. */
  35127. addSkeleton(newSkeleton: Skeleton): void;
  35128. /**
  35129. * Adds the given particle system to this scene
  35130. * @param newParticleSystem The particle system to add
  35131. */
  35132. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35133. /**
  35134. * Adds the given animation to this scene
  35135. * @param newAnimation The animation to add
  35136. */
  35137. addAnimation(newAnimation: Animation): void;
  35138. /**
  35139. * Adds the given animation group to this scene.
  35140. * @param newAnimationGroup The animation group to add
  35141. */
  35142. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35143. /**
  35144. * Adds the given multi-material to this scene
  35145. * @param newMultiMaterial The multi-material to add
  35146. */
  35147. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35148. /**
  35149. * Adds the given material to this scene
  35150. * @param newMaterial The material to add
  35151. */
  35152. addMaterial(newMaterial: Material): void;
  35153. /**
  35154. * Adds the given morph target to this scene
  35155. * @param newMorphTargetManager The morph target to add
  35156. */
  35157. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35158. /**
  35159. * Adds the given geometry to this scene
  35160. * @param newGeometry The geometry to add
  35161. */
  35162. addGeometry(newGeometry: Geometry): void;
  35163. /**
  35164. * Adds the given action manager to this scene
  35165. * @param newActionManager The action manager to add
  35166. */
  35167. addActionManager(newActionManager: AbstractActionManager): void;
  35168. /**
  35169. * Adds the given texture to this scene.
  35170. * @param newTexture The texture to add
  35171. */
  35172. addTexture(newTexture: BaseTexture): void;
  35173. /**
  35174. * Switch active camera
  35175. * @param newCamera defines the new active camera
  35176. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35177. */
  35178. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35179. /**
  35180. * sets the active camera of the scene using its ID
  35181. * @param id defines the camera's ID
  35182. * @return the new active camera or null if none found.
  35183. */
  35184. setActiveCameraByID(id: string): Nullable<Camera>;
  35185. /**
  35186. * sets the active camera of the scene using its name
  35187. * @param name defines the camera's name
  35188. * @returns the new active camera or null if none found.
  35189. */
  35190. setActiveCameraByName(name: string): Nullable<Camera>;
  35191. /**
  35192. * get an animation group using its name
  35193. * @param name defines the material's name
  35194. * @return the animation group or null if none found.
  35195. */
  35196. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35197. /**
  35198. * Get a material using its unique id
  35199. * @param uniqueId defines the material's unique id
  35200. * @return the material or null if none found.
  35201. */
  35202. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35203. /**
  35204. * get a material using its id
  35205. * @param id defines the material's ID
  35206. * @return the material or null if none found.
  35207. */
  35208. getMaterialByID(id: string): Nullable<Material>;
  35209. /**
  35210. * Gets a the last added material using a given id
  35211. * @param id defines the material's ID
  35212. * @return the last material with the given id or null if none found.
  35213. */
  35214. getLastMaterialByID(id: string): Nullable<Material>;
  35215. /**
  35216. * Gets a material using its name
  35217. * @param name defines the material's name
  35218. * @return the material or null if none found.
  35219. */
  35220. getMaterialByName(name: string): Nullable<Material>;
  35221. /**
  35222. * Get a texture using its unique id
  35223. * @param uniqueId defines the texture's unique id
  35224. * @return the texture or null if none found.
  35225. */
  35226. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35227. /**
  35228. * Gets a camera using its id
  35229. * @param id defines the id to look for
  35230. * @returns the camera or null if not found
  35231. */
  35232. getCameraByID(id: string): Nullable<Camera>;
  35233. /**
  35234. * Gets a camera using its unique id
  35235. * @param uniqueId defines the unique id to look for
  35236. * @returns the camera or null if not found
  35237. */
  35238. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35239. /**
  35240. * Gets a camera using its name
  35241. * @param name defines the camera's name
  35242. * @return the camera or null if none found.
  35243. */
  35244. getCameraByName(name: string): Nullable<Camera>;
  35245. /**
  35246. * Gets a bone using its id
  35247. * @param id defines the bone's id
  35248. * @return the bone or null if not found
  35249. */
  35250. getBoneByID(id: string): Nullable<Bone>;
  35251. /**
  35252. * Gets a bone using its id
  35253. * @param name defines the bone's name
  35254. * @return the bone or null if not found
  35255. */
  35256. getBoneByName(name: string): Nullable<Bone>;
  35257. /**
  35258. * Gets a light node using its name
  35259. * @param name defines the the light's name
  35260. * @return the light or null if none found.
  35261. */
  35262. getLightByName(name: string): Nullable<Light>;
  35263. /**
  35264. * Gets a light node using its id
  35265. * @param id defines the light's id
  35266. * @return the light or null if none found.
  35267. */
  35268. getLightByID(id: string): Nullable<Light>;
  35269. /**
  35270. * Gets a light node using its scene-generated unique ID
  35271. * @param uniqueId defines the light's unique id
  35272. * @return the light or null if none found.
  35273. */
  35274. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35275. /**
  35276. * Gets a particle system by id
  35277. * @param id defines the particle system id
  35278. * @return the corresponding system or null if none found
  35279. */
  35280. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35281. /**
  35282. * Gets a geometry using its ID
  35283. * @param id defines the geometry's id
  35284. * @return the geometry or null if none found.
  35285. */
  35286. getGeometryByID(id: string): Nullable<Geometry>;
  35287. private _getGeometryByUniqueID;
  35288. /**
  35289. * Add a new geometry to this scene
  35290. * @param geometry defines the geometry to be added to the scene.
  35291. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35292. * @return a boolean defining if the geometry was added or not
  35293. */
  35294. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35295. /**
  35296. * Removes an existing geometry
  35297. * @param geometry defines the geometry to be removed from the scene
  35298. * @return a boolean defining if the geometry was removed or not
  35299. */
  35300. removeGeometry(geometry: Geometry): boolean;
  35301. /**
  35302. * Gets the list of geometries attached to the scene
  35303. * @returns an array of Geometry
  35304. */
  35305. getGeometries(): Geometry[];
  35306. /**
  35307. * Gets the first added mesh found of a given ID
  35308. * @param id defines the id to search for
  35309. * @return the mesh found or null if not found at all
  35310. */
  35311. getMeshByID(id: string): Nullable<AbstractMesh>;
  35312. /**
  35313. * Gets a list of meshes using their id
  35314. * @param id defines the id to search for
  35315. * @returns a list of meshes
  35316. */
  35317. getMeshesByID(id: string): Array<AbstractMesh>;
  35318. /**
  35319. * Gets the first added transform node found of a given ID
  35320. * @param id defines the id to search for
  35321. * @return the found transform node or null if not found at all.
  35322. */
  35323. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35324. /**
  35325. * Gets a transform node with its auto-generated unique id
  35326. * @param uniqueId efines the unique id to search for
  35327. * @return the found transform node or null if not found at all.
  35328. */
  35329. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35330. /**
  35331. * Gets a list of transform nodes using their id
  35332. * @param id defines the id to search for
  35333. * @returns a list of transform nodes
  35334. */
  35335. getTransformNodesByID(id: string): Array<TransformNode>;
  35336. /**
  35337. * Gets a mesh with its auto-generated unique id
  35338. * @param uniqueId defines the unique id to search for
  35339. * @return the found mesh or null if not found at all.
  35340. */
  35341. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35342. /**
  35343. * Gets a the last added mesh using a given id
  35344. * @param id defines the id to search for
  35345. * @return the found mesh or null if not found at all.
  35346. */
  35347. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35348. /**
  35349. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35350. * @param id defines the id to search for
  35351. * @return the found node or null if not found at all
  35352. */
  35353. getLastEntryByID(id: string): Nullable<Node>;
  35354. /**
  35355. * Gets a node (Mesh, Camera, Light) using a given id
  35356. * @param id defines the id to search for
  35357. * @return the found node or null if not found at all
  35358. */
  35359. getNodeByID(id: string): Nullable<Node>;
  35360. /**
  35361. * Gets a node (Mesh, Camera, Light) using a given name
  35362. * @param name defines the name to search for
  35363. * @return the found node or null if not found at all.
  35364. */
  35365. getNodeByName(name: string): Nullable<Node>;
  35366. /**
  35367. * Gets a mesh using a given name
  35368. * @param name defines the name to search for
  35369. * @return the found mesh or null if not found at all.
  35370. */
  35371. getMeshByName(name: string): Nullable<AbstractMesh>;
  35372. /**
  35373. * Gets a transform node using a given name
  35374. * @param name defines the name to search for
  35375. * @return the found transform node or null if not found at all.
  35376. */
  35377. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35378. /**
  35379. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35380. * @param id defines the id to search for
  35381. * @return the found skeleton or null if not found at all.
  35382. */
  35383. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35384. /**
  35385. * Gets a skeleton using a given auto generated unique id
  35386. * @param uniqueId defines the unique id to search for
  35387. * @return the found skeleton or null if not found at all.
  35388. */
  35389. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35390. /**
  35391. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35392. * @param id defines the id to search for
  35393. * @return the found skeleton or null if not found at all.
  35394. */
  35395. getSkeletonById(id: string): Nullable<Skeleton>;
  35396. /**
  35397. * Gets a skeleton using a given name
  35398. * @param name defines the name to search for
  35399. * @return the found skeleton or null if not found at all.
  35400. */
  35401. getSkeletonByName(name: string): Nullable<Skeleton>;
  35402. /**
  35403. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35404. * @param id defines the id to search for
  35405. * @return the found morph target manager or null if not found at all.
  35406. */
  35407. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35408. /**
  35409. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35410. * @param id defines the id to search for
  35411. * @return the found morph target or null if not found at all.
  35412. */
  35413. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35414. /**
  35415. * Gets a boolean indicating if the given mesh is active
  35416. * @param mesh defines the mesh to look for
  35417. * @returns true if the mesh is in the active list
  35418. */
  35419. isActiveMesh(mesh: AbstractMesh): boolean;
  35420. /**
  35421. * Return a unique id as a string which can serve as an identifier for the scene
  35422. */
  35423. readonly uid: string;
  35424. /**
  35425. * Add an externaly attached data from its key.
  35426. * This method call will fail and return false, if such key already exists.
  35427. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35428. * @param key the unique key that identifies the data
  35429. * @param data the data object to associate to the key for this Engine instance
  35430. * @return true if no such key were already present and the data was added successfully, false otherwise
  35431. */
  35432. addExternalData<T>(key: string, data: T): boolean;
  35433. /**
  35434. * Get an externaly attached data from its key
  35435. * @param key the unique key that identifies the data
  35436. * @return the associated data, if present (can be null), or undefined if not present
  35437. */
  35438. getExternalData<T>(key: string): Nullable<T>;
  35439. /**
  35440. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35441. * @param key the unique key that identifies the data
  35442. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35443. * @return the associated data, can be null if the factory returned null.
  35444. */
  35445. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35446. /**
  35447. * Remove an externaly attached data from the Engine instance
  35448. * @param key the unique key that identifies the data
  35449. * @return true if the data was successfully removed, false if it doesn't exist
  35450. */
  35451. removeExternalData(key: string): boolean;
  35452. private _evaluateSubMesh;
  35453. /**
  35454. * Clear the processed materials smart array preventing retention point in material dispose.
  35455. */
  35456. freeProcessedMaterials(): void;
  35457. private _preventFreeActiveMeshesAndRenderingGroups;
  35458. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35459. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35460. * when disposing several meshes in a row or a hierarchy of meshes.
  35461. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35462. */
  35463. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35464. /**
  35465. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35466. */
  35467. freeActiveMeshes(): void;
  35468. /**
  35469. * Clear the info related to rendering groups preventing retention points during dispose.
  35470. */
  35471. freeRenderingGroups(): void;
  35472. /** @hidden */
  35473. _isInIntermediateRendering(): boolean;
  35474. /**
  35475. * Lambda returning the list of potentially active meshes.
  35476. */
  35477. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35478. /**
  35479. * Lambda returning the list of potentially active sub meshes.
  35480. */
  35481. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35482. /**
  35483. * Lambda returning the list of potentially intersecting sub meshes.
  35484. */
  35485. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35486. /**
  35487. * Lambda returning the list of potentially colliding sub meshes.
  35488. */
  35489. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35490. private _activeMeshesFrozen;
  35491. /**
  35492. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35493. * @returns the current scene
  35494. */
  35495. freezeActiveMeshes(): Scene;
  35496. /**
  35497. * Use this function to restart evaluating active meshes on every frame
  35498. * @returns the current scene
  35499. */
  35500. unfreezeActiveMeshes(): Scene;
  35501. private _evaluateActiveMeshes;
  35502. private _activeMesh;
  35503. /**
  35504. * Update the transform matrix to update from the current active camera
  35505. * @param force defines a boolean used to force the update even if cache is up to date
  35506. */
  35507. updateTransformMatrix(force?: boolean): void;
  35508. private _bindFrameBuffer;
  35509. /** @hidden */
  35510. _allowPostProcessClearColor: boolean;
  35511. /** @hidden */
  35512. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35513. private _processSubCameras;
  35514. private _checkIntersections;
  35515. /** @hidden */
  35516. _advancePhysicsEngineStep(step: number): void;
  35517. /**
  35518. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35519. */
  35520. getDeterministicFrameTime: () => number;
  35521. /** @hidden */
  35522. _animate(): void;
  35523. /** Execute all animations (for a frame) */
  35524. animate(): void;
  35525. /**
  35526. * Render the scene
  35527. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35528. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35529. */
  35530. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35531. /**
  35532. * Freeze all materials
  35533. * A frozen material will not be updatable but should be faster to render
  35534. */
  35535. freezeMaterials(): void;
  35536. /**
  35537. * Unfreeze all materials
  35538. * A frozen material will not be updatable but should be faster to render
  35539. */
  35540. unfreezeMaterials(): void;
  35541. /**
  35542. * Releases all held ressources
  35543. */
  35544. dispose(): void;
  35545. /**
  35546. * Gets if the scene is already disposed
  35547. */
  35548. readonly isDisposed: boolean;
  35549. /**
  35550. * Call this function to reduce memory footprint of the scene.
  35551. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35552. */
  35553. clearCachedVertexData(): void;
  35554. /**
  35555. * This function will remove the local cached buffer data from texture.
  35556. * It will save memory but will prevent the texture from being rebuilt
  35557. */
  35558. cleanCachedTextureBuffer(): void;
  35559. /**
  35560. * Get the world extend vectors with an optional filter
  35561. *
  35562. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35563. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35564. */
  35565. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35566. min: Vector3;
  35567. max: Vector3;
  35568. };
  35569. /**
  35570. * Creates a ray that can be used to pick in the scene
  35571. * @param x defines the x coordinate of the origin (on-screen)
  35572. * @param y defines the y coordinate of the origin (on-screen)
  35573. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35574. * @param camera defines the camera to use for the picking
  35575. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35576. * @returns a Ray
  35577. */
  35578. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35579. /**
  35580. * Creates a ray that can be used to pick in the scene
  35581. * @param x defines the x coordinate of the origin (on-screen)
  35582. * @param y defines the y coordinate of the origin (on-screen)
  35583. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35584. * @param result defines the ray where to store the picking ray
  35585. * @param camera defines the camera to use for the picking
  35586. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35587. * @returns the current scene
  35588. */
  35589. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35590. /**
  35591. * Creates a ray that can be used to pick in the scene
  35592. * @param x defines the x coordinate of the origin (on-screen)
  35593. * @param y defines the y coordinate of the origin (on-screen)
  35594. * @param camera defines the camera to use for the picking
  35595. * @returns a Ray
  35596. */
  35597. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35598. /**
  35599. * Creates a ray that can be used to pick in the scene
  35600. * @param x defines the x coordinate of the origin (on-screen)
  35601. * @param y defines the y coordinate of the origin (on-screen)
  35602. * @param result defines the ray where to store the picking ray
  35603. * @param camera defines the camera to use for the picking
  35604. * @returns the current scene
  35605. */
  35606. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35607. /** Launch a ray to try to pick a mesh in the scene
  35608. * @param x position on screen
  35609. * @param y position on screen
  35610. * @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
  35611. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35612. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35613. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35614. * @returns a PickingInfo
  35615. */
  35616. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35617. /** Use the given ray to pick a mesh in the scene
  35618. * @param ray The ray to use to pick meshes
  35619. * @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
  35620. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35621. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35622. * @returns a PickingInfo
  35623. */
  35624. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35625. /**
  35626. * Launch a ray to try to pick a mesh in the scene
  35627. * @param x X position on screen
  35628. * @param y Y position on screen
  35629. * @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
  35630. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35631. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35632. * @returns an array of PickingInfo
  35633. */
  35634. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35635. /**
  35636. * Launch a ray to try to pick a mesh in the scene
  35637. * @param ray Ray to use
  35638. * @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
  35639. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35640. * @returns an array of PickingInfo
  35641. */
  35642. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35643. /**
  35644. * Force the value of meshUnderPointer
  35645. * @param mesh defines the mesh to use
  35646. */
  35647. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35648. /**
  35649. * Gets the mesh under the pointer
  35650. * @returns a Mesh or null if no mesh is under the pointer
  35651. */
  35652. getPointerOverMesh(): Nullable<AbstractMesh>;
  35653. /** @hidden */
  35654. _rebuildGeometries(): void;
  35655. /** @hidden */
  35656. _rebuildTextures(): void;
  35657. private _getByTags;
  35658. /**
  35659. * Get a list of meshes by tags
  35660. * @param tagsQuery defines the tags query to use
  35661. * @param forEach defines a predicate used to filter results
  35662. * @returns an array of Mesh
  35663. */
  35664. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35665. /**
  35666. * Get a list of cameras by tags
  35667. * @param tagsQuery defines the tags query to use
  35668. * @param forEach defines a predicate used to filter results
  35669. * @returns an array of Camera
  35670. */
  35671. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35672. /**
  35673. * Get a list of lights by tags
  35674. * @param tagsQuery defines the tags query to use
  35675. * @param forEach defines a predicate used to filter results
  35676. * @returns an array of Light
  35677. */
  35678. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35679. /**
  35680. * Get a list of materials by tags
  35681. * @param tagsQuery defines the tags query to use
  35682. * @param forEach defines a predicate used to filter results
  35683. * @returns an array of Material
  35684. */
  35685. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35686. /**
  35687. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35688. * This allowed control for front to back rendering or reversly depending of the special needs.
  35689. *
  35690. * @param renderingGroupId The rendering group id corresponding to its index
  35691. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35692. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35693. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35694. */
  35695. 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;
  35696. /**
  35697. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35698. *
  35699. * @param renderingGroupId The rendering group id corresponding to its index
  35700. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35701. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35702. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35703. */
  35704. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35705. /**
  35706. * Gets the current auto clear configuration for one rendering group of the rendering
  35707. * manager.
  35708. * @param index the rendering group index to get the information for
  35709. * @returns The auto clear setup for the requested rendering group
  35710. */
  35711. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35712. private _blockMaterialDirtyMechanism;
  35713. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35714. blockMaterialDirtyMechanism: boolean;
  35715. /**
  35716. * Will flag all materials as dirty to trigger new shader compilation
  35717. * @param flag defines the flag used to specify which material part must be marked as dirty
  35718. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35719. */
  35720. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35721. /** @hidden */
  35722. _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;
  35723. /** @hidden */
  35724. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35725. }
  35726. }
  35727. declare module "babylonjs/assetContainer" {
  35728. import { AbstractScene } from "babylonjs/abstractScene";
  35729. import { Scene } from "babylonjs/scene";
  35730. import { Mesh } from "babylonjs/Meshes/mesh";
  35731. /**
  35732. * Set of assets to keep when moving a scene into an asset container.
  35733. */
  35734. export class KeepAssets extends AbstractScene {
  35735. }
  35736. /**
  35737. * Container with a set of assets that can be added or removed from a scene.
  35738. */
  35739. export class AssetContainer extends AbstractScene {
  35740. /**
  35741. * The scene the AssetContainer belongs to.
  35742. */
  35743. scene: Scene;
  35744. /**
  35745. * Instantiates an AssetContainer.
  35746. * @param scene The scene the AssetContainer belongs to.
  35747. */
  35748. constructor(scene: Scene);
  35749. /**
  35750. * Adds all the assets from the container to the scene.
  35751. */
  35752. addAllToScene(): void;
  35753. /**
  35754. * Removes all the assets in the container from the scene
  35755. */
  35756. removeAllFromScene(): void;
  35757. /**
  35758. * Disposes all the assets in the container
  35759. */
  35760. dispose(): void;
  35761. private _moveAssets;
  35762. /**
  35763. * Removes all the assets contained in the scene and adds them to the container.
  35764. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35765. */
  35766. moveAllFromScene(keepAssets?: KeepAssets): void;
  35767. /**
  35768. * 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.
  35769. * @returns the root mesh
  35770. */
  35771. createRootMesh(): Mesh;
  35772. }
  35773. }
  35774. declare module "babylonjs/abstractScene" {
  35775. import { Scene } from "babylonjs/scene";
  35776. import { Nullable } from "babylonjs/types";
  35777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35778. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35779. import { Geometry } from "babylonjs/Meshes/geometry";
  35780. import { Skeleton } from "babylonjs/Bones/skeleton";
  35781. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35782. import { AssetContainer } from "babylonjs/assetContainer";
  35783. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35784. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35785. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35786. import { Material } from "babylonjs/Materials/material";
  35787. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35788. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35789. import { Camera } from "babylonjs/Cameras/camera";
  35790. import { Light } from "babylonjs/Lights/light";
  35791. import { Node } from "babylonjs/node";
  35792. import { Animation } from "babylonjs/Animations/animation";
  35793. /**
  35794. * Defines how the parser contract is defined.
  35795. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35796. */
  35797. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35798. /**
  35799. * Defines how the individual parser contract is defined.
  35800. * These parser can parse an individual asset
  35801. */
  35802. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35803. /**
  35804. * Base class of the scene acting as a container for the different elements composing a scene.
  35805. * This class is dynamically extended by the different components of the scene increasing
  35806. * flexibility and reducing coupling
  35807. */
  35808. export abstract class AbstractScene {
  35809. /**
  35810. * Stores the list of available parsers in the application.
  35811. */
  35812. private static _BabylonFileParsers;
  35813. /**
  35814. * Stores the list of available individual parsers in the application.
  35815. */
  35816. private static _IndividualBabylonFileParsers;
  35817. /**
  35818. * Adds a parser in the list of available ones
  35819. * @param name Defines the name of the parser
  35820. * @param parser Defines the parser to add
  35821. */
  35822. static AddParser(name: string, parser: BabylonFileParser): void;
  35823. /**
  35824. * Gets a general parser from the list of avaialble ones
  35825. * @param name Defines the name of the parser
  35826. * @returns the requested parser or null
  35827. */
  35828. static GetParser(name: string): Nullable<BabylonFileParser>;
  35829. /**
  35830. * Adds n individual parser in the list of available ones
  35831. * @param name Defines the name of the parser
  35832. * @param parser Defines the parser to add
  35833. */
  35834. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35835. /**
  35836. * Gets an individual parser from the list of avaialble ones
  35837. * @param name Defines the name of the parser
  35838. * @returns the requested parser or null
  35839. */
  35840. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35841. /**
  35842. * Parser json data and populate both a scene and its associated container object
  35843. * @param jsonData Defines the data to parse
  35844. * @param scene Defines the scene to parse the data for
  35845. * @param container Defines the container attached to the parsing sequence
  35846. * @param rootUrl Defines the root url of the data
  35847. */
  35848. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35849. /**
  35850. * Gets the list of root nodes (ie. nodes with no parent)
  35851. */
  35852. rootNodes: Node[];
  35853. /** All of the cameras added to this scene
  35854. * @see http://doc.babylonjs.com/babylon101/cameras
  35855. */
  35856. cameras: Camera[];
  35857. /**
  35858. * All of the lights added to this scene
  35859. * @see http://doc.babylonjs.com/babylon101/lights
  35860. */
  35861. lights: Light[];
  35862. /**
  35863. * All of the (abstract) meshes added to this scene
  35864. */
  35865. meshes: AbstractMesh[];
  35866. /**
  35867. * The list of skeletons added to the scene
  35868. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35869. */
  35870. skeletons: Skeleton[];
  35871. /**
  35872. * All of the particle systems added to this scene
  35873. * @see http://doc.babylonjs.com/babylon101/particles
  35874. */
  35875. particleSystems: IParticleSystem[];
  35876. /**
  35877. * Gets a list of Animations associated with the scene
  35878. */
  35879. animations: Animation[];
  35880. /**
  35881. * All of the animation groups added to this scene
  35882. * @see http://doc.babylonjs.com/how_to/group
  35883. */
  35884. animationGroups: AnimationGroup[];
  35885. /**
  35886. * All of the multi-materials added to this scene
  35887. * @see http://doc.babylonjs.com/how_to/multi_materials
  35888. */
  35889. multiMaterials: MultiMaterial[];
  35890. /**
  35891. * All of the materials added to this scene
  35892. * In the context of a Scene, it is not supposed to be modified manually.
  35893. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35894. * Note also that the order of the Material wihin the array is not significant and might change.
  35895. * @see http://doc.babylonjs.com/babylon101/materials
  35896. */
  35897. materials: Material[];
  35898. /**
  35899. * The list of morph target managers added to the scene
  35900. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35901. */
  35902. morphTargetManagers: MorphTargetManager[];
  35903. /**
  35904. * The list of geometries used in the scene.
  35905. */
  35906. geometries: Geometry[];
  35907. /**
  35908. * All of the tranform nodes added to this scene
  35909. * In the context of a Scene, it is not supposed to be modified manually.
  35910. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35911. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35912. * @see http://doc.babylonjs.com/how_to/transformnode
  35913. */
  35914. transformNodes: TransformNode[];
  35915. /**
  35916. * ActionManagers available on the scene.
  35917. */
  35918. actionManagers: AbstractActionManager[];
  35919. /**
  35920. * Textures to keep.
  35921. */
  35922. textures: BaseTexture[];
  35923. /**
  35924. * Environment texture for the scene
  35925. */
  35926. environmentTexture: Nullable<BaseTexture>;
  35927. }
  35928. }
  35929. declare module "babylonjs/Audio/sound" {
  35930. import { Observable } from "babylonjs/Misc/observable";
  35931. import { Vector3 } from "babylonjs/Maths/math.vector";
  35932. import { Nullable } from "babylonjs/types";
  35933. import { Scene } from "babylonjs/scene";
  35934. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35935. /**
  35936. * Interface used to define options for Sound class
  35937. */
  35938. export interface ISoundOptions {
  35939. /**
  35940. * Does the sound autoplay once loaded.
  35941. */
  35942. autoplay?: boolean;
  35943. /**
  35944. * Does the sound loop after it finishes playing once.
  35945. */
  35946. loop?: boolean;
  35947. /**
  35948. * Sound's volume
  35949. */
  35950. volume?: number;
  35951. /**
  35952. * Is it a spatial sound?
  35953. */
  35954. spatialSound?: boolean;
  35955. /**
  35956. * Maximum distance to hear that sound
  35957. */
  35958. maxDistance?: number;
  35959. /**
  35960. * Uses user defined attenuation function
  35961. */
  35962. useCustomAttenuation?: boolean;
  35963. /**
  35964. * Define the roll off factor of spatial sounds.
  35965. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35966. */
  35967. rolloffFactor?: number;
  35968. /**
  35969. * Define the reference distance the sound should be heard perfectly.
  35970. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35971. */
  35972. refDistance?: number;
  35973. /**
  35974. * Define the distance attenuation model the sound will follow.
  35975. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35976. */
  35977. distanceModel?: string;
  35978. /**
  35979. * Defines the playback speed (1 by default)
  35980. */
  35981. playbackRate?: number;
  35982. /**
  35983. * Defines if the sound is from a streaming source
  35984. */
  35985. streaming?: boolean;
  35986. /**
  35987. * Defines an optional length (in seconds) inside the sound file
  35988. */
  35989. length?: number;
  35990. /**
  35991. * Defines an optional offset (in seconds) inside the sound file
  35992. */
  35993. offset?: number;
  35994. /**
  35995. * If true, URLs will not be required to state the audio file codec to use.
  35996. */
  35997. skipCodecCheck?: boolean;
  35998. }
  35999. /**
  36000. * Defines a sound that can be played in the application.
  36001. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36002. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36003. */
  36004. export class Sound {
  36005. /**
  36006. * The name of the sound in the scene.
  36007. */
  36008. name: string;
  36009. /**
  36010. * Does the sound autoplay once loaded.
  36011. */
  36012. autoplay: boolean;
  36013. /**
  36014. * Does the sound loop after it finishes playing once.
  36015. */
  36016. loop: boolean;
  36017. /**
  36018. * Does the sound use a custom attenuation curve to simulate the falloff
  36019. * happening when the source gets further away from the camera.
  36020. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36021. */
  36022. useCustomAttenuation: boolean;
  36023. /**
  36024. * The sound track id this sound belongs to.
  36025. */
  36026. soundTrackId: number;
  36027. /**
  36028. * Is this sound currently played.
  36029. */
  36030. isPlaying: boolean;
  36031. /**
  36032. * Is this sound currently paused.
  36033. */
  36034. isPaused: boolean;
  36035. /**
  36036. * Does this sound enables spatial sound.
  36037. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36038. */
  36039. spatialSound: boolean;
  36040. /**
  36041. * Define the reference distance the sound should be heard perfectly.
  36042. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36043. */
  36044. refDistance: number;
  36045. /**
  36046. * Define the roll off factor of spatial sounds.
  36047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36048. */
  36049. rolloffFactor: number;
  36050. /**
  36051. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36052. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36053. */
  36054. maxDistance: number;
  36055. /**
  36056. * Define the distance attenuation model the sound will follow.
  36057. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36058. */
  36059. distanceModel: string;
  36060. /**
  36061. * @hidden
  36062. * Back Compat
  36063. **/
  36064. onended: () => any;
  36065. /**
  36066. * Observable event when the current playing sound finishes.
  36067. */
  36068. onEndedObservable: Observable<Sound>;
  36069. private _panningModel;
  36070. private _playbackRate;
  36071. private _streaming;
  36072. private _startTime;
  36073. private _startOffset;
  36074. private _position;
  36075. /** @hidden */
  36076. _positionInEmitterSpace: boolean;
  36077. private _localDirection;
  36078. private _volume;
  36079. private _isReadyToPlay;
  36080. private _isDirectional;
  36081. private _readyToPlayCallback;
  36082. private _audioBuffer;
  36083. private _soundSource;
  36084. private _streamingSource;
  36085. private _soundPanner;
  36086. private _soundGain;
  36087. private _inputAudioNode;
  36088. private _outputAudioNode;
  36089. private _coneInnerAngle;
  36090. private _coneOuterAngle;
  36091. private _coneOuterGain;
  36092. private _scene;
  36093. private _connectedTransformNode;
  36094. private _customAttenuationFunction;
  36095. private _registerFunc;
  36096. private _isOutputConnected;
  36097. private _htmlAudioElement;
  36098. private _urlType;
  36099. private _length?;
  36100. private _offset?;
  36101. /** @hidden */
  36102. static _SceneComponentInitialization: (scene: Scene) => void;
  36103. /**
  36104. * Create a sound and attach it to a scene
  36105. * @param name Name of your sound
  36106. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36107. * @param scene defines the scene the sound belongs to
  36108. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36109. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36110. */
  36111. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36112. /**
  36113. * Release the sound and its associated resources
  36114. */
  36115. dispose(): void;
  36116. /**
  36117. * Gets if the sounds is ready to be played or not.
  36118. * @returns true if ready, otherwise false
  36119. */
  36120. isReady(): boolean;
  36121. private _soundLoaded;
  36122. /**
  36123. * Sets the data of the sound from an audiobuffer
  36124. * @param audioBuffer The audioBuffer containing the data
  36125. */
  36126. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36127. /**
  36128. * Updates the current sounds options such as maxdistance, loop...
  36129. * @param options A JSON object containing values named as the object properties
  36130. */
  36131. updateOptions(options: ISoundOptions): void;
  36132. private _createSpatialParameters;
  36133. private _updateSpatialParameters;
  36134. /**
  36135. * Switch the panning model to HRTF:
  36136. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36138. */
  36139. switchPanningModelToHRTF(): void;
  36140. /**
  36141. * Switch the panning model to Equal Power:
  36142. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36143. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36144. */
  36145. switchPanningModelToEqualPower(): void;
  36146. private _switchPanningModel;
  36147. /**
  36148. * Connect this sound to a sound track audio node like gain...
  36149. * @param soundTrackAudioNode the sound track audio node to connect to
  36150. */
  36151. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36152. /**
  36153. * Transform this sound into a directional source
  36154. * @param coneInnerAngle Size of the inner cone in degree
  36155. * @param coneOuterAngle Size of the outer cone in degree
  36156. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36157. */
  36158. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36159. /**
  36160. * Gets or sets the inner angle for the directional cone.
  36161. */
  36162. /**
  36163. * Gets or sets the inner angle for the directional cone.
  36164. */
  36165. directionalConeInnerAngle: number;
  36166. /**
  36167. * Gets or sets the outer angle for the directional cone.
  36168. */
  36169. /**
  36170. * Gets or sets the outer angle for the directional cone.
  36171. */
  36172. directionalConeOuterAngle: number;
  36173. /**
  36174. * Sets the position of the emitter if spatial sound is enabled
  36175. * @param newPosition Defines the new posisiton
  36176. */
  36177. setPosition(newPosition: Vector3): void;
  36178. /**
  36179. * Sets the local direction of the emitter if spatial sound is enabled
  36180. * @param newLocalDirection Defines the new local direction
  36181. */
  36182. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36183. private _updateDirection;
  36184. /** @hidden */
  36185. updateDistanceFromListener(): void;
  36186. /**
  36187. * Sets a new custom attenuation function for the sound.
  36188. * @param callback Defines the function used for the attenuation
  36189. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36190. */
  36191. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36192. /**
  36193. * Play the sound
  36194. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36195. * @param offset (optional) Start the sound at a specific time in seconds
  36196. * @param length (optional) Sound duration (in seconds)
  36197. */
  36198. play(time?: number, offset?: number, length?: number): void;
  36199. private _onended;
  36200. /**
  36201. * Stop the sound
  36202. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36203. */
  36204. stop(time?: number): void;
  36205. /**
  36206. * Put the sound in pause
  36207. */
  36208. pause(): void;
  36209. /**
  36210. * Sets a dedicated volume for this sounds
  36211. * @param newVolume Define the new volume of the sound
  36212. * @param time Define time for gradual change to new volume
  36213. */
  36214. setVolume(newVolume: number, time?: number): void;
  36215. /**
  36216. * Set the sound play back rate
  36217. * @param newPlaybackRate Define the playback rate the sound should be played at
  36218. */
  36219. setPlaybackRate(newPlaybackRate: number): void;
  36220. /**
  36221. * Gets the volume of the sound.
  36222. * @returns the volume of the sound
  36223. */
  36224. getVolume(): number;
  36225. /**
  36226. * Attach the sound to a dedicated mesh
  36227. * @param transformNode The transform node to connect the sound with
  36228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36229. */
  36230. attachToMesh(transformNode: TransformNode): void;
  36231. /**
  36232. * Detach the sound from the previously attached mesh
  36233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36234. */
  36235. detachFromMesh(): void;
  36236. private _onRegisterAfterWorldMatrixUpdate;
  36237. /**
  36238. * Clone the current sound in the scene.
  36239. * @returns the new sound clone
  36240. */
  36241. clone(): Nullable<Sound>;
  36242. /**
  36243. * Gets the current underlying audio buffer containing the data
  36244. * @returns the audio buffer
  36245. */
  36246. getAudioBuffer(): Nullable<AudioBuffer>;
  36247. /**
  36248. * Serializes the Sound in a JSON representation
  36249. * @returns the JSON representation of the sound
  36250. */
  36251. serialize(): any;
  36252. /**
  36253. * Parse a JSON representation of a sound to innstantiate in a given scene
  36254. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36255. * @param scene Define the scene the new parsed sound should be created in
  36256. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36257. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36258. * @returns the newly parsed sound
  36259. */
  36260. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36261. }
  36262. }
  36263. declare module "babylonjs/Actions/directAudioActions" {
  36264. import { Action } from "babylonjs/Actions/action";
  36265. import { Condition } from "babylonjs/Actions/condition";
  36266. import { Sound } from "babylonjs/Audio/sound";
  36267. /**
  36268. * This defines an action helpful to play a defined sound on a triggered action.
  36269. */
  36270. export class PlaySoundAction extends Action {
  36271. private _sound;
  36272. /**
  36273. * Instantiate the action
  36274. * @param triggerOptions defines the trigger options
  36275. * @param sound defines the sound to play
  36276. * @param condition defines the trigger related conditions
  36277. */
  36278. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36279. /** @hidden */
  36280. _prepare(): void;
  36281. /**
  36282. * Execute the action and play the sound.
  36283. */
  36284. execute(): void;
  36285. /**
  36286. * Serializes the actions and its related information.
  36287. * @param parent defines the object to serialize in
  36288. * @returns the serialized object
  36289. */
  36290. serialize(parent: any): any;
  36291. }
  36292. /**
  36293. * This defines an action helpful to stop a defined sound on a triggered action.
  36294. */
  36295. export class StopSoundAction extends Action {
  36296. private _sound;
  36297. /**
  36298. * Instantiate the action
  36299. * @param triggerOptions defines the trigger options
  36300. * @param sound defines the sound to stop
  36301. * @param condition defines the trigger related conditions
  36302. */
  36303. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36304. /** @hidden */
  36305. _prepare(): void;
  36306. /**
  36307. * Execute the action and stop the sound.
  36308. */
  36309. execute(): void;
  36310. /**
  36311. * Serializes the actions and its related information.
  36312. * @param parent defines the object to serialize in
  36313. * @returns the serialized object
  36314. */
  36315. serialize(parent: any): any;
  36316. }
  36317. }
  36318. declare module "babylonjs/Actions/interpolateValueAction" {
  36319. import { Action } from "babylonjs/Actions/action";
  36320. import { Condition } from "babylonjs/Actions/condition";
  36321. import { Observable } from "babylonjs/Misc/observable";
  36322. /**
  36323. * This defines an action responsible to change the value of a property
  36324. * by interpolating between its current value and the newly set one once triggered.
  36325. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36326. */
  36327. export class InterpolateValueAction extends Action {
  36328. /**
  36329. * Defines the path of the property where the value should be interpolated
  36330. */
  36331. propertyPath: string;
  36332. /**
  36333. * Defines the target value at the end of the interpolation.
  36334. */
  36335. value: any;
  36336. /**
  36337. * Defines the time it will take for the property to interpolate to the value.
  36338. */
  36339. duration: number;
  36340. /**
  36341. * Defines if the other scene animations should be stopped when the action has been triggered
  36342. */
  36343. stopOtherAnimations?: boolean;
  36344. /**
  36345. * Defines a callback raised once the interpolation animation has been done.
  36346. */
  36347. onInterpolationDone?: () => void;
  36348. /**
  36349. * Observable triggered once the interpolation animation has been done.
  36350. */
  36351. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36352. private _target;
  36353. private _effectiveTarget;
  36354. private _property;
  36355. /**
  36356. * Instantiate the action
  36357. * @param triggerOptions defines the trigger options
  36358. * @param target defines the object containing the value to interpolate
  36359. * @param propertyPath defines the path to the property in the target object
  36360. * @param value defines the target value at the end of the interpolation
  36361. * @param duration deines the time it will take for the property to interpolate to the value.
  36362. * @param condition defines the trigger related conditions
  36363. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36364. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36365. */
  36366. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36367. /** @hidden */
  36368. _prepare(): void;
  36369. /**
  36370. * Execute the action starts the value interpolation.
  36371. */
  36372. execute(): void;
  36373. /**
  36374. * Serializes the actions and its related information.
  36375. * @param parent defines the object to serialize in
  36376. * @returns the serialized object
  36377. */
  36378. serialize(parent: any): any;
  36379. }
  36380. }
  36381. declare module "babylonjs/Actions/index" {
  36382. export * from "babylonjs/Actions/abstractActionManager";
  36383. export * from "babylonjs/Actions/action";
  36384. export * from "babylonjs/Actions/actionEvent";
  36385. export * from "babylonjs/Actions/actionManager";
  36386. export * from "babylonjs/Actions/condition";
  36387. export * from "babylonjs/Actions/directActions";
  36388. export * from "babylonjs/Actions/directAudioActions";
  36389. export * from "babylonjs/Actions/interpolateValueAction";
  36390. }
  36391. declare module "babylonjs/Animations/index" {
  36392. export * from "babylonjs/Animations/animatable";
  36393. export * from "babylonjs/Animations/animation";
  36394. export * from "babylonjs/Animations/animationGroup";
  36395. export * from "babylonjs/Animations/animationPropertiesOverride";
  36396. export * from "babylonjs/Animations/easing";
  36397. export * from "babylonjs/Animations/runtimeAnimation";
  36398. export * from "babylonjs/Animations/animationEvent";
  36399. export * from "babylonjs/Animations/animationGroup";
  36400. export * from "babylonjs/Animations/animationKey";
  36401. export * from "babylonjs/Animations/animationRange";
  36402. export * from "babylonjs/Animations/animatable.interface";
  36403. }
  36404. declare module "babylonjs/Audio/soundTrack" {
  36405. import { Sound } from "babylonjs/Audio/sound";
  36406. import { Analyser } from "babylonjs/Audio/analyser";
  36407. import { Scene } from "babylonjs/scene";
  36408. /**
  36409. * Options allowed during the creation of a sound track.
  36410. */
  36411. export interface ISoundTrackOptions {
  36412. /**
  36413. * The volume the sound track should take during creation
  36414. */
  36415. volume?: number;
  36416. /**
  36417. * Define if the sound track is the main sound track of the scene
  36418. */
  36419. mainTrack?: boolean;
  36420. }
  36421. /**
  36422. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36423. * It will be also used in a future release to apply effects on a specific track.
  36424. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36425. */
  36426. export class SoundTrack {
  36427. /**
  36428. * The unique identifier of the sound track in the scene.
  36429. */
  36430. id: number;
  36431. /**
  36432. * The list of sounds included in the sound track.
  36433. */
  36434. soundCollection: Array<Sound>;
  36435. private _outputAudioNode;
  36436. private _scene;
  36437. private _isMainTrack;
  36438. private _connectedAnalyser;
  36439. private _options;
  36440. private _isInitialized;
  36441. /**
  36442. * Creates a new sound track.
  36443. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36444. * @param scene Define the scene the sound track belongs to
  36445. * @param options
  36446. */
  36447. constructor(scene: Scene, options?: ISoundTrackOptions);
  36448. private _initializeSoundTrackAudioGraph;
  36449. /**
  36450. * Release the sound track and its associated resources
  36451. */
  36452. dispose(): void;
  36453. /**
  36454. * Adds a sound to this sound track
  36455. * @param sound define the cound to add
  36456. * @ignoreNaming
  36457. */
  36458. AddSound(sound: Sound): void;
  36459. /**
  36460. * Removes a sound to this sound track
  36461. * @param sound define the cound to remove
  36462. * @ignoreNaming
  36463. */
  36464. RemoveSound(sound: Sound): void;
  36465. /**
  36466. * Set a global volume for the full sound track.
  36467. * @param newVolume Define the new volume of the sound track
  36468. */
  36469. setVolume(newVolume: number): void;
  36470. /**
  36471. * Switch the panning model to HRTF:
  36472. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36473. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36474. */
  36475. switchPanningModelToHRTF(): void;
  36476. /**
  36477. * Switch the panning model to Equal Power:
  36478. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36479. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36480. */
  36481. switchPanningModelToEqualPower(): void;
  36482. /**
  36483. * Connect the sound track to an audio analyser allowing some amazing
  36484. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36485. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36486. * @param analyser The analyser to connect to the engine
  36487. */
  36488. connectToAnalyser(analyser: Analyser): void;
  36489. }
  36490. }
  36491. declare module "babylonjs/Audio/audioSceneComponent" {
  36492. import { Sound } from "babylonjs/Audio/sound";
  36493. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36494. import { Nullable } from "babylonjs/types";
  36495. import { Vector3 } from "babylonjs/Maths/math.vector";
  36496. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36497. import { Scene } from "babylonjs/scene";
  36498. import { AbstractScene } from "babylonjs/abstractScene";
  36499. import "babylonjs/Audio/audioEngine";
  36500. module "babylonjs/abstractScene" {
  36501. interface AbstractScene {
  36502. /**
  36503. * The list of sounds used in the scene.
  36504. */
  36505. sounds: Nullable<Array<Sound>>;
  36506. }
  36507. }
  36508. module "babylonjs/scene" {
  36509. interface Scene {
  36510. /**
  36511. * @hidden
  36512. * Backing field
  36513. */
  36514. _mainSoundTrack: SoundTrack;
  36515. /**
  36516. * The main sound track played by the scene.
  36517. * It cotains your primary collection of sounds.
  36518. */
  36519. mainSoundTrack: SoundTrack;
  36520. /**
  36521. * The list of sound tracks added to the scene
  36522. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36523. */
  36524. soundTracks: Nullable<Array<SoundTrack>>;
  36525. /**
  36526. * Gets a sound using a given name
  36527. * @param name defines the name to search for
  36528. * @return the found sound or null if not found at all.
  36529. */
  36530. getSoundByName(name: string): Nullable<Sound>;
  36531. /**
  36532. * Gets or sets if audio support is enabled
  36533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36534. */
  36535. audioEnabled: boolean;
  36536. /**
  36537. * Gets or sets if audio will be output to headphones
  36538. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36539. */
  36540. headphone: boolean;
  36541. /**
  36542. * Gets or sets custom audio listener position provider
  36543. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36544. */
  36545. audioListenerPositionProvider: Nullable<() => Vector3>;
  36546. }
  36547. }
  36548. /**
  36549. * Defines the sound scene component responsible to manage any sounds
  36550. * in a given scene.
  36551. */
  36552. export class AudioSceneComponent implements ISceneSerializableComponent {
  36553. /**
  36554. * The component name helpfull to identify the component in the list of scene components.
  36555. */
  36556. readonly name: string;
  36557. /**
  36558. * The scene the component belongs to.
  36559. */
  36560. scene: Scene;
  36561. private _audioEnabled;
  36562. /**
  36563. * Gets whether audio is enabled or not.
  36564. * Please use related enable/disable method to switch state.
  36565. */
  36566. readonly audioEnabled: boolean;
  36567. private _headphone;
  36568. /**
  36569. * Gets whether audio is outputing to headphone or not.
  36570. * Please use the according Switch methods to change output.
  36571. */
  36572. readonly headphone: boolean;
  36573. private _audioListenerPositionProvider;
  36574. /**
  36575. * Gets the current audio listener position provider
  36576. */
  36577. /**
  36578. * Sets a custom listener position for all sounds in the scene
  36579. * By default, this is the position of the first active camera
  36580. */
  36581. audioListenerPositionProvider: Nullable<() => Vector3>;
  36582. /**
  36583. * Creates a new instance of the component for the given scene
  36584. * @param scene Defines the scene to register the component in
  36585. */
  36586. constructor(scene: Scene);
  36587. /**
  36588. * Registers the component in a given scene
  36589. */
  36590. register(): void;
  36591. /**
  36592. * Rebuilds the elements related to this component in case of
  36593. * context lost for instance.
  36594. */
  36595. rebuild(): void;
  36596. /**
  36597. * Serializes the component data to the specified json object
  36598. * @param serializationObject The object to serialize to
  36599. */
  36600. serialize(serializationObject: any): void;
  36601. /**
  36602. * Adds all the elements from the container to the scene
  36603. * @param container the container holding the elements
  36604. */
  36605. addFromContainer(container: AbstractScene): void;
  36606. /**
  36607. * Removes all the elements in the container from the scene
  36608. * @param container contains the elements to remove
  36609. * @param dispose if the removed element should be disposed (default: false)
  36610. */
  36611. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36612. /**
  36613. * Disposes the component and the associated ressources.
  36614. */
  36615. dispose(): void;
  36616. /**
  36617. * Disables audio in the associated scene.
  36618. */
  36619. disableAudio(): void;
  36620. /**
  36621. * Enables audio in the associated scene.
  36622. */
  36623. enableAudio(): void;
  36624. /**
  36625. * Switch audio to headphone output.
  36626. */
  36627. switchAudioModeForHeadphones(): void;
  36628. /**
  36629. * Switch audio to normal speakers.
  36630. */
  36631. switchAudioModeForNormalSpeakers(): void;
  36632. private _afterRender;
  36633. }
  36634. }
  36635. declare module "babylonjs/Audio/weightedsound" {
  36636. import { Sound } from "babylonjs/Audio/sound";
  36637. /**
  36638. * Wraps one or more Sound objects and selects one with random weight for playback.
  36639. */
  36640. export class WeightedSound {
  36641. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36642. loop: boolean;
  36643. private _coneInnerAngle;
  36644. private _coneOuterAngle;
  36645. private _volume;
  36646. /** A Sound is currently playing. */
  36647. isPlaying: boolean;
  36648. /** A Sound is currently paused. */
  36649. isPaused: boolean;
  36650. private _sounds;
  36651. private _weights;
  36652. private _currentIndex?;
  36653. /**
  36654. * Creates a new WeightedSound from the list of sounds given.
  36655. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36656. * @param sounds Array of Sounds that will be selected from.
  36657. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36658. */
  36659. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36660. /**
  36661. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36662. */
  36663. /**
  36664. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36665. */
  36666. directionalConeInnerAngle: number;
  36667. /**
  36668. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36669. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36670. */
  36671. /**
  36672. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36673. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36674. */
  36675. directionalConeOuterAngle: number;
  36676. /**
  36677. * Playback volume.
  36678. */
  36679. /**
  36680. * Playback volume.
  36681. */
  36682. volume: number;
  36683. private _onended;
  36684. /**
  36685. * Suspend playback
  36686. */
  36687. pause(): void;
  36688. /**
  36689. * Stop playback
  36690. */
  36691. stop(): void;
  36692. /**
  36693. * Start playback.
  36694. * @param startOffset Position the clip head at a specific time in seconds.
  36695. */
  36696. play(startOffset?: number): void;
  36697. }
  36698. }
  36699. declare module "babylonjs/Audio/index" {
  36700. export * from "babylonjs/Audio/analyser";
  36701. export * from "babylonjs/Audio/audioEngine";
  36702. export * from "babylonjs/Audio/audioSceneComponent";
  36703. export * from "babylonjs/Audio/sound";
  36704. export * from "babylonjs/Audio/soundTrack";
  36705. export * from "babylonjs/Audio/weightedsound";
  36706. }
  36707. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36708. import { Behavior } from "babylonjs/Behaviors/behavior";
  36709. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36710. import { BackEase } from "babylonjs/Animations/easing";
  36711. /**
  36712. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36713. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36714. */
  36715. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36716. /**
  36717. * Gets the name of the behavior.
  36718. */
  36719. readonly name: string;
  36720. /**
  36721. * The easing function used by animations
  36722. */
  36723. static EasingFunction: BackEase;
  36724. /**
  36725. * The easing mode used by animations
  36726. */
  36727. static EasingMode: number;
  36728. /**
  36729. * The duration of the animation, in milliseconds
  36730. */
  36731. transitionDuration: number;
  36732. /**
  36733. * Length of the distance animated by the transition when lower radius is reached
  36734. */
  36735. lowerRadiusTransitionRange: number;
  36736. /**
  36737. * Length of the distance animated by the transition when upper radius is reached
  36738. */
  36739. upperRadiusTransitionRange: number;
  36740. private _autoTransitionRange;
  36741. /**
  36742. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36743. */
  36744. /**
  36745. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36746. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36747. */
  36748. autoTransitionRange: boolean;
  36749. private _attachedCamera;
  36750. private _onAfterCheckInputsObserver;
  36751. private _onMeshTargetChangedObserver;
  36752. /**
  36753. * Initializes the behavior.
  36754. */
  36755. init(): void;
  36756. /**
  36757. * Attaches the behavior to its arc rotate camera.
  36758. * @param camera Defines the camera to attach the behavior to
  36759. */
  36760. attach(camera: ArcRotateCamera): void;
  36761. /**
  36762. * Detaches the behavior from its current arc rotate camera.
  36763. */
  36764. detach(): void;
  36765. private _radiusIsAnimating;
  36766. private _radiusBounceTransition;
  36767. private _animatables;
  36768. private _cachedWheelPrecision;
  36769. /**
  36770. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36771. * @param radiusLimit The limit to check against.
  36772. * @return Bool to indicate if at limit.
  36773. */
  36774. private _isRadiusAtLimit;
  36775. /**
  36776. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36777. * @param radiusDelta The delta by which to animate to. Can be negative.
  36778. */
  36779. private _applyBoundRadiusAnimation;
  36780. /**
  36781. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36782. */
  36783. protected _clearAnimationLocks(): void;
  36784. /**
  36785. * Stops and removes all animations that have been applied to the camera
  36786. */
  36787. stopAllAnimations(): void;
  36788. }
  36789. }
  36790. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36791. import { Behavior } from "babylonjs/Behaviors/behavior";
  36792. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36793. import { ExponentialEase } from "babylonjs/Animations/easing";
  36794. import { Nullable } from "babylonjs/types";
  36795. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36796. import { Vector3 } from "babylonjs/Maths/math.vector";
  36797. /**
  36798. * 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.
  36799. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36800. */
  36801. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36802. /**
  36803. * Gets the name of the behavior.
  36804. */
  36805. readonly name: string;
  36806. private _mode;
  36807. private _radiusScale;
  36808. private _positionScale;
  36809. private _defaultElevation;
  36810. private _elevationReturnTime;
  36811. private _elevationReturnWaitTime;
  36812. private _zoomStopsAnimation;
  36813. private _framingTime;
  36814. /**
  36815. * The easing function used by animations
  36816. */
  36817. static EasingFunction: ExponentialEase;
  36818. /**
  36819. * The easing mode used by animations
  36820. */
  36821. static EasingMode: number;
  36822. /**
  36823. * Sets the current mode used by the behavior
  36824. */
  36825. /**
  36826. * Gets current mode used by the behavior.
  36827. */
  36828. mode: number;
  36829. /**
  36830. * Sets the scale applied to the radius (1 by default)
  36831. */
  36832. /**
  36833. * Gets the scale applied to the radius
  36834. */
  36835. radiusScale: number;
  36836. /**
  36837. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36838. */
  36839. /**
  36840. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36841. */
  36842. positionScale: number;
  36843. /**
  36844. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36845. * behaviour is triggered, in radians.
  36846. */
  36847. /**
  36848. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36849. * behaviour is triggered, in radians.
  36850. */
  36851. defaultElevation: number;
  36852. /**
  36853. * Sets the time (in milliseconds) taken to return to the default beta position.
  36854. * Negative value indicates camera should not return to default.
  36855. */
  36856. /**
  36857. * Gets the time (in milliseconds) taken to return to the default beta position.
  36858. * Negative value indicates camera should not return to default.
  36859. */
  36860. elevationReturnTime: number;
  36861. /**
  36862. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36863. */
  36864. /**
  36865. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36866. */
  36867. elevationReturnWaitTime: number;
  36868. /**
  36869. * Sets the flag that indicates if user zooming should stop animation.
  36870. */
  36871. /**
  36872. * Gets the flag that indicates if user zooming should stop animation.
  36873. */
  36874. zoomStopsAnimation: boolean;
  36875. /**
  36876. * Sets the transition time when framing the mesh, in milliseconds
  36877. */
  36878. /**
  36879. * Gets the transition time when framing the mesh, in milliseconds
  36880. */
  36881. framingTime: number;
  36882. /**
  36883. * Define if the behavior should automatically change the configured
  36884. * camera limits and sensibilities.
  36885. */
  36886. autoCorrectCameraLimitsAndSensibility: boolean;
  36887. private _onPrePointerObservableObserver;
  36888. private _onAfterCheckInputsObserver;
  36889. private _onMeshTargetChangedObserver;
  36890. private _attachedCamera;
  36891. private _isPointerDown;
  36892. private _lastInteractionTime;
  36893. /**
  36894. * Initializes the behavior.
  36895. */
  36896. init(): void;
  36897. /**
  36898. * Attaches the behavior to its arc rotate camera.
  36899. * @param camera Defines the camera to attach the behavior to
  36900. */
  36901. attach(camera: ArcRotateCamera): void;
  36902. /**
  36903. * Detaches the behavior from its current arc rotate camera.
  36904. */
  36905. detach(): void;
  36906. private _animatables;
  36907. private _betaIsAnimating;
  36908. private _betaTransition;
  36909. private _radiusTransition;
  36910. private _vectorTransition;
  36911. /**
  36912. * Targets the given mesh and updates zoom level accordingly.
  36913. * @param mesh The mesh to target.
  36914. * @param radius Optional. If a cached radius position already exists, overrides default.
  36915. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36916. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36917. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36918. */
  36919. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36920. /**
  36921. * Targets the given mesh with its children and updates zoom level accordingly.
  36922. * @param mesh The mesh to target.
  36923. * @param radius Optional. If a cached radius position already exists, overrides default.
  36924. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36925. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36926. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36927. */
  36928. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36929. /**
  36930. * Targets the given meshes with their children and updates zoom level accordingly.
  36931. * @param meshes The mesh to target.
  36932. * @param radius Optional. If a cached radius position already exists, overrides default.
  36933. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36934. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36935. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36936. */
  36937. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36938. /**
  36939. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36940. * @param minimumWorld Determines the smaller position of the bounding box extend
  36941. * @param maximumWorld Determines the bigger position of the bounding box extend
  36942. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36943. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36944. */
  36945. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36946. /**
  36947. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36948. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36949. * frustum width.
  36950. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36951. * to fully enclose the mesh in the viewing frustum.
  36952. */
  36953. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36954. /**
  36955. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36956. * is automatically returned to its default position (expected to be above ground plane).
  36957. */
  36958. private _maintainCameraAboveGround;
  36959. /**
  36960. * Returns the frustum slope based on the canvas ratio and camera FOV
  36961. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36962. */
  36963. private _getFrustumSlope;
  36964. /**
  36965. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36966. */
  36967. private _clearAnimationLocks;
  36968. /**
  36969. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36970. */
  36971. private _applyUserInteraction;
  36972. /**
  36973. * Stops and removes all animations that have been applied to the camera
  36974. */
  36975. stopAllAnimations(): void;
  36976. /**
  36977. * Gets a value indicating if the user is moving the camera
  36978. */
  36979. readonly isUserIsMoving: boolean;
  36980. /**
  36981. * The camera can move all the way towards the mesh.
  36982. */
  36983. static IgnoreBoundsSizeMode: number;
  36984. /**
  36985. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36986. */
  36987. static FitFrustumSidesMode: number;
  36988. }
  36989. }
  36990. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36991. import { Nullable } from "babylonjs/types";
  36992. import { Camera } from "babylonjs/Cameras/camera";
  36993. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36994. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36995. /**
  36996. * Base class for Camera Pointer Inputs.
  36997. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36998. * for example usage.
  36999. */
  37000. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37001. /**
  37002. * Defines the camera the input is attached to.
  37003. */
  37004. abstract camera: Camera;
  37005. /**
  37006. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37007. */
  37008. protected _altKey: boolean;
  37009. protected _ctrlKey: boolean;
  37010. protected _metaKey: boolean;
  37011. protected _shiftKey: boolean;
  37012. /**
  37013. * Which mouse buttons were pressed at time of last mouse event.
  37014. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37015. */
  37016. protected _buttonsPressed: number;
  37017. /**
  37018. * Defines the buttons associated with the input to handle camera move.
  37019. */
  37020. buttons: number[];
  37021. /**
  37022. * Attach the input controls to a specific dom element to get the input from.
  37023. * @param element Defines the element the controls should be listened from
  37024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37025. */
  37026. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37027. /**
  37028. * Detach the current controls from the specified dom element.
  37029. * @param element Defines the element to stop listening the inputs from
  37030. */
  37031. detachControl(element: Nullable<HTMLElement>): void;
  37032. /**
  37033. * Gets the class name of the current input.
  37034. * @returns the class name
  37035. */
  37036. getClassName(): string;
  37037. /**
  37038. * Get the friendly name associated with the input class.
  37039. * @returns the input friendly name
  37040. */
  37041. getSimpleName(): string;
  37042. /**
  37043. * Called on pointer POINTERDOUBLETAP event.
  37044. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37045. */
  37046. protected onDoubleTap(type: string): void;
  37047. /**
  37048. * Called on pointer POINTERMOVE event if only a single touch is active.
  37049. * Override this method to provide functionality.
  37050. */
  37051. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37052. /**
  37053. * Called on pointer POINTERMOVE event if multiple touches are active.
  37054. * Override this method to provide functionality.
  37055. */
  37056. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37057. /**
  37058. * Called on JS contextmenu event.
  37059. * Override this method to provide functionality.
  37060. */
  37061. protected onContextMenu(evt: PointerEvent): void;
  37062. /**
  37063. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37064. * press.
  37065. * Override this method to provide functionality.
  37066. */
  37067. protected onButtonDown(evt: PointerEvent): void;
  37068. /**
  37069. * Called each time a new POINTERUP event occurs. Ie, for each button
  37070. * release.
  37071. * Override this method to provide functionality.
  37072. */
  37073. protected onButtonUp(evt: PointerEvent): void;
  37074. /**
  37075. * Called when window becomes inactive.
  37076. * Override this method to provide functionality.
  37077. */
  37078. protected onLostFocus(): void;
  37079. private _pointerInput;
  37080. private _observer;
  37081. private _onLostFocus;
  37082. private pointA;
  37083. private pointB;
  37084. }
  37085. }
  37086. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37087. import { Nullable } from "babylonjs/types";
  37088. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37089. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37090. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37091. /**
  37092. * Manage the pointers inputs to control an arc rotate camera.
  37093. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37094. */
  37095. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37096. /**
  37097. * Defines the camera the input is attached to.
  37098. */
  37099. camera: ArcRotateCamera;
  37100. /**
  37101. * Gets the class name of the current input.
  37102. * @returns the class name
  37103. */
  37104. getClassName(): string;
  37105. /**
  37106. * Defines the buttons associated with the input to handle camera move.
  37107. */
  37108. buttons: number[];
  37109. /**
  37110. * Defines the pointer angular sensibility along the X axis or how fast is
  37111. * the camera rotating.
  37112. */
  37113. angularSensibilityX: number;
  37114. /**
  37115. * Defines the pointer angular sensibility along the Y axis or how fast is
  37116. * the camera rotating.
  37117. */
  37118. angularSensibilityY: number;
  37119. /**
  37120. * Defines the pointer pinch precision or how fast is the camera zooming.
  37121. */
  37122. pinchPrecision: number;
  37123. /**
  37124. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37125. * from 0.
  37126. * It defines the percentage of current camera.radius to use as delta when
  37127. * pinch zoom is used.
  37128. */
  37129. pinchDeltaPercentage: number;
  37130. /**
  37131. * Defines the pointer panning sensibility or how fast is the camera moving.
  37132. */
  37133. panningSensibility: number;
  37134. /**
  37135. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37136. */
  37137. multiTouchPanning: boolean;
  37138. /**
  37139. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37140. * zoom (pinch) through multitouch.
  37141. */
  37142. multiTouchPanAndZoom: boolean;
  37143. /**
  37144. * Revers pinch action direction.
  37145. */
  37146. pinchInwards: boolean;
  37147. private _isPanClick;
  37148. private _twoFingerActivityCount;
  37149. private _isPinching;
  37150. /**
  37151. * Called on pointer POINTERMOVE event if only a single touch is active.
  37152. */
  37153. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37154. /**
  37155. * Called on pointer POINTERDOUBLETAP event.
  37156. */
  37157. protected onDoubleTap(type: string): void;
  37158. /**
  37159. * Called on pointer POINTERMOVE event if multiple touches are active.
  37160. */
  37161. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37162. /**
  37163. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37164. * press.
  37165. */
  37166. protected onButtonDown(evt: PointerEvent): void;
  37167. /**
  37168. * Called each time a new POINTERUP event occurs. Ie, for each button
  37169. * release.
  37170. */
  37171. protected onButtonUp(evt: PointerEvent): void;
  37172. /**
  37173. * Called when window becomes inactive.
  37174. */
  37175. protected onLostFocus(): void;
  37176. }
  37177. }
  37178. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37179. import { Nullable } from "babylonjs/types";
  37180. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37181. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37182. /**
  37183. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37185. */
  37186. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37187. /**
  37188. * Defines the camera the input is attached to.
  37189. */
  37190. camera: ArcRotateCamera;
  37191. /**
  37192. * Defines the list of key codes associated with the up action (increase alpha)
  37193. */
  37194. keysUp: number[];
  37195. /**
  37196. * Defines the list of key codes associated with the down action (decrease alpha)
  37197. */
  37198. keysDown: number[];
  37199. /**
  37200. * Defines the list of key codes associated with the left action (increase beta)
  37201. */
  37202. keysLeft: number[];
  37203. /**
  37204. * Defines the list of key codes associated with the right action (decrease beta)
  37205. */
  37206. keysRight: number[];
  37207. /**
  37208. * Defines the list of key codes associated with the reset action.
  37209. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37210. */
  37211. keysReset: number[];
  37212. /**
  37213. * Defines the panning sensibility of the inputs.
  37214. * (How fast is the camera paning)
  37215. */
  37216. panningSensibility: number;
  37217. /**
  37218. * Defines the zooming sensibility of the inputs.
  37219. * (How fast is the camera zooming)
  37220. */
  37221. zoomingSensibility: number;
  37222. /**
  37223. * Defines wether maintaining the alt key down switch the movement mode from
  37224. * orientation to zoom.
  37225. */
  37226. useAltToZoom: boolean;
  37227. /**
  37228. * Rotation speed of the camera
  37229. */
  37230. angularSpeed: number;
  37231. private _keys;
  37232. private _ctrlPressed;
  37233. private _altPressed;
  37234. private _onCanvasBlurObserver;
  37235. private _onKeyboardObserver;
  37236. private _engine;
  37237. private _scene;
  37238. /**
  37239. * Attach the input controls to a specific dom element to get the input from.
  37240. * @param element Defines the element the controls should be listened from
  37241. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37242. */
  37243. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37244. /**
  37245. * Detach the current controls from the specified dom element.
  37246. * @param element Defines the element to stop listening the inputs from
  37247. */
  37248. detachControl(element: Nullable<HTMLElement>): void;
  37249. /**
  37250. * Update the current camera state depending on the inputs that have been used this frame.
  37251. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37252. */
  37253. checkInputs(): void;
  37254. /**
  37255. * Gets the class name of the current intput.
  37256. * @returns the class name
  37257. */
  37258. getClassName(): string;
  37259. /**
  37260. * Get the friendly name associated with the input class.
  37261. * @returns the input friendly name
  37262. */
  37263. getSimpleName(): string;
  37264. }
  37265. }
  37266. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37267. import { Nullable } from "babylonjs/types";
  37268. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37269. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37270. /**
  37271. * Manage the mouse wheel inputs to control an arc rotate camera.
  37272. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37273. */
  37274. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37275. /**
  37276. * Defines the camera the input is attached to.
  37277. */
  37278. camera: ArcRotateCamera;
  37279. /**
  37280. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37281. */
  37282. wheelPrecision: number;
  37283. /**
  37284. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37285. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37286. */
  37287. wheelDeltaPercentage: number;
  37288. private _wheel;
  37289. private _observer;
  37290. private computeDeltaFromMouseWheelLegacyEvent;
  37291. /**
  37292. * Attach the input controls to a specific dom element to get the input from.
  37293. * @param element Defines the element the controls should be listened from
  37294. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37295. */
  37296. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37297. /**
  37298. * Detach the current controls from the specified dom element.
  37299. * @param element Defines the element to stop listening the inputs from
  37300. */
  37301. detachControl(element: Nullable<HTMLElement>): void;
  37302. /**
  37303. * Gets the class name of the current intput.
  37304. * @returns the class name
  37305. */
  37306. getClassName(): string;
  37307. /**
  37308. * Get the friendly name associated with the input class.
  37309. * @returns the input friendly name
  37310. */
  37311. getSimpleName(): string;
  37312. }
  37313. }
  37314. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37315. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37316. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37317. /**
  37318. * Default Inputs manager for the ArcRotateCamera.
  37319. * It groups all the default supported inputs for ease of use.
  37320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37321. */
  37322. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37323. /**
  37324. * Instantiates a new ArcRotateCameraInputsManager.
  37325. * @param camera Defines the camera the inputs belong to
  37326. */
  37327. constructor(camera: ArcRotateCamera);
  37328. /**
  37329. * Add mouse wheel input support to the input manager.
  37330. * @returns the current input manager
  37331. */
  37332. addMouseWheel(): ArcRotateCameraInputsManager;
  37333. /**
  37334. * Add pointers input support to the input manager.
  37335. * @returns the current input manager
  37336. */
  37337. addPointers(): ArcRotateCameraInputsManager;
  37338. /**
  37339. * Add keyboard input support to the input manager.
  37340. * @returns the current input manager
  37341. */
  37342. addKeyboard(): ArcRotateCameraInputsManager;
  37343. }
  37344. }
  37345. declare module "babylonjs/Cameras/arcRotateCamera" {
  37346. import { Observable } from "babylonjs/Misc/observable";
  37347. import { Nullable } from "babylonjs/types";
  37348. import { Scene } from "babylonjs/scene";
  37349. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37351. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37352. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37353. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37354. import { Camera } from "babylonjs/Cameras/camera";
  37355. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37356. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37357. import { Collider } from "babylonjs/Collisions/collider";
  37358. /**
  37359. * This represents an orbital type of camera.
  37360. *
  37361. * 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.
  37362. * 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.
  37363. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37364. */
  37365. export class ArcRotateCamera extends TargetCamera {
  37366. /**
  37367. * Defines the rotation angle of the camera along the longitudinal axis.
  37368. */
  37369. alpha: number;
  37370. /**
  37371. * Defines the rotation angle of the camera along the latitudinal axis.
  37372. */
  37373. beta: number;
  37374. /**
  37375. * Defines the radius of the camera from it s target point.
  37376. */
  37377. radius: number;
  37378. protected _target: Vector3;
  37379. protected _targetHost: Nullable<AbstractMesh>;
  37380. /**
  37381. * Defines the target point of the camera.
  37382. * The camera looks towards it form the radius distance.
  37383. */
  37384. target: Vector3;
  37385. /**
  37386. * Define the current local position of the camera in the scene
  37387. */
  37388. position: Vector3;
  37389. protected _upVector: Vector3;
  37390. protected _upToYMatrix: Matrix;
  37391. protected _YToUpMatrix: Matrix;
  37392. /**
  37393. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37394. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37395. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37396. */
  37397. upVector: Vector3;
  37398. /**
  37399. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37400. */
  37401. setMatUp(): void;
  37402. /**
  37403. * Current inertia value on the longitudinal axis.
  37404. * The bigger this number the longer it will take for the camera to stop.
  37405. */
  37406. inertialAlphaOffset: number;
  37407. /**
  37408. * Current inertia value on the latitudinal axis.
  37409. * The bigger this number the longer it will take for the camera to stop.
  37410. */
  37411. inertialBetaOffset: number;
  37412. /**
  37413. * Current inertia value on the radius axis.
  37414. * The bigger this number the longer it will take for the camera to stop.
  37415. */
  37416. inertialRadiusOffset: number;
  37417. /**
  37418. * Minimum allowed angle on the longitudinal axis.
  37419. * This can help limiting how the Camera is able to move in the scene.
  37420. */
  37421. lowerAlphaLimit: Nullable<number>;
  37422. /**
  37423. * Maximum allowed angle on the longitudinal axis.
  37424. * This can help limiting how the Camera is able to move in the scene.
  37425. */
  37426. upperAlphaLimit: Nullable<number>;
  37427. /**
  37428. * Minimum allowed angle on the latitudinal axis.
  37429. * This can help limiting how the Camera is able to move in the scene.
  37430. */
  37431. lowerBetaLimit: number;
  37432. /**
  37433. * Maximum allowed angle on the latitudinal axis.
  37434. * This can help limiting how the Camera is able to move in the scene.
  37435. */
  37436. upperBetaLimit: number;
  37437. /**
  37438. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37439. * This can help limiting how the Camera is able to move in the scene.
  37440. */
  37441. lowerRadiusLimit: Nullable<number>;
  37442. /**
  37443. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37444. * This can help limiting how the Camera is able to move in the scene.
  37445. */
  37446. upperRadiusLimit: Nullable<number>;
  37447. /**
  37448. * Defines the current inertia value used during panning of the camera along the X axis.
  37449. */
  37450. inertialPanningX: number;
  37451. /**
  37452. * Defines the current inertia value used during panning of the camera along the Y axis.
  37453. */
  37454. inertialPanningY: number;
  37455. /**
  37456. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37457. * Basically if your fingers moves away from more than this distance you will be considered
  37458. * in pinch mode.
  37459. */
  37460. pinchToPanMaxDistance: number;
  37461. /**
  37462. * Defines the maximum distance the camera can pan.
  37463. * This could help keeping the cammera always in your scene.
  37464. */
  37465. panningDistanceLimit: Nullable<number>;
  37466. /**
  37467. * Defines the target of the camera before paning.
  37468. */
  37469. panningOriginTarget: Vector3;
  37470. /**
  37471. * Defines the value of the inertia used during panning.
  37472. * 0 would mean stop inertia and one would mean no decelleration at all.
  37473. */
  37474. panningInertia: number;
  37475. /**
  37476. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37477. */
  37478. angularSensibilityX: number;
  37479. /**
  37480. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37481. */
  37482. angularSensibilityY: number;
  37483. /**
  37484. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37485. */
  37486. pinchPrecision: number;
  37487. /**
  37488. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37489. * It will be used instead of pinchDeltaPrecision if different from 0.
  37490. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37491. */
  37492. pinchDeltaPercentage: number;
  37493. /**
  37494. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37495. */
  37496. panningSensibility: number;
  37497. /**
  37498. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37499. */
  37500. keysUp: number[];
  37501. /**
  37502. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37503. */
  37504. keysDown: number[];
  37505. /**
  37506. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37507. */
  37508. keysLeft: number[];
  37509. /**
  37510. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37511. */
  37512. keysRight: number[];
  37513. /**
  37514. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37515. */
  37516. wheelPrecision: number;
  37517. /**
  37518. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37519. * It will be used instead of pinchDeltaPrecision if different from 0.
  37520. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37521. */
  37522. wheelDeltaPercentage: number;
  37523. /**
  37524. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37525. */
  37526. zoomOnFactor: number;
  37527. /**
  37528. * Defines a screen offset for the camera position.
  37529. */
  37530. targetScreenOffset: Vector2;
  37531. /**
  37532. * Allows the camera to be completely reversed.
  37533. * If false the camera can not arrive upside down.
  37534. */
  37535. allowUpsideDown: boolean;
  37536. /**
  37537. * Define if double tap/click is used to restore the previously saved state of the camera.
  37538. */
  37539. useInputToRestoreState: boolean;
  37540. /** @hidden */
  37541. _viewMatrix: Matrix;
  37542. /** @hidden */
  37543. _useCtrlForPanning: boolean;
  37544. /** @hidden */
  37545. _panningMouseButton: number;
  37546. /**
  37547. * Defines the input associated to the camera.
  37548. */
  37549. inputs: ArcRotateCameraInputsManager;
  37550. /** @hidden */
  37551. _reset: () => void;
  37552. /**
  37553. * Defines the allowed panning axis.
  37554. */
  37555. panningAxis: Vector3;
  37556. protected _localDirection: Vector3;
  37557. protected _transformedDirection: Vector3;
  37558. private _bouncingBehavior;
  37559. /**
  37560. * Gets the bouncing behavior of the camera if it has been enabled.
  37561. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37562. */
  37563. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37564. /**
  37565. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37566. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37567. */
  37568. useBouncingBehavior: boolean;
  37569. private _framingBehavior;
  37570. /**
  37571. * Gets the framing behavior of the camera if it has been enabled.
  37572. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37573. */
  37574. readonly framingBehavior: Nullable<FramingBehavior>;
  37575. /**
  37576. * Defines if the framing behavior of the camera is enabled on the camera.
  37577. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37578. */
  37579. useFramingBehavior: boolean;
  37580. private _autoRotationBehavior;
  37581. /**
  37582. * Gets the auto rotation behavior of the camera if it has been enabled.
  37583. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37584. */
  37585. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37586. /**
  37587. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37588. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37589. */
  37590. useAutoRotationBehavior: boolean;
  37591. /**
  37592. * Observable triggered when the mesh target has been changed on the camera.
  37593. */
  37594. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37595. /**
  37596. * Event raised when the camera is colliding with a mesh.
  37597. */
  37598. onCollide: (collidedMesh: AbstractMesh) => void;
  37599. /**
  37600. * Defines whether the camera should check collision with the objects oh the scene.
  37601. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37602. */
  37603. checkCollisions: boolean;
  37604. /**
  37605. * Defines the collision radius of the camera.
  37606. * This simulates a sphere around the camera.
  37607. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37608. */
  37609. collisionRadius: Vector3;
  37610. protected _collider: Collider;
  37611. protected _previousPosition: Vector3;
  37612. protected _collisionVelocity: Vector3;
  37613. protected _newPosition: Vector3;
  37614. protected _previousAlpha: number;
  37615. protected _previousBeta: number;
  37616. protected _previousRadius: number;
  37617. protected _collisionTriggered: boolean;
  37618. protected _targetBoundingCenter: Nullable<Vector3>;
  37619. private _computationVector;
  37620. /**
  37621. * Instantiates a new ArcRotateCamera in a given scene
  37622. * @param name Defines the name of the camera
  37623. * @param alpha Defines the camera rotation along the logitudinal axis
  37624. * @param beta Defines the camera rotation along the latitudinal axis
  37625. * @param radius Defines the camera distance from its target
  37626. * @param target Defines the camera target
  37627. * @param scene Defines the scene the camera belongs to
  37628. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37629. */
  37630. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37631. /** @hidden */
  37632. _initCache(): void;
  37633. /** @hidden */
  37634. _updateCache(ignoreParentClass?: boolean): void;
  37635. protected _getTargetPosition(): Vector3;
  37636. private _storedAlpha;
  37637. private _storedBeta;
  37638. private _storedRadius;
  37639. private _storedTarget;
  37640. private _storedTargetScreenOffset;
  37641. /**
  37642. * Stores the current state of the camera (alpha, beta, radius and target)
  37643. * @returns the camera itself
  37644. */
  37645. storeState(): Camera;
  37646. /**
  37647. * @hidden
  37648. * Restored camera state. You must call storeState() first
  37649. */
  37650. _restoreStateValues(): boolean;
  37651. /** @hidden */
  37652. _isSynchronizedViewMatrix(): boolean;
  37653. /**
  37654. * Attached controls to the current camera.
  37655. * @param element Defines the element the controls should be listened from
  37656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37657. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37658. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37659. */
  37660. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37661. /**
  37662. * Detach the current controls from the camera.
  37663. * The camera will stop reacting to inputs.
  37664. * @param element Defines the element to stop listening the inputs from
  37665. */
  37666. detachControl(element: HTMLElement): void;
  37667. /** @hidden */
  37668. _checkInputs(): void;
  37669. protected _checkLimits(): void;
  37670. /**
  37671. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37672. */
  37673. rebuildAnglesAndRadius(): void;
  37674. /**
  37675. * Use a position to define the current camera related information like alpha, beta and radius
  37676. * @param position Defines the position to set the camera at
  37677. */
  37678. setPosition(position: Vector3): void;
  37679. /**
  37680. * Defines the target the camera should look at.
  37681. * This will automatically adapt alpha beta and radius to fit within the new target.
  37682. * @param target Defines the new target as a Vector or a mesh
  37683. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37684. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37685. */
  37686. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37687. /** @hidden */
  37688. _getViewMatrix(): Matrix;
  37689. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37690. /**
  37691. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37692. * @param meshes Defines the mesh to zoom on
  37693. * @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)
  37694. */
  37695. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37696. /**
  37697. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37698. * The target will be changed but the radius
  37699. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37700. * @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)
  37701. */
  37702. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37703. min: Vector3;
  37704. max: Vector3;
  37705. distance: number;
  37706. }, doNotUpdateMaxZ?: boolean): void;
  37707. /**
  37708. * @override
  37709. * Override Camera.createRigCamera
  37710. */
  37711. createRigCamera(name: string, cameraIndex: number): Camera;
  37712. /**
  37713. * @hidden
  37714. * @override
  37715. * Override Camera._updateRigCameras
  37716. */
  37717. _updateRigCameras(): void;
  37718. /**
  37719. * Destroy the camera and release the current resources hold by it.
  37720. */
  37721. dispose(): void;
  37722. /**
  37723. * Gets the current object class name.
  37724. * @return the class name
  37725. */
  37726. getClassName(): string;
  37727. }
  37728. }
  37729. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37730. import { Behavior } from "babylonjs/Behaviors/behavior";
  37731. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37732. /**
  37733. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37734. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37735. */
  37736. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37737. /**
  37738. * Gets the name of the behavior.
  37739. */
  37740. readonly name: string;
  37741. private _zoomStopsAnimation;
  37742. private _idleRotationSpeed;
  37743. private _idleRotationWaitTime;
  37744. private _idleRotationSpinupTime;
  37745. /**
  37746. * Sets the flag that indicates if user zooming should stop animation.
  37747. */
  37748. /**
  37749. * Gets the flag that indicates if user zooming should stop animation.
  37750. */
  37751. zoomStopsAnimation: boolean;
  37752. /**
  37753. * Sets the default speed at which the camera rotates around the model.
  37754. */
  37755. /**
  37756. * Gets the default speed at which the camera rotates around the model.
  37757. */
  37758. idleRotationSpeed: number;
  37759. /**
  37760. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37761. */
  37762. /**
  37763. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37764. */
  37765. idleRotationWaitTime: number;
  37766. /**
  37767. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37768. */
  37769. /**
  37770. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37771. */
  37772. idleRotationSpinupTime: number;
  37773. /**
  37774. * Gets a value indicating if the camera is currently rotating because of this behavior
  37775. */
  37776. readonly rotationInProgress: boolean;
  37777. private _onPrePointerObservableObserver;
  37778. private _onAfterCheckInputsObserver;
  37779. private _attachedCamera;
  37780. private _isPointerDown;
  37781. private _lastFrameTime;
  37782. private _lastInteractionTime;
  37783. private _cameraRotationSpeed;
  37784. /**
  37785. * Initializes the behavior.
  37786. */
  37787. init(): void;
  37788. /**
  37789. * Attaches the behavior to its arc rotate camera.
  37790. * @param camera Defines the camera to attach the behavior to
  37791. */
  37792. attach(camera: ArcRotateCamera): void;
  37793. /**
  37794. * Detaches the behavior from its current arc rotate camera.
  37795. */
  37796. detach(): void;
  37797. /**
  37798. * Returns true if user is scrolling.
  37799. * @return true if user is scrolling.
  37800. */
  37801. private _userIsZooming;
  37802. private _lastFrameRadius;
  37803. private _shouldAnimationStopForInteraction;
  37804. /**
  37805. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37806. */
  37807. private _applyUserInteraction;
  37808. private _userIsMoving;
  37809. }
  37810. }
  37811. declare module "babylonjs/Behaviors/Cameras/index" {
  37812. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37813. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37814. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37815. }
  37816. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37817. import { Mesh } from "babylonjs/Meshes/mesh";
  37818. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37819. import { Behavior } from "babylonjs/Behaviors/behavior";
  37820. /**
  37821. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37822. */
  37823. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37824. private ui;
  37825. /**
  37826. * The name of the behavior
  37827. */
  37828. name: string;
  37829. /**
  37830. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37831. */
  37832. distanceAwayFromFace: number;
  37833. /**
  37834. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37835. */
  37836. distanceAwayFromBottomOfFace: number;
  37837. private _faceVectors;
  37838. private _target;
  37839. private _scene;
  37840. private _onRenderObserver;
  37841. private _tmpMatrix;
  37842. private _tmpVector;
  37843. /**
  37844. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37845. * @param ui The transform node that should be attched to the mesh
  37846. */
  37847. constructor(ui: TransformNode);
  37848. /**
  37849. * Initializes the behavior
  37850. */
  37851. init(): void;
  37852. private _closestFace;
  37853. private _zeroVector;
  37854. private _lookAtTmpMatrix;
  37855. private _lookAtToRef;
  37856. /**
  37857. * Attaches the AttachToBoxBehavior to the passed in mesh
  37858. * @param target The mesh that the specified node will be attached to
  37859. */
  37860. attach(target: Mesh): void;
  37861. /**
  37862. * Detaches the behavior from the mesh
  37863. */
  37864. detach(): void;
  37865. }
  37866. }
  37867. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37868. import { Behavior } from "babylonjs/Behaviors/behavior";
  37869. import { Mesh } from "babylonjs/Meshes/mesh";
  37870. /**
  37871. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37872. */
  37873. export class FadeInOutBehavior implements Behavior<Mesh> {
  37874. /**
  37875. * Time in milliseconds to delay before fading in (Default: 0)
  37876. */
  37877. delay: number;
  37878. /**
  37879. * Time in milliseconds for the mesh to fade in (Default: 300)
  37880. */
  37881. fadeInTime: number;
  37882. private _millisecondsPerFrame;
  37883. private _hovered;
  37884. private _hoverValue;
  37885. private _ownerNode;
  37886. /**
  37887. * Instatiates the FadeInOutBehavior
  37888. */
  37889. constructor();
  37890. /**
  37891. * The name of the behavior
  37892. */
  37893. readonly name: string;
  37894. /**
  37895. * Initializes the behavior
  37896. */
  37897. init(): void;
  37898. /**
  37899. * Attaches the fade behavior on the passed in mesh
  37900. * @param ownerNode The mesh that will be faded in/out once attached
  37901. */
  37902. attach(ownerNode: Mesh): void;
  37903. /**
  37904. * Detaches the behavior from the mesh
  37905. */
  37906. detach(): void;
  37907. /**
  37908. * Triggers the mesh to begin fading in or out
  37909. * @param value if the object should fade in or out (true to fade in)
  37910. */
  37911. fadeIn(value: boolean): void;
  37912. private _update;
  37913. private _setAllVisibility;
  37914. }
  37915. }
  37916. declare module "babylonjs/Misc/pivotTools" {
  37917. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37918. /**
  37919. * Class containing a set of static utilities functions for managing Pivots
  37920. * @hidden
  37921. */
  37922. export class PivotTools {
  37923. private static _PivotCached;
  37924. private static _OldPivotPoint;
  37925. private static _PivotTranslation;
  37926. private static _PivotTmpVector;
  37927. /** @hidden */
  37928. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37929. /** @hidden */
  37930. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37931. }
  37932. }
  37933. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37934. import { Scene } from "babylonjs/scene";
  37935. import { Vector4 } from "babylonjs/Maths/math.vector";
  37936. import { Mesh } from "babylonjs/Meshes/mesh";
  37937. import { Nullable } from "babylonjs/types";
  37938. import { Plane } from "babylonjs/Maths/math.plane";
  37939. /**
  37940. * Class containing static functions to help procedurally build meshes
  37941. */
  37942. export class PlaneBuilder {
  37943. /**
  37944. * Creates a plane mesh
  37945. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37946. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37947. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37948. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37949. * * 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
  37950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37951. * @param name defines the name of the mesh
  37952. * @param options defines the options used to create the mesh
  37953. * @param scene defines the hosting scene
  37954. * @returns the plane mesh
  37955. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37956. */
  37957. static CreatePlane(name: string, options: {
  37958. size?: number;
  37959. width?: number;
  37960. height?: number;
  37961. sideOrientation?: number;
  37962. frontUVs?: Vector4;
  37963. backUVs?: Vector4;
  37964. updatable?: boolean;
  37965. sourcePlane?: Plane;
  37966. }, scene?: Nullable<Scene>): Mesh;
  37967. }
  37968. }
  37969. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37970. import { Behavior } from "babylonjs/Behaviors/behavior";
  37971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37972. import { Observable } from "babylonjs/Misc/observable";
  37973. import { Vector3 } from "babylonjs/Maths/math.vector";
  37974. import { Ray } from "babylonjs/Culling/ray";
  37975. import "babylonjs/Meshes/Builders/planeBuilder";
  37976. /**
  37977. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37978. */
  37979. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37980. private static _AnyMouseID;
  37981. /**
  37982. * Abstract mesh the behavior is set on
  37983. */
  37984. attachedNode: AbstractMesh;
  37985. private _dragPlane;
  37986. private _scene;
  37987. private _pointerObserver;
  37988. private _beforeRenderObserver;
  37989. private static _planeScene;
  37990. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37991. /**
  37992. * 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)
  37993. */
  37994. maxDragAngle: number;
  37995. /**
  37996. * @hidden
  37997. */
  37998. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37999. /**
  38000. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38001. */
  38002. currentDraggingPointerID: number;
  38003. /**
  38004. * The last position where the pointer hit the drag plane in world space
  38005. */
  38006. lastDragPosition: Vector3;
  38007. /**
  38008. * If the behavior is currently in a dragging state
  38009. */
  38010. dragging: boolean;
  38011. /**
  38012. * 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)
  38013. */
  38014. dragDeltaRatio: number;
  38015. /**
  38016. * If the drag plane orientation should be updated during the dragging (Default: true)
  38017. */
  38018. updateDragPlane: boolean;
  38019. private _debugMode;
  38020. private _moving;
  38021. /**
  38022. * Fires each time the attached mesh is dragged with the pointer
  38023. * * delta between last drag position and current drag position in world space
  38024. * * dragDistance along the drag axis
  38025. * * dragPlaneNormal normal of the current drag plane used during the drag
  38026. * * dragPlanePoint in world space where the drag intersects the drag plane
  38027. */
  38028. onDragObservable: Observable<{
  38029. delta: Vector3;
  38030. dragPlanePoint: Vector3;
  38031. dragPlaneNormal: Vector3;
  38032. dragDistance: number;
  38033. pointerId: number;
  38034. }>;
  38035. /**
  38036. * Fires each time a drag begins (eg. mouse down on mesh)
  38037. */
  38038. onDragStartObservable: Observable<{
  38039. dragPlanePoint: Vector3;
  38040. pointerId: number;
  38041. }>;
  38042. /**
  38043. * Fires each time a drag ends (eg. mouse release after drag)
  38044. */
  38045. onDragEndObservable: Observable<{
  38046. dragPlanePoint: Vector3;
  38047. pointerId: number;
  38048. }>;
  38049. /**
  38050. * If the attached mesh should be moved when dragged
  38051. */
  38052. moveAttached: boolean;
  38053. /**
  38054. * If the drag behavior will react to drag events (Default: true)
  38055. */
  38056. enabled: boolean;
  38057. /**
  38058. * If pointer events should start and release the drag (Default: true)
  38059. */
  38060. startAndReleaseDragOnPointerEvents: boolean;
  38061. /**
  38062. * If camera controls should be detached during the drag
  38063. */
  38064. detachCameraControls: boolean;
  38065. /**
  38066. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38067. */
  38068. useObjectOrienationForDragging: boolean;
  38069. private _options;
  38070. /**
  38071. * Creates a pointer drag behavior that can be attached to a mesh
  38072. * @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)
  38073. */
  38074. constructor(options?: {
  38075. dragAxis?: Vector3;
  38076. dragPlaneNormal?: Vector3;
  38077. });
  38078. /**
  38079. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38080. */
  38081. validateDrag: (targetPosition: Vector3) => boolean;
  38082. /**
  38083. * The name of the behavior
  38084. */
  38085. readonly name: string;
  38086. /**
  38087. * Initializes the behavior
  38088. */
  38089. init(): void;
  38090. private _tmpVector;
  38091. private _alternatePickedPoint;
  38092. private _worldDragAxis;
  38093. private _targetPosition;
  38094. private _attachedElement;
  38095. /**
  38096. * Attaches the drag behavior the passed in mesh
  38097. * @param ownerNode The mesh that will be dragged around once attached
  38098. * @param predicate Predicate to use for pick filtering
  38099. */
  38100. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38101. /**
  38102. * Force relase the drag action by code.
  38103. */
  38104. releaseDrag(): void;
  38105. private _startDragRay;
  38106. private _lastPointerRay;
  38107. /**
  38108. * Simulates the start of a pointer drag event on the behavior
  38109. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38110. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38111. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38112. */
  38113. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38114. private _startDrag;
  38115. private _dragDelta;
  38116. private _moveDrag;
  38117. private _pickWithRayOnDragPlane;
  38118. private _pointA;
  38119. private _pointB;
  38120. private _pointC;
  38121. private _lineA;
  38122. private _lineB;
  38123. private _localAxis;
  38124. private _lookAt;
  38125. private _updateDragPlanePosition;
  38126. /**
  38127. * Detaches the behavior from the mesh
  38128. */
  38129. detach(): void;
  38130. }
  38131. }
  38132. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38133. import { Mesh } from "babylonjs/Meshes/mesh";
  38134. import { Behavior } from "babylonjs/Behaviors/behavior";
  38135. /**
  38136. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38137. */
  38138. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38139. private _dragBehaviorA;
  38140. private _dragBehaviorB;
  38141. private _startDistance;
  38142. private _initialScale;
  38143. private _targetScale;
  38144. private _ownerNode;
  38145. private _sceneRenderObserver;
  38146. /**
  38147. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38148. */
  38149. constructor();
  38150. /**
  38151. * The name of the behavior
  38152. */
  38153. readonly name: string;
  38154. /**
  38155. * Initializes the behavior
  38156. */
  38157. init(): void;
  38158. private _getCurrentDistance;
  38159. /**
  38160. * Attaches the scale behavior the passed in mesh
  38161. * @param ownerNode The mesh that will be scaled around once attached
  38162. */
  38163. attach(ownerNode: Mesh): void;
  38164. /**
  38165. * Detaches the behavior from the mesh
  38166. */
  38167. detach(): void;
  38168. }
  38169. }
  38170. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38171. import { Behavior } from "babylonjs/Behaviors/behavior";
  38172. import { Mesh } from "babylonjs/Meshes/mesh";
  38173. import { Observable } from "babylonjs/Misc/observable";
  38174. /**
  38175. * 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
  38176. */
  38177. export class SixDofDragBehavior implements Behavior<Mesh> {
  38178. private static _virtualScene;
  38179. private _ownerNode;
  38180. private _sceneRenderObserver;
  38181. private _scene;
  38182. private _targetPosition;
  38183. private _virtualOriginMesh;
  38184. private _virtualDragMesh;
  38185. private _pointerObserver;
  38186. private _moving;
  38187. private _startingOrientation;
  38188. /**
  38189. * 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)
  38190. */
  38191. private zDragFactor;
  38192. /**
  38193. * If the object should rotate to face the drag origin
  38194. */
  38195. rotateDraggedObject: boolean;
  38196. /**
  38197. * If the behavior is currently in a dragging state
  38198. */
  38199. dragging: boolean;
  38200. /**
  38201. * 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)
  38202. */
  38203. dragDeltaRatio: number;
  38204. /**
  38205. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38206. */
  38207. currentDraggingPointerID: number;
  38208. /**
  38209. * If camera controls should be detached during the drag
  38210. */
  38211. detachCameraControls: boolean;
  38212. /**
  38213. * Fires each time a drag starts
  38214. */
  38215. onDragStartObservable: Observable<{}>;
  38216. /**
  38217. * Fires each time a drag ends (eg. mouse release after drag)
  38218. */
  38219. onDragEndObservable: Observable<{}>;
  38220. /**
  38221. * 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
  38222. */
  38223. constructor();
  38224. /**
  38225. * The name of the behavior
  38226. */
  38227. readonly name: string;
  38228. /**
  38229. * Initializes the behavior
  38230. */
  38231. init(): void;
  38232. /**
  38233. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38234. */
  38235. private readonly _pointerCamera;
  38236. /**
  38237. * Attaches the scale behavior the passed in mesh
  38238. * @param ownerNode The mesh that will be scaled around once attached
  38239. */
  38240. attach(ownerNode: Mesh): void;
  38241. /**
  38242. * Detaches the behavior from the mesh
  38243. */
  38244. detach(): void;
  38245. }
  38246. }
  38247. declare module "babylonjs/Behaviors/Meshes/index" {
  38248. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38249. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38250. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38251. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38252. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38253. }
  38254. declare module "babylonjs/Behaviors/index" {
  38255. export * from "babylonjs/Behaviors/behavior";
  38256. export * from "babylonjs/Behaviors/Cameras/index";
  38257. export * from "babylonjs/Behaviors/Meshes/index";
  38258. }
  38259. declare module "babylonjs/Bones/boneIKController" {
  38260. import { Bone } from "babylonjs/Bones/bone";
  38261. import { Vector3 } from "babylonjs/Maths/math.vector";
  38262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38263. import { Nullable } from "babylonjs/types";
  38264. /**
  38265. * Class used to apply inverse kinematics to bones
  38266. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38267. */
  38268. export class BoneIKController {
  38269. private static _tmpVecs;
  38270. private static _tmpQuat;
  38271. private static _tmpMats;
  38272. /**
  38273. * Gets or sets the target mesh
  38274. */
  38275. targetMesh: AbstractMesh;
  38276. /** Gets or sets the mesh used as pole */
  38277. poleTargetMesh: AbstractMesh;
  38278. /**
  38279. * Gets or sets the bone used as pole
  38280. */
  38281. poleTargetBone: Nullable<Bone>;
  38282. /**
  38283. * Gets or sets the target position
  38284. */
  38285. targetPosition: Vector3;
  38286. /**
  38287. * Gets or sets the pole target position
  38288. */
  38289. poleTargetPosition: Vector3;
  38290. /**
  38291. * Gets or sets the pole target local offset
  38292. */
  38293. poleTargetLocalOffset: Vector3;
  38294. /**
  38295. * Gets or sets the pole angle
  38296. */
  38297. poleAngle: number;
  38298. /**
  38299. * Gets or sets the mesh associated with the controller
  38300. */
  38301. mesh: AbstractMesh;
  38302. /**
  38303. * 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)
  38304. */
  38305. slerpAmount: number;
  38306. private _bone1Quat;
  38307. private _bone1Mat;
  38308. private _bone2Ang;
  38309. private _bone1;
  38310. private _bone2;
  38311. private _bone1Length;
  38312. private _bone2Length;
  38313. private _maxAngle;
  38314. private _maxReach;
  38315. private _rightHandedSystem;
  38316. private _bendAxis;
  38317. private _slerping;
  38318. private _adjustRoll;
  38319. /**
  38320. * Gets or sets maximum allowed angle
  38321. */
  38322. maxAngle: number;
  38323. /**
  38324. * Creates a new BoneIKController
  38325. * @param mesh defines the mesh to control
  38326. * @param bone defines the bone to control
  38327. * @param options defines options to set up the controller
  38328. */
  38329. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38330. targetMesh?: AbstractMesh;
  38331. poleTargetMesh?: AbstractMesh;
  38332. poleTargetBone?: Bone;
  38333. poleTargetLocalOffset?: Vector3;
  38334. poleAngle?: number;
  38335. bendAxis?: Vector3;
  38336. maxAngle?: number;
  38337. slerpAmount?: number;
  38338. });
  38339. private _setMaxAngle;
  38340. /**
  38341. * Force the controller to update the bones
  38342. */
  38343. update(): void;
  38344. }
  38345. }
  38346. declare module "babylonjs/Bones/boneLookController" {
  38347. import { Vector3 } from "babylonjs/Maths/math.vector";
  38348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38349. import { Bone } from "babylonjs/Bones/bone";
  38350. import { Space } from "babylonjs/Maths/math.axis";
  38351. /**
  38352. * Class used to make a bone look toward a point in space
  38353. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38354. */
  38355. export class BoneLookController {
  38356. private static _tmpVecs;
  38357. private static _tmpQuat;
  38358. private static _tmpMats;
  38359. /**
  38360. * The target Vector3 that the bone will look at
  38361. */
  38362. target: Vector3;
  38363. /**
  38364. * The mesh that the bone is attached to
  38365. */
  38366. mesh: AbstractMesh;
  38367. /**
  38368. * The bone that will be looking to the target
  38369. */
  38370. bone: Bone;
  38371. /**
  38372. * The up axis of the coordinate system that is used when the bone is rotated
  38373. */
  38374. upAxis: Vector3;
  38375. /**
  38376. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38377. */
  38378. upAxisSpace: Space;
  38379. /**
  38380. * Used to make an adjustment to the yaw of the bone
  38381. */
  38382. adjustYaw: number;
  38383. /**
  38384. * Used to make an adjustment to the pitch of the bone
  38385. */
  38386. adjustPitch: number;
  38387. /**
  38388. * Used to make an adjustment to the roll of the bone
  38389. */
  38390. adjustRoll: number;
  38391. /**
  38392. * 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)
  38393. */
  38394. slerpAmount: number;
  38395. private _minYaw;
  38396. private _maxYaw;
  38397. private _minPitch;
  38398. private _maxPitch;
  38399. private _minYawSin;
  38400. private _minYawCos;
  38401. private _maxYawSin;
  38402. private _maxYawCos;
  38403. private _midYawConstraint;
  38404. private _minPitchTan;
  38405. private _maxPitchTan;
  38406. private _boneQuat;
  38407. private _slerping;
  38408. private _transformYawPitch;
  38409. private _transformYawPitchInv;
  38410. private _firstFrameSkipped;
  38411. private _yawRange;
  38412. private _fowardAxis;
  38413. /**
  38414. * Gets or sets the minimum yaw angle that the bone can look to
  38415. */
  38416. minYaw: number;
  38417. /**
  38418. * Gets or sets the maximum yaw angle that the bone can look to
  38419. */
  38420. maxYaw: number;
  38421. /**
  38422. * Gets or sets the minimum pitch angle that the bone can look to
  38423. */
  38424. minPitch: number;
  38425. /**
  38426. * Gets or sets the maximum pitch angle that the bone can look to
  38427. */
  38428. maxPitch: number;
  38429. /**
  38430. * Create a BoneLookController
  38431. * @param mesh the mesh that the bone belongs to
  38432. * @param bone the bone that will be looking to the target
  38433. * @param target the target Vector3 to look at
  38434. * @param options optional settings:
  38435. * * maxYaw: the maximum angle the bone will yaw to
  38436. * * minYaw: the minimum angle the bone will yaw to
  38437. * * maxPitch: the maximum angle the bone will pitch to
  38438. * * minPitch: the minimum angle the bone will yaw to
  38439. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38440. * * upAxis: the up axis of the coordinate system
  38441. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38442. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38443. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38444. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38445. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38446. * * adjustRoll: used to make an adjustment to the roll of the bone
  38447. **/
  38448. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38449. maxYaw?: number;
  38450. minYaw?: number;
  38451. maxPitch?: number;
  38452. minPitch?: number;
  38453. slerpAmount?: number;
  38454. upAxis?: Vector3;
  38455. upAxisSpace?: Space;
  38456. yawAxis?: Vector3;
  38457. pitchAxis?: Vector3;
  38458. adjustYaw?: number;
  38459. adjustPitch?: number;
  38460. adjustRoll?: number;
  38461. });
  38462. /**
  38463. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38464. */
  38465. update(): void;
  38466. private _getAngleDiff;
  38467. private _getAngleBetween;
  38468. private _isAngleBetween;
  38469. }
  38470. }
  38471. declare module "babylonjs/Bones/index" {
  38472. export * from "babylonjs/Bones/bone";
  38473. export * from "babylonjs/Bones/boneIKController";
  38474. export * from "babylonjs/Bones/boneLookController";
  38475. export * from "babylonjs/Bones/skeleton";
  38476. }
  38477. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38478. import { Nullable } from "babylonjs/types";
  38479. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38480. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38481. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38482. /**
  38483. * Manage the gamepad inputs to control an arc rotate camera.
  38484. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38485. */
  38486. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38487. /**
  38488. * Defines the camera the input is attached to.
  38489. */
  38490. camera: ArcRotateCamera;
  38491. /**
  38492. * Defines the gamepad the input is gathering event from.
  38493. */
  38494. gamepad: Nullable<Gamepad>;
  38495. /**
  38496. * Defines the gamepad rotation sensiblity.
  38497. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38498. */
  38499. gamepadRotationSensibility: number;
  38500. /**
  38501. * Defines the gamepad move sensiblity.
  38502. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38503. */
  38504. gamepadMoveSensibility: number;
  38505. private _yAxisScale;
  38506. /**
  38507. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38508. */
  38509. invertYAxis: boolean;
  38510. private _onGamepadConnectedObserver;
  38511. private _onGamepadDisconnectedObserver;
  38512. /**
  38513. * Attach the input controls to a specific dom element to get the input from.
  38514. * @param element Defines the element the controls should be listened from
  38515. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38516. */
  38517. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38518. /**
  38519. * Detach the current controls from the specified dom element.
  38520. * @param element Defines the element to stop listening the inputs from
  38521. */
  38522. detachControl(element: Nullable<HTMLElement>): void;
  38523. /**
  38524. * Update the current camera state depending on the inputs that have been used this frame.
  38525. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38526. */
  38527. checkInputs(): void;
  38528. /**
  38529. * Gets the class name of the current intput.
  38530. * @returns the class name
  38531. */
  38532. getClassName(): string;
  38533. /**
  38534. * Get the friendly name associated with the input class.
  38535. * @returns the input friendly name
  38536. */
  38537. getSimpleName(): string;
  38538. }
  38539. }
  38540. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38541. import { Nullable } from "babylonjs/types";
  38542. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38543. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38544. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38545. interface ArcRotateCameraInputsManager {
  38546. /**
  38547. * Add orientation input support to the input manager.
  38548. * @returns the current input manager
  38549. */
  38550. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38551. }
  38552. }
  38553. /**
  38554. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38555. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38556. */
  38557. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38558. /**
  38559. * Defines the camera the input is attached to.
  38560. */
  38561. camera: ArcRotateCamera;
  38562. /**
  38563. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38564. */
  38565. alphaCorrection: number;
  38566. /**
  38567. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38568. */
  38569. gammaCorrection: number;
  38570. private _alpha;
  38571. private _gamma;
  38572. private _dirty;
  38573. private _deviceOrientationHandler;
  38574. /**
  38575. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38576. */
  38577. constructor();
  38578. /**
  38579. * Attach the input controls to a specific dom element to get the input from.
  38580. * @param element Defines the element the controls should be listened from
  38581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38582. */
  38583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38584. /** @hidden */
  38585. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38586. /**
  38587. * Update the current camera state depending on the inputs that have been used this frame.
  38588. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38589. */
  38590. checkInputs(): void;
  38591. /**
  38592. * Detach the current controls from the specified dom element.
  38593. * @param element Defines the element to stop listening the inputs from
  38594. */
  38595. detachControl(element: Nullable<HTMLElement>): void;
  38596. /**
  38597. * Gets the class name of the current intput.
  38598. * @returns the class name
  38599. */
  38600. getClassName(): string;
  38601. /**
  38602. * Get the friendly name associated with the input class.
  38603. * @returns the input friendly name
  38604. */
  38605. getSimpleName(): string;
  38606. }
  38607. }
  38608. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38609. import { Nullable } from "babylonjs/types";
  38610. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38611. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38612. /**
  38613. * Listen to mouse events to control the camera.
  38614. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38615. */
  38616. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38617. /**
  38618. * Defines the camera the input is attached to.
  38619. */
  38620. camera: FlyCamera;
  38621. /**
  38622. * Defines if touch is enabled. (Default is true.)
  38623. */
  38624. touchEnabled: boolean;
  38625. /**
  38626. * Defines the buttons associated with the input to handle camera rotation.
  38627. */
  38628. buttons: number[];
  38629. /**
  38630. * Assign buttons for Yaw control.
  38631. */
  38632. buttonsYaw: number[];
  38633. /**
  38634. * Assign buttons for Pitch control.
  38635. */
  38636. buttonsPitch: number[];
  38637. /**
  38638. * Assign buttons for Roll control.
  38639. */
  38640. buttonsRoll: number[];
  38641. /**
  38642. * Detect if any button is being pressed while mouse is moved.
  38643. * -1 = Mouse locked.
  38644. * 0 = Left button.
  38645. * 1 = Middle Button.
  38646. * 2 = Right Button.
  38647. */
  38648. activeButton: number;
  38649. /**
  38650. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38651. * Higher values reduce its sensitivity.
  38652. */
  38653. angularSensibility: number;
  38654. private _mousemoveCallback;
  38655. private _observer;
  38656. private _rollObserver;
  38657. private previousPosition;
  38658. private noPreventDefault;
  38659. private element;
  38660. /**
  38661. * Listen to mouse events to control the camera.
  38662. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38663. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38664. */
  38665. constructor(touchEnabled?: boolean);
  38666. /**
  38667. * Attach the mouse control to the HTML DOM element.
  38668. * @param element Defines the element that listens to the input events.
  38669. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38670. */
  38671. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38672. /**
  38673. * Detach the current controls from the specified dom element.
  38674. * @param element Defines the element to stop listening the inputs from
  38675. */
  38676. detachControl(element: Nullable<HTMLElement>): void;
  38677. /**
  38678. * Gets the class name of the current input.
  38679. * @returns the class name.
  38680. */
  38681. getClassName(): string;
  38682. /**
  38683. * Get the friendly name associated with the input class.
  38684. * @returns the input's friendly name.
  38685. */
  38686. getSimpleName(): string;
  38687. private _pointerInput;
  38688. private _onMouseMove;
  38689. /**
  38690. * Rotate camera by mouse offset.
  38691. */
  38692. private rotateCamera;
  38693. }
  38694. }
  38695. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38696. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38697. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38698. /**
  38699. * Default Inputs manager for the FlyCamera.
  38700. * It groups all the default supported inputs for ease of use.
  38701. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38702. */
  38703. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38704. /**
  38705. * Instantiates a new FlyCameraInputsManager.
  38706. * @param camera Defines the camera the inputs belong to.
  38707. */
  38708. constructor(camera: FlyCamera);
  38709. /**
  38710. * Add keyboard input support to the input manager.
  38711. * @returns the new FlyCameraKeyboardMoveInput().
  38712. */
  38713. addKeyboard(): FlyCameraInputsManager;
  38714. /**
  38715. * Add mouse input support to the input manager.
  38716. * @param touchEnabled Enable touch screen support.
  38717. * @returns the new FlyCameraMouseInput().
  38718. */
  38719. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38720. }
  38721. }
  38722. declare module "babylonjs/Cameras/flyCamera" {
  38723. import { Scene } from "babylonjs/scene";
  38724. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38726. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38727. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38728. /**
  38729. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38730. * such as in a 3D Space Shooter or a Flight Simulator.
  38731. */
  38732. export class FlyCamera extends TargetCamera {
  38733. /**
  38734. * Define the collision ellipsoid of the camera.
  38735. * This is helpful for simulating a camera body, like a player's body.
  38736. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38737. */
  38738. ellipsoid: Vector3;
  38739. /**
  38740. * Define an offset for the position of the ellipsoid around the camera.
  38741. * This can be helpful if the camera is attached away from the player's body center,
  38742. * such as at its head.
  38743. */
  38744. ellipsoidOffset: Vector3;
  38745. /**
  38746. * Enable or disable collisions of the camera with the rest of the scene objects.
  38747. */
  38748. checkCollisions: boolean;
  38749. /**
  38750. * Enable or disable gravity on the camera.
  38751. */
  38752. applyGravity: boolean;
  38753. /**
  38754. * Define the current direction the camera is moving to.
  38755. */
  38756. cameraDirection: Vector3;
  38757. /**
  38758. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38759. * This overrides and empties cameraRotation.
  38760. */
  38761. rotationQuaternion: Quaternion;
  38762. /**
  38763. * Track Roll to maintain the wanted Rolling when looking around.
  38764. */
  38765. _trackRoll: number;
  38766. /**
  38767. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38768. */
  38769. rollCorrect: number;
  38770. /**
  38771. * Mimic a banked turn, Rolling the camera when Yawing.
  38772. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38773. */
  38774. bankedTurn: boolean;
  38775. /**
  38776. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38777. */
  38778. bankedTurnLimit: number;
  38779. /**
  38780. * Value of 0 disables the banked Roll.
  38781. * Value of 1 is equal to the Yaw angle in radians.
  38782. */
  38783. bankedTurnMultiplier: number;
  38784. /**
  38785. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38786. */
  38787. inputs: FlyCameraInputsManager;
  38788. /**
  38789. * Gets the input sensibility for mouse input.
  38790. * Higher values reduce sensitivity.
  38791. */
  38792. /**
  38793. * Sets the input sensibility for a mouse input.
  38794. * Higher values reduce sensitivity.
  38795. */
  38796. angularSensibility: number;
  38797. /**
  38798. * Get the keys for camera movement forward.
  38799. */
  38800. /**
  38801. * Set the keys for camera movement forward.
  38802. */
  38803. keysForward: number[];
  38804. /**
  38805. * Get the keys for camera movement backward.
  38806. */
  38807. keysBackward: number[];
  38808. /**
  38809. * Get the keys for camera movement up.
  38810. */
  38811. /**
  38812. * Set the keys for camera movement up.
  38813. */
  38814. keysUp: number[];
  38815. /**
  38816. * Get the keys for camera movement down.
  38817. */
  38818. /**
  38819. * Set the keys for camera movement down.
  38820. */
  38821. keysDown: number[];
  38822. /**
  38823. * Get the keys for camera movement left.
  38824. */
  38825. /**
  38826. * Set the keys for camera movement left.
  38827. */
  38828. keysLeft: number[];
  38829. /**
  38830. * Set the keys for camera movement right.
  38831. */
  38832. /**
  38833. * Set the keys for camera movement right.
  38834. */
  38835. keysRight: number[];
  38836. /**
  38837. * Event raised when the camera collides with a mesh in the scene.
  38838. */
  38839. onCollide: (collidedMesh: AbstractMesh) => void;
  38840. private _collider;
  38841. private _needMoveForGravity;
  38842. private _oldPosition;
  38843. private _diffPosition;
  38844. private _newPosition;
  38845. /** @hidden */
  38846. _localDirection: Vector3;
  38847. /** @hidden */
  38848. _transformedDirection: Vector3;
  38849. /**
  38850. * Instantiates a FlyCamera.
  38851. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38852. * such as in a 3D Space Shooter or a Flight Simulator.
  38853. * @param name Define the name of the camera in the scene.
  38854. * @param position Define the starting position of the camera in the scene.
  38855. * @param scene Define the scene the camera belongs to.
  38856. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38857. */
  38858. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38859. /**
  38860. * Attach a control to the HTML DOM element.
  38861. * @param element Defines the element that listens to the input events.
  38862. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38863. */
  38864. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38865. /**
  38866. * Detach a control from the HTML DOM element.
  38867. * The camera will stop reacting to that input.
  38868. * @param element Defines the element that listens to the input events.
  38869. */
  38870. detachControl(element: HTMLElement): void;
  38871. private _collisionMask;
  38872. /**
  38873. * Get the mask that the camera ignores in collision events.
  38874. */
  38875. /**
  38876. * Set the mask that the camera ignores in collision events.
  38877. */
  38878. collisionMask: number;
  38879. /** @hidden */
  38880. _collideWithWorld(displacement: Vector3): void;
  38881. /** @hidden */
  38882. private _onCollisionPositionChange;
  38883. /** @hidden */
  38884. _checkInputs(): void;
  38885. /** @hidden */
  38886. _decideIfNeedsToMove(): boolean;
  38887. /** @hidden */
  38888. _updatePosition(): void;
  38889. /**
  38890. * Restore the Roll to its target value at the rate specified.
  38891. * @param rate - Higher means slower restoring.
  38892. * @hidden
  38893. */
  38894. restoreRoll(rate: number): void;
  38895. /**
  38896. * Destroy the camera and release the current resources held by it.
  38897. */
  38898. dispose(): void;
  38899. /**
  38900. * Get the current object class name.
  38901. * @returns the class name.
  38902. */
  38903. getClassName(): string;
  38904. }
  38905. }
  38906. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38907. import { Nullable } from "babylonjs/types";
  38908. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38909. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38910. /**
  38911. * Listen to keyboard events to control the camera.
  38912. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38913. */
  38914. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38915. /**
  38916. * Defines the camera the input is attached to.
  38917. */
  38918. camera: FlyCamera;
  38919. /**
  38920. * The list of keyboard keys used to control the forward move of the camera.
  38921. */
  38922. keysForward: number[];
  38923. /**
  38924. * The list of keyboard keys used to control the backward move of the camera.
  38925. */
  38926. keysBackward: number[];
  38927. /**
  38928. * The list of keyboard keys used to control the forward move of the camera.
  38929. */
  38930. keysUp: number[];
  38931. /**
  38932. * The list of keyboard keys used to control the backward move of the camera.
  38933. */
  38934. keysDown: number[];
  38935. /**
  38936. * The list of keyboard keys used to control the right strafe move of the camera.
  38937. */
  38938. keysRight: number[];
  38939. /**
  38940. * The list of keyboard keys used to control the left strafe move of the camera.
  38941. */
  38942. keysLeft: number[];
  38943. private _keys;
  38944. private _onCanvasBlurObserver;
  38945. private _onKeyboardObserver;
  38946. private _engine;
  38947. private _scene;
  38948. /**
  38949. * Attach the input controls to a specific dom element to get the input from.
  38950. * @param element Defines the element the controls should be listened from
  38951. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38952. */
  38953. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38954. /**
  38955. * Detach the current controls from the specified dom element.
  38956. * @param element Defines the element to stop listening the inputs from
  38957. */
  38958. detachControl(element: Nullable<HTMLElement>): void;
  38959. /**
  38960. * Gets the class name of the current intput.
  38961. * @returns the class name
  38962. */
  38963. getClassName(): string;
  38964. /** @hidden */
  38965. _onLostFocus(e: FocusEvent): void;
  38966. /**
  38967. * Get the friendly name associated with the input class.
  38968. * @returns the input friendly name
  38969. */
  38970. getSimpleName(): string;
  38971. /**
  38972. * Update the current camera state depending on the inputs that have been used this frame.
  38973. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38974. */
  38975. checkInputs(): void;
  38976. }
  38977. }
  38978. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38979. import { Nullable } from "babylonjs/types";
  38980. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38981. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38982. /**
  38983. * Manage the mouse wheel inputs to control a follow camera.
  38984. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38985. */
  38986. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38987. /**
  38988. * Defines the camera the input is attached to.
  38989. */
  38990. camera: FollowCamera;
  38991. /**
  38992. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38993. */
  38994. axisControlRadius: boolean;
  38995. /**
  38996. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38997. */
  38998. axisControlHeight: boolean;
  38999. /**
  39000. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39001. */
  39002. axisControlRotation: boolean;
  39003. /**
  39004. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39005. * relation to mouseWheel events.
  39006. */
  39007. wheelPrecision: number;
  39008. /**
  39009. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39010. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39011. */
  39012. wheelDeltaPercentage: number;
  39013. private _wheel;
  39014. private _observer;
  39015. /**
  39016. * Attach the input controls to a specific dom element to get the input from.
  39017. * @param element Defines the element the controls should be listened from
  39018. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39019. */
  39020. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39021. /**
  39022. * Detach the current controls from the specified dom element.
  39023. * @param element Defines the element to stop listening the inputs from
  39024. */
  39025. detachControl(element: Nullable<HTMLElement>): void;
  39026. /**
  39027. * Gets the class name of the current intput.
  39028. * @returns the class name
  39029. */
  39030. getClassName(): string;
  39031. /**
  39032. * Get the friendly name associated with the input class.
  39033. * @returns the input friendly name
  39034. */
  39035. getSimpleName(): string;
  39036. }
  39037. }
  39038. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39039. import { Nullable } from "babylonjs/types";
  39040. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39041. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39042. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39043. /**
  39044. * Manage the pointers inputs to control an follow camera.
  39045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39046. */
  39047. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39048. /**
  39049. * Defines the camera the input is attached to.
  39050. */
  39051. camera: FollowCamera;
  39052. /**
  39053. * Gets the class name of the current input.
  39054. * @returns the class name
  39055. */
  39056. getClassName(): string;
  39057. /**
  39058. * Defines the pointer angular sensibility along the X axis or how fast is
  39059. * the camera rotating.
  39060. * A negative number will reverse the axis direction.
  39061. */
  39062. angularSensibilityX: number;
  39063. /**
  39064. * Defines the pointer angular sensibility along the Y axis or how fast is
  39065. * the camera rotating.
  39066. * A negative number will reverse the axis direction.
  39067. */
  39068. angularSensibilityY: number;
  39069. /**
  39070. * Defines the pointer pinch precision or how fast is the camera zooming.
  39071. * A negative number will reverse the axis direction.
  39072. */
  39073. pinchPrecision: number;
  39074. /**
  39075. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39076. * from 0.
  39077. * It defines the percentage of current camera.radius to use as delta when
  39078. * pinch zoom is used.
  39079. */
  39080. pinchDeltaPercentage: number;
  39081. /**
  39082. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39083. */
  39084. axisXControlRadius: boolean;
  39085. /**
  39086. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39087. */
  39088. axisXControlHeight: boolean;
  39089. /**
  39090. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39091. */
  39092. axisXControlRotation: boolean;
  39093. /**
  39094. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39095. */
  39096. axisYControlRadius: boolean;
  39097. /**
  39098. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39099. */
  39100. axisYControlHeight: boolean;
  39101. /**
  39102. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39103. */
  39104. axisYControlRotation: boolean;
  39105. /**
  39106. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39107. */
  39108. axisPinchControlRadius: boolean;
  39109. /**
  39110. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39111. */
  39112. axisPinchControlHeight: boolean;
  39113. /**
  39114. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39115. */
  39116. axisPinchControlRotation: boolean;
  39117. /**
  39118. * Log error messages if basic misconfiguration has occurred.
  39119. */
  39120. warningEnable: boolean;
  39121. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39122. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39123. private _warningCounter;
  39124. private _warning;
  39125. }
  39126. }
  39127. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39128. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39129. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39130. /**
  39131. * Default Inputs manager for the FollowCamera.
  39132. * It groups all the default supported inputs for ease of use.
  39133. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39134. */
  39135. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39136. /**
  39137. * Instantiates a new FollowCameraInputsManager.
  39138. * @param camera Defines the camera the inputs belong to
  39139. */
  39140. constructor(camera: FollowCamera);
  39141. /**
  39142. * Add keyboard input support to the input manager.
  39143. * @returns the current input manager
  39144. */
  39145. addKeyboard(): FollowCameraInputsManager;
  39146. /**
  39147. * Add mouse wheel input support to the input manager.
  39148. * @returns the current input manager
  39149. */
  39150. addMouseWheel(): FollowCameraInputsManager;
  39151. /**
  39152. * Add pointers input support to the input manager.
  39153. * @returns the current input manager
  39154. */
  39155. addPointers(): FollowCameraInputsManager;
  39156. /**
  39157. * Add orientation input support to the input manager.
  39158. * @returns the current input manager
  39159. */
  39160. addVRDeviceOrientation(): FollowCameraInputsManager;
  39161. }
  39162. }
  39163. declare module "babylonjs/Cameras/followCamera" {
  39164. import { Nullable } from "babylonjs/types";
  39165. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39166. import { Scene } from "babylonjs/scene";
  39167. import { Vector3 } from "babylonjs/Maths/math.vector";
  39168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39169. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39170. /**
  39171. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39172. * an arc rotate version arcFollowCamera are available.
  39173. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39174. */
  39175. export class FollowCamera extends TargetCamera {
  39176. /**
  39177. * Distance the follow camera should follow an object at
  39178. */
  39179. radius: number;
  39180. /**
  39181. * Minimum allowed distance of the camera to the axis of rotation
  39182. * (The camera can not get closer).
  39183. * This can help limiting how the Camera is able to move in the scene.
  39184. */
  39185. lowerRadiusLimit: Nullable<number>;
  39186. /**
  39187. * Maximum allowed distance of the camera to the axis of rotation
  39188. * (The camera can not get further).
  39189. * This can help limiting how the Camera is able to move in the scene.
  39190. */
  39191. upperRadiusLimit: Nullable<number>;
  39192. /**
  39193. * Define a rotation offset between the camera and the object it follows
  39194. */
  39195. rotationOffset: number;
  39196. /**
  39197. * Minimum allowed angle to camera position relative to target object.
  39198. * This can help limiting how the Camera is able to move in the scene.
  39199. */
  39200. lowerRotationOffsetLimit: Nullable<number>;
  39201. /**
  39202. * Maximum allowed angle to camera position relative to target object.
  39203. * This can help limiting how the Camera is able to move in the scene.
  39204. */
  39205. upperRotationOffsetLimit: Nullable<number>;
  39206. /**
  39207. * Define a height offset between the camera and the object it follows.
  39208. * It can help following an object from the top (like a car chaing a plane)
  39209. */
  39210. heightOffset: number;
  39211. /**
  39212. * Minimum allowed height of camera position relative to target object.
  39213. * This can help limiting how the Camera is able to move in the scene.
  39214. */
  39215. lowerHeightOffsetLimit: Nullable<number>;
  39216. /**
  39217. * Maximum allowed height of camera position relative to target object.
  39218. * This can help limiting how the Camera is able to move in the scene.
  39219. */
  39220. upperHeightOffsetLimit: Nullable<number>;
  39221. /**
  39222. * Define how fast the camera can accelerate to follow it s target.
  39223. */
  39224. cameraAcceleration: number;
  39225. /**
  39226. * Define the speed limit of the camera following an object.
  39227. */
  39228. maxCameraSpeed: number;
  39229. /**
  39230. * Define the target of the camera.
  39231. */
  39232. lockedTarget: Nullable<AbstractMesh>;
  39233. /**
  39234. * Defines the input associated with the camera.
  39235. */
  39236. inputs: FollowCameraInputsManager;
  39237. /**
  39238. * Instantiates the follow camera.
  39239. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39240. * @param name Define the name of the camera in the scene
  39241. * @param position Define the position of the camera
  39242. * @param scene Define the scene the camera belong to
  39243. * @param lockedTarget Define the target of the camera
  39244. */
  39245. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39246. private _follow;
  39247. /**
  39248. * Attached controls to the current camera.
  39249. * @param element Defines the element the controls should be listened from
  39250. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39251. */
  39252. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39253. /**
  39254. * Detach the current controls from the camera.
  39255. * The camera will stop reacting to inputs.
  39256. * @param element Defines the element to stop listening the inputs from
  39257. */
  39258. detachControl(element: HTMLElement): void;
  39259. /** @hidden */
  39260. _checkInputs(): void;
  39261. private _checkLimits;
  39262. /**
  39263. * Gets the camera class name.
  39264. * @returns the class name
  39265. */
  39266. getClassName(): string;
  39267. }
  39268. /**
  39269. * Arc Rotate version of the follow camera.
  39270. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39271. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39272. */
  39273. export class ArcFollowCamera extends TargetCamera {
  39274. /** The longitudinal angle of the camera */
  39275. alpha: number;
  39276. /** The latitudinal angle of the camera */
  39277. beta: number;
  39278. /** The radius of the camera from its target */
  39279. radius: number;
  39280. /** Define the camera target (the messh it should follow) */
  39281. target: Nullable<AbstractMesh>;
  39282. private _cartesianCoordinates;
  39283. /**
  39284. * Instantiates a new ArcFollowCamera
  39285. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39286. * @param name Define the name of the camera
  39287. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39288. * @param beta Define the rotation angle of the camera around the elevation axis
  39289. * @param radius Define the radius of the camera from its target point
  39290. * @param target Define the target of the camera
  39291. * @param scene Define the scene the camera belongs to
  39292. */
  39293. constructor(name: string,
  39294. /** The longitudinal angle of the camera */
  39295. alpha: number,
  39296. /** The latitudinal angle of the camera */
  39297. beta: number,
  39298. /** The radius of the camera from its target */
  39299. radius: number,
  39300. /** Define the camera target (the messh it should follow) */
  39301. target: Nullable<AbstractMesh>, scene: Scene);
  39302. private _follow;
  39303. /** @hidden */
  39304. _checkInputs(): void;
  39305. /**
  39306. * Returns the class name of the object.
  39307. * It is mostly used internally for serialization purposes.
  39308. */
  39309. getClassName(): string;
  39310. }
  39311. }
  39312. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39313. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39314. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39315. import { Nullable } from "babylonjs/types";
  39316. /**
  39317. * Manage the keyboard inputs to control the movement of a follow camera.
  39318. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39319. */
  39320. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39321. /**
  39322. * Defines the camera the input is attached to.
  39323. */
  39324. camera: FollowCamera;
  39325. /**
  39326. * Defines the list of key codes associated with the up action (increase heightOffset)
  39327. */
  39328. keysHeightOffsetIncr: number[];
  39329. /**
  39330. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39331. */
  39332. keysHeightOffsetDecr: number[];
  39333. /**
  39334. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39335. */
  39336. keysHeightOffsetModifierAlt: boolean;
  39337. /**
  39338. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39339. */
  39340. keysHeightOffsetModifierCtrl: boolean;
  39341. /**
  39342. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39343. */
  39344. keysHeightOffsetModifierShift: boolean;
  39345. /**
  39346. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39347. */
  39348. keysRotationOffsetIncr: number[];
  39349. /**
  39350. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39351. */
  39352. keysRotationOffsetDecr: number[];
  39353. /**
  39354. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39355. */
  39356. keysRotationOffsetModifierAlt: boolean;
  39357. /**
  39358. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39359. */
  39360. keysRotationOffsetModifierCtrl: boolean;
  39361. /**
  39362. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39363. */
  39364. keysRotationOffsetModifierShift: boolean;
  39365. /**
  39366. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39367. */
  39368. keysRadiusIncr: number[];
  39369. /**
  39370. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39371. */
  39372. keysRadiusDecr: number[];
  39373. /**
  39374. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39375. */
  39376. keysRadiusModifierAlt: boolean;
  39377. /**
  39378. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39379. */
  39380. keysRadiusModifierCtrl: boolean;
  39381. /**
  39382. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39383. */
  39384. keysRadiusModifierShift: boolean;
  39385. /**
  39386. * Defines the rate of change of heightOffset.
  39387. */
  39388. heightSensibility: number;
  39389. /**
  39390. * Defines the rate of change of rotationOffset.
  39391. */
  39392. rotationSensibility: number;
  39393. /**
  39394. * Defines the rate of change of radius.
  39395. */
  39396. radiusSensibility: number;
  39397. private _keys;
  39398. private _ctrlPressed;
  39399. private _altPressed;
  39400. private _shiftPressed;
  39401. private _onCanvasBlurObserver;
  39402. private _onKeyboardObserver;
  39403. private _engine;
  39404. private _scene;
  39405. /**
  39406. * Attach the input controls to a specific dom element to get the input from.
  39407. * @param element Defines the element the controls should be listened from
  39408. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39409. */
  39410. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39411. /**
  39412. * Detach the current controls from the specified dom element.
  39413. * @param element Defines the element to stop listening the inputs from
  39414. */
  39415. detachControl(element: Nullable<HTMLElement>): void;
  39416. /**
  39417. * Update the current camera state depending on the inputs that have been used this frame.
  39418. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39419. */
  39420. checkInputs(): void;
  39421. /**
  39422. * Gets the class name of the current input.
  39423. * @returns the class name
  39424. */
  39425. getClassName(): string;
  39426. /**
  39427. * Get the friendly name associated with the input class.
  39428. * @returns the input friendly name
  39429. */
  39430. getSimpleName(): string;
  39431. /**
  39432. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39433. * allow modification of the heightOffset value.
  39434. */
  39435. private _modifierHeightOffset;
  39436. /**
  39437. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39438. * allow modification of the rotationOffset value.
  39439. */
  39440. private _modifierRotationOffset;
  39441. /**
  39442. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39443. * allow modification of the radius value.
  39444. */
  39445. private _modifierRadius;
  39446. }
  39447. }
  39448. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39449. import { Nullable } from "babylonjs/types";
  39450. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39451. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39452. import { Observable } from "babylonjs/Misc/observable";
  39453. module "babylonjs/Cameras/freeCameraInputsManager" {
  39454. interface FreeCameraInputsManager {
  39455. /**
  39456. * @hidden
  39457. */
  39458. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39459. /**
  39460. * Add orientation input support to the input manager.
  39461. * @returns the current input manager
  39462. */
  39463. addDeviceOrientation(): FreeCameraInputsManager;
  39464. }
  39465. }
  39466. /**
  39467. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39468. * Screen rotation is taken into account.
  39469. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39470. */
  39471. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39472. private _camera;
  39473. private _screenOrientationAngle;
  39474. private _constantTranform;
  39475. private _screenQuaternion;
  39476. private _alpha;
  39477. private _beta;
  39478. private _gamma;
  39479. /**
  39480. * Can be used to detect if a device orientation sensor is availible on a device
  39481. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39482. * @returns a promise that will resolve on orientation change
  39483. */
  39484. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39485. /**
  39486. * @hidden
  39487. */
  39488. _onDeviceOrientationChangedObservable: Observable<void>;
  39489. /**
  39490. * Instantiates a new input
  39491. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39492. */
  39493. constructor();
  39494. /**
  39495. * Define the camera controlled by the input.
  39496. */
  39497. camera: FreeCamera;
  39498. /**
  39499. * Attach the input controls to a specific dom element to get the input from.
  39500. * @param element Defines the element the controls should be listened from
  39501. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39502. */
  39503. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39504. private _orientationChanged;
  39505. private _deviceOrientation;
  39506. /**
  39507. * Detach the current controls from the specified dom element.
  39508. * @param element Defines the element to stop listening the inputs from
  39509. */
  39510. detachControl(element: Nullable<HTMLElement>): void;
  39511. /**
  39512. * Update the current camera state depending on the inputs that have been used this frame.
  39513. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39514. */
  39515. checkInputs(): void;
  39516. /**
  39517. * Gets the class name of the current intput.
  39518. * @returns the class name
  39519. */
  39520. getClassName(): string;
  39521. /**
  39522. * Get the friendly name associated with the input class.
  39523. * @returns the input friendly name
  39524. */
  39525. getSimpleName(): string;
  39526. }
  39527. }
  39528. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39529. import { Nullable } from "babylonjs/types";
  39530. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39531. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39532. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39533. /**
  39534. * Manage the gamepad inputs to control a free camera.
  39535. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39536. */
  39537. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39538. /**
  39539. * Define the camera the input is attached to.
  39540. */
  39541. camera: FreeCamera;
  39542. /**
  39543. * Define the Gamepad controlling the input
  39544. */
  39545. gamepad: Nullable<Gamepad>;
  39546. /**
  39547. * Defines the gamepad rotation sensiblity.
  39548. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39549. */
  39550. gamepadAngularSensibility: number;
  39551. /**
  39552. * Defines the gamepad move sensiblity.
  39553. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39554. */
  39555. gamepadMoveSensibility: number;
  39556. private _yAxisScale;
  39557. /**
  39558. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39559. */
  39560. invertYAxis: boolean;
  39561. private _onGamepadConnectedObserver;
  39562. private _onGamepadDisconnectedObserver;
  39563. private _cameraTransform;
  39564. private _deltaTransform;
  39565. private _vector3;
  39566. private _vector2;
  39567. /**
  39568. * Attach the input controls to a specific dom element to get the input from.
  39569. * @param element Defines the element the controls should be listened from
  39570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39571. */
  39572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39573. /**
  39574. * Detach the current controls from the specified dom element.
  39575. * @param element Defines the element to stop listening the inputs from
  39576. */
  39577. detachControl(element: Nullable<HTMLElement>): void;
  39578. /**
  39579. * Update the current camera state depending on the inputs that have been used this frame.
  39580. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39581. */
  39582. checkInputs(): void;
  39583. /**
  39584. * Gets the class name of the current intput.
  39585. * @returns the class name
  39586. */
  39587. getClassName(): string;
  39588. /**
  39589. * Get the friendly name associated with the input class.
  39590. * @returns the input friendly name
  39591. */
  39592. getSimpleName(): string;
  39593. }
  39594. }
  39595. declare module "babylonjs/Misc/virtualJoystick" {
  39596. import { Nullable } from "babylonjs/types";
  39597. import { Vector3 } from "babylonjs/Maths/math.vector";
  39598. /**
  39599. * Defines the potential axis of a Joystick
  39600. */
  39601. export enum JoystickAxis {
  39602. /** X axis */
  39603. X = 0,
  39604. /** Y axis */
  39605. Y = 1,
  39606. /** Z axis */
  39607. Z = 2
  39608. }
  39609. /**
  39610. * Class used to define virtual joystick (used in touch mode)
  39611. */
  39612. export class VirtualJoystick {
  39613. /**
  39614. * Gets or sets a boolean indicating that left and right values must be inverted
  39615. */
  39616. reverseLeftRight: boolean;
  39617. /**
  39618. * Gets or sets a boolean indicating that up and down values must be inverted
  39619. */
  39620. reverseUpDown: boolean;
  39621. /**
  39622. * Gets the offset value for the position (ie. the change of the position value)
  39623. */
  39624. deltaPosition: Vector3;
  39625. /**
  39626. * Gets a boolean indicating if the virtual joystick was pressed
  39627. */
  39628. pressed: boolean;
  39629. /**
  39630. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39631. */
  39632. static Canvas: Nullable<HTMLCanvasElement>;
  39633. private static _globalJoystickIndex;
  39634. private static vjCanvasContext;
  39635. private static vjCanvasWidth;
  39636. private static vjCanvasHeight;
  39637. private static halfWidth;
  39638. private _action;
  39639. private _axisTargetedByLeftAndRight;
  39640. private _axisTargetedByUpAndDown;
  39641. private _joystickSensibility;
  39642. private _inversedSensibility;
  39643. private _joystickPointerID;
  39644. private _joystickColor;
  39645. private _joystickPointerPos;
  39646. private _joystickPreviousPointerPos;
  39647. private _joystickPointerStartPos;
  39648. private _deltaJoystickVector;
  39649. private _leftJoystick;
  39650. private _touches;
  39651. private _onPointerDownHandlerRef;
  39652. private _onPointerMoveHandlerRef;
  39653. private _onPointerUpHandlerRef;
  39654. private _onResize;
  39655. /**
  39656. * Creates a new virtual joystick
  39657. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39658. */
  39659. constructor(leftJoystick?: boolean);
  39660. /**
  39661. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39662. * @param newJoystickSensibility defines the new sensibility
  39663. */
  39664. setJoystickSensibility(newJoystickSensibility: number): void;
  39665. private _onPointerDown;
  39666. private _onPointerMove;
  39667. private _onPointerUp;
  39668. /**
  39669. * Change the color of the virtual joystick
  39670. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39671. */
  39672. setJoystickColor(newColor: string): void;
  39673. /**
  39674. * Defines a callback to call when the joystick is touched
  39675. * @param action defines the callback
  39676. */
  39677. setActionOnTouch(action: () => any): void;
  39678. /**
  39679. * Defines which axis you'd like to control for left & right
  39680. * @param axis defines the axis to use
  39681. */
  39682. setAxisForLeftRight(axis: JoystickAxis): void;
  39683. /**
  39684. * Defines which axis you'd like to control for up & down
  39685. * @param axis defines the axis to use
  39686. */
  39687. setAxisForUpDown(axis: JoystickAxis): void;
  39688. private _drawVirtualJoystick;
  39689. /**
  39690. * Release internal HTML canvas
  39691. */
  39692. releaseCanvas(): void;
  39693. }
  39694. }
  39695. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39696. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39697. import { Nullable } from "babylonjs/types";
  39698. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39699. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39700. module "babylonjs/Cameras/freeCameraInputsManager" {
  39701. interface FreeCameraInputsManager {
  39702. /**
  39703. * Add virtual joystick input support to the input manager.
  39704. * @returns the current input manager
  39705. */
  39706. addVirtualJoystick(): FreeCameraInputsManager;
  39707. }
  39708. }
  39709. /**
  39710. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39711. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39712. */
  39713. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39714. /**
  39715. * Defines the camera the input is attached to.
  39716. */
  39717. camera: FreeCamera;
  39718. private _leftjoystick;
  39719. private _rightjoystick;
  39720. /**
  39721. * Gets the left stick of the virtual joystick.
  39722. * @returns The virtual Joystick
  39723. */
  39724. getLeftJoystick(): VirtualJoystick;
  39725. /**
  39726. * Gets the right stick of the virtual joystick.
  39727. * @returns The virtual Joystick
  39728. */
  39729. getRightJoystick(): VirtualJoystick;
  39730. /**
  39731. * Update the current camera state depending on the inputs that have been used this frame.
  39732. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39733. */
  39734. checkInputs(): void;
  39735. /**
  39736. * Attach the input controls to a specific dom element to get the input from.
  39737. * @param element Defines the element the controls should be listened from
  39738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39739. */
  39740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39741. /**
  39742. * Detach the current controls from the specified dom element.
  39743. * @param element Defines the element to stop listening the inputs from
  39744. */
  39745. detachControl(element: Nullable<HTMLElement>): void;
  39746. /**
  39747. * Gets the class name of the current intput.
  39748. * @returns the class name
  39749. */
  39750. getClassName(): string;
  39751. /**
  39752. * Get the friendly name associated with the input class.
  39753. * @returns the input friendly name
  39754. */
  39755. getSimpleName(): string;
  39756. }
  39757. }
  39758. declare module "babylonjs/Cameras/Inputs/index" {
  39759. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39760. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39761. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39762. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39763. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39764. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39765. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39766. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39767. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39768. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39769. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39770. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39771. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39772. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39773. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39774. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39775. }
  39776. declare module "babylonjs/Cameras/touchCamera" {
  39777. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39778. import { Scene } from "babylonjs/scene";
  39779. import { Vector3 } from "babylonjs/Maths/math.vector";
  39780. /**
  39781. * This represents a FPS type of camera controlled by touch.
  39782. * This is like a universal camera minus the Gamepad controls.
  39783. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39784. */
  39785. export class TouchCamera extends FreeCamera {
  39786. /**
  39787. * Defines the touch sensibility for rotation.
  39788. * The higher the faster.
  39789. */
  39790. touchAngularSensibility: number;
  39791. /**
  39792. * Defines the touch sensibility for move.
  39793. * The higher the faster.
  39794. */
  39795. touchMoveSensibility: number;
  39796. /**
  39797. * Instantiates a new touch camera.
  39798. * This represents a FPS type of camera controlled by touch.
  39799. * This is like a universal camera minus the Gamepad controls.
  39800. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39801. * @param name Define the name of the camera in the scene
  39802. * @param position Define the start position of the camera in the scene
  39803. * @param scene Define the scene the camera belongs to
  39804. */
  39805. constructor(name: string, position: Vector3, scene: Scene);
  39806. /**
  39807. * Gets the current object class name.
  39808. * @return the class name
  39809. */
  39810. getClassName(): string;
  39811. /** @hidden */
  39812. _setupInputs(): void;
  39813. }
  39814. }
  39815. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39816. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39817. import { Scene } from "babylonjs/scene";
  39818. import { Vector3 } from "babylonjs/Maths/math.vector";
  39819. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39820. import { Axis } from "babylonjs/Maths/math.axis";
  39821. /**
  39822. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39823. * being tilted forward or back and left or right.
  39824. */
  39825. export class DeviceOrientationCamera extends FreeCamera {
  39826. private _initialQuaternion;
  39827. private _quaternionCache;
  39828. private _tmpDragQuaternion;
  39829. private _disablePointerInputWhenUsingDeviceOrientation;
  39830. /**
  39831. * Creates a new device orientation camera
  39832. * @param name The name of the camera
  39833. * @param position The start position camera
  39834. * @param scene The scene the camera belongs to
  39835. */
  39836. constructor(name: string, position: Vector3, scene: Scene);
  39837. /**
  39838. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39839. */
  39840. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39841. private _dragFactor;
  39842. /**
  39843. * Enabled turning on the y axis when the orientation sensor is active
  39844. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39845. */
  39846. enableHorizontalDragging(dragFactor?: number): void;
  39847. /**
  39848. * Gets the current instance class name ("DeviceOrientationCamera").
  39849. * This helps avoiding instanceof at run time.
  39850. * @returns the class name
  39851. */
  39852. getClassName(): string;
  39853. /**
  39854. * @hidden
  39855. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39856. */
  39857. _checkInputs(): void;
  39858. /**
  39859. * Reset the camera to its default orientation on the specified axis only.
  39860. * @param axis The axis to reset
  39861. */
  39862. resetToCurrentRotation(axis?: Axis): void;
  39863. }
  39864. }
  39865. declare module "babylonjs/Gamepads/xboxGamepad" {
  39866. import { Observable } from "babylonjs/Misc/observable";
  39867. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39868. /**
  39869. * Defines supported buttons for XBox360 compatible gamepads
  39870. */
  39871. export enum Xbox360Button {
  39872. /** A */
  39873. A = 0,
  39874. /** B */
  39875. B = 1,
  39876. /** X */
  39877. X = 2,
  39878. /** Y */
  39879. Y = 3,
  39880. /** Start */
  39881. Start = 4,
  39882. /** Back */
  39883. Back = 5,
  39884. /** Left button */
  39885. LB = 6,
  39886. /** Right button */
  39887. RB = 7,
  39888. /** Left stick */
  39889. LeftStick = 8,
  39890. /** Right stick */
  39891. RightStick = 9
  39892. }
  39893. /** Defines values for XBox360 DPad */
  39894. export enum Xbox360Dpad {
  39895. /** Up */
  39896. Up = 0,
  39897. /** Down */
  39898. Down = 1,
  39899. /** Left */
  39900. Left = 2,
  39901. /** Right */
  39902. Right = 3
  39903. }
  39904. /**
  39905. * Defines a XBox360 gamepad
  39906. */
  39907. export class Xbox360Pad extends Gamepad {
  39908. private _leftTrigger;
  39909. private _rightTrigger;
  39910. private _onlefttriggerchanged;
  39911. private _onrighttriggerchanged;
  39912. private _onbuttondown;
  39913. private _onbuttonup;
  39914. private _ondpaddown;
  39915. private _ondpadup;
  39916. /** Observable raised when a button is pressed */
  39917. onButtonDownObservable: Observable<Xbox360Button>;
  39918. /** Observable raised when a button is released */
  39919. onButtonUpObservable: Observable<Xbox360Button>;
  39920. /** Observable raised when a pad is pressed */
  39921. onPadDownObservable: Observable<Xbox360Dpad>;
  39922. /** Observable raised when a pad is released */
  39923. onPadUpObservable: Observable<Xbox360Dpad>;
  39924. private _buttonA;
  39925. private _buttonB;
  39926. private _buttonX;
  39927. private _buttonY;
  39928. private _buttonBack;
  39929. private _buttonStart;
  39930. private _buttonLB;
  39931. private _buttonRB;
  39932. private _buttonLeftStick;
  39933. private _buttonRightStick;
  39934. private _dPadUp;
  39935. private _dPadDown;
  39936. private _dPadLeft;
  39937. private _dPadRight;
  39938. private _isXboxOnePad;
  39939. /**
  39940. * Creates a new XBox360 gamepad object
  39941. * @param id defines the id of this gamepad
  39942. * @param index defines its index
  39943. * @param gamepad defines the internal HTML gamepad object
  39944. * @param xboxOne defines if it is a XBox One gamepad
  39945. */
  39946. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39947. /**
  39948. * Defines the callback to call when left trigger is pressed
  39949. * @param callback defines the callback to use
  39950. */
  39951. onlefttriggerchanged(callback: (value: number) => void): void;
  39952. /**
  39953. * Defines the callback to call when right trigger is pressed
  39954. * @param callback defines the callback to use
  39955. */
  39956. onrighttriggerchanged(callback: (value: number) => void): void;
  39957. /**
  39958. * Gets the left trigger value
  39959. */
  39960. /**
  39961. * Sets the left trigger value
  39962. */
  39963. leftTrigger: number;
  39964. /**
  39965. * Gets the right trigger value
  39966. */
  39967. /**
  39968. * Sets the right trigger value
  39969. */
  39970. rightTrigger: number;
  39971. /**
  39972. * Defines the callback to call when a button is pressed
  39973. * @param callback defines the callback to use
  39974. */
  39975. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39976. /**
  39977. * Defines the callback to call when a button is released
  39978. * @param callback defines the callback to use
  39979. */
  39980. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39981. /**
  39982. * Defines the callback to call when a pad is pressed
  39983. * @param callback defines the callback to use
  39984. */
  39985. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39986. /**
  39987. * Defines the callback to call when a pad is released
  39988. * @param callback defines the callback to use
  39989. */
  39990. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39991. private _setButtonValue;
  39992. private _setDPadValue;
  39993. /**
  39994. * Gets the value of the `A` button
  39995. */
  39996. /**
  39997. * Sets the value of the `A` button
  39998. */
  39999. buttonA: number;
  40000. /**
  40001. * Gets the value of the `B` button
  40002. */
  40003. /**
  40004. * Sets the value of the `B` button
  40005. */
  40006. buttonB: number;
  40007. /**
  40008. * Gets the value of the `X` button
  40009. */
  40010. /**
  40011. * Sets the value of the `X` button
  40012. */
  40013. buttonX: number;
  40014. /**
  40015. * Gets the value of the `Y` button
  40016. */
  40017. /**
  40018. * Sets the value of the `Y` button
  40019. */
  40020. buttonY: number;
  40021. /**
  40022. * Gets the value of the `Start` button
  40023. */
  40024. /**
  40025. * Sets the value of the `Start` button
  40026. */
  40027. buttonStart: number;
  40028. /**
  40029. * Gets the value of the `Back` button
  40030. */
  40031. /**
  40032. * Sets the value of the `Back` button
  40033. */
  40034. buttonBack: number;
  40035. /**
  40036. * Gets the value of the `Left` button
  40037. */
  40038. /**
  40039. * Sets the value of the `Left` button
  40040. */
  40041. buttonLB: number;
  40042. /**
  40043. * Gets the value of the `Right` button
  40044. */
  40045. /**
  40046. * Sets the value of the `Right` button
  40047. */
  40048. buttonRB: number;
  40049. /**
  40050. * Gets the value of the Left joystick
  40051. */
  40052. /**
  40053. * Sets the value of the Left joystick
  40054. */
  40055. buttonLeftStick: number;
  40056. /**
  40057. * Gets the value of the Right joystick
  40058. */
  40059. /**
  40060. * Sets the value of the Right joystick
  40061. */
  40062. buttonRightStick: number;
  40063. /**
  40064. * Gets the value of D-pad up
  40065. */
  40066. /**
  40067. * Sets the value of D-pad up
  40068. */
  40069. dPadUp: number;
  40070. /**
  40071. * Gets the value of D-pad down
  40072. */
  40073. /**
  40074. * Sets the value of D-pad down
  40075. */
  40076. dPadDown: number;
  40077. /**
  40078. * Gets the value of D-pad left
  40079. */
  40080. /**
  40081. * Sets the value of D-pad left
  40082. */
  40083. dPadLeft: number;
  40084. /**
  40085. * Gets the value of D-pad right
  40086. */
  40087. /**
  40088. * Sets the value of D-pad right
  40089. */
  40090. dPadRight: number;
  40091. /**
  40092. * Force the gamepad to synchronize with device values
  40093. */
  40094. update(): void;
  40095. /**
  40096. * Disposes the gamepad
  40097. */
  40098. dispose(): void;
  40099. }
  40100. }
  40101. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40102. import { Observable } from "babylonjs/Misc/observable";
  40103. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40104. /**
  40105. * Defines supported buttons for DualShock compatible gamepads
  40106. */
  40107. export enum DualShockButton {
  40108. /** Cross */
  40109. Cross = 0,
  40110. /** Circle */
  40111. Circle = 1,
  40112. /** Square */
  40113. Square = 2,
  40114. /** Triangle */
  40115. Triangle = 3,
  40116. /** Options */
  40117. Options = 4,
  40118. /** Share */
  40119. Share = 5,
  40120. /** L1 */
  40121. L1 = 6,
  40122. /** R1 */
  40123. R1 = 7,
  40124. /** Left stick */
  40125. LeftStick = 8,
  40126. /** Right stick */
  40127. RightStick = 9
  40128. }
  40129. /** Defines values for DualShock DPad */
  40130. export enum DualShockDpad {
  40131. /** Up */
  40132. Up = 0,
  40133. /** Down */
  40134. Down = 1,
  40135. /** Left */
  40136. Left = 2,
  40137. /** Right */
  40138. Right = 3
  40139. }
  40140. /**
  40141. * Defines a DualShock gamepad
  40142. */
  40143. export class DualShockPad extends Gamepad {
  40144. private _leftTrigger;
  40145. private _rightTrigger;
  40146. private _onlefttriggerchanged;
  40147. private _onrighttriggerchanged;
  40148. private _onbuttondown;
  40149. private _onbuttonup;
  40150. private _ondpaddown;
  40151. private _ondpadup;
  40152. /** Observable raised when a button is pressed */
  40153. onButtonDownObservable: Observable<DualShockButton>;
  40154. /** Observable raised when a button is released */
  40155. onButtonUpObservable: Observable<DualShockButton>;
  40156. /** Observable raised when a pad is pressed */
  40157. onPadDownObservable: Observable<DualShockDpad>;
  40158. /** Observable raised when a pad is released */
  40159. onPadUpObservable: Observable<DualShockDpad>;
  40160. private _buttonCross;
  40161. private _buttonCircle;
  40162. private _buttonSquare;
  40163. private _buttonTriangle;
  40164. private _buttonShare;
  40165. private _buttonOptions;
  40166. private _buttonL1;
  40167. private _buttonR1;
  40168. private _buttonLeftStick;
  40169. private _buttonRightStick;
  40170. private _dPadUp;
  40171. private _dPadDown;
  40172. private _dPadLeft;
  40173. private _dPadRight;
  40174. /**
  40175. * Creates a new DualShock gamepad object
  40176. * @param id defines the id of this gamepad
  40177. * @param index defines its index
  40178. * @param gamepad defines the internal HTML gamepad object
  40179. */
  40180. constructor(id: string, index: number, gamepad: any);
  40181. /**
  40182. * Defines the callback to call when left trigger is pressed
  40183. * @param callback defines the callback to use
  40184. */
  40185. onlefttriggerchanged(callback: (value: number) => void): void;
  40186. /**
  40187. * Defines the callback to call when right trigger is pressed
  40188. * @param callback defines the callback to use
  40189. */
  40190. onrighttriggerchanged(callback: (value: number) => void): void;
  40191. /**
  40192. * Gets the left trigger value
  40193. */
  40194. /**
  40195. * Sets the left trigger value
  40196. */
  40197. leftTrigger: number;
  40198. /**
  40199. * Gets the right trigger value
  40200. */
  40201. /**
  40202. * Sets the right trigger value
  40203. */
  40204. rightTrigger: number;
  40205. /**
  40206. * Defines the callback to call when a button is pressed
  40207. * @param callback defines the callback to use
  40208. */
  40209. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40210. /**
  40211. * Defines the callback to call when a button is released
  40212. * @param callback defines the callback to use
  40213. */
  40214. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40215. /**
  40216. * Defines the callback to call when a pad is pressed
  40217. * @param callback defines the callback to use
  40218. */
  40219. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40220. /**
  40221. * Defines the callback to call when a pad is released
  40222. * @param callback defines the callback to use
  40223. */
  40224. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40225. private _setButtonValue;
  40226. private _setDPadValue;
  40227. /**
  40228. * Gets the value of the `Cross` button
  40229. */
  40230. /**
  40231. * Sets the value of the `Cross` button
  40232. */
  40233. buttonCross: number;
  40234. /**
  40235. * Gets the value of the `Circle` button
  40236. */
  40237. /**
  40238. * Sets the value of the `Circle` button
  40239. */
  40240. buttonCircle: number;
  40241. /**
  40242. * Gets the value of the `Square` button
  40243. */
  40244. /**
  40245. * Sets the value of the `Square` button
  40246. */
  40247. buttonSquare: number;
  40248. /**
  40249. * Gets the value of the `Triangle` button
  40250. */
  40251. /**
  40252. * Sets the value of the `Triangle` button
  40253. */
  40254. buttonTriangle: number;
  40255. /**
  40256. * Gets the value of the `Options` button
  40257. */
  40258. /**
  40259. * Sets the value of the `Options` button
  40260. */
  40261. buttonOptions: number;
  40262. /**
  40263. * Gets the value of the `Share` button
  40264. */
  40265. /**
  40266. * Sets the value of the `Share` button
  40267. */
  40268. buttonShare: number;
  40269. /**
  40270. * Gets the value of the `L1` button
  40271. */
  40272. /**
  40273. * Sets the value of the `L1` button
  40274. */
  40275. buttonL1: number;
  40276. /**
  40277. * Gets the value of the `R1` button
  40278. */
  40279. /**
  40280. * Sets the value of the `R1` button
  40281. */
  40282. buttonR1: number;
  40283. /**
  40284. * Gets the value of the Left joystick
  40285. */
  40286. /**
  40287. * Sets the value of the Left joystick
  40288. */
  40289. buttonLeftStick: number;
  40290. /**
  40291. * Gets the value of the Right joystick
  40292. */
  40293. /**
  40294. * Sets the value of the Right joystick
  40295. */
  40296. buttonRightStick: number;
  40297. /**
  40298. * Gets the value of D-pad up
  40299. */
  40300. /**
  40301. * Sets the value of D-pad up
  40302. */
  40303. dPadUp: number;
  40304. /**
  40305. * Gets the value of D-pad down
  40306. */
  40307. /**
  40308. * Sets the value of D-pad down
  40309. */
  40310. dPadDown: number;
  40311. /**
  40312. * Gets the value of D-pad left
  40313. */
  40314. /**
  40315. * Sets the value of D-pad left
  40316. */
  40317. dPadLeft: number;
  40318. /**
  40319. * Gets the value of D-pad right
  40320. */
  40321. /**
  40322. * Sets the value of D-pad right
  40323. */
  40324. dPadRight: number;
  40325. /**
  40326. * Force the gamepad to synchronize with device values
  40327. */
  40328. update(): void;
  40329. /**
  40330. * Disposes the gamepad
  40331. */
  40332. dispose(): void;
  40333. }
  40334. }
  40335. declare module "babylonjs/Gamepads/gamepadManager" {
  40336. import { Observable } from "babylonjs/Misc/observable";
  40337. import { Nullable } from "babylonjs/types";
  40338. import { Scene } from "babylonjs/scene";
  40339. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40340. /**
  40341. * Manager for handling gamepads
  40342. */
  40343. export class GamepadManager {
  40344. private _scene?;
  40345. private _babylonGamepads;
  40346. private _oneGamepadConnected;
  40347. /** @hidden */
  40348. _isMonitoring: boolean;
  40349. private _gamepadEventSupported;
  40350. private _gamepadSupport;
  40351. /**
  40352. * observable to be triggered when the gamepad controller has been connected
  40353. */
  40354. onGamepadConnectedObservable: Observable<Gamepad>;
  40355. /**
  40356. * observable to be triggered when the gamepad controller has been disconnected
  40357. */
  40358. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40359. private _onGamepadConnectedEvent;
  40360. private _onGamepadDisconnectedEvent;
  40361. /**
  40362. * Initializes the gamepad manager
  40363. * @param _scene BabylonJS scene
  40364. */
  40365. constructor(_scene?: Scene | undefined);
  40366. /**
  40367. * The gamepads in the game pad manager
  40368. */
  40369. readonly gamepads: Gamepad[];
  40370. /**
  40371. * Get the gamepad controllers based on type
  40372. * @param type The type of gamepad controller
  40373. * @returns Nullable gamepad
  40374. */
  40375. getGamepadByType(type?: number): Nullable<Gamepad>;
  40376. /**
  40377. * Disposes the gamepad manager
  40378. */
  40379. dispose(): void;
  40380. private _addNewGamepad;
  40381. private _startMonitoringGamepads;
  40382. private _stopMonitoringGamepads;
  40383. /** @hidden */
  40384. _checkGamepadsStatus(): void;
  40385. private _updateGamepadObjects;
  40386. }
  40387. }
  40388. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40389. import { Nullable } from "babylonjs/types";
  40390. import { Scene } from "babylonjs/scene";
  40391. import { ISceneComponent } from "babylonjs/sceneComponent";
  40392. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40393. module "babylonjs/scene" {
  40394. interface Scene {
  40395. /** @hidden */
  40396. _gamepadManager: Nullable<GamepadManager>;
  40397. /**
  40398. * Gets the gamepad manager associated with the scene
  40399. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40400. */
  40401. gamepadManager: GamepadManager;
  40402. }
  40403. }
  40404. module "babylonjs/Cameras/freeCameraInputsManager" {
  40405. /**
  40406. * Interface representing a free camera inputs manager
  40407. */
  40408. interface FreeCameraInputsManager {
  40409. /**
  40410. * Adds gamepad input support to the FreeCameraInputsManager.
  40411. * @returns the FreeCameraInputsManager
  40412. */
  40413. addGamepad(): FreeCameraInputsManager;
  40414. }
  40415. }
  40416. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40417. /**
  40418. * Interface representing an arc rotate camera inputs manager
  40419. */
  40420. interface ArcRotateCameraInputsManager {
  40421. /**
  40422. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40423. * @returns the camera inputs manager
  40424. */
  40425. addGamepad(): ArcRotateCameraInputsManager;
  40426. }
  40427. }
  40428. /**
  40429. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40430. */
  40431. export class GamepadSystemSceneComponent implements ISceneComponent {
  40432. /**
  40433. * The component name helpfull to identify the component in the list of scene components.
  40434. */
  40435. readonly name: string;
  40436. /**
  40437. * The scene the component belongs to.
  40438. */
  40439. scene: Scene;
  40440. /**
  40441. * Creates a new instance of the component for the given scene
  40442. * @param scene Defines the scene to register the component in
  40443. */
  40444. constructor(scene: Scene);
  40445. /**
  40446. * Registers the component in a given scene
  40447. */
  40448. register(): void;
  40449. /**
  40450. * Rebuilds the elements related to this component in case of
  40451. * context lost for instance.
  40452. */
  40453. rebuild(): void;
  40454. /**
  40455. * Disposes the component and the associated ressources
  40456. */
  40457. dispose(): void;
  40458. private _beforeCameraUpdate;
  40459. }
  40460. }
  40461. declare module "babylonjs/Cameras/universalCamera" {
  40462. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40463. import { Scene } from "babylonjs/scene";
  40464. import { Vector3 } from "babylonjs/Maths/math.vector";
  40465. import "babylonjs/Gamepads/gamepadSceneComponent";
  40466. /**
  40467. * 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,
  40468. * which still works and will still be found in many Playgrounds.
  40469. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40470. */
  40471. export class UniversalCamera extends TouchCamera {
  40472. /**
  40473. * Defines the gamepad rotation sensiblity.
  40474. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40475. */
  40476. gamepadAngularSensibility: number;
  40477. /**
  40478. * Defines the gamepad move sensiblity.
  40479. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40480. */
  40481. gamepadMoveSensibility: number;
  40482. /**
  40483. * 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,
  40484. * which still works and will still be found in many Playgrounds.
  40485. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40486. * @param name Define the name of the camera in the scene
  40487. * @param position Define the start position of the camera in the scene
  40488. * @param scene Define the scene the camera belongs to
  40489. */
  40490. constructor(name: string, position: Vector3, scene: Scene);
  40491. /**
  40492. * Gets the current object class name.
  40493. * @return the class name
  40494. */
  40495. getClassName(): string;
  40496. }
  40497. }
  40498. declare module "babylonjs/Cameras/gamepadCamera" {
  40499. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40500. import { Scene } from "babylonjs/scene";
  40501. import { Vector3 } from "babylonjs/Maths/math.vector";
  40502. /**
  40503. * This represents a FPS type of camera. This is only here for back compat purpose.
  40504. * Please use the UniversalCamera instead as both are identical.
  40505. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40506. */
  40507. export class GamepadCamera extends UniversalCamera {
  40508. /**
  40509. * Instantiates a new Gamepad Camera
  40510. * This represents a FPS type of camera. This is only here for back compat purpose.
  40511. * Please use the UniversalCamera instead as both are identical.
  40512. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40513. * @param name Define the name of the camera in the scene
  40514. * @param position Define the start position of the camera in the scene
  40515. * @param scene Define the scene the camera belongs to
  40516. */
  40517. constructor(name: string, position: Vector3, scene: Scene);
  40518. /**
  40519. * Gets the current object class name.
  40520. * @return the class name
  40521. */
  40522. getClassName(): string;
  40523. }
  40524. }
  40525. declare module "babylonjs/Shaders/pass.fragment" {
  40526. /** @hidden */
  40527. export var passPixelShader: {
  40528. name: string;
  40529. shader: string;
  40530. };
  40531. }
  40532. declare module "babylonjs/Shaders/passCube.fragment" {
  40533. /** @hidden */
  40534. export var passCubePixelShader: {
  40535. name: string;
  40536. shader: string;
  40537. };
  40538. }
  40539. declare module "babylonjs/PostProcesses/passPostProcess" {
  40540. import { Nullable } from "babylonjs/types";
  40541. import { Camera } from "babylonjs/Cameras/camera";
  40542. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40543. import { Engine } from "babylonjs/Engines/engine";
  40544. import "babylonjs/Shaders/pass.fragment";
  40545. import "babylonjs/Shaders/passCube.fragment";
  40546. /**
  40547. * PassPostProcess which produces an output the same as it's input
  40548. */
  40549. export class PassPostProcess extends PostProcess {
  40550. /**
  40551. * Creates the PassPostProcess
  40552. * @param name The name of the effect.
  40553. * @param options The required width/height ratio to downsize to before computing the render pass.
  40554. * @param camera The camera to apply the render pass to.
  40555. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40556. * @param engine The engine which the post process will be applied. (default: current engine)
  40557. * @param reusable If the post process can be reused on the same frame. (default: false)
  40558. * @param textureType The type of texture to be used when performing the post processing.
  40559. * @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)
  40560. */
  40561. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40562. }
  40563. /**
  40564. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40565. */
  40566. export class PassCubePostProcess extends PostProcess {
  40567. private _face;
  40568. /**
  40569. * Gets or sets the cube face to display.
  40570. * * 0 is +X
  40571. * * 1 is -X
  40572. * * 2 is +Y
  40573. * * 3 is -Y
  40574. * * 4 is +Z
  40575. * * 5 is -Z
  40576. */
  40577. face: number;
  40578. /**
  40579. * Creates the PassCubePostProcess
  40580. * @param name The name of the effect.
  40581. * @param options The required width/height ratio to downsize to before computing the render pass.
  40582. * @param camera The camera to apply the render pass to.
  40583. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40584. * @param engine The engine which the post process will be applied. (default: current engine)
  40585. * @param reusable If the post process can be reused on the same frame. (default: false)
  40586. * @param textureType The type of texture to be used when performing the post processing.
  40587. * @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)
  40588. */
  40589. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40590. }
  40591. }
  40592. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40593. /** @hidden */
  40594. export var anaglyphPixelShader: {
  40595. name: string;
  40596. shader: string;
  40597. };
  40598. }
  40599. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40600. import { Engine } from "babylonjs/Engines/engine";
  40601. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40602. import { Camera } from "babylonjs/Cameras/camera";
  40603. import "babylonjs/Shaders/anaglyph.fragment";
  40604. /**
  40605. * Postprocess used to generate anaglyphic rendering
  40606. */
  40607. export class AnaglyphPostProcess extends PostProcess {
  40608. private _passedProcess;
  40609. /**
  40610. * Creates a new AnaglyphPostProcess
  40611. * @param name defines postprocess name
  40612. * @param options defines creation options or target ratio scale
  40613. * @param rigCameras defines cameras using this postprocess
  40614. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40615. * @param engine defines hosting engine
  40616. * @param reusable defines if the postprocess will be reused multiple times per frame
  40617. */
  40618. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40619. }
  40620. }
  40621. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40622. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40623. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40624. import { Scene } from "babylonjs/scene";
  40625. import { Vector3 } from "babylonjs/Maths/math.vector";
  40626. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40627. /**
  40628. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40629. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40630. */
  40631. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40632. /**
  40633. * Creates a new AnaglyphArcRotateCamera
  40634. * @param name defines camera name
  40635. * @param alpha defines alpha angle (in radians)
  40636. * @param beta defines beta angle (in radians)
  40637. * @param radius defines radius
  40638. * @param target defines camera target
  40639. * @param interaxialDistance defines distance between each color axis
  40640. * @param scene defines the hosting scene
  40641. */
  40642. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40643. /**
  40644. * Gets camera class name
  40645. * @returns AnaglyphArcRotateCamera
  40646. */
  40647. getClassName(): string;
  40648. }
  40649. }
  40650. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40651. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40652. import { Scene } from "babylonjs/scene";
  40653. import { Vector3 } from "babylonjs/Maths/math.vector";
  40654. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40655. /**
  40656. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40657. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40658. */
  40659. export class AnaglyphFreeCamera extends FreeCamera {
  40660. /**
  40661. * Creates a new AnaglyphFreeCamera
  40662. * @param name defines camera name
  40663. * @param position defines initial position
  40664. * @param interaxialDistance defines distance between each color axis
  40665. * @param scene defines the hosting scene
  40666. */
  40667. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40668. /**
  40669. * Gets camera class name
  40670. * @returns AnaglyphFreeCamera
  40671. */
  40672. getClassName(): string;
  40673. }
  40674. }
  40675. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40676. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40677. import { Scene } from "babylonjs/scene";
  40678. import { Vector3 } from "babylonjs/Maths/math.vector";
  40679. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40680. /**
  40681. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40682. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40683. */
  40684. export class AnaglyphGamepadCamera extends GamepadCamera {
  40685. /**
  40686. * Creates a new AnaglyphGamepadCamera
  40687. * @param name defines camera name
  40688. * @param position defines initial position
  40689. * @param interaxialDistance defines distance between each color axis
  40690. * @param scene defines the hosting scene
  40691. */
  40692. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40693. /**
  40694. * Gets camera class name
  40695. * @returns AnaglyphGamepadCamera
  40696. */
  40697. getClassName(): string;
  40698. }
  40699. }
  40700. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40701. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40702. import { Scene } from "babylonjs/scene";
  40703. import { Vector3 } from "babylonjs/Maths/math.vector";
  40704. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40705. /**
  40706. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40707. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40708. */
  40709. export class AnaglyphUniversalCamera extends UniversalCamera {
  40710. /**
  40711. * Creates a new AnaglyphUniversalCamera
  40712. * @param name defines camera name
  40713. * @param position defines initial position
  40714. * @param interaxialDistance defines distance between each color axis
  40715. * @param scene defines the hosting scene
  40716. */
  40717. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40718. /**
  40719. * Gets camera class name
  40720. * @returns AnaglyphUniversalCamera
  40721. */
  40722. getClassName(): string;
  40723. }
  40724. }
  40725. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40726. /** @hidden */
  40727. export var stereoscopicInterlacePixelShader: {
  40728. name: string;
  40729. shader: string;
  40730. };
  40731. }
  40732. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40733. import { Camera } from "babylonjs/Cameras/camera";
  40734. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40735. import { Engine } from "babylonjs/Engines/engine";
  40736. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40737. /**
  40738. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40739. */
  40740. export class StereoscopicInterlacePostProcess extends PostProcess {
  40741. private _stepSize;
  40742. private _passedProcess;
  40743. /**
  40744. * Initializes a StereoscopicInterlacePostProcess
  40745. * @param name The name of the effect.
  40746. * @param rigCameras The rig cameras to be appled to the post process
  40747. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40748. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40749. * @param engine The engine which the post process will be applied. (default: current engine)
  40750. * @param reusable If the post process can be reused on the same frame. (default: false)
  40751. */
  40752. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40753. }
  40754. }
  40755. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40756. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40757. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40758. import { Scene } from "babylonjs/scene";
  40759. import { Vector3 } from "babylonjs/Maths/math.vector";
  40760. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40761. /**
  40762. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40763. * @see http://doc.babylonjs.com/features/cameras
  40764. */
  40765. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40766. /**
  40767. * Creates a new StereoscopicArcRotateCamera
  40768. * @param name defines camera name
  40769. * @param alpha defines alpha angle (in radians)
  40770. * @param beta defines beta angle (in radians)
  40771. * @param radius defines radius
  40772. * @param target defines camera target
  40773. * @param interaxialDistance defines distance between each color axis
  40774. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40775. * @param scene defines the hosting scene
  40776. */
  40777. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40778. /**
  40779. * Gets camera class name
  40780. * @returns StereoscopicArcRotateCamera
  40781. */
  40782. getClassName(): string;
  40783. }
  40784. }
  40785. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40786. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40787. import { Scene } from "babylonjs/scene";
  40788. import { Vector3 } from "babylonjs/Maths/math.vector";
  40789. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40790. /**
  40791. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40792. * @see http://doc.babylonjs.com/features/cameras
  40793. */
  40794. export class StereoscopicFreeCamera extends FreeCamera {
  40795. /**
  40796. * Creates a new StereoscopicFreeCamera
  40797. * @param name defines camera name
  40798. * @param position defines initial position
  40799. * @param interaxialDistance defines distance between each color axis
  40800. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40801. * @param scene defines the hosting scene
  40802. */
  40803. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40804. /**
  40805. * Gets camera class name
  40806. * @returns StereoscopicFreeCamera
  40807. */
  40808. getClassName(): string;
  40809. }
  40810. }
  40811. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40812. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40813. import { Scene } from "babylonjs/scene";
  40814. import { Vector3 } from "babylonjs/Maths/math.vector";
  40815. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40816. /**
  40817. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40818. * @see http://doc.babylonjs.com/features/cameras
  40819. */
  40820. export class StereoscopicGamepadCamera extends GamepadCamera {
  40821. /**
  40822. * Creates a new StereoscopicGamepadCamera
  40823. * @param name defines camera name
  40824. * @param position defines initial position
  40825. * @param interaxialDistance defines distance between each color axis
  40826. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40827. * @param scene defines the hosting scene
  40828. */
  40829. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40830. /**
  40831. * Gets camera class name
  40832. * @returns StereoscopicGamepadCamera
  40833. */
  40834. getClassName(): string;
  40835. }
  40836. }
  40837. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40838. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40839. import { Scene } from "babylonjs/scene";
  40840. import { Vector3 } from "babylonjs/Maths/math.vector";
  40841. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40842. /**
  40843. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40844. * @see http://doc.babylonjs.com/features/cameras
  40845. */
  40846. export class StereoscopicUniversalCamera extends UniversalCamera {
  40847. /**
  40848. * Creates a new StereoscopicUniversalCamera
  40849. * @param name defines camera name
  40850. * @param position defines initial position
  40851. * @param interaxialDistance defines distance between each color axis
  40852. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40853. * @param scene defines the hosting scene
  40854. */
  40855. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40856. /**
  40857. * Gets camera class name
  40858. * @returns StereoscopicUniversalCamera
  40859. */
  40860. getClassName(): string;
  40861. }
  40862. }
  40863. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40864. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40865. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40866. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40867. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40868. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40869. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40870. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40871. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40872. }
  40873. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40874. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40875. import { Scene } from "babylonjs/scene";
  40876. import { Vector3 } from "babylonjs/Maths/math.vector";
  40877. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40878. /**
  40879. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40880. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40881. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40882. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40883. */
  40884. export class VirtualJoysticksCamera extends FreeCamera {
  40885. /**
  40886. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40887. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40888. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40889. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40890. * @param name Define the name of the camera in the scene
  40891. * @param position Define the start position of the camera in the scene
  40892. * @param scene Define the scene the camera belongs to
  40893. */
  40894. constructor(name: string, position: Vector3, scene: Scene);
  40895. /**
  40896. * Gets the current object class name.
  40897. * @return the class name
  40898. */
  40899. getClassName(): string;
  40900. }
  40901. }
  40902. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40903. import { Matrix } from "babylonjs/Maths/math.vector";
  40904. /**
  40905. * This represents all the required metrics to create a VR camera.
  40906. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40907. */
  40908. export class VRCameraMetrics {
  40909. /**
  40910. * Define the horizontal resolution off the screen.
  40911. */
  40912. hResolution: number;
  40913. /**
  40914. * Define the vertical resolution off the screen.
  40915. */
  40916. vResolution: number;
  40917. /**
  40918. * Define the horizontal screen size.
  40919. */
  40920. hScreenSize: number;
  40921. /**
  40922. * Define the vertical screen size.
  40923. */
  40924. vScreenSize: number;
  40925. /**
  40926. * Define the vertical screen center position.
  40927. */
  40928. vScreenCenter: number;
  40929. /**
  40930. * Define the distance of the eyes to the screen.
  40931. */
  40932. eyeToScreenDistance: number;
  40933. /**
  40934. * Define the distance between both lenses
  40935. */
  40936. lensSeparationDistance: number;
  40937. /**
  40938. * Define the distance between both viewer's eyes.
  40939. */
  40940. interpupillaryDistance: number;
  40941. /**
  40942. * Define the distortion factor of the VR postprocess.
  40943. * Please, touch with care.
  40944. */
  40945. distortionK: number[];
  40946. /**
  40947. * Define the chromatic aberration correction factors for the VR post process.
  40948. */
  40949. chromaAbCorrection: number[];
  40950. /**
  40951. * Define the scale factor of the post process.
  40952. * The smaller the better but the slower.
  40953. */
  40954. postProcessScaleFactor: number;
  40955. /**
  40956. * Define an offset for the lens center.
  40957. */
  40958. lensCenterOffset: number;
  40959. /**
  40960. * Define if the current vr camera should compensate the distortion of the lense or not.
  40961. */
  40962. compensateDistortion: boolean;
  40963. /**
  40964. * Defines if multiview should be enabled when rendering (Default: false)
  40965. */
  40966. multiviewEnabled: boolean;
  40967. /**
  40968. * Gets the rendering aspect ratio based on the provided resolutions.
  40969. */
  40970. readonly aspectRatio: number;
  40971. /**
  40972. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40973. */
  40974. readonly aspectRatioFov: number;
  40975. /**
  40976. * @hidden
  40977. */
  40978. readonly leftHMatrix: Matrix;
  40979. /**
  40980. * @hidden
  40981. */
  40982. readonly rightHMatrix: Matrix;
  40983. /**
  40984. * @hidden
  40985. */
  40986. readonly leftPreViewMatrix: Matrix;
  40987. /**
  40988. * @hidden
  40989. */
  40990. readonly rightPreViewMatrix: Matrix;
  40991. /**
  40992. * Get the default VRMetrics based on the most generic setup.
  40993. * @returns the default vr metrics
  40994. */
  40995. static GetDefault(): VRCameraMetrics;
  40996. }
  40997. }
  40998. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40999. /** @hidden */
  41000. export var vrDistortionCorrectionPixelShader: {
  41001. name: string;
  41002. shader: string;
  41003. };
  41004. }
  41005. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41006. import { Camera } from "babylonjs/Cameras/camera";
  41007. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41008. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41009. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41010. /**
  41011. * VRDistortionCorrectionPostProcess used for mobile VR
  41012. */
  41013. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41014. private _isRightEye;
  41015. private _distortionFactors;
  41016. private _postProcessScaleFactor;
  41017. private _lensCenterOffset;
  41018. private _scaleIn;
  41019. private _scaleFactor;
  41020. private _lensCenter;
  41021. /**
  41022. * Initializes the VRDistortionCorrectionPostProcess
  41023. * @param name The name of the effect.
  41024. * @param camera The camera to apply the render pass to.
  41025. * @param isRightEye If this is for the right eye distortion
  41026. * @param vrMetrics All the required metrics for the VR camera
  41027. */
  41028. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41029. }
  41030. }
  41031. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41032. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41033. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41034. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41035. import { Scene } from "babylonjs/scene";
  41036. import { Vector3 } from "babylonjs/Maths/math.vector";
  41037. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41038. import "babylonjs/Cameras/RigModes/vrRigMode";
  41039. /**
  41040. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41041. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41042. */
  41043. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41044. /**
  41045. * Creates a new VRDeviceOrientationArcRotateCamera
  41046. * @param name defines camera name
  41047. * @param alpha defines the camera rotation along the logitudinal axis
  41048. * @param beta defines the camera rotation along the latitudinal axis
  41049. * @param radius defines the camera distance from its target
  41050. * @param target defines the camera target
  41051. * @param scene defines the scene the camera belongs to
  41052. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41053. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41054. */
  41055. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41056. /**
  41057. * Gets camera class name
  41058. * @returns VRDeviceOrientationArcRotateCamera
  41059. */
  41060. getClassName(): string;
  41061. }
  41062. }
  41063. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41064. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41065. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41066. import { Scene } from "babylonjs/scene";
  41067. import { Vector3 } from "babylonjs/Maths/math.vector";
  41068. import "babylonjs/Cameras/RigModes/vrRigMode";
  41069. /**
  41070. * Camera used to simulate VR rendering (based on FreeCamera)
  41071. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41072. */
  41073. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41074. /**
  41075. * Creates a new VRDeviceOrientationFreeCamera
  41076. * @param name defines camera name
  41077. * @param position defines the start position of the camera
  41078. * @param scene defines the scene the camera belongs to
  41079. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41080. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41081. */
  41082. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41083. /**
  41084. * Gets camera class name
  41085. * @returns VRDeviceOrientationFreeCamera
  41086. */
  41087. getClassName(): string;
  41088. }
  41089. }
  41090. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41091. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41092. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41093. import { Scene } from "babylonjs/scene";
  41094. import { Vector3 } from "babylonjs/Maths/math.vector";
  41095. import "babylonjs/Gamepads/gamepadSceneComponent";
  41096. /**
  41097. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41098. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41099. */
  41100. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41101. /**
  41102. * Creates a new VRDeviceOrientationGamepadCamera
  41103. * @param name defines camera name
  41104. * @param position defines the start position of the camera
  41105. * @param scene defines the scene the camera belongs to
  41106. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41107. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41108. */
  41109. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41110. /**
  41111. * Gets camera class name
  41112. * @returns VRDeviceOrientationGamepadCamera
  41113. */
  41114. getClassName(): string;
  41115. }
  41116. }
  41117. declare module "babylonjs/Materials/pushMaterial" {
  41118. import { Nullable } from "babylonjs/types";
  41119. import { Scene } from "babylonjs/scene";
  41120. import { Matrix } from "babylonjs/Maths/math.vector";
  41121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41122. import { Mesh } from "babylonjs/Meshes/mesh";
  41123. import { Material } from "babylonjs/Materials/material";
  41124. import { Effect } from "babylonjs/Materials/effect";
  41125. /**
  41126. * Base class of materials working in push mode in babylon JS
  41127. * @hidden
  41128. */
  41129. export class PushMaterial extends Material {
  41130. protected _activeEffect: Effect;
  41131. protected _normalMatrix: Matrix;
  41132. /**
  41133. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41134. * This means that the material can keep using a previous shader while a new one is being compiled.
  41135. * This is mostly used when shader parallel compilation is supported (true by default)
  41136. */
  41137. allowShaderHotSwapping: boolean;
  41138. constructor(name: string, scene: Scene);
  41139. getEffect(): Effect;
  41140. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41141. /**
  41142. * Binds the given world matrix to the active effect
  41143. *
  41144. * @param world the matrix to bind
  41145. */
  41146. bindOnlyWorldMatrix(world: Matrix): void;
  41147. /**
  41148. * Binds the given normal matrix to the active effect
  41149. *
  41150. * @param normalMatrix the matrix to bind
  41151. */
  41152. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41153. bind(world: Matrix, mesh?: Mesh): void;
  41154. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41155. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41156. }
  41157. }
  41158. declare module "babylonjs/Materials/materialFlags" {
  41159. /**
  41160. * This groups all the flags used to control the materials channel.
  41161. */
  41162. export class MaterialFlags {
  41163. private static _DiffuseTextureEnabled;
  41164. /**
  41165. * Are diffuse textures enabled in the application.
  41166. */
  41167. static DiffuseTextureEnabled: boolean;
  41168. private static _AmbientTextureEnabled;
  41169. /**
  41170. * Are ambient textures enabled in the application.
  41171. */
  41172. static AmbientTextureEnabled: boolean;
  41173. private static _OpacityTextureEnabled;
  41174. /**
  41175. * Are opacity textures enabled in the application.
  41176. */
  41177. static OpacityTextureEnabled: boolean;
  41178. private static _ReflectionTextureEnabled;
  41179. /**
  41180. * Are reflection textures enabled in the application.
  41181. */
  41182. static ReflectionTextureEnabled: boolean;
  41183. private static _EmissiveTextureEnabled;
  41184. /**
  41185. * Are emissive textures enabled in the application.
  41186. */
  41187. static EmissiveTextureEnabled: boolean;
  41188. private static _SpecularTextureEnabled;
  41189. /**
  41190. * Are specular textures enabled in the application.
  41191. */
  41192. static SpecularTextureEnabled: boolean;
  41193. private static _BumpTextureEnabled;
  41194. /**
  41195. * Are bump textures enabled in the application.
  41196. */
  41197. static BumpTextureEnabled: boolean;
  41198. private static _LightmapTextureEnabled;
  41199. /**
  41200. * Are lightmap textures enabled in the application.
  41201. */
  41202. static LightmapTextureEnabled: boolean;
  41203. private static _RefractionTextureEnabled;
  41204. /**
  41205. * Are refraction textures enabled in the application.
  41206. */
  41207. static RefractionTextureEnabled: boolean;
  41208. private static _ColorGradingTextureEnabled;
  41209. /**
  41210. * Are color grading textures enabled in the application.
  41211. */
  41212. static ColorGradingTextureEnabled: boolean;
  41213. private static _FresnelEnabled;
  41214. /**
  41215. * Are fresnels enabled in the application.
  41216. */
  41217. static FresnelEnabled: boolean;
  41218. private static _ClearCoatTextureEnabled;
  41219. /**
  41220. * Are clear coat textures enabled in the application.
  41221. */
  41222. static ClearCoatTextureEnabled: boolean;
  41223. private static _ClearCoatBumpTextureEnabled;
  41224. /**
  41225. * Are clear coat bump textures enabled in the application.
  41226. */
  41227. static ClearCoatBumpTextureEnabled: boolean;
  41228. private static _ClearCoatTintTextureEnabled;
  41229. /**
  41230. * Are clear coat tint textures enabled in the application.
  41231. */
  41232. static ClearCoatTintTextureEnabled: boolean;
  41233. private static _SheenTextureEnabled;
  41234. /**
  41235. * Are sheen textures enabled in the application.
  41236. */
  41237. static SheenTextureEnabled: boolean;
  41238. private static _AnisotropicTextureEnabled;
  41239. /**
  41240. * Are anisotropic textures enabled in the application.
  41241. */
  41242. static AnisotropicTextureEnabled: boolean;
  41243. private static _ThicknessTextureEnabled;
  41244. /**
  41245. * Are thickness textures enabled in the application.
  41246. */
  41247. static ThicknessTextureEnabled: boolean;
  41248. }
  41249. }
  41250. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41251. /** @hidden */
  41252. export var defaultFragmentDeclaration: {
  41253. name: string;
  41254. shader: string;
  41255. };
  41256. }
  41257. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41258. /** @hidden */
  41259. export var defaultUboDeclaration: {
  41260. name: string;
  41261. shader: string;
  41262. };
  41263. }
  41264. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41265. /** @hidden */
  41266. export var lightFragmentDeclaration: {
  41267. name: string;
  41268. shader: string;
  41269. };
  41270. }
  41271. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41272. /** @hidden */
  41273. export var lightUboDeclaration: {
  41274. name: string;
  41275. shader: string;
  41276. };
  41277. }
  41278. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41279. /** @hidden */
  41280. export var lightsFragmentFunctions: {
  41281. name: string;
  41282. shader: string;
  41283. };
  41284. }
  41285. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41286. /** @hidden */
  41287. export var shadowsFragmentFunctions: {
  41288. name: string;
  41289. shader: string;
  41290. };
  41291. }
  41292. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41293. /** @hidden */
  41294. export var fresnelFunction: {
  41295. name: string;
  41296. shader: string;
  41297. };
  41298. }
  41299. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41300. /** @hidden */
  41301. export var reflectionFunction: {
  41302. name: string;
  41303. shader: string;
  41304. };
  41305. }
  41306. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41307. /** @hidden */
  41308. export var bumpFragmentFunctions: {
  41309. name: string;
  41310. shader: string;
  41311. };
  41312. }
  41313. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41314. /** @hidden */
  41315. export var logDepthDeclaration: {
  41316. name: string;
  41317. shader: string;
  41318. };
  41319. }
  41320. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41321. /** @hidden */
  41322. export var bumpFragment: {
  41323. name: string;
  41324. shader: string;
  41325. };
  41326. }
  41327. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41328. /** @hidden */
  41329. export var depthPrePass: {
  41330. name: string;
  41331. shader: string;
  41332. };
  41333. }
  41334. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41335. /** @hidden */
  41336. export var lightFragment: {
  41337. name: string;
  41338. shader: string;
  41339. };
  41340. }
  41341. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41342. /** @hidden */
  41343. export var logDepthFragment: {
  41344. name: string;
  41345. shader: string;
  41346. };
  41347. }
  41348. declare module "babylonjs/Shaders/default.fragment" {
  41349. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41350. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41351. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41352. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41353. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41354. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41355. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41356. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41357. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41358. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41359. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41360. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41361. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41362. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41363. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41364. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41365. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41366. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41367. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41368. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41369. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41370. /** @hidden */
  41371. export var defaultPixelShader: {
  41372. name: string;
  41373. shader: string;
  41374. };
  41375. }
  41376. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41377. /** @hidden */
  41378. export var defaultVertexDeclaration: {
  41379. name: string;
  41380. shader: string;
  41381. };
  41382. }
  41383. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41384. /** @hidden */
  41385. export var bumpVertexDeclaration: {
  41386. name: string;
  41387. shader: string;
  41388. };
  41389. }
  41390. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41391. /** @hidden */
  41392. export var bumpVertex: {
  41393. name: string;
  41394. shader: string;
  41395. };
  41396. }
  41397. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41398. /** @hidden */
  41399. export var fogVertex: {
  41400. name: string;
  41401. shader: string;
  41402. };
  41403. }
  41404. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41405. /** @hidden */
  41406. export var shadowsVertex: {
  41407. name: string;
  41408. shader: string;
  41409. };
  41410. }
  41411. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41412. /** @hidden */
  41413. export var pointCloudVertex: {
  41414. name: string;
  41415. shader: string;
  41416. };
  41417. }
  41418. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41419. /** @hidden */
  41420. export var logDepthVertex: {
  41421. name: string;
  41422. shader: string;
  41423. };
  41424. }
  41425. declare module "babylonjs/Shaders/default.vertex" {
  41426. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41427. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41428. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41429. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41430. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41431. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41432. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41433. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41434. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41435. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41436. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41437. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41438. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41439. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41440. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41441. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41442. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41443. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41444. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41445. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41446. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41447. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41448. /** @hidden */
  41449. export var defaultVertexShader: {
  41450. name: string;
  41451. shader: string;
  41452. };
  41453. }
  41454. declare module "babylonjs/Materials/standardMaterial" {
  41455. import { SmartArray } from "babylonjs/Misc/smartArray";
  41456. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41457. import { Nullable } from "babylonjs/types";
  41458. import { Scene } from "babylonjs/scene";
  41459. import { Matrix } from "babylonjs/Maths/math.vector";
  41460. import { Color3 } from "babylonjs/Maths/math.color";
  41461. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41463. import { Mesh } from "babylonjs/Meshes/mesh";
  41464. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41465. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41466. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41467. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41468. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41469. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41470. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41471. import "babylonjs/Shaders/default.fragment";
  41472. import "babylonjs/Shaders/default.vertex";
  41473. /** @hidden */
  41474. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41475. MAINUV1: boolean;
  41476. MAINUV2: boolean;
  41477. DIFFUSE: boolean;
  41478. DIFFUSEDIRECTUV: number;
  41479. AMBIENT: boolean;
  41480. AMBIENTDIRECTUV: number;
  41481. OPACITY: boolean;
  41482. OPACITYDIRECTUV: number;
  41483. OPACITYRGB: boolean;
  41484. REFLECTION: boolean;
  41485. EMISSIVE: boolean;
  41486. EMISSIVEDIRECTUV: number;
  41487. SPECULAR: boolean;
  41488. SPECULARDIRECTUV: number;
  41489. BUMP: boolean;
  41490. BUMPDIRECTUV: number;
  41491. PARALLAX: boolean;
  41492. PARALLAXOCCLUSION: boolean;
  41493. SPECULAROVERALPHA: boolean;
  41494. CLIPPLANE: boolean;
  41495. CLIPPLANE2: boolean;
  41496. CLIPPLANE3: boolean;
  41497. CLIPPLANE4: boolean;
  41498. ALPHATEST: boolean;
  41499. DEPTHPREPASS: boolean;
  41500. ALPHAFROMDIFFUSE: boolean;
  41501. POINTSIZE: boolean;
  41502. FOG: boolean;
  41503. SPECULARTERM: boolean;
  41504. DIFFUSEFRESNEL: boolean;
  41505. OPACITYFRESNEL: boolean;
  41506. REFLECTIONFRESNEL: boolean;
  41507. REFRACTIONFRESNEL: boolean;
  41508. EMISSIVEFRESNEL: boolean;
  41509. FRESNEL: boolean;
  41510. NORMAL: boolean;
  41511. UV1: boolean;
  41512. UV2: boolean;
  41513. VERTEXCOLOR: boolean;
  41514. VERTEXALPHA: boolean;
  41515. NUM_BONE_INFLUENCERS: number;
  41516. BonesPerMesh: number;
  41517. BONETEXTURE: boolean;
  41518. INSTANCES: boolean;
  41519. GLOSSINESS: boolean;
  41520. ROUGHNESS: boolean;
  41521. EMISSIVEASILLUMINATION: boolean;
  41522. LINKEMISSIVEWITHDIFFUSE: boolean;
  41523. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41524. LIGHTMAP: boolean;
  41525. LIGHTMAPDIRECTUV: number;
  41526. OBJECTSPACE_NORMALMAP: boolean;
  41527. USELIGHTMAPASSHADOWMAP: boolean;
  41528. REFLECTIONMAP_3D: boolean;
  41529. REFLECTIONMAP_SPHERICAL: boolean;
  41530. REFLECTIONMAP_PLANAR: boolean;
  41531. REFLECTIONMAP_CUBIC: boolean;
  41532. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41533. REFLECTIONMAP_PROJECTION: boolean;
  41534. REFLECTIONMAP_SKYBOX: boolean;
  41535. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41536. REFLECTIONMAP_EXPLICIT: boolean;
  41537. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41538. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41539. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41540. INVERTCUBICMAP: boolean;
  41541. LOGARITHMICDEPTH: boolean;
  41542. REFRACTION: boolean;
  41543. REFRACTIONMAP_3D: boolean;
  41544. REFLECTIONOVERALPHA: boolean;
  41545. TWOSIDEDLIGHTING: boolean;
  41546. SHADOWFLOAT: boolean;
  41547. MORPHTARGETS: boolean;
  41548. MORPHTARGETS_NORMAL: boolean;
  41549. MORPHTARGETS_TANGENT: boolean;
  41550. MORPHTARGETS_UV: boolean;
  41551. NUM_MORPH_INFLUENCERS: number;
  41552. NONUNIFORMSCALING: boolean;
  41553. PREMULTIPLYALPHA: boolean;
  41554. IMAGEPROCESSING: boolean;
  41555. VIGNETTE: boolean;
  41556. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41557. VIGNETTEBLENDMODEOPAQUE: boolean;
  41558. TONEMAPPING: boolean;
  41559. TONEMAPPING_ACES: boolean;
  41560. CONTRAST: boolean;
  41561. COLORCURVES: boolean;
  41562. COLORGRADING: boolean;
  41563. COLORGRADING3D: boolean;
  41564. SAMPLER3DGREENDEPTH: boolean;
  41565. SAMPLER3DBGRMAP: boolean;
  41566. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41567. MULTIVIEW: boolean;
  41568. /**
  41569. * If the reflection texture on this material is in linear color space
  41570. * @hidden
  41571. */
  41572. IS_REFLECTION_LINEAR: boolean;
  41573. /**
  41574. * If the refraction texture on this material is in linear color space
  41575. * @hidden
  41576. */
  41577. IS_REFRACTION_LINEAR: boolean;
  41578. EXPOSURE: boolean;
  41579. constructor();
  41580. setReflectionMode(modeToEnable: string): void;
  41581. }
  41582. /**
  41583. * This is the default material used in Babylon. It is the best trade off between quality
  41584. * and performances.
  41585. * @see http://doc.babylonjs.com/babylon101/materials
  41586. */
  41587. export class StandardMaterial extends PushMaterial {
  41588. private _diffuseTexture;
  41589. /**
  41590. * The basic texture of the material as viewed under a light.
  41591. */
  41592. diffuseTexture: Nullable<BaseTexture>;
  41593. private _ambientTexture;
  41594. /**
  41595. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41596. */
  41597. ambientTexture: Nullable<BaseTexture>;
  41598. private _opacityTexture;
  41599. /**
  41600. * Define the transparency of the material from a texture.
  41601. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41602. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41603. */
  41604. opacityTexture: Nullable<BaseTexture>;
  41605. private _reflectionTexture;
  41606. /**
  41607. * Define the texture used to display the reflection.
  41608. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41609. */
  41610. reflectionTexture: Nullable<BaseTexture>;
  41611. private _emissiveTexture;
  41612. /**
  41613. * Define texture of the material as if self lit.
  41614. * This will be mixed in the final result even in the absence of light.
  41615. */
  41616. emissiveTexture: Nullable<BaseTexture>;
  41617. private _specularTexture;
  41618. /**
  41619. * Define how the color and intensity of the highlight given by the light in the material.
  41620. */
  41621. specularTexture: Nullable<BaseTexture>;
  41622. private _bumpTexture;
  41623. /**
  41624. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41625. * 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.
  41626. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41627. */
  41628. bumpTexture: Nullable<BaseTexture>;
  41629. private _lightmapTexture;
  41630. /**
  41631. * Complex lighting can be computationally expensive to compute at runtime.
  41632. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41633. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41634. */
  41635. lightmapTexture: Nullable<BaseTexture>;
  41636. private _refractionTexture;
  41637. /**
  41638. * Define the texture used to display the refraction.
  41639. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41640. */
  41641. refractionTexture: Nullable<BaseTexture>;
  41642. /**
  41643. * The color of the material lit by the environmental background lighting.
  41644. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41645. */
  41646. ambientColor: Color3;
  41647. /**
  41648. * The basic color of the material as viewed under a light.
  41649. */
  41650. diffuseColor: Color3;
  41651. /**
  41652. * Define how the color and intensity of the highlight given by the light in the material.
  41653. */
  41654. specularColor: Color3;
  41655. /**
  41656. * Define the color of the material as if self lit.
  41657. * This will be mixed in the final result even in the absence of light.
  41658. */
  41659. emissiveColor: Color3;
  41660. /**
  41661. * Defines how sharp are the highlights in the material.
  41662. * The bigger the value the sharper giving a more glossy feeling to the result.
  41663. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41664. */
  41665. specularPower: number;
  41666. private _useAlphaFromDiffuseTexture;
  41667. /**
  41668. * Does the transparency come from the diffuse texture alpha channel.
  41669. */
  41670. useAlphaFromDiffuseTexture: boolean;
  41671. private _useEmissiveAsIllumination;
  41672. /**
  41673. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41674. */
  41675. useEmissiveAsIllumination: boolean;
  41676. private _linkEmissiveWithDiffuse;
  41677. /**
  41678. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41679. * the emissive level when the final color is close to one.
  41680. */
  41681. linkEmissiveWithDiffuse: boolean;
  41682. private _useSpecularOverAlpha;
  41683. /**
  41684. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41685. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41686. */
  41687. useSpecularOverAlpha: boolean;
  41688. private _useReflectionOverAlpha;
  41689. /**
  41690. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41691. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41692. */
  41693. useReflectionOverAlpha: boolean;
  41694. private _disableLighting;
  41695. /**
  41696. * Does lights from the scene impacts this material.
  41697. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41698. */
  41699. disableLighting: boolean;
  41700. private _useObjectSpaceNormalMap;
  41701. /**
  41702. * Allows using an object space normal map (instead of tangent space).
  41703. */
  41704. useObjectSpaceNormalMap: boolean;
  41705. private _useParallax;
  41706. /**
  41707. * Is parallax enabled or not.
  41708. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41709. */
  41710. useParallax: boolean;
  41711. private _useParallaxOcclusion;
  41712. /**
  41713. * Is parallax occlusion enabled or not.
  41714. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41715. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41716. */
  41717. useParallaxOcclusion: boolean;
  41718. /**
  41719. * 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.
  41720. */
  41721. parallaxScaleBias: number;
  41722. private _roughness;
  41723. /**
  41724. * Helps to define how blurry the reflections should appears in the material.
  41725. */
  41726. roughness: number;
  41727. /**
  41728. * In case of refraction, define the value of the index of refraction.
  41729. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41730. */
  41731. indexOfRefraction: number;
  41732. /**
  41733. * Invert the refraction texture alongside the y axis.
  41734. * It can be useful with procedural textures or probe for instance.
  41735. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41736. */
  41737. invertRefractionY: boolean;
  41738. /**
  41739. * Defines the alpha limits in alpha test mode.
  41740. */
  41741. alphaCutOff: number;
  41742. private _useLightmapAsShadowmap;
  41743. /**
  41744. * In case of light mapping, define whether the map contains light or shadow informations.
  41745. */
  41746. useLightmapAsShadowmap: boolean;
  41747. private _diffuseFresnelParameters;
  41748. /**
  41749. * Define the diffuse fresnel parameters of the material.
  41750. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41751. */
  41752. diffuseFresnelParameters: FresnelParameters;
  41753. private _opacityFresnelParameters;
  41754. /**
  41755. * Define the opacity fresnel parameters of the material.
  41756. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41757. */
  41758. opacityFresnelParameters: FresnelParameters;
  41759. private _reflectionFresnelParameters;
  41760. /**
  41761. * Define the reflection fresnel parameters of the material.
  41762. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41763. */
  41764. reflectionFresnelParameters: FresnelParameters;
  41765. private _refractionFresnelParameters;
  41766. /**
  41767. * Define the refraction fresnel parameters of the material.
  41768. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41769. */
  41770. refractionFresnelParameters: FresnelParameters;
  41771. private _emissiveFresnelParameters;
  41772. /**
  41773. * Define the emissive fresnel parameters of the material.
  41774. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41775. */
  41776. emissiveFresnelParameters: FresnelParameters;
  41777. private _useReflectionFresnelFromSpecular;
  41778. /**
  41779. * If true automatically deducts the fresnels values from the material specularity.
  41780. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41781. */
  41782. useReflectionFresnelFromSpecular: boolean;
  41783. private _useGlossinessFromSpecularMapAlpha;
  41784. /**
  41785. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41786. */
  41787. useGlossinessFromSpecularMapAlpha: boolean;
  41788. private _maxSimultaneousLights;
  41789. /**
  41790. * Defines the maximum number of lights that can be used in the material
  41791. */
  41792. maxSimultaneousLights: number;
  41793. private _invertNormalMapX;
  41794. /**
  41795. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41796. */
  41797. invertNormalMapX: boolean;
  41798. private _invertNormalMapY;
  41799. /**
  41800. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41801. */
  41802. invertNormalMapY: boolean;
  41803. private _twoSidedLighting;
  41804. /**
  41805. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41806. */
  41807. twoSidedLighting: boolean;
  41808. /**
  41809. * Default configuration related to image processing available in the standard Material.
  41810. */
  41811. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41812. /**
  41813. * Gets the image processing configuration used either in this material.
  41814. */
  41815. /**
  41816. * Sets the Default image processing configuration used either in the this material.
  41817. *
  41818. * If sets to null, the scene one is in use.
  41819. */
  41820. imageProcessingConfiguration: ImageProcessingConfiguration;
  41821. /**
  41822. * Keep track of the image processing observer to allow dispose and replace.
  41823. */
  41824. private _imageProcessingObserver;
  41825. /**
  41826. * Attaches a new image processing configuration to the Standard Material.
  41827. * @param configuration
  41828. */
  41829. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41830. /**
  41831. * Gets wether the color curves effect is enabled.
  41832. */
  41833. /**
  41834. * Sets wether the color curves effect is enabled.
  41835. */
  41836. cameraColorCurvesEnabled: boolean;
  41837. /**
  41838. * Gets wether the color grading effect is enabled.
  41839. */
  41840. /**
  41841. * Gets wether the color grading effect is enabled.
  41842. */
  41843. cameraColorGradingEnabled: boolean;
  41844. /**
  41845. * Gets wether tonemapping is enabled or not.
  41846. */
  41847. /**
  41848. * Sets wether tonemapping is enabled or not
  41849. */
  41850. cameraToneMappingEnabled: boolean;
  41851. /**
  41852. * The camera exposure used on this material.
  41853. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41854. * This corresponds to a photographic exposure.
  41855. */
  41856. /**
  41857. * The camera exposure used on this material.
  41858. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41859. * This corresponds to a photographic exposure.
  41860. */
  41861. cameraExposure: number;
  41862. /**
  41863. * Gets The camera contrast used on this material.
  41864. */
  41865. /**
  41866. * Sets The camera contrast used on this material.
  41867. */
  41868. cameraContrast: number;
  41869. /**
  41870. * Gets the Color Grading 2D Lookup Texture.
  41871. */
  41872. /**
  41873. * Sets the Color Grading 2D Lookup Texture.
  41874. */
  41875. cameraColorGradingTexture: Nullable<BaseTexture>;
  41876. /**
  41877. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41878. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41879. * 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;
  41880. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41881. */
  41882. /**
  41883. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41884. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41885. * 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;
  41886. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41887. */
  41888. cameraColorCurves: Nullable<ColorCurves>;
  41889. /**
  41890. * Custom callback helping to override the default shader used in the material.
  41891. */
  41892. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41893. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41894. protected _worldViewProjectionMatrix: Matrix;
  41895. protected _globalAmbientColor: Color3;
  41896. protected _useLogarithmicDepth: boolean;
  41897. protected _rebuildInParallel: boolean;
  41898. /**
  41899. * Instantiates a new standard material.
  41900. * This is the default material used in Babylon. It is the best trade off between quality
  41901. * and performances.
  41902. * @see http://doc.babylonjs.com/babylon101/materials
  41903. * @param name Define the name of the material in the scene
  41904. * @param scene Define the scene the material belong to
  41905. */
  41906. constructor(name: string, scene: Scene);
  41907. /**
  41908. * Gets a boolean indicating that current material needs to register RTT
  41909. */
  41910. readonly hasRenderTargetTextures: boolean;
  41911. /**
  41912. * Gets the current class name of the material e.g. "StandardMaterial"
  41913. * Mainly use in serialization.
  41914. * @returns the class name
  41915. */
  41916. getClassName(): string;
  41917. /**
  41918. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41919. * You can try switching to logarithmic depth.
  41920. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41921. */
  41922. useLogarithmicDepth: boolean;
  41923. /**
  41924. * Specifies if the material will require alpha blending
  41925. * @returns a boolean specifying if alpha blending is needed
  41926. */
  41927. needAlphaBlending(): boolean;
  41928. /**
  41929. * Specifies if this material should be rendered in alpha test mode
  41930. * @returns a boolean specifying if an alpha test is needed.
  41931. */
  41932. needAlphaTesting(): boolean;
  41933. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41934. /**
  41935. * Get the texture used for alpha test purpose.
  41936. * @returns the diffuse texture in case of the standard material.
  41937. */
  41938. getAlphaTestTexture(): Nullable<BaseTexture>;
  41939. /**
  41940. * Get if the submesh is ready to be used and all its information available.
  41941. * Child classes can use it to update shaders
  41942. * @param mesh defines the mesh to check
  41943. * @param subMesh defines which submesh to check
  41944. * @param useInstances specifies that instances should be used
  41945. * @returns a boolean indicating that the submesh is ready or not
  41946. */
  41947. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41948. /**
  41949. * Builds the material UBO layouts.
  41950. * Used internally during the effect preparation.
  41951. */
  41952. buildUniformLayout(): void;
  41953. /**
  41954. * Unbinds the material from the mesh
  41955. */
  41956. unbind(): void;
  41957. /**
  41958. * Binds the submesh to this material by preparing the effect and shader to draw
  41959. * @param world defines the world transformation matrix
  41960. * @param mesh defines the mesh containing the submesh
  41961. * @param subMesh defines the submesh to bind the material to
  41962. */
  41963. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41964. /**
  41965. * Get the list of animatables in the material.
  41966. * @returns the list of animatables object used in the material
  41967. */
  41968. getAnimatables(): IAnimatable[];
  41969. /**
  41970. * Gets the active textures from the material
  41971. * @returns an array of textures
  41972. */
  41973. getActiveTextures(): BaseTexture[];
  41974. /**
  41975. * Specifies if the material uses a texture
  41976. * @param texture defines the texture to check against the material
  41977. * @returns a boolean specifying if the material uses the texture
  41978. */
  41979. hasTexture(texture: BaseTexture): boolean;
  41980. /**
  41981. * Disposes the material
  41982. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41983. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41984. */
  41985. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41986. /**
  41987. * Makes a duplicate of the material, and gives it a new name
  41988. * @param name defines the new name for the duplicated material
  41989. * @returns the cloned material
  41990. */
  41991. clone(name: string): StandardMaterial;
  41992. /**
  41993. * Serializes this material in a JSON representation
  41994. * @returns the serialized material object
  41995. */
  41996. serialize(): any;
  41997. /**
  41998. * Creates a standard material from parsed material data
  41999. * @param source defines the JSON representation of the material
  42000. * @param scene defines the hosting scene
  42001. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42002. * @returns a new standard material
  42003. */
  42004. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42005. /**
  42006. * Are diffuse textures enabled in the application.
  42007. */
  42008. static DiffuseTextureEnabled: boolean;
  42009. /**
  42010. * Are ambient textures enabled in the application.
  42011. */
  42012. static AmbientTextureEnabled: boolean;
  42013. /**
  42014. * Are opacity textures enabled in the application.
  42015. */
  42016. static OpacityTextureEnabled: boolean;
  42017. /**
  42018. * Are reflection textures enabled in the application.
  42019. */
  42020. static ReflectionTextureEnabled: boolean;
  42021. /**
  42022. * Are emissive textures enabled in the application.
  42023. */
  42024. static EmissiveTextureEnabled: boolean;
  42025. /**
  42026. * Are specular textures enabled in the application.
  42027. */
  42028. static SpecularTextureEnabled: boolean;
  42029. /**
  42030. * Are bump textures enabled in the application.
  42031. */
  42032. static BumpTextureEnabled: boolean;
  42033. /**
  42034. * Are lightmap textures enabled in the application.
  42035. */
  42036. static LightmapTextureEnabled: boolean;
  42037. /**
  42038. * Are refraction textures enabled in the application.
  42039. */
  42040. static RefractionTextureEnabled: boolean;
  42041. /**
  42042. * Are color grading textures enabled in the application.
  42043. */
  42044. static ColorGradingTextureEnabled: boolean;
  42045. /**
  42046. * Are fresnels enabled in the application.
  42047. */
  42048. static FresnelEnabled: boolean;
  42049. }
  42050. }
  42051. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42052. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42053. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42054. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42055. /** @hidden */
  42056. export var imageProcessingPixelShader: {
  42057. name: string;
  42058. shader: string;
  42059. };
  42060. }
  42061. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42062. import { Nullable } from "babylonjs/types";
  42063. import { Color4 } from "babylonjs/Maths/math.color";
  42064. import { Camera } from "babylonjs/Cameras/camera";
  42065. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42066. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42067. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42068. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42069. import { Engine } from "babylonjs/Engines/engine";
  42070. import "babylonjs/Shaders/imageProcessing.fragment";
  42071. import "babylonjs/Shaders/postprocess.vertex";
  42072. /**
  42073. * ImageProcessingPostProcess
  42074. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42075. */
  42076. export class ImageProcessingPostProcess extends PostProcess {
  42077. /**
  42078. * Default configuration related to image processing available in the PBR Material.
  42079. */
  42080. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42081. /**
  42082. * Gets the image processing configuration used either in this material.
  42083. */
  42084. /**
  42085. * Sets the Default image processing configuration used either in the this material.
  42086. *
  42087. * If sets to null, the scene one is in use.
  42088. */
  42089. imageProcessingConfiguration: ImageProcessingConfiguration;
  42090. /**
  42091. * Keep track of the image processing observer to allow dispose and replace.
  42092. */
  42093. private _imageProcessingObserver;
  42094. /**
  42095. * Attaches a new image processing configuration to the PBR Material.
  42096. * @param configuration
  42097. */
  42098. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42099. /**
  42100. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42101. */
  42102. /**
  42103. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42104. */
  42105. colorCurves: Nullable<ColorCurves>;
  42106. /**
  42107. * Gets wether the color curves effect is enabled.
  42108. */
  42109. /**
  42110. * Sets wether the color curves effect is enabled.
  42111. */
  42112. colorCurvesEnabled: boolean;
  42113. /**
  42114. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42115. */
  42116. /**
  42117. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42118. */
  42119. colorGradingTexture: Nullable<BaseTexture>;
  42120. /**
  42121. * Gets wether the color grading effect is enabled.
  42122. */
  42123. /**
  42124. * Gets wether the color grading effect is enabled.
  42125. */
  42126. colorGradingEnabled: boolean;
  42127. /**
  42128. * Gets exposure used in the effect.
  42129. */
  42130. /**
  42131. * Sets exposure used in the effect.
  42132. */
  42133. exposure: number;
  42134. /**
  42135. * Gets wether tonemapping is enabled or not.
  42136. */
  42137. /**
  42138. * Sets wether tonemapping is enabled or not
  42139. */
  42140. toneMappingEnabled: boolean;
  42141. /**
  42142. * Gets the type of tone mapping effect.
  42143. */
  42144. /**
  42145. * Sets the type of tone mapping effect.
  42146. */
  42147. toneMappingType: number;
  42148. /**
  42149. * Gets contrast used in the effect.
  42150. */
  42151. /**
  42152. * Sets contrast used in the effect.
  42153. */
  42154. contrast: number;
  42155. /**
  42156. * Gets Vignette stretch size.
  42157. */
  42158. /**
  42159. * Sets Vignette stretch size.
  42160. */
  42161. vignetteStretch: number;
  42162. /**
  42163. * Gets Vignette centre X Offset.
  42164. */
  42165. /**
  42166. * Sets Vignette centre X Offset.
  42167. */
  42168. vignetteCentreX: number;
  42169. /**
  42170. * Gets Vignette centre Y Offset.
  42171. */
  42172. /**
  42173. * Sets Vignette centre Y Offset.
  42174. */
  42175. vignetteCentreY: number;
  42176. /**
  42177. * Gets Vignette weight or intensity of the vignette effect.
  42178. */
  42179. /**
  42180. * Sets Vignette weight or intensity of the vignette effect.
  42181. */
  42182. vignetteWeight: number;
  42183. /**
  42184. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42185. * if vignetteEnabled is set to true.
  42186. */
  42187. /**
  42188. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42189. * if vignetteEnabled is set to true.
  42190. */
  42191. vignetteColor: Color4;
  42192. /**
  42193. * Gets Camera field of view used by the Vignette effect.
  42194. */
  42195. /**
  42196. * Sets Camera field of view used by the Vignette effect.
  42197. */
  42198. vignetteCameraFov: number;
  42199. /**
  42200. * Gets the vignette blend mode allowing different kind of effect.
  42201. */
  42202. /**
  42203. * Sets the vignette blend mode allowing different kind of effect.
  42204. */
  42205. vignetteBlendMode: number;
  42206. /**
  42207. * Gets wether the vignette effect is enabled.
  42208. */
  42209. /**
  42210. * Sets wether the vignette effect is enabled.
  42211. */
  42212. vignetteEnabled: boolean;
  42213. private _fromLinearSpace;
  42214. /**
  42215. * Gets wether the input of the processing is in Gamma or Linear Space.
  42216. */
  42217. /**
  42218. * Sets wether the input of the processing is in Gamma or Linear Space.
  42219. */
  42220. fromLinearSpace: boolean;
  42221. /**
  42222. * Defines cache preventing GC.
  42223. */
  42224. private _defines;
  42225. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42226. /**
  42227. * "ImageProcessingPostProcess"
  42228. * @returns "ImageProcessingPostProcess"
  42229. */
  42230. getClassName(): string;
  42231. protected _updateParameters(): void;
  42232. dispose(camera?: Camera): void;
  42233. }
  42234. }
  42235. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42236. import { Scene } from "babylonjs/scene";
  42237. import { Color3 } from "babylonjs/Maths/math.color";
  42238. import { Mesh } from "babylonjs/Meshes/mesh";
  42239. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42240. import { Nullable } from "babylonjs/types";
  42241. /**
  42242. * Class containing static functions to help procedurally build meshes
  42243. */
  42244. export class GroundBuilder {
  42245. /**
  42246. * Creates a ground mesh
  42247. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42248. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42250. * @param name defines the name of the mesh
  42251. * @param options defines the options used to create the mesh
  42252. * @param scene defines the hosting scene
  42253. * @returns the ground mesh
  42254. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42255. */
  42256. static CreateGround(name: string, options: {
  42257. width?: number;
  42258. height?: number;
  42259. subdivisions?: number;
  42260. subdivisionsX?: number;
  42261. subdivisionsY?: number;
  42262. updatable?: boolean;
  42263. }, scene: any): Mesh;
  42264. /**
  42265. * Creates a tiled ground mesh
  42266. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42267. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42268. * * 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
  42269. * * 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
  42270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42271. * @param name defines the name of the mesh
  42272. * @param options defines the options used to create the mesh
  42273. * @param scene defines the hosting scene
  42274. * @returns the tiled ground mesh
  42275. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42276. */
  42277. static CreateTiledGround(name: string, options: {
  42278. xmin: number;
  42279. zmin: number;
  42280. xmax: number;
  42281. zmax: number;
  42282. subdivisions?: {
  42283. w: number;
  42284. h: number;
  42285. };
  42286. precision?: {
  42287. w: number;
  42288. h: number;
  42289. };
  42290. updatable?: boolean;
  42291. }, scene?: Nullable<Scene>): Mesh;
  42292. /**
  42293. * Creates a ground mesh from a height map
  42294. * * The parameter `url` sets the URL of the height map image resource.
  42295. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42296. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42297. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42298. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42299. * * 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.
  42300. * * 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).
  42301. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42303. * @param name defines the name of the mesh
  42304. * @param url defines the url to the height map
  42305. * @param options defines the options used to create the mesh
  42306. * @param scene defines the hosting scene
  42307. * @returns the ground mesh
  42308. * @see https://doc.babylonjs.com/babylon101/height_map
  42309. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42310. */
  42311. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42312. width?: number;
  42313. height?: number;
  42314. subdivisions?: number;
  42315. minHeight?: number;
  42316. maxHeight?: number;
  42317. colorFilter?: Color3;
  42318. alphaFilter?: number;
  42319. updatable?: boolean;
  42320. onReady?: (mesh: GroundMesh) => void;
  42321. }, scene?: Nullable<Scene>): GroundMesh;
  42322. }
  42323. }
  42324. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42325. import { Vector4 } from "babylonjs/Maths/math.vector";
  42326. import { Mesh } from "babylonjs/Meshes/mesh";
  42327. /**
  42328. * Class containing static functions to help procedurally build meshes
  42329. */
  42330. export class TorusBuilder {
  42331. /**
  42332. * Creates a torus mesh
  42333. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42334. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42335. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42336. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42337. * * 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
  42338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42339. * @param name defines the name of the mesh
  42340. * @param options defines the options used to create the mesh
  42341. * @param scene defines the hosting scene
  42342. * @returns the torus mesh
  42343. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42344. */
  42345. static CreateTorus(name: string, options: {
  42346. diameter?: number;
  42347. thickness?: number;
  42348. tessellation?: number;
  42349. updatable?: boolean;
  42350. sideOrientation?: number;
  42351. frontUVs?: Vector4;
  42352. backUVs?: Vector4;
  42353. }, scene: any): Mesh;
  42354. }
  42355. }
  42356. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42357. import { Vector4 } from "babylonjs/Maths/math.vector";
  42358. import { Color4 } from "babylonjs/Maths/math.color";
  42359. import { Mesh } from "babylonjs/Meshes/mesh";
  42360. /**
  42361. * Class containing static functions to help procedurally build meshes
  42362. */
  42363. export class CylinderBuilder {
  42364. /**
  42365. * Creates a cylinder or a cone mesh
  42366. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42367. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42368. * * 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.
  42369. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42370. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42371. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42372. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42373. * * 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).
  42374. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42375. * * 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).
  42376. * * 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
  42377. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42378. * * 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
  42379. * * 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.
  42380. * * If `enclose` is false, a ring surface is one element.
  42381. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42382. * * 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
  42383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42384. * * 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
  42385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42386. * @param name defines the name of the mesh
  42387. * @param options defines the options used to create the mesh
  42388. * @param scene defines the hosting scene
  42389. * @returns the cylinder mesh
  42390. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42391. */
  42392. static CreateCylinder(name: string, options: {
  42393. height?: number;
  42394. diameterTop?: number;
  42395. diameterBottom?: number;
  42396. diameter?: number;
  42397. tessellation?: number;
  42398. subdivisions?: number;
  42399. arc?: number;
  42400. faceColors?: Color4[];
  42401. faceUV?: Vector4[];
  42402. updatable?: boolean;
  42403. hasRings?: boolean;
  42404. enclose?: boolean;
  42405. cap?: number;
  42406. sideOrientation?: number;
  42407. frontUVs?: Vector4;
  42408. backUVs?: Vector4;
  42409. }, scene: any): Mesh;
  42410. }
  42411. }
  42412. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42413. import { Observable } from "babylonjs/Misc/observable";
  42414. import { Nullable } from "babylonjs/types";
  42415. import { Camera } from "babylonjs/Cameras/camera";
  42416. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42417. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42418. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42419. import { Scene } from "babylonjs/scene";
  42420. import { Vector3 } from "babylonjs/Maths/math.vector";
  42421. import { Color3 } from "babylonjs/Maths/math.color";
  42422. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42423. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42424. import { Mesh } from "babylonjs/Meshes/mesh";
  42425. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42426. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42427. import "babylonjs/Meshes/Builders/groundBuilder";
  42428. import "babylonjs/Meshes/Builders/torusBuilder";
  42429. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42430. import "babylonjs/Gamepads/gamepadSceneComponent";
  42431. import "babylonjs/Animations/animatable";
  42432. /**
  42433. * Options to modify the vr teleportation behavior.
  42434. */
  42435. export interface VRTeleportationOptions {
  42436. /**
  42437. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42438. */
  42439. floorMeshName?: string;
  42440. /**
  42441. * A list of meshes to be used as the teleportation floor. (default: empty)
  42442. */
  42443. floorMeshes?: Mesh[];
  42444. }
  42445. /**
  42446. * Options to modify the vr experience helper's behavior.
  42447. */
  42448. export interface VRExperienceHelperOptions extends WebVROptions {
  42449. /**
  42450. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42451. */
  42452. createDeviceOrientationCamera?: boolean;
  42453. /**
  42454. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42455. */
  42456. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42457. /**
  42458. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42459. */
  42460. laserToggle?: boolean;
  42461. /**
  42462. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42463. */
  42464. floorMeshes?: Mesh[];
  42465. /**
  42466. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42467. */
  42468. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42469. }
  42470. /**
  42471. * Event containing information after VR has been entered
  42472. */
  42473. export class OnAfterEnteringVRObservableEvent {
  42474. /**
  42475. * If entering vr was successful
  42476. */
  42477. success: boolean;
  42478. }
  42479. /**
  42480. * Helps to quickly add VR support to an existing scene.
  42481. * See http://doc.babylonjs.com/how_to/webvr_helper
  42482. */
  42483. export class VRExperienceHelper {
  42484. /** Options to modify the vr experience helper's behavior. */
  42485. webVROptions: VRExperienceHelperOptions;
  42486. private _scene;
  42487. private _position;
  42488. private _btnVR;
  42489. private _btnVRDisplayed;
  42490. private _webVRsupported;
  42491. private _webVRready;
  42492. private _webVRrequesting;
  42493. private _webVRpresenting;
  42494. private _hasEnteredVR;
  42495. private _fullscreenVRpresenting;
  42496. private _canvas;
  42497. private _webVRCamera;
  42498. private _vrDeviceOrientationCamera;
  42499. private _deviceOrientationCamera;
  42500. private _existingCamera;
  42501. private _onKeyDown;
  42502. private _onVrDisplayPresentChange;
  42503. private _onVRDisplayChanged;
  42504. private _onVRRequestPresentStart;
  42505. private _onVRRequestPresentComplete;
  42506. /**
  42507. * 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)
  42508. */
  42509. enableGazeEvenWhenNoPointerLock: boolean;
  42510. /**
  42511. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42512. */
  42513. exitVROnDoubleTap: boolean;
  42514. /**
  42515. * Observable raised right before entering VR.
  42516. */
  42517. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42518. /**
  42519. * Observable raised when entering VR has completed.
  42520. */
  42521. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42522. /**
  42523. * Observable raised when exiting VR.
  42524. */
  42525. onExitingVRObservable: Observable<VRExperienceHelper>;
  42526. /**
  42527. * Observable raised when controller mesh is loaded.
  42528. */
  42529. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42530. /** Return this.onEnteringVRObservable
  42531. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42532. */
  42533. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42534. /** Return this.onExitingVRObservable
  42535. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42536. */
  42537. readonly onExitingVR: Observable<VRExperienceHelper>;
  42538. /** Return this.onControllerMeshLoadedObservable
  42539. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42540. */
  42541. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42542. private _rayLength;
  42543. private _useCustomVRButton;
  42544. private _teleportationRequested;
  42545. private _teleportActive;
  42546. private _floorMeshName;
  42547. private _floorMeshesCollection;
  42548. private _rotationAllowed;
  42549. private _teleportBackwardsVector;
  42550. private _teleportationTarget;
  42551. private _isDefaultTeleportationTarget;
  42552. private _postProcessMove;
  42553. private _teleportationFillColor;
  42554. private _teleportationBorderColor;
  42555. private _rotationAngle;
  42556. private _haloCenter;
  42557. private _cameraGazer;
  42558. private _padSensibilityUp;
  42559. private _padSensibilityDown;
  42560. private _leftController;
  42561. private _rightController;
  42562. /**
  42563. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42564. */
  42565. onNewMeshSelected: Observable<AbstractMesh>;
  42566. /**
  42567. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42568. * This observable will provide the mesh and the controller used to select the mesh
  42569. */
  42570. onMeshSelectedWithController: Observable<{
  42571. mesh: AbstractMesh;
  42572. controller: WebVRController;
  42573. }>;
  42574. /**
  42575. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42576. */
  42577. onNewMeshPicked: Observable<PickingInfo>;
  42578. private _circleEase;
  42579. /**
  42580. * Observable raised before camera teleportation
  42581. */
  42582. onBeforeCameraTeleport: Observable<Vector3>;
  42583. /**
  42584. * Observable raised after camera teleportation
  42585. */
  42586. onAfterCameraTeleport: Observable<Vector3>;
  42587. /**
  42588. * Observable raised when current selected mesh gets unselected
  42589. */
  42590. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42591. private _raySelectionPredicate;
  42592. /**
  42593. * To be optionaly changed by user to define custom ray selection
  42594. */
  42595. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42596. /**
  42597. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42598. */
  42599. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42600. /**
  42601. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42602. */
  42603. teleportationEnabled: boolean;
  42604. private _defaultHeight;
  42605. private _teleportationInitialized;
  42606. private _interactionsEnabled;
  42607. private _interactionsRequested;
  42608. private _displayGaze;
  42609. private _displayLaserPointer;
  42610. /**
  42611. * The mesh used to display where the user is going to teleport.
  42612. */
  42613. /**
  42614. * Sets the mesh to be used to display where the user is going to teleport.
  42615. */
  42616. teleportationTarget: Mesh;
  42617. /**
  42618. * 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
  42619. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42620. * See http://doc.babylonjs.com/resources/baking_transformations
  42621. */
  42622. gazeTrackerMesh: Mesh;
  42623. /**
  42624. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42625. */
  42626. updateGazeTrackerScale: boolean;
  42627. /**
  42628. * If the gaze trackers color should be updated when selecting meshes
  42629. */
  42630. updateGazeTrackerColor: boolean;
  42631. /**
  42632. * If the controller laser color should be updated when selecting meshes
  42633. */
  42634. updateControllerLaserColor: boolean;
  42635. /**
  42636. * The gaze tracking mesh corresponding to the left controller
  42637. */
  42638. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42639. /**
  42640. * The gaze tracking mesh corresponding to the right controller
  42641. */
  42642. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42643. /**
  42644. * If the ray of the gaze should be displayed.
  42645. */
  42646. /**
  42647. * Sets if the ray of the gaze should be displayed.
  42648. */
  42649. displayGaze: boolean;
  42650. /**
  42651. * If the ray of the LaserPointer should be displayed.
  42652. */
  42653. /**
  42654. * Sets if the ray of the LaserPointer should be displayed.
  42655. */
  42656. displayLaserPointer: boolean;
  42657. /**
  42658. * The deviceOrientationCamera used as the camera when not in VR.
  42659. */
  42660. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42661. /**
  42662. * Based on the current WebVR support, returns the current VR camera used.
  42663. */
  42664. readonly currentVRCamera: Nullable<Camera>;
  42665. /**
  42666. * The webVRCamera which is used when in VR.
  42667. */
  42668. readonly webVRCamera: WebVRFreeCamera;
  42669. /**
  42670. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42671. */
  42672. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42673. /**
  42674. * The html button that is used to trigger entering into VR.
  42675. */
  42676. readonly vrButton: Nullable<HTMLButtonElement>;
  42677. private readonly _teleportationRequestInitiated;
  42678. /**
  42679. * Defines wether or not Pointer lock should be requested when switching to
  42680. * full screen.
  42681. */
  42682. requestPointerLockOnFullScreen: boolean;
  42683. /**
  42684. * Instantiates a VRExperienceHelper.
  42685. * Helps to quickly add VR support to an existing scene.
  42686. * @param scene The scene the VRExperienceHelper belongs to.
  42687. * @param webVROptions Options to modify the vr experience helper's behavior.
  42688. */
  42689. constructor(scene: Scene,
  42690. /** Options to modify the vr experience helper's behavior. */
  42691. webVROptions?: VRExperienceHelperOptions);
  42692. private _onDefaultMeshLoaded;
  42693. private _onResize;
  42694. private _onFullscreenChange;
  42695. /**
  42696. * Gets a value indicating if we are currently in VR mode.
  42697. */
  42698. readonly isInVRMode: boolean;
  42699. private onVrDisplayPresentChange;
  42700. private onVRDisplayChanged;
  42701. private moveButtonToBottomRight;
  42702. private displayVRButton;
  42703. private updateButtonVisibility;
  42704. private _cachedAngularSensibility;
  42705. /**
  42706. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42707. * Otherwise, will use the fullscreen API.
  42708. */
  42709. enterVR(): void;
  42710. /**
  42711. * Attempt to exit VR, or fullscreen.
  42712. */
  42713. exitVR(): void;
  42714. /**
  42715. * The position of the vr experience helper.
  42716. */
  42717. /**
  42718. * Sets the position of the vr experience helper.
  42719. */
  42720. position: Vector3;
  42721. /**
  42722. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42723. */
  42724. enableInteractions(): void;
  42725. private readonly _noControllerIsActive;
  42726. private beforeRender;
  42727. private _isTeleportationFloor;
  42728. /**
  42729. * Adds a floor mesh to be used for teleportation.
  42730. * @param floorMesh the mesh to be used for teleportation.
  42731. */
  42732. addFloorMesh(floorMesh: Mesh): void;
  42733. /**
  42734. * Removes a floor mesh from being used for teleportation.
  42735. * @param floorMesh the mesh to be removed.
  42736. */
  42737. removeFloorMesh(floorMesh: Mesh): void;
  42738. /**
  42739. * Enables interactions and teleportation using the VR controllers and gaze.
  42740. * @param vrTeleportationOptions options to modify teleportation behavior.
  42741. */
  42742. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42743. private _onNewGamepadConnected;
  42744. private _tryEnableInteractionOnController;
  42745. private _onNewGamepadDisconnected;
  42746. private _enableInteractionOnController;
  42747. private _checkTeleportWithRay;
  42748. private _checkRotate;
  42749. private _checkTeleportBackwards;
  42750. private _enableTeleportationOnController;
  42751. private _createTeleportationCircles;
  42752. private _displayTeleportationTarget;
  42753. private _hideTeleportationTarget;
  42754. private _rotateCamera;
  42755. private _moveTeleportationSelectorTo;
  42756. private _workingVector;
  42757. private _workingQuaternion;
  42758. private _workingMatrix;
  42759. /**
  42760. * Teleports the users feet to the desired location
  42761. * @param location The location where the user's feet should be placed
  42762. */
  42763. teleportCamera(location: Vector3): void;
  42764. private _convertNormalToDirectionOfRay;
  42765. private _castRayAndSelectObject;
  42766. private _notifySelectedMeshUnselected;
  42767. /**
  42768. * Sets the color of the laser ray from the vr controllers.
  42769. * @param color new color for the ray.
  42770. */
  42771. changeLaserColor(color: Color3): void;
  42772. /**
  42773. * Sets the color of the ray from the vr headsets gaze.
  42774. * @param color new color for the ray.
  42775. */
  42776. changeGazeColor(color: Color3): void;
  42777. /**
  42778. * Exits VR and disposes of the vr experience helper
  42779. */
  42780. dispose(): void;
  42781. /**
  42782. * Gets the name of the VRExperienceHelper class
  42783. * @returns "VRExperienceHelper"
  42784. */
  42785. getClassName(): string;
  42786. }
  42787. }
  42788. declare module "babylonjs/Cameras/VR/index" {
  42789. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42790. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42791. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42792. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42793. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42794. export * from "babylonjs/Cameras/VR/webVRCamera";
  42795. }
  42796. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42797. import { Observable } from "babylonjs/Misc/observable";
  42798. import { Nullable } from "babylonjs/types";
  42799. import { IDisposable, Scene } from "babylonjs/scene";
  42800. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42801. /**
  42802. * Manages an XRSession to work with Babylon's engine
  42803. * @see https://doc.babylonjs.com/how_to/webxr
  42804. */
  42805. export class WebXRSessionManager implements IDisposable {
  42806. private scene;
  42807. /**
  42808. * Fires every time a new xrFrame arrives which can be used to update the camera
  42809. */
  42810. onXRFrameObservable: Observable<any>;
  42811. /**
  42812. * Fires when the xr session is ended either by the device or manually done
  42813. */
  42814. onXRSessionEnded: Observable<any>;
  42815. /**
  42816. * Underlying xr session
  42817. */
  42818. session: XRSession;
  42819. /**
  42820. * Type of reference space used when creating the session
  42821. */
  42822. referenceSpace: XRReferenceSpace;
  42823. /** @hidden */
  42824. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42825. /**
  42826. * Current XR frame
  42827. */
  42828. currentFrame: Nullable<XRFrame>;
  42829. private _xrNavigator;
  42830. private baseLayer;
  42831. /**
  42832. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42833. * @param scene The scene which the session should be created for
  42834. */
  42835. constructor(scene: Scene);
  42836. /**
  42837. * Initializes the manager
  42838. * After initialization enterXR can be called to start an XR session
  42839. * @returns Promise which resolves after it is initialized
  42840. */
  42841. initializeAsync(): Promise<void>;
  42842. /**
  42843. * Initializes an xr session
  42844. * @param xrSessionMode mode to initialize
  42845. * @returns a promise which will resolve once the session has been initialized
  42846. */
  42847. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42848. /**
  42849. * Sets the reference space on the xr session
  42850. * @param referenceSpace space to set
  42851. * @returns a promise that will resolve once the reference space has been set
  42852. */
  42853. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42854. /**
  42855. * Updates the render state of the session
  42856. * @param state state to set
  42857. * @returns a promise that resolves once the render state has been updated
  42858. */
  42859. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42860. /**
  42861. * Starts rendering to the xr layer
  42862. * @returns a promise that will resolve once rendering has started
  42863. */
  42864. startRenderingToXRAsync(): Promise<void>;
  42865. /**
  42866. * Stops the xrSession and restores the renderloop
  42867. * @returns Promise which resolves after it exits XR
  42868. */
  42869. exitXRAsync(): Promise<unknown>;
  42870. /**
  42871. * Checks if a session would be supported for the creation options specified
  42872. * @param sessionMode session mode to check if supported eg. immersive-vr
  42873. * @returns true if supported
  42874. */
  42875. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42876. /**
  42877. * @hidden
  42878. * Converts the render layer of xrSession to a render target
  42879. * @param session session to create render target for
  42880. * @param scene scene the new render target should be created for
  42881. */
  42882. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42883. /**
  42884. * Disposes of the session manager
  42885. */
  42886. dispose(): void;
  42887. }
  42888. }
  42889. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42890. import { Scene } from "babylonjs/scene";
  42891. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42892. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42893. /**
  42894. * WebXR Camera which holds the views for the xrSession
  42895. * @see https://doc.babylonjs.com/how_to/webxr
  42896. */
  42897. export class WebXRCamera extends FreeCamera {
  42898. private static _TmpMatrix;
  42899. /**
  42900. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42901. * @param name the name of the camera
  42902. * @param scene the scene to add the camera to
  42903. */
  42904. constructor(name: string, scene: Scene);
  42905. private _updateNumberOfRigCameras;
  42906. /** @hidden */
  42907. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42908. /**
  42909. * Updates the cameras position from the current pose information of the XR session
  42910. * @param xrSessionManager the session containing pose information
  42911. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42912. */
  42913. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42914. }
  42915. }
  42916. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42917. import { Nullable } from "babylonjs/types";
  42918. import { IDisposable } from "babylonjs/scene";
  42919. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42920. /**
  42921. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42922. */
  42923. export class WebXRManagedOutputCanvas implements IDisposable {
  42924. private helper;
  42925. private _canvas;
  42926. /**
  42927. * xrpresent context of the canvas which can be used to display/mirror xr content
  42928. */
  42929. canvasContext: WebGLRenderingContext;
  42930. /**
  42931. * xr layer for the canvas
  42932. */
  42933. xrLayer: Nullable<XRWebGLLayer>;
  42934. /**
  42935. * Initializes the xr layer for the session
  42936. * @param xrSession xr session
  42937. * @returns a promise that will resolve once the XR Layer has been created
  42938. */
  42939. initializeXRLayerAsync(xrSession: any): any;
  42940. /**
  42941. * Initializes the canvas to be added/removed upon entering/exiting xr
  42942. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42943. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42944. */
  42945. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42946. /**
  42947. * Disposes of the object
  42948. */
  42949. dispose(): void;
  42950. private _setManagedOutputCanvas;
  42951. private _addCanvas;
  42952. private _removeCanvas;
  42953. }
  42954. }
  42955. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42956. import { Observable } from "babylonjs/Misc/observable";
  42957. import { IDisposable, Scene } from "babylonjs/scene";
  42958. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42960. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42961. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42962. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42963. /**
  42964. * States of the webXR experience
  42965. */
  42966. export enum WebXRState {
  42967. /**
  42968. * Transitioning to being in XR mode
  42969. */
  42970. ENTERING_XR = 0,
  42971. /**
  42972. * Transitioning to non XR mode
  42973. */
  42974. EXITING_XR = 1,
  42975. /**
  42976. * In XR mode and presenting
  42977. */
  42978. IN_XR = 2,
  42979. /**
  42980. * Not entered XR mode
  42981. */
  42982. NOT_IN_XR = 3
  42983. }
  42984. /**
  42985. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42986. * @see https://doc.babylonjs.com/how_to/webxr
  42987. */
  42988. export class WebXRExperienceHelper implements IDisposable {
  42989. private scene;
  42990. /**
  42991. * 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
  42992. */
  42993. container: AbstractMesh;
  42994. /**
  42995. * Camera used to render xr content
  42996. */
  42997. camera: WebXRCamera;
  42998. /**
  42999. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43000. */
  43001. state: WebXRState;
  43002. private _setState;
  43003. private static _TmpVector;
  43004. /**
  43005. * Fires when the state of the experience helper has changed
  43006. */
  43007. onStateChangedObservable: Observable<WebXRState>;
  43008. /** Session manager used to keep track of xr session */
  43009. sessionManager: WebXRSessionManager;
  43010. private _nonVRCamera;
  43011. private _originalSceneAutoClear;
  43012. private _supported;
  43013. /**
  43014. * Creates the experience helper
  43015. * @param scene the scene to attach the experience helper to
  43016. * @returns a promise for the experience helper
  43017. */
  43018. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43019. /**
  43020. * Creates a WebXRExperienceHelper
  43021. * @param scene The scene the helper should be created in
  43022. */
  43023. private constructor();
  43024. /**
  43025. * Exits XR mode and returns the scene to its original state
  43026. * @returns promise that resolves after xr mode has exited
  43027. */
  43028. exitXRAsync(): Promise<unknown>;
  43029. /**
  43030. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43031. * @param sessionCreationOptions options for the XR session
  43032. * @param referenceSpaceType frame of reference of the XR session
  43033. * @param outputCanvas the output canvas that will be used to enter XR mode
  43034. * @returns promise that resolves after xr mode has entered
  43035. */
  43036. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  43037. /**
  43038. * Updates the global position of the camera by moving the camera's container
  43039. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43040. * @param position The desired global position of the camera
  43041. */
  43042. setPositionOfCameraUsingContainer(position: Vector3): void;
  43043. /**
  43044. * Rotates the xr camera by rotating the camera's container around the camera's position
  43045. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43046. * @param rotation the desired quaternion rotation to apply to the camera
  43047. */
  43048. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43049. /**
  43050. * Disposes of the experience helper
  43051. */
  43052. dispose(): void;
  43053. }
  43054. }
  43055. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43056. import { Nullable } from "babylonjs/types";
  43057. import { Observable } from "babylonjs/Misc/observable";
  43058. import { IDisposable, Scene } from "babylonjs/scene";
  43059. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43060. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43061. /**
  43062. * Button which can be used to enter a different mode of XR
  43063. */
  43064. export class WebXREnterExitUIButton {
  43065. /** button element */
  43066. element: HTMLElement;
  43067. /** XR initialization options for the button */
  43068. sessionMode: XRSessionMode;
  43069. /** Reference space type */
  43070. referenceSpaceType: XRReferenceSpaceType;
  43071. /**
  43072. * Creates a WebXREnterExitUIButton
  43073. * @param element button element
  43074. * @param sessionMode XR initialization session mode
  43075. * @param referenceSpaceType the type of reference space to be used
  43076. */
  43077. constructor(
  43078. /** button element */
  43079. element: HTMLElement,
  43080. /** XR initialization options for the button */
  43081. sessionMode: XRSessionMode,
  43082. /** Reference space type */
  43083. referenceSpaceType: XRReferenceSpaceType);
  43084. /**
  43085. * Overwritable function which can be used to update the button's visuals when the state changes
  43086. * @param activeButton the current active button in the UI
  43087. */
  43088. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43089. }
  43090. /**
  43091. * Options to create the webXR UI
  43092. */
  43093. export class WebXREnterExitUIOptions {
  43094. /**
  43095. * Context to enter xr with
  43096. */
  43097. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  43098. /**
  43099. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43100. */
  43101. customButtons?: Array<WebXREnterExitUIButton>;
  43102. }
  43103. /**
  43104. * UI to allow the user to enter/exit XR mode
  43105. */
  43106. export class WebXREnterExitUI implements IDisposable {
  43107. private scene;
  43108. private _overlay;
  43109. private _buttons;
  43110. private _activeButton;
  43111. /**
  43112. * Fired every time the active button is changed.
  43113. *
  43114. * When xr is entered via a button that launches xr that button will be the callback parameter
  43115. *
  43116. * When exiting xr the callback parameter will be null)
  43117. */
  43118. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43119. /**
  43120. * Creates UI to allow the user to enter/exit XR mode
  43121. * @param scene the scene to add the ui to
  43122. * @param helper the xr experience helper to enter/exit xr with
  43123. * @param options options to configure the UI
  43124. * @returns the created ui
  43125. */
  43126. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43127. private constructor();
  43128. private _updateButtons;
  43129. /**
  43130. * Disposes of the object
  43131. */
  43132. dispose(): void;
  43133. }
  43134. }
  43135. declare module "babylonjs/Cameras/XR/webXRController" {
  43136. import { Nullable } from "babylonjs/types";
  43137. import { Observable } from "babylonjs/Misc/observable";
  43138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43139. import { Ray } from "babylonjs/Culling/ray";
  43140. import { Scene } from "babylonjs/scene";
  43141. /**
  43142. * Represents an XR input
  43143. */
  43144. export class WebXRController {
  43145. private scene;
  43146. /** The underlying input source for the controller */
  43147. inputSource: XRInputSource;
  43148. private parentContainer;
  43149. /**
  43150. * 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
  43151. */
  43152. grip?: AbstractMesh;
  43153. /**
  43154. * Pointer which can be used to select objects or attach a visible laser to
  43155. */
  43156. pointer: AbstractMesh;
  43157. /**
  43158. * Event that fires when the controller is removed/disposed
  43159. */
  43160. onDisposeObservable: Observable<{}>;
  43161. private _tmpMatrix;
  43162. private _tmpQuaternion;
  43163. private _tmpVector;
  43164. /**
  43165. * Creates the controller
  43166. * @see https://doc.babylonjs.com/how_to/webxr
  43167. * @param scene the scene which the controller should be associated to
  43168. * @param inputSource the underlying input source for the controller
  43169. * @param parentContainer parent that the controller meshes should be children of
  43170. */
  43171. constructor(scene: Scene,
  43172. /** The underlying input source for the controller */
  43173. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43174. /**
  43175. * Updates the controller pose based on the given XRFrame
  43176. * @param xrFrame xr frame to update the pose with
  43177. * @param referenceSpace reference space to use
  43178. */
  43179. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43180. /**
  43181. * Gets a world space ray coming from the controller
  43182. * @param result the resulting ray
  43183. */
  43184. getWorldPointerRayToRef(result: Ray): void;
  43185. /**
  43186. * Disposes of the object
  43187. */
  43188. dispose(): void;
  43189. }
  43190. }
  43191. declare module "babylonjs/Cameras/XR/webXRInput" {
  43192. import { Observable } from "babylonjs/Misc/observable";
  43193. import { IDisposable } from "babylonjs/scene";
  43194. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43195. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43196. /**
  43197. * XR input used to track XR inputs such as controllers/rays
  43198. */
  43199. export class WebXRInput implements IDisposable {
  43200. /**
  43201. * Base experience the input listens to
  43202. */
  43203. baseExperience: WebXRExperienceHelper;
  43204. /**
  43205. * XR controllers being tracked
  43206. */
  43207. controllers: Array<WebXRController>;
  43208. private _frameObserver;
  43209. private _stateObserver;
  43210. /**
  43211. * Event when a controller has been connected/added
  43212. */
  43213. onControllerAddedObservable: Observable<WebXRController>;
  43214. /**
  43215. * Event when a controller has been removed/disconnected
  43216. */
  43217. onControllerRemovedObservable: Observable<WebXRController>;
  43218. /**
  43219. * Initializes the WebXRInput
  43220. * @param baseExperience experience helper which the input should be created for
  43221. */
  43222. constructor(
  43223. /**
  43224. * Base experience the input listens to
  43225. */
  43226. baseExperience: WebXRExperienceHelper);
  43227. private _onInputSourcesChange;
  43228. private _addAndRemoveControllers;
  43229. /**
  43230. * Disposes of the object
  43231. */
  43232. dispose(): void;
  43233. }
  43234. }
  43235. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43237. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43238. /**
  43239. * Enables teleportation
  43240. */
  43241. export class WebXRControllerTeleportation {
  43242. private _teleportationFillColor;
  43243. private _teleportationBorderColor;
  43244. private _tmpRay;
  43245. private _tmpVector;
  43246. /**
  43247. * Creates a WebXRControllerTeleportation
  43248. * @param input input manager to add teleportation to
  43249. * @param floorMeshes floormeshes which can be teleported to
  43250. */
  43251. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43252. }
  43253. }
  43254. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43255. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43256. /**
  43257. * Handles pointer input automatically for the pointer of XR controllers
  43258. */
  43259. export class WebXRControllerPointerSelection {
  43260. private static _idCounter;
  43261. private _tmpRay;
  43262. /**
  43263. * Creates a WebXRControllerPointerSelection
  43264. * @param input input manager to setup pointer selection
  43265. */
  43266. constructor(input: WebXRInput);
  43267. private _convertNormalToDirectionOfRay;
  43268. private _updatePointerDistance;
  43269. }
  43270. }
  43271. declare module "babylonjs/Loading/sceneLoader" {
  43272. import { Observable } from "babylonjs/Misc/observable";
  43273. import { Nullable } from "babylonjs/types";
  43274. import { Scene } from "babylonjs/scene";
  43275. import { Engine } from "babylonjs/Engines/engine";
  43276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43277. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43278. import { AssetContainer } from "babylonjs/assetContainer";
  43279. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43280. import { Skeleton } from "babylonjs/Bones/skeleton";
  43281. /**
  43282. * Class used to represent data loading progression
  43283. */
  43284. export class SceneLoaderProgressEvent {
  43285. /** defines if data length to load can be evaluated */
  43286. readonly lengthComputable: boolean;
  43287. /** defines the loaded data length */
  43288. readonly loaded: number;
  43289. /** defines the data length to load */
  43290. readonly total: number;
  43291. /**
  43292. * Create a new progress event
  43293. * @param lengthComputable defines if data length to load can be evaluated
  43294. * @param loaded defines the loaded data length
  43295. * @param total defines the data length to load
  43296. */
  43297. constructor(
  43298. /** defines if data length to load can be evaluated */
  43299. lengthComputable: boolean,
  43300. /** defines the loaded data length */
  43301. loaded: number,
  43302. /** defines the data length to load */
  43303. total: number);
  43304. /**
  43305. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43306. * @param event defines the source event
  43307. * @returns a new SceneLoaderProgressEvent
  43308. */
  43309. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43310. }
  43311. /**
  43312. * Interface used by SceneLoader plugins to define supported file extensions
  43313. */
  43314. export interface ISceneLoaderPluginExtensions {
  43315. /**
  43316. * Defines the list of supported extensions
  43317. */
  43318. [extension: string]: {
  43319. isBinary: boolean;
  43320. };
  43321. }
  43322. /**
  43323. * Interface used by SceneLoader plugin factory
  43324. */
  43325. export interface ISceneLoaderPluginFactory {
  43326. /**
  43327. * Defines the name of the factory
  43328. */
  43329. name: string;
  43330. /**
  43331. * Function called to create a new plugin
  43332. * @return the new plugin
  43333. */
  43334. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43335. /**
  43336. * Boolean indicating if the plugin can direct load specific data
  43337. */
  43338. canDirectLoad?: (data: string) => boolean;
  43339. }
  43340. /**
  43341. * Interface used to define a SceneLoader plugin
  43342. */
  43343. export interface ISceneLoaderPlugin {
  43344. /**
  43345. * The friendly name of this plugin.
  43346. */
  43347. name: string;
  43348. /**
  43349. * The file extensions supported by this plugin.
  43350. */
  43351. extensions: string | ISceneLoaderPluginExtensions;
  43352. /**
  43353. * Import meshes into a scene.
  43354. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43355. * @param scene The scene to import into
  43356. * @param data The data to import
  43357. * @param rootUrl The root url for scene and resources
  43358. * @param meshes The meshes array to import into
  43359. * @param particleSystems The particle systems array to import into
  43360. * @param skeletons The skeletons array to import into
  43361. * @param onError The callback when import fails
  43362. * @returns True if successful or false otherwise
  43363. */
  43364. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43365. /**
  43366. * Load into a scene.
  43367. * @param scene The scene to load into
  43368. * @param data The data to import
  43369. * @param rootUrl The root url for scene and resources
  43370. * @param onError The callback when import fails
  43371. * @returns true if successful or false otherwise
  43372. */
  43373. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43374. /**
  43375. * The callback that returns true if the data can be directly loaded.
  43376. */
  43377. canDirectLoad?: (data: string) => boolean;
  43378. /**
  43379. * The callback that allows custom handling of the root url based on the response url.
  43380. */
  43381. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43382. /**
  43383. * Load into an asset container.
  43384. * @param scene The scene to load into
  43385. * @param data The data to import
  43386. * @param rootUrl The root url for scene and resources
  43387. * @param onError The callback when import fails
  43388. * @returns The loaded asset container
  43389. */
  43390. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43391. }
  43392. /**
  43393. * Interface used to define an async SceneLoader plugin
  43394. */
  43395. export interface ISceneLoaderPluginAsync {
  43396. /**
  43397. * The friendly name of this plugin.
  43398. */
  43399. name: string;
  43400. /**
  43401. * The file extensions supported by this plugin.
  43402. */
  43403. extensions: string | ISceneLoaderPluginExtensions;
  43404. /**
  43405. * Import meshes into a scene.
  43406. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43407. * @param scene The scene to import into
  43408. * @param data The data to import
  43409. * @param rootUrl The root url for scene and resources
  43410. * @param onProgress The callback when the load progresses
  43411. * @param fileName Defines the name of the file to load
  43412. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43413. */
  43414. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43415. meshes: AbstractMesh[];
  43416. particleSystems: IParticleSystem[];
  43417. skeletons: Skeleton[];
  43418. animationGroups: AnimationGroup[];
  43419. }>;
  43420. /**
  43421. * Load into a scene.
  43422. * @param scene The scene to load into
  43423. * @param data The data to import
  43424. * @param rootUrl The root url for scene and resources
  43425. * @param onProgress The callback when the load progresses
  43426. * @param fileName Defines the name of the file to load
  43427. * @returns Nothing
  43428. */
  43429. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43430. /**
  43431. * The callback that returns true if the data can be directly loaded.
  43432. */
  43433. canDirectLoad?: (data: string) => boolean;
  43434. /**
  43435. * The callback that allows custom handling of the root url based on the response url.
  43436. */
  43437. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43438. /**
  43439. * Load into an asset container.
  43440. * @param scene The scene to load into
  43441. * @param data The data to import
  43442. * @param rootUrl The root url for scene and resources
  43443. * @param onProgress The callback when the load progresses
  43444. * @param fileName Defines the name of the file to load
  43445. * @returns The loaded asset container
  43446. */
  43447. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43448. }
  43449. /**
  43450. * Class used to load scene from various file formats using registered plugins
  43451. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43452. */
  43453. export class SceneLoader {
  43454. /**
  43455. * No logging while loading
  43456. */
  43457. static readonly NO_LOGGING: number;
  43458. /**
  43459. * Minimal logging while loading
  43460. */
  43461. static readonly MINIMAL_LOGGING: number;
  43462. /**
  43463. * Summary logging while loading
  43464. */
  43465. static readonly SUMMARY_LOGGING: number;
  43466. /**
  43467. * Detailled logging while loading
  43468. */
  43469. static readonly DETAILED_LOGGING: number;
  43470. /**
  43471. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43472. */
  43473. static ForceFullSceneLoadingForIncremental: boolean;
  43474. /**
  43475. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43476. */
  43477. static ShowLoadingScreen: boolean;
  43478. /**
  43479. * Defines the current logging level (while loading the scene)
  43480. * @ignorenaming
  43481. */
  43482. static loggingLevel: number;
  43483. /**
  43484. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43485. */
  43486. static CleanBoneMatrixWeights: boolean;
  43487. /**
  43488. * Event raised when a plugin is used to load a scene
  43489. */
  43490. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43491. private static _registeredPlugins;
  43492. private static _getDefaultPlugin;
  43493. private static _getPluginForExtension;
  43494. private static _getPluginForDirectLoad;
  43495. private static _getPluginForFilename;
  43496. private static _getDirectLoad;
  43497. private static _loadData;
  43498. private static _getFileInfo;
  43499. /**
  43500. * Gets a plugin that can load the given extension
  43501. * @param extension defines the extension to load
  43502. * @returns a plugin or null if none works
  43503. */
  43504. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43505. /**
  43506. * Gets a boolean indicating that the given extension can be loaded
  43507. * @param extension defines the extension to load
  43508. * @returns true if the extension is supported
  43509. */
  43510. static IsPluginForExtensionAvailable(extension: string): boolean;
  43511. /**
  43512. * Adds a new plugin to the list of registered plugins
  43513. * @param plugin defines the plugin to add
  43514. */
  43515. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43516. /**
  43517. * Import meshes into a scene
  43518. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43519. * @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)
  43520. * @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)
  43521. * @param scene the instance of BABYLON.Scene to append to
  43522. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43523. * @param onProgress a callback with a progress event for each file being loaded
  43524. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43525. * @param pluginExtension the extension used to determine the plugin
  43526. * @returns The loaded plugin
  43527. */
  43528. 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>;
  43529. /**
  43530. * Import meshes into a scene
  43531. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43532. * @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)
  43533. * @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)
  43534. * @param scene the instance of BABYLON.Scene to append to
  43535. * @param onProgress a callback with a progress event for each file being loaded
  43536. * @param pluginExtension the extension used to determine the plugin
  43537. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43538. */
  43539. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43540. meshes: AbstractMesh[];
  43541. particleSystems: IParticleSystem[];
  43542. skeletons: Skeleton[];
  43543. animationGroups: AnimationGroup[];
  43544. }>;
  43545. /**
  43546. * Load a scene
  43547. * @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)
  43548. * @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)
  43549. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43550. * @param onSuccess a callback with the scene when import succeeds
  43551. * @param onProgress a callback with a progress event for each file being loaded
  43552. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43553. * @param pluginExtension the extension used to determine the plugin
  43554. * @returns The loaded plugin
  43555. */
  43556. 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>;
  43557. /**
  43558. * Load a scene
  43559. * @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)
  43560. * @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)
  43561. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43562. * @param onProgress a callback with a progress event for each file being loaded
  43563. * @param pluginExtension the extension used to determine the plugin
  43564. * @returns The loaded scene
  43565. */
  43566. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43567. /**
  43568. * Append a scene
  43569. * @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)
  43570. * @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)
  43571. * @param scene is the instance of BABYLON.Scene to append to
  43572. * @param onSuccess a callback with the scene when import succeeds
  43573. * @param onProgress a callback with a progress event for each file being loaded
  43574. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43575. * @param pluginExtension the extension used to determine the plugin
  43576. * @returns The loaded plugin
  43577. */
  43578. 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>;
  43579. /**
  43580. * Append a scene
  43581. * @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)
  43582. * @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)
  43583. * @param scene is the instance of BABYLON.Scene to append to
  43584. * @param onProgress a callback with a progress event for each file being loaded
  43585. * @param pluginExtension the extension used to determine the plugin
  43586. * @returns The given scene
  43587. */
  43588. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43589. /**
  43590. * Load a scene into an asset container
  43591. * @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)
  43592. * @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)
  43593. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43594. * @param onSuccess a callback with the scene when import succeeds
  43595. * @param onProgress a callback with a progress event for each file being loaded
  43596. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43597. * @param pluginExtension the extension used to determine the plugin
  43598. * @returns The loaded plugin
  43599. */
  43600. 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>;
  43601. /**
  43602. * Load a scene into an asset container
  43603. * @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)
  43604. * @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)
  43605. * @param scene is the instance of Scene to append to
  43606. * @param onProgress a callback with a progress event for each file being loaded
  43607. * @param pluginExtension the extension used to determine the plugin
  43608. * @returns The loaded asset container
  43609. */
  43610. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43611. }
  43612. }
  43613. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43614. import { Scene } from "babylonjs/scene";
  43615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43616. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43617. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43618. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43619. /**
  43620. * Generic Controller
  43621. */
  43622. export class GenericController extends WebVRController {
  43623. /**
  43624. * Base Url for the controller model.
  43625. */
  43626. static readonly MODEL_BASE_URL: string;
  43627. /**
  43628. * File name for the controller model.
  43629. */
  43630. static readonly MODEL_FILENAME: string;
  43631. /**
  43632. * Creates a new GenericController from a gamepad
  43633. * @param vrGamepad the gamepad that the controller should be created from
  43634. */
  43635. constructor(vrGamepad: any);
  43636. /**
  43637. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43638. * @param scene scene in which to add meshes
  43639. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43640. */
  43641. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43642. /**
  43643. * Called once for each button that changed state since the last frame
  43644. * @param buttonIdx Which button index changed
  43645. * @param state New state of the button
  43646. * @param changes Which properties on the state changed since last frame
  43647. */
  43648. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43649. }
  43650. }
  43651. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43652. import { Observable } from "babylonjs/Misc/observable";
  43653. import { Scene } from "babylonjs/scene";
  43654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43655. import { Ray } from "babylonjs/Culling/ray";
  43656. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43657. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43658. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43659. /**
  43660. * Defines the WindowsMotionController object that the state of the windows motion controller
  43661. */
  43662. export class WindowsMotionController extends WebVRController {
  43663. /**
  43664. * The base url used to load the left and right controller models
  43665. */
  43666. static MODEL_BASE_URL: string;
  43667. /**
  43668. * The name of the left controller model file
  43669. */
  43670. static MODEL_LEFT_FILENAME: string;
  43671. /**
  43672. * The name of the right controller model file
  43673. */
  43674. static MODEL_RIGHT_FILENAME: string;
  43675. /**
  43676. * The controller name prefix for this controller type
  43677. */
  43678. static readonly GAMEPAD_ID_PREFIX: string;
  43679. /**
  43680. * The controller id pattern for this controller type
  43681. */
  43682. private static readonly GAMEPAD_ID_PATTERN;
  43683. private _loadedMeshInfo;
  43684. private readonly _mapping;
  43685. /**
  43686. * Fired when the trackpad on this controller is clicked
  43687. */
  43688. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43689. /**
  43690. * Fired when the trackpad on this controller is modified
  43691. */
  43692. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43693. /**
  43694. * The current x and y values of this controller's trackpad
  43695. */
  43696. trackpad: StickValues;
  43697. /**
  43698. * Creates a new WindowsMotionController from a gamepad
  43699. * @param vrGamepad the gamepad that the controller should be created from
  43700. */
  43701. constructor(vrGamepad: any);
  43702. /**
  43703. * Fired when the trigger on this controller is modified
  43704. */
  43705. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43706. /**
  43707. * Fired when the menu button on this controller is modified
  43708. */
  43709. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43710. /**
  43711. * Fired when the grip button on this controller is modified
  43712. */
  43713. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43714. /**
  43715. * Fired when the thumbstick button on this controller is modified
  43716. */
  43717. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43718. /**
  43719. * Fired when the touchpad button on this controller is modified
  43720. */
  43721. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43722. /**
  43723. * Fired when the touchpad values on this controller are modified
  43724. */
  43725. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43726. private _updateTrackpad;
  43727. /**
  43728. * Called once per frame by the engine.
  43729. */
  43730. update(): void;
  43731. /**
  43732. * Called once for each button that changed state since the last frame
  43733. * @param buttonIdx Which button index changed
  43734. * @param state New state of the button
  43735. * @param changes Which properties on the state changed since last frame
  43736. */
  43737. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43738. /**
  43739. * Moves the buttons on the controller mesh based on their current state
  43740. * @param buttonName the name of the button to move
  43741. * @param buttonValue the value of the button which determines the buttons new position
  43742. */
  43743. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43744. /**
  43745. * Moves the axis on the controller mesh based on its current state
  43746. * @param axis the index of the axis
  43747. * @param axisValue the value of the axis which determines the meshes new position
  43748. * @hidden
  43749. */
  43750. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43751. /**
  43752. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43753. * @param scene scene in which to add meshes
  43754. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43755. */
  43756. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43757. /**
  43758. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43759. * can be transformed by button presses and axes values, based on this._mapping.
  43760. *
  43761. * @param scene scene in which the meshes exist
  43762. * @param meshes list of meshes that make up the controller model to process
  43763. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43764. */
  43765. private processModel;
  43766. private createMeshInfo;
  43767. /**
  43768. * Gets the ray of the controller in the direction the controller is pointing
  43769. * @param length the length the resulting ray should be
  43770. * @returns a ray in the direction the controller is pointing
  43771. */
  43772. getForwardRay(length?: number): Ray;
  43773. /**
  43774. * Disposes of the controller
  43775. */
  43776. dispose(): void;
  43777. }
  43778. }
  43779. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43780. import { Observable } from "babylonjs/Misc/observable";
  43781. import { Scene } from "babylonjs/scene";
  43782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43783. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43784. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43785. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43786. /**
  43787. * Oculus Touch Controller
  43788. */
  43789. export class OculusTouchController extends WebVRController {
  43790. /**
  43791. * Base Url for the controller model.
  43792. */
  43793. static MODEL_BASE_URL: string;
  43794. /**
  43795. * File name for the left controller model.
  43796. */
  43797. static MODEL_LEFT_FILENAME: string;
  43798. /**
  43799. * File name for the right controller model.
  43800. */
  43801. static MODEL_RIGHT_FILENAME: string;
  43802. /**
  43803. * Base Url for the Quest controller model.
  43804. */
  43805. static QUEST_MODEL_BASE_URL: string;
  43806. /**
  43807. * @hidden
  43808. * If the controllers are running on a device that needs the updated Quest controller models
  43809. */
  43810. static _IsQuest: boolean;
  43811. /**
  43812. * Fired when the secondary trigger on this controller is modified
  43813. */
  43814. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43815. /**
  43816. * Fired when the thumb rest on this controller is modified
  43817. */
  43818. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43819. /**
  43820. * Creates a new OculusTouchController from a gamepad
  43821. * @param vrGamepad the gamepad that the controller should be created from
  43822. */
  43823. constructor(vrGamepad: any);
  43824. /**
  43825. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43826. * @param scene scene in which to add meshes
  43827. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43828. */
  43829. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43830. /**
  43831. * Fired when the A button on this controller is modified
  43832. */
  43833. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43834. /**
  43835. * Fired when the B button on this controller is modified
  43836. */
  43837. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43838. /**
  43839. * Fired when the X button on this controller is modified
  43840. */
  43841. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43842. /**
  43843. * Fired when the Y button on this controller is modified
  43844. */
  43845. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43846. /**
  43847. * Called once for each button that changed state since the last frame
  43848. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43849. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43850. * 2) secondary trigger (same)
  43851. * 3) A (right) X (left), touch, pressed = value
  43852. * 4) B / Y
  43853. * 5) thumb rest
  43854. * @param buttonIdx Which button index changed
  43855. * @param state New state of the button
  43856. * @param changes Which properties on the state changed since last frame
  43857. */
  43858. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43859. }
  43860. }
  43861. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43862. import { Scene } from "babylonjs/scene";
  43863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43864. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43865. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43866. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43867. import { Observable } from "babylonjs/Misc/observable";
  43868. /**
  43869. * Vive Controller
  43870. */
  43871. export class ViveController extends WebVRController {
  43872. /**
  43873. * Base Url for the controller model.
  43874. */
  43875. static MODEL_BASE_URL: string;
  43876. /**
  43877. * File name for the controller model.
  43878. */
  43879. static MODEL_FILENAME: string;
  43880. /**
  43881. * Creates a new ViveController from a gamepad
  43882. * @param vrGamepad the gamepad that the controller should be created from
  43883. */
  43884. constructor(vrGamepad: any);
  43885. /**
  43886. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43887. * @param scene scene in which to add meshes
  43888. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43889. */
  43890. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43891. /**
  43892. * Fired when the left button on this controller is modified
  43893. */
  43894. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43895. /**
  43896. * Fired when the right button on this controller is modified
  43897. */
  43898. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43899. /**
  43900. * Fired when the menu button on this controller is modified
  43901. */
  43902. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43903. /**
  43904. * Called once for each button that changed state since the last frame
  43905. * Vive mapping:
  43906. * 0: touchpad
  43907. * 1: trigger
  43908. * 2: left AND right buttons
  43909. * 3: menu button
  43910. * @param buttonIdx Which button index changed
  43911. * @param state New state of the button
  43912. * @param changes Which properties on the state changed since last frame
  43913. */
  43914. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43915. }
  43916. }
  43917. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43918. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43919. /**
  43920. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43921. */
  43922. export class WebXRControllerModelLoader {
  43923. /**
  43924. * Creates the WebXRControllerModelLoader
  43925. * @param input xr input that creates the controllers
  43926. */
  43927. constructor(input: WebXRInput);
  43928. }
  43929. }
  43930. declare module "babylonjs/Cameras/XR/index" {
  43931. export * from "babylonjs/Cameras/XR/webXRCamera";
  43932. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43933. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43934. export * from "babylonjs/Cameras/XR/webXRInput";
  43935. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43936. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43937. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43938. export * from "babylonjs/Cameras/XR/webXRController";
  43939. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43940. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43941. }
  43942. declare module "babylonjs/Cameras/RigModes/index" {
  43943. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43944. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43945. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43946. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43947. }
  43948. declare module "babylonjs/Cameras/index" {
  43949. export * from "babylonjs/Cameras/Inputs/index";
  43950. export * from "babylonjs/Cameras/cameraInputsManager";
  43951. export * from "babylonjs/Cameras/camera";
  43952. export * from "babylonjs/Cameras/targetCamera";
  43953. export * from "babylonjs/Cameras/freeCamera";
  43954. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43955. export * from "babylonjs/Cameras/touchCamera";
  43956. export * from "babylonjs/Cameras/arcRotateCamera";
  43957. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43958. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43959. export * from "babylonjs/Cameras/flyCamera";
  43960. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43961. export * from "babylonjs/Cameras/followCamera";
  43962. export * from "babylonjs/Cameras/followCameraInputsManager";
  43963. export * from "babylonjs/Cameras/gamepadCamera";
  43964. export * from "babylonjs/Cameras/Stereoscopic/index";
  43965. export * from "babylonjs/Cameras/universalCamera";
  43966. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43967. export * from "babylonjs/Cameras/VR/index";
  43968. export * from "babylonjs/Cameras/XR/index";
  43969. export * from "babylonjs/Cameras/RigModes/index";
  43970. }
  43971. declare module "babylonjs/Collisions/index" {
  43972. export * from "babylonjs/Collisions/collider";
  43973. export * from "babylonjs/Collisions/collisionCoordinator";
  43974. export * from "babylonjs/Collisions/pickingInfo";
  43975. export * from "babylonjs/Collisions/intersectionInfo";
  43976. export * from "babylonjs/Collisions/meshCollisionData";
  43977. }
  43978. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43979. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43980. import { Vector3 } from "babylonjs/Maths/math.vector";
  43981. import { Ray } from "babylonjs/Culling/ray";
  43982. import { Plane } from "babylonjs/Maths/math.plane";
  43983. /**
  43984. * Contains an array of blocks representing the octree
  43985. */
  43986. export interface IOctreeContainer<T> {
  43987. /**
  43988. * Blocks within the octree
  43989. */
  43990. blocks: Array<OctreeBlock<T>>;
  43991. }
  43992. /**
  43993. * Class used to store a cell in an octree
  43994. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43995. */
  43996. export class OctreeBlock<T> {
  43997. /**
  43998. * Gets the content of the current block
  43999. */
  44000. entries: T[];
  44001. /**
  44002. * Gets the list of block children
  44003. */
  44004. blocks: Array<OctreeBlock<T>>;
  44005. private _depth;
  44006. private _maxDepth;
  44007. private _capacity;
  44008. private _minPoint;
  44009. private _maxPoint;
  44010. private _boundingVectors;
  44011. private _creationFunc;
  44012. /**
  44013. * Creates a new block
  44014. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44015. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44016. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44017. * @param depth defines the current depth of this block in the octree
  44018. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44019. * @param creationFunc defines a callback to call when an element is added to the block
  44020. */
  44021. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44022. /**
  44023. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44024. */
  44025. readonly capacity: number;
  44026. /**
  44027. * Gets the minimum vector (in world space) of the block's bounding box
  44028. */
  44029. readonly minPoint: Vector3;
  44030. /**
  44031. * Gets the maximum vector (in world space) of the block's bounding box
  44032. */
  44033. readonly maxPoint: Vector3;
  44034. /**
  44035. * Add a new element to this block
  44036. * @param entry defines the element to add
  44037. */
  44038. addEntry(entry: T): void;
  44039. /**
  44040. * Remove an element from this block
  44041. * @param entry defines the element to remove
  44042. */
  44043. removeEntry(entry: T): void;
  44044. /**
  44045. * Add an array of elements to this block
  44046. * @param entries defines the array of elements to add
  44047. */
  44048. addEntries(entries: T[]): void;
  44049. /**
  44050. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44051. * @param frustumPlanes defines the frustum planes to test
  44052. * @param selection defines the array to store current content if selection is positive
  44053. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44054. */
  44055. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44056. /**
  44057. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44058. * @param sphereCenter defines the bounding sphere center
  44059. * @param sphereRadius defines the bounding sphere radius
  44060. * @param selection defines the array to store current content if selection is positive
  44061. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44062. */
  44063. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44064. /**
  44065. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44066. * @param ray defines the ray to test with
  44067. * @param selection defines the array to store current content if selection is positive
  44068. */
  44069. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44070. /**
  44071. * Subdivide the content into child blocks (this block will then be empty)
  44072. */
  44073. createInnerBlocks(): void;
  44074. /**
  44075. * @hidden
  44076. */
  44077. 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;
  44078. }
  44079. }
  44080. declare module "babylonjs/Culling/Octrees/octree" {
  44081. import { SmartArray } from "babylonjs/Misc/smartArray";
  44082. import { Vector3 } from "babylonjs/Maths/math.vector";
  44083. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44085. import { Ray } from "babylonjs/Culling/ray";
  44086. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44087. import { Plane } from "babylonjs/Maths/math.plane";
  44088. /**
  44089. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44090. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44091. */
  44092. export class Octree<T> {
  44093. /** 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.) */
  44094. maxDepth: number;
  44095. /**
  44096. * Blocks within the octree containing objects
  44097. */
  44098. blocks: Array<OctreeBlock<T>>;
  44099. /**
  44100. * Content stored in the octree
  44101. */
  44102. dynamicContent: T[];
  44103. private _maxBlockCapacity;
  44104. private _selectionContent;
  44105. private _creationFunc;
  44106. /**
  44107. * Creates a octree
  44108. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44109. * @param creationFunc function to be used to instatiate the octree
  44110. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44111. * @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.)
  44112. */
  44113. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44114. /** 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.) */
  44115. maxDepth?: number);
  44116. /**
  44117. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44118. * @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);
  44119. * @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);
  44120. * @param entries meshes to be added to the octree blocks
  44121. */
  44122. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44123. /**
  44124. * Adds a mesh to the octree
  44125. * @param entry Mesh to add to the octree
  44126. */
  44127. addMesh(entry: T): void;
  44128. /**
  44129. * Remove an element from the octree
  44130. * @param entry defines the element to remove
  44131. */
  44132. removeMesh(entry: T): void;
  44133. /**
  44134. * Selects an array of meshes within the frustum
  44135. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44136. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44137. * @returns array of meshes within the frustum
  44138. */
  44139. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44140. /**
  44141. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44142. * @param sphereCenter defines the bounding sphere center
  44143. * @param sphereRadius defines the bounding sphere radius
  44144. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44145. * @returns an array of objects that intersect the sphere
  44146. */
  44147. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44148. /**
  44149. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44150. * @param ray defines the ray to test with
  44151. * @returns array of intersected objects
  44152. */
  44153. intersectsRay(ray: Ray): SmartArray<T>;
  44154. /**
  44155. * Adds a mesh into the octree block if it intersects the block
  44156. */
  44157. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44158. /**
  44159. * Adds a submesh into the octree block if it intersects the block
  44160. */
  44161. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44162. }
  44163. }
  44164. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44165. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44166. import { Scene } from "babylonjs/scene";
  44167. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44169. import { Ray } from "babylonjs/Culling/ray";
  44170. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44171. import { Collider } from "babylonjs/Collisions/collider";
  44172. module "babylonjs/scene" {
  44173. interface Scene {
  44174. /**
  44175. * @hidden
  44176. * Backing Filed
  44177. */
  44178. _selectionOctree: Octree<AbstractMesh>;
  44179. /**
  44180. * Gets the octree used to boost mesh selection (picking)
  44181. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44182. */
  44183. selectionOctree: Octree<AbstractMesh>;
  44184. /**
  44185. * Creates or updates the octree used to boost selection (picking)
  44186. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44187. * @param maxCapacity defines the maximum capacity per leaf
  44188. * @param maxDepth defines the maximum depth of the octree
  44189. * @returns an octree of AbstractMesh
  44190. */
  44191. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44192. }
  44193. }
  44194. module "babylonjs/Meshes/abstractMesh" {
  44195. interface AbstractMesh {
  44196. /**
  44197. * @hidden
  44198. * Backing Field
  44199. */
  44200. _submeshesOctree: Octree<SubMesh>;
  44201. /**
  44202. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44203. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44204. * @param maxCapacity defines the maximum size of each block (64 by default)
  44205. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44206. * @returns the new octree
  44207. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44208. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44209. */
  44210. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44211. }
  44212. }
  44213. /**
  44214. * Defines the octree scene component responsible to manage any octrees
  44215. * in a given scene.
  44216. */
  44217. export class OctreeSceneComponent {
  44218. /**
  44219. * The component name help to identify the component in the list of scene components.
  44220. */
  44221. readonly name: string;
  44222. /**
  44223. * The scene the component belongs to.
  44224. */
  44225. scene: Scene;
  44226. /**
  44227. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44228. */
  44229. readonly checksIsEnabled: boolean;
  44230. /**
  44231. * Creates a new instance of the component for the given scene
  44232. * @param scene Defines the scene to register the component in
  44233. */
  44234. constructor(scene: Scene);
  44235. /**
  44236. * Registers the component in a given scene
  44237. */
  44238. register(): void;
  44239. /**
  44240. * Return the list of active meshes
  44241. * @returns the list of active meshes
  44242. */
  44243. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44244. /**
  44245. * Return the list of active sub meshes
  44246. * @param mesh The mesh to get the candidates sub meshes from
  44247. * @returns the list of active sub meshes
  44248. */
  44249. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44250. private _tempRay;
  44251. /**
  44252. * Return the list of sub meshes intersecting with a given local ray
  44253. * @param mesh defines the mesh to find the submesh for
  44254. * @param localRay defines the ray in local space
  44255. * @returns the list of intersecting sub meshes
  44256. */
  44257. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44258. /**
  44259. * Return the list of sub meshes colliding with a collider
  44260. * @param mesh defines the mesh to find the submesh for
  44261. * @param collider defines the collider to evaluate the collision against
  44262. * @returns the list of colliding sub meshes
  44263. */
  44264. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44265. /**
  44266. * Rebuilds the elements related to this component in case of
  44267. * context lost for instance.
  44268. */
  44269. rebuild(): void;
  44270. /**
  44271. * Disposes the component and the associated ressources.
  44272. */
  44273. dispose(): void;
  44274. }
  44275. }
  44276. declare module "babylonjs/Culling/Octrees/index" {
  44277. export * from "babylonjs/Culling/Octrees/octree";
  44278. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44279. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44280. }
  44281. declare module "babylonjs/Culling/index" {
  44282. export * from "babylonjs/Culling/boundingBox";
  44283. export * from "babylonjs/Culling/boundingInfo";
  44284. export * from "babylonjs/Culling/boundingSphere";
  44285. export * from "babylonjs/Culling/Octrees/index";
  44286. export * from "babylonjs/Culling/ray";
  44287. }
  44288. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44289. import { IDisposable, Scene } from "babylonjs/scene";
  44290. import { Nullable } from "babylonjs/types";
  44291. import { Observable } from "babylonjs/Misc/observable";
  44292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44293. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44294. import { Camera } from "babylonjs/Cameras/camera";
  44295. /**
  44296. * Renders a layer on top of an existing scene
  44297. */
  44298. export class UtilityLayerRenderer implements IDisposable {
  44299. /** the original scene that will be rendered on top of */
  44300. originalScene: Scene;
  44301. private _pointerCaptures;
  44302. private _lastPointerEvents;
  44303. private static _DefaultUtilityLayer;
  44304. private static _DefaultKeepDepthUtilityLayer;
  44305. private _sharedGizmoLight;
  44306. private _renderCamera;
  44307. /**
  44308. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44309. * @returns the camera that is used when rendering the utility layer
  44310. */
  44311. getRenderCamera(): Nullable<Camera>;
  44312. /**
  44313. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44314. * @param cam the camera that should be used when rendering the utility layer
  44315. */
  44316. setRenderCamera(cam: Nullable<Camera>): void;
  44317. /**
  44318. * @hidden
  44319. * Light which used by gizmos to get light shading
  44320. */
  44321. _getSharedGizmoLight(): HemisphericLight;
  44322. /**
  44323. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44324. */
  44325. pickUtilitySceneFirst: boolean;
  44326. /**
  44327. * 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)
  44328. */
  44329. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44330. /**
  44331. * 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)
  44332. */
  44333. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44334. /**
  44335. * The scene that is rendered on top of the original scene
  44336. */
  44337. utilityLayerScene: Scene;
  44338. /**
  44339. * If the utility layer should automatically be rendered on top of existing scene
  44340. */
  44341. shouldRender: boolean;
  44342. /**
  44343. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44344. */
  44345. onlyCheckPointerDownEvents: boolean;
  44346. /**
  44347. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44348. */
  44349. processAllEvents: boolean;
  44350. /**
  44351. * Observable raised when the pointer move from the utility layer scene to the main scene
  44352. */
  44353. onPointerOutObservable: Observable<number>;
  44354. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44355. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44356. private _afterRenderObserver;
  44357. private _sceneDisposeObserver;
  44358. private _originalPointerObserver;
  44359. /**
  44360. * Instantiates a UtilityLayerRenderer
  44361. * @param originalScene the original scene that will be rendered on top of
  44362. * @param handleEvents boolean indicating if the utility layer should handle events
  44363. */
  44364. constructor(
  44365. /** the original scene that will be rendered on top of */
  44366. originalScene: Scene, handleEvents?: boolean);
  44367. private _notifyObservers;
  44368. /**
  44369. * Renders the utility layers scene on top of the original scene
  44370. */
  44371. render(): void;
  44372. /**
  44373. * Disposes of the renderer
  44374. */
  44375. dispose(): void;
  44376. private _updateCamera;
  44377. }
  44378. }
  44379. declare module "babylonjs/Gizmos/gizmo" {
  44380. import { Nullable } from "babylonjs/types";
  44381. import { IDisposable } from "babylonjs/scene";
  44382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44383. import { Mesh } from "babylonjs/Meshes/mesh";
  44384. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44385. /**
  44386. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44387. */
  44388. export class Gizmo implements IDisposable {
  44389. /** The utility layer the gizmo will be added to */
  44390. gizmoLayer: UtilityLayerRenderer;
  44391. /**
  44392. * The root mesh of the gizmo
  44393. */
  44394. _rootMesh: Mesh;
  44395. private _attachedMesh;
  44396. /**
  44397. * Ratio for the scale of the gizmo (Default: 1)
  44398. */
  44399. scaleRatio: number;
  44400. /**
  44401. * If a custom mesh has been set (Default: false)
  44402. */
  44403. protected _customMeshSet: boolean;
  44404. /**
  44405. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44406. * * When set, interactions will be enabled
  44407. */
  44408. attachedMesh: Nullable<AbstractMesh>;
  44409. /**
  44410. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44411. * @param mesh The mesh to replace the default mesh of the gizmo
  44412. */
  44413. setCustomMesh(mesh: Mesh): void;
  44414. /**
  44415. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44416. */
  44417. updateGizmoRotationToMatchAttachedMesh: boolean;
  44418. /**
  44419. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44420. */
  44421. updateGizmoPositionToMatchAttachedMesh: boolean;
  44422. /**
  44423. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44424. */
  44425. updateScale: boolean;
  44426. protected _interactionsEnabled: boolean;
  44427. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44428. private _beforeRenderObserver;
  44429. private _tempVector;
  44430. /**
  44431. * Creates a gizmo
  44432. * @param gizmoLayer The utility layer the gizmo will be added to
  44433. */
  44434. constructor(
  44435. /** The utility layer the gizmo will be added to */
  44436. gizmoLayer?: UtilityLayerRenderer);
  44437. /**
  44438. * Updates the gizmo to match the attached mesh's position/rotation
  44439. */
  44440. protected _update(): void;
  44441. /**
  44442. * Disposes of the gizmo
  44443. */
  44444. dispose(): void;
  44445. }
  44446. }
  44447. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44448. import { Observable } from "babylonjs/Misc/observable";
  44449. import { Nullable } from "babylonjs/types";
  44450. import { Vector3 } from "babylonjs/Maths/math.vector";
  44451. import { Color3 } from "babylonjs/Maths/math.color";
  44452. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44454. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44455. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44456. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44457. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44458. import { Scene } from "babylonjs/scene";
  44459. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44460. /**
  44461. * Single plane drag gizmo
  44462. */
  44463. export class PlaneDragGizmo extends Gizmo {
  44464. /**
  44465. * Drag behavior responsible for the gizmos dragging interactions
  44466. */
  44467. dragBehavior: PointerDragBehavior;
  44468. private _pointerObserver;
  44469. /**
  44470. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44471. */
  44472. snapDistance: number;
  44473. /**
  44474. * Event that fires each time the gizmo snaps to a new location.
  44475. * * snapDistance is the the change in distance
  44476. */
  44477. onSnapObservable: Observable<{
  44478. snapDistance: number;
  44479. }>;
  44480. private _plane;
  44481. private _coloredMaterial;
  44482. private _hoverMaterial;
  44483. private _isEnabled;
  44484. private _parent;
  44485. /** @hidden */
  44486. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44487. /** @hidden */
  44488. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44489. /**
  44490. * Creates a PlaneDragGizmo
  44491. * @param gizmoLayer The utility layer the gizmo will be added to
  44492. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44493. * @param color The color of the gizmo
  44494. */
  44495. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44496. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44497. /**
  44498. * If the gizmo is enabled
  44499. */
  44500. isEnabled: boolean;
  44501. /**
  44502. * Disposes of the gizmo
  44503. */
  44504. dispose(): void;
  44505. }
  44506. }
  44507. declare module "babylonjs/Gizmos/positionGizmo" {
  44508. import { Observable } from "babylonjs/Misc/observable";
  44509. import { Nullable } from "babylonjs/types";
  44510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44511. import { Mesh } from "babylonjs/Meshes/mesh";
  44512. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44513. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44514. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44515. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44516. /**
  44517. * Gizmo that enables dragging a mesh along 3 axis
  44518. */
  44519. export class PositionGizmo extends Gizmo {
  44520. /**
  44521. * Internal gizmo used for interactions on the x axis
  44522. */
  44523. xGizmo: AxisDragGizmo;
  44524. /**
  44525. * Internal gizmo used for interactions on the y axis
  44526. */
  44527. yGizmo: AxisDragGizmo;
  44528. /**
  44529. * Internal gizmo used for interactions on the z axis
  44530. */
  44531. zGizmo: AxisDragGizmo;
  44532. /**
  44533. * Internal gizmo used for interactions on the yz plane
  44534. */
  44535. xPlaneGizmo: PlaneDragGizmo;
  44536. /**
  44537. * Internal gizmo used for interactions on the xz plane
  44538. */
  44539. yPlaneGizmo: PlaneDragGizmo;
  44540. /**
  44541. * Internal gizmo used for interactions on the xy plane
  44542. */
  44543. zPlaneGizmo: PlaneDragGizmo;
  44544. /**
  44545. * private variables
  44546. */
  44547. private _meshAttached;
  44548. private _updateGizmoRotationToMatchAttachedMesh;
  44549. private _snapDistance;
  44550. private _scaleRatio;
  44551. /** Fires an event when any of it's sub gizmos are dragged */
  44552. onDragStartObservable: Observable<unknown>;
  44553. /** Fires an event when any of it's sub gizmos are released from dragging */
  44554. onDragEndObservable: Observable<unknown>;
  44555. /**
  44556. * If set to true, planar drag is enabled
  44557. */
  44558. private _planarGizmoEnabled;
  44559. attachedMesh: Nullable<AbstractMesh>;
  44560. /**
  44561. * Creates a PositionGizmo
  44562. * @param gizmoLayer The utility layer the gizmo will be added to
  44563. */
  44564. constructor(gizmoLayer?: UtilityLayerRenderer);
  44565. /**
  44566. * If the planar drag gizmo is enabled
  44567. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44568. */
  44569. planarGizmoEnabled: boolean;
  44570. updateGizmoRotationToMatchAttachedMesh: boolean;
  44571. /**
  44572. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44573. */
  44574. snapDistance: number;
  44575. /**
  44576. * Ratio for the scale of the gizmo (Default: 1)
  44577. */
  44578. scaleRatio: number;
  44579. /**
  44580. * Disposes of the gizmo
  44581. */
  44582. dispose(): void;
  44583. /**
  44584. * CustomMeshes are not supported by this gizmo
  44585. * @param mesh The mesh to replace the default mesh of the gizmo
  44586. */
  44587. setCustomMesh(mesh: Mesh): void;
  44588. }
  44589. }
  44590. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44591. import { Observable } from "babylonjs/Misc/observable";
  44592. import { Nullable } from "babylonjs/types";
  44593. import { Vector3 } from "babylonjs/Maths/math.vector";
  44594. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44596. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44597. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44598. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44599. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44600. import { Scene } from "babylonjs/scene";
  44601. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44602. import { Color3 } from "babylonjs/Maths/math.color";
  44603. /**
  44604. * Single axis drag gizmo
  44605. */
  44606. export class AxisDragGizmo extends Gizmo {
  44607. /**
  44608. * Drag behavior responsible for the gizmos dragging interactions
  44609. */
  44610. dragBehavior: PointerDragBehavior;
  44611. private _pointerObserver;
  44612. /**
  44613. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44614. */
  44615. snapDistance: number;
  44616. /**
  44617. * Event that fires each time the gizmo snaps to a new location.
  44618. * * snapDistance is the the change in distance
  44619. */
  44620. onSnapObservable: Observable<{
  44621. snapDistance: number;
  44622. }>;
  44623. private _isEnabled;
  44624. private _parent;
  44625. private _arrow;
  44626. private _coloredMaterial;
  44627. private _hoverMaterial;
  44628. /** @hidden */
  44629. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44630. /** @hidden */
  44631. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44632. /**
  44633. * Creates an AxisDragGizmo
  44634. * @param gizmoLayer The utility layer the gizmo will be added to
  44635. * @param dragAxis The axis which the gizmo will be able to drag on
  44636. * @param color The color of the gizmo
  44637. */
  44638. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44639. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44640. /**
  44641. * If the gizmo is enabled
  44642. */
  44643. isEnabled: boolean;
  44644. /**
  44645. * Disposes of the gizmo
  44646. */
  44647. dispose(): void;
  44648. }
  44649. }
  44650. declare module "babylonjs/Debug/axesViewer" {
  44651. import { Vector3 } from "babylonjs/Maths/math.vector";
  44652. import { Nullable } from "babylonjs/types";
  44653. import { Scene } from "babylonjs/scene";
  44654. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44655. /**
  44656. * The Axes viewer will show 3 axes in a specific point in space
  44657. */
  44658. export class AxesViewer {
  44659. private _xAxis;
  44660. private _yAxis;
  44661. private _zAxis;
  44662. private _scaleLinesFactor;
  44663. private _instanced;
  44664. /**
  44665. * Gets the hosting scene
  44666. */
  44667. scene: Scene;
  44668. /**
  44669. * Gets or sets a number used to scale line length
  44670. */
  44671. scaleLines: number;
  44672. /** Gets the node hierarchy used to render x-axis */
  44673. readonly xAxis: TransformNode;
  44674. /** Gets the node hierarchy used to render y-axis */
  44675. readonly yAxis: TransformNode;
  44676. /** Gets the node hierarchy used to render z-axis */
  44677. readonly zAxis: TransformNode;
  44678. /**
  44679. * Creates a new AxesViewer
  44680. * @param scene defines the hosting scene
  44681. * @param scaleLines defines a number used to scale line length (1 by default)
  44682. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44683. * @param xAxis defines the node hierarchy used to render the x-axis
  44684. * @param yAxis defines the node hierarchy used to render the y-axis
  44685. * @param zAxis defines the node hierarchy used to render the z-axis
  44686. */
  44687. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44688. /**
  44689. * Force the viewer to update
  44690. * @param position defines the position of the viewer
  44691. * @param xaxis defines the x axis of the viewer
  44692. * @param yaxis defines the y axis of the viewer
  44693. * @param zaxis defines the z axis of the viewer
  44694. */
  44695. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44696. /**
  44697. * Creates an instance of this axes viewer.
  44698. * @returns a new axes viewer with instanced meshes
  44699. */
  44700. createInstance(): AxesViewer;
  44701. /** Releases resources */
  44702. dispose(): void;
  44703. private static _SetRenderingGroupId;
  44704. }
  44705. }
  44706. declare module "babylonjs/Debug/boneAxesViewer" {
  44707. import { Nullable } from "babylonjs/types";
  44708. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44709. import { Vector3 } from "babylonjs/Maths/math.vector";
  44710. import { Mesh } from "babylonjs/Meshes/mesh";
  44711. import { Bone } from "babylonjs/Bones/bone";
  44712. import { Scene } from "babylonjs/scene";
  44713. /**
  44714. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44715. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44716. */
  44717. export class BoneAxesViewer extends AxesViewer {
  44718. /**
  44719. * Gets or sets the target mesh where to display the axes viewer
  44720. */
  44721. mesh: Nullable<Mesh>;
  44722. /**
  44723. * Gets or sets the target bone where to display the axes viewer
  44724. */
  44725. bone: Nullable<Bone>;
  44726. /** Gets current position */
  44727. pos: Vector3;
  44728. /** Gets direction of X axis */
  44729. xaxis: Vector3;
  44730. /** Gets direction of Y axis */
  44731. yaxis: Vector3;
  44732. /** Gets direction of Z axis */
  44733. zaxis: Vector3;
  44734. /**
  44735. * Creates a new BoneAxesViewer
  44736. * @param scene defines the hosting scene
  44737. * @param bone defines the target bone
  44738. * @param mesh defines the target mesh
  44739. * @param scaleLines defines a scaling factor for line length (1 by default)
  44740. */
  44741. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44742. /**
  44743. * Force the viewer to update
  44744. */
  44745. update(): void;
  44746. /** Releases resources */
  44747. dispose(): void;
  44748. }
  44749. }
  44750. declare module "babylonjs/Debug/debugLayer" {
  44751. import { Scene } from "babylonjs/scene";
  44752. /**
  44753. * Interface used to define scene explorer extensibility option
  44754. */
  44755. export interface IExplorerExtensibilityOption {
  44756. /**
  44757. * Define the option label
  44758. */
  44759. label: string;
  44760. /**
  44761. * Defines the action to execute on click
  44762. */
  44763. action: (entity: any) => void;
  44764. }
  44765. /**
  44766. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44767. */
  44768. export interface IExplorerExtensibilityGroup {
  44769. /**
  44770. * Defines a predicate to test if a given type mut be extended
  44771. */
  44772. predicate: (entity: any) => boolean;
  44773. /**
  44774. * Gets the list of options added to a type
  44775. */
  44776. entries: IExplorerExtensibilityOption[];
  44777. }
  44778. /**
  44779. * Interface used to define the options to use to create the Inspector
  44780. */
  44781. export interface IInspectorOptions {
  44782. /**
  44783. * Display in overlay mode (default: false)
  44784. */
  44785. overlay?: boolean;
  44786. /**
  44787. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44788. */
  44789. globalRoot?: HTMLElement;
  44790. /**
  44791. * Display the Scene explorer
  44792. */
  44793. showExplorer?: boolean;
  44794. /**
  44795. * Display the property inspector
  44796. */
  44797. showInspector?: boolean;
  44798. /**
  44799. * Display in embed mode (both panes on the right)
  44800. */
  44801. embedMode?: boolean;
  44802. /**
  44803. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44804. */
  44805. handleResize?: boolean;
  44806. /**
  44807. * Allow the panes to popup (default: true)
  44808. */
  44809. enablePopup?: boolean;
  44810. /**
  44811. * Allow the panes to be closed by users (default: true)
  44812. */
  44813. enableClose?: boolean;
  44814. /**
  44815. * Optional list of extensibility entries
  44816. */
  44817. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44818. /**
  44819. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44820. */
  44821. inspectorURL?: string;
  44822. }
  44823. module "babylonjs/scene" {
  44824. interface Scene {
  44825. /**
  44826. * @hidden
  44827. * Backing field
  44828. */
  44829. _debugLayer: DebugLayer;
  44830. /**
  44831. * Gets the debug layer (aka Inspector) associated with the scene
  44832. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44833. */
  44834. debugLayer: DebugLayer;
  44835. }
  44836. }
  44837. /**
  44838. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44839. * what is happening in your scene
  44840. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44841. */
  44842. export class DebugLayer {
  44843. /**
  44844. * Define the url to get the inspector script from.
  44845. * By default it uses the babylonjs CDN.
  44846. * @ignoreNaming
  44847. */
  44848. static InspectorURL: string;
  44849. private _scene;
  44850. private BJSINSPECTOR;
  44851. private _onPropertyChangedObservable?;
  44852. /**
  44853. * Observable triggered when a property is changed through the inspector.
  44854. */
  44855. readonly onPropertyChangedObservable: any;
  44856. /**
  44857. * Instantiates a new debug layer.
  44858. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44859. * what is happening in your scene
  44860. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44861. * @param scene Defines the scene to inspect
  44862. */
  44863. constructor(scene: Scene);
  44864. /** Creates the inspector window. */
  44865. private _createInspector;
  44866. /**
  44867. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44868. * @param entity defines the entity to select
  44869. * @param lineContainerTitle defines the specific block to highlight
  44870. */
  44871. select(entity: any, lineContainerTitle?: string): void;
  44872. /** Get the inspector from bundle or global */
  44873. private _getGlobalInspector;
  44874. /**
  44875. * Get if the inspector is visible or not.
  44876. * @returns true if visible otherwise, false
  44877. */
  44878. isVisible(): boolean;
  44879. /**
  44880. * Hide the inspector and close its window.
  44881. */
  44882. hide(): void;
  44883. /**
  44884. * Launch the debugLayer.
  44885. * @param config Define the configuration of the inspector
  44886. * @return a promise fulfilled when the debug layer is visible
  44887. */
  44888. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44889. }
  44890. }
  44891. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44892. import { Nullable } from "babylonjs/types";
  44893. import { Scene } from "babylonjs/scene";
  44894. import { Vector4 } from "babylonjs/Maths/math.vector";
  44895. import { Color4 } from "babylonjs/Maths/math.color";
  44896. import { Mesh } from "babylonjs/Meshes/mesh";
  44897. /**
  44898. * Class containing static functions to help procedurally build meshes
  44899. */
  44900. export class BoxBuilder {
  44901. /**
  44902. * Creates a box mesh
  44903. * * The parameter `size` sets the size (float) of each box side (default 1)
  44904. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44905. * * 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)
  44906. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44908. * * 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
  44909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44910. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44911. * @param name defines the name of the mesh
  44912. * @param options defines the options used to create the mesh
  44913. * @param scene defines the hosting scene
  44914. * @returns the box mesh
  44915. */
  44916. static CreateBox(name: string, options: {
  44917. size?: number;
  44918. width?: number;
  44919. height?: number;
  44920. depth?: number;
  44921. faceUV?: Vector4[];
  44922. faceColors?: Color4[];
  44923. sideOrientation?: number;
  44924. frontUVs?: Vector4;
  44925. backUVs?: Vector4;
  44926. wrap?: boolean;
  44927. topBaseAt?: number;
  44928. bottomBaseAt?: number;
  44929. updatable?: boolean;
  44930. }, scene?: Nullable<Scene>): Mesh;
  44931. }
  44932. }
  44933. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44934. import { Vector4 } from "babylonjs/Maths/math.vector";
  44935. import { Mesh } from "babylonjs/Meshes/mesh";
  44936. import { Scene } from "babylonjs/scene";
  44937. import { Nullable } from "babylonjs/types";
  44938. /**
  44939. * Class containing static functions to help procedurally build meshes
  44940. */
  44941. export class SphereBuilder {
  44942. /**
  44943. * Creates a sphere mesh
  44944. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44945. * * 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`)
  44946. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44947. * * 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
  44948. * * 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)
  44949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44950. * * 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
  44951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44952. * @param name defines the name of the mesh
  44953. * @param options defines the options used to create the mesh
  44954. * @param scene defines the hosting scene
  44955. * @returns the sphere mesh
  44956. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44957. */
  44958. static CreateSphere(name: string, options: {
  44959. segments?: number;
  44960. diameter?: number;
  44961. diameterX?: number;
  44962. diameterY?: number;
  44963. diameterZ?: number;
  44964. arc?: number;
  44965. slice?: number;
  44966. sideOrientation?: number;
  44967. frontUVs?: Vector4;
  44968. backUVs?: Vector4;
  44969. updatable?: boolean;
  44970. }, scene?: Nullable<Scene>): Mesh;
  44971. }
  44972. }
  44973. declare module "babylonjs/Debug/physicsViewer" {
  44974. import { Nullable } from "babylonjs/types";
  44975. import { Scene } from "babylonjs/scene";
  44976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44977. import { Mesh } from "babylonjs/Meshes/mesh";
  44978. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44979. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44980. /**
  44981. * Used to show the physics impostor around the specific mesh
  44982. */
  44983. export class PhysicsViewer {
  44984. /** @hidden */
  44985. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44986. /** @hidden */
  44987. protected _meshes: Array<Nullable<AbstractMesh>>;
  44988. /** @hidden */
  44989. protected _scene: Nullable<Scene>;
  44990. /** @hidden */
  44991. protected _numMeshes: number;
  44992. /** @hidden */
  44993. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44994. private _renderFunction;
  44995. private _utilityLayer;
  44996. private _debugBoxMesh;
  44997. private _debugSphereMesh;
  44998. private _debugCylinderMesh;
  44999. private _debugMaterial;
  45000. private _debugMeshMeshes;
  45001. /**
  45002. * Creates a new PhysicsViewer
  45003. * @param scene defines the hosting scene
  45004. */
  45005. constructor(scene: Scene);
  45006. /** @hidden */
  45007. protected _updateDebugMeshes(): void;
  45008. /**
  45009. * Renders a specified physic impostor
  45010. * @param impostor defines the impostor to render
  45011. * @param targetMesh defines the mesh represented by the impostor
  45012. * @returns the new debug mesh used to render the impostor
  45013. */
  45014. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45015. /**
  45016. * Hides a specified physic impostor
  45017. * @param impostor defines the impostor to hide
  45018. */
  45019. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45020. private _getDebugMaterial;
  45021. private _getDebugBoxMesh;
  45022. private _getDebugSphereMesh;
  45023. private _getDebugCylinderMesh;
  45024. private _getDebugMeshMesh;
  45025. private _getDebugMesh;
  45026. /** Releases all resources */
  45027. dispose(): void;
  45028. }
  45029. }
  45030. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45031. import { Vector3 } from "babylonjs/Maths/math.vector";
  45032. import { Color4 } from "babylonjs/Maths/math.color";
  45033. import { Nullable } from "babylonjs/types";
  45034. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45035. import { Scene } from "babylonjs/scene";
  45036. /**
  45037. * Class containing static functions to help procedurally build meshes
  45038. */
  45039. export class LinesBuilder {
  45040. /**
  45041. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45042. * * 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
  45043. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45044. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45045. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45046. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45047. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45048. * * 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
  45049. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45051. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45052. * @param name defines the name of the new line system
  45053. * @param options defines the options used to create the line system
  45054. * @param scene defines the hosting scene
  45055. * @returns a new line system mesh
  45056. */
  45057. static CreateLineSystem(name: string, options: {
  45058. lines: Vector3[][];
  45059. updatable?: boolean;
  45060. instance?: Nullable<LinesMesh>;
  45061. colors?: Nullable<Color4[][]>;
  45062. useVertexAlpha?: boolean;
  45063. }, scene: Nullable<Scene>): LinesMesh;
  45064. /**
  45065. * Creates a line mesh
  45066. * 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
  45067. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45068. * * The parameter `points` is an array successive Vector3
  45069. * * 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
  45070. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45071. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45072. * * When updating an instance, remember that only point positions can change, not the number of points
  45073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45074. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45075. * @param name defines the name of the new line system
  45076. * @param options defines the options used to create the line system
  45077. * @param scene defines the hosting scene
  45078. * @returns a new line mesh
  45079. */
  45080. static CreateLines(name: string, options: {
  45081. points: Vector3[];
  45082. updatable?: boolean;
  45083. instance?: Nullable<LinesMesh>;
  45084. colors?: Color4[];
  45085. useVertexAlpha?: boolean;
  45086. }, scene?: Nullable<Scene>): LinesMesh;
  45087. /**
  45088. * Creates a dashed line mesh
  45089. * * 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
  45090. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45091. * * The parameter `points` is an array successive Vector3
  45092. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45093. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45094. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45095. * * 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
  45096. * * When updating an instance, remember that only point positions can change, not the number of points
  45097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45098. * @param name defines the name of the mesh
  45099. * @param options defines the options used to create the mesh
  45100. * @param scene defines the hosting scene
  45101. * @returns the dashed line mesh
  45102. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45103. */
  45104. static CreateDashedLines(name: string, options: {
  45105. points: Vector3[];
  45106. dashSize?: number;
  45107. gapSize?: number;
  45108. dashNb?: number;
  45109. updatable?: boolean;
  45110. instance?: LinesMesh;
  45111. }, scene?: Nullable<Scene>): LinesMesh;
  45112. }
  45113. }
  45114. declare module "babylonjs/Debug/rayHelper" {
  45115. import { Nullable } from "babylonjs/types";
  45116. import { Ray } from "babylonjs/Culling/ray";
  45117. import { Vector3 } from "babylonjs/Maths/math.vector";
  45118. import { Color3 } from "babylonjs/Maths/math.color";
  45119. import { Scene } from "babylonjs/scene";
  45120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45121. import "babylonjs/Meshes/Builders/linesBuilder";
  45122. /**
  45123. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45124. * in order to better appreciate the issue one might have.
  45125. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45126. */
  45127. export class RayHelper {
  45128. /**
  45129. * Defines the ray we are currently tryin to visualize.
  45130. */
  45131. ray: Nullable<Ray>;
  45132. private _renderPoints;
  45133. private _renderLine;
  45134. private _renderFunction;
  45135. private _scene;
  45136. private _updateToMeshFunction;
  45137. private _attachedToMesh;
  45138. private _meshSpaceDirection;
  45139. private _meshSpaceOrigin;
  45140. /**
  45141. * Helper function to create a colored helper in a scene in one line.
  45142. * @param ray Defines the ray we are currently tryin to visualize
  45143. * @param scene Defines the scene the ray is used in
  45144. * @param color Defines the color we want to see the ray in
  45145. * @returns The newly created ray helper.
  45146. */
  45147. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45148. /**
  45149. * Instantiate a new ray helper.
  45150. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45151. * in order to better appreciate the issue one might have.
  45152. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45153. * @param ray Defines the ray we are currently tryin to visualize
  45154. */
  45155. constructor(ray: Ray);
  45156. /**
  45157. * Shows the ray we are willing to debug.
  45158. * @param scene Defines the scene the ray needs to be rendered in
  45159. * @param color Defines the color the ray needs to be rendered in
  45160. */
  45161. show(scene: Scene, color?: Color3): void;
  45162. /**
  45163. * Hides the ray we are debugging.
  45164. */
  45165. hide(): void;
  45166. private _render;
  45167. /**
  45168. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45169. * @param mesh Defines the mesh we want the helper attached to
  45170. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45171. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45172. * @param length Defines the length of the ray
  45173. */
  45174. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45175. /**
  45176. * Detach the ray helper from the mesh it has previously been attached to.
  45177. */
  45178. detachFromMesh(): void;
  45179. private _updateToMesh;
  45180. /**
  45181. * Dispose the helper and release its associated resources.
  45182. */
  45183. dispose(): void;
  45184. }
  45185. }
  45186. declare module "babylonjs/Debug/skeletonViewer" {
  45187. import { Color3 } from "babylonjs/Maths/math.color";
  45188. import { Scene } from "babylonjs/scene";
  45189. import { Nullable } from "babylonjs/types";
  45190. import { Skeleton } from "babylonjs/Bones/skeleton";
  45191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45192. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45193. /**
  45194. * Class used to render a debug view of a given skeleton
  45195. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45196. */
  45197. export class SkeletonViewer {
  45198. /** defines the skeleton to render */
  45199. skeleton: Skeleton;
  45200. /** defines the mesh attached to the skeleton */
  45201. mesh: AbstractMesh;
  45202. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45203. autoUpdateBonesMatrices: boolean;
  45204. /** defines the rendering group id to use with the viewer */
  45205. renderingGroupId: number;
  45206. /** Gets or sets the color used to render the skeleton */
  45207. color: Color3;
  45208. private _scene;
  45209. private _debugLines;
  45210. private _debugMesh;
  45211. private _isEnabled;
  45212. private _renderFunction;
  45213. private _utilityLayer;
  45214. /**
  45215. * Returns the mesh used to render the bones
  45216. */
  45217. readonly debugMesh: Nullable<LinesMesh>;
  45218. /**
  45219. * Creates a new SkeletonViewer
  45220. * @param skeleton defines the skeleton to render
  45221. * @param mesh defines the mesh attached to the skeleton
  45222. * @param scene defines the hosting scene
  45223. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45224. * @param renderingGroupId defines the rendering group id to use with the viewer
  45225. */
  45226. constructor(
  45227. /** defines the skeleton to render */
  45228. skeleton: Skeleton,
  45229. /** defines the mesh attached to the skeleton */
  45230. mesh: AbstractMesh, scene: Scene,
  45231. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45232. autoUpdateBonesMatrices?: boolean,
  45233. /** defines the rendering group id to use with the viewer */
  45234. renderingGroupId?: number);
  45235. /** Gets or sets a boolean indicating if the viewer is enabled */
  45236. isEnabled: boolean;
  45237. private _getBonePosition;
  45238. private _getLinesForBonesWithLength;
  45239. private _getLinesForBonesNoLength;
  45240. /** Update the viewer to sync with current skeleton state */
  45241. update(): void;
  45242. /** Release associated resources */
  45243. dispose(): void;
  45244. }
  45245. }
  45246. declare module "babylonjs/Debug/index" {
  45247. export * from "babylonjs/Debug/axesViewer";
  45248. export * from "babylonjs/Debug/boneAxesViewer";
  45249. export * from "babylonjs/Debug/debugLayer";
  45250. export * from "babylonjs/Debug/physicsViewer";
  45251. export * from "babylonjs/Debug/rayHelper";
  45252. export * from "babylonjs/Debug/skeletonViewer";
  45253. }
  45254. declare module "babylonjs/Engines/nullEngine" {
  45255. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45256. import { Scene } from "babylonjs/scene";
  45257. import { Engine } from "babylonjs/Engines/engine";
  45258. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45259. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45260. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45261. import { Effect } from "babylonjs/Materials/effect";
  45262. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45263. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45264. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45265. /**
  45266. * Options to create the null engine
  45267. */
  45268. export class NullEngineOptions {
  45269. /**
  45270. * Render width (Default: 512)
  45271. */
  45272. renderWidth: number;
  45273. /**
  45274. * Render height (Default: 256)
  45275. */
  45276. renderHeight: number;
  45277. /**
  45278. * Texture size (Default: 512)
  45279. */
  45280. textureSize: number;
  45281. /**
  45282. * If delta time between frames should be constant
  45283. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45284. */
  45285. deterministicLockstep: boolean;
  45286. /**
  45287. * Maximum about of steps between frames (Default: 4)
  45288. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45289. */
  45290. lockstepMaxSteps: number;
  45291. }
  45292. /**
  45293. * The null engine class provides support for headless version of babylon.js.
  45294. * This can be used in server side scenario or for testing purposes
  45295. */
  45296. export class NullEngine extends Engine {
  45297. private _options;
  45298. /**
  45299. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45300. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45301. * @returns true if engine is in deterministic lock step mode
  45302. */
  45303. isDeterministicLockStep(): boolean;
  45304. /**
  45305. * Gets the max steps when engine is running in deterministic lock step
  45306. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45307. * @returns the max steps
  45308. */
  45309. getLockstepMaxSteps(): number;
  45310. /**
  45311. * Gets the current hardware scaling level.
  45312. * By default the hardware scaling level is computed from the window device ratio.
  45313. * 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.
  45314. * @returns a number indicating the current hardware scaling level
  45315. */
  45316. getHardwareScalingLevel(): number;
  45317. constructor(options?: NullEngineOptions);
  45318. /**
  45319. * Creates a vertex buffer
  45320. * @param vertices the data for the vertex buffer
  45321. * @returns the new WebGL static buffer
  45322. */
  45323. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45324. /**
  45325. * Creates a new index buffer
  45326. * @param indices defines the content of the index buffer
  45327. * @param updatable defines if the index buffer must be updatable
  45328. * @returns a new webGL buffer
  45329. */
  45330. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45331. /**
  45332. * Clear the current render buffer or the current render target (if any is set up)
  45333. * @param color defines the color to use
  45334. * @param backBuffer defines if the back buffer must be cleared
  45335. * @param depth defines if the depth buffer must be cleared
  45336. * @param stencil defines if the stencil buffer must be cleared
  45337. */
  45338. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45339. /**
  45340. * Gets the current render width
  45341. * @param useScreen defines if screen size must be used (or the current render target if any)
  45342. * @returns a number defining the current render width
  45343. */
  45344. getRenderWidth(useScreen?: boolean): number;
  45345. /**
  45346. * Gets the current render height
  45347. * @param useScreen defines if screen size must be used (or the current render target if any)
  45348. * @returns a number defining the current render height
  45349. */
  45350. getRenderHeight(useScreen?: boolean): number;
  45351. /**
  45352. * Set the WebGL's viewport
  45353. * @param viewport defines the viewport element to be used
  45354. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45355. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45356. */
  45357. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45358. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45359. /**
  45360. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45361. * @param pipelineContext defines the pipeline context to use
  45362. * @param uniformsNames defines the list of uniform names
  45363. * @returns an array of webGL uniform locations
  45364. */
  45365. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45366. /**
  45367. * Gets the lsit of active attributes for a given webGL program
  45368. * @param pipelineContext defines the pipeline context to use
  45369. * @param attributesNames defines the list of attribute names to get
  45370. * @returns an array of indices indicating the offset of each attribute
  45371. */
  45372. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45373. /**
  45374. * Binds an effect to the webGL context
  45375. * @param effect defines the effect to bind
  45376. */
  45377. bindSamplers(effect: Effect): void;
  45378. /**
  45379. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45380. * @param effect defines the effect to activate
  45381. */
  45382. enableEffect(effect: Effect): void;
  45383. /**
  45384. * Set various states to the webGL context
  45385. * @param culling defines backface culling state
  45386. * @param zOffset defines the value to apply to zOffset (0 by default)
  45387. * @param force defines if states must be applied even if cache is up to date
  45388. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45389. */
  45390. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45391. /**
  45392. * Set the value of an uniform to an array of int32
  45393. * @param uniform defines the webGL uniform location where to store the value
  45394. * @param array defines the array of int32 to store
  45395. */
  45396. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45397. /**
  45398. * Set the value of an uniform to an array of int32 (stored as vec2)
  45399. * @param uniform defines the webGL uniform location where to store the value
  45400. * @param array defines the array of int32 to store
  45401. */
  45402. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45403. /**
  45404. * Set the value of an uniform to an array of int32 (stored as vec3)
  45405. * @param uniform defines the webGL uniform location where to store the value
  45406. * @param array defines the array of int32 to store
  45407. */
  45408. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45409. /**
  45410. * Set the value of an uniform to an array of int32 (stored as vec4)
  45411. * @param uniform defines the webGL uniform location where to store the value
  45412. * @param array defines the array of int32 to store
  45413. */
  45414. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45415. /**
  45416. * Set the value of an uniform to an array of float32
  45417. * @param uniform defines the webGL uniform location where to store the value
  45418. * @param array defines the array of float32 to store
  45419. */
  45420. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45421. /**
  45422. * Set the value of an uniform to an array of float32 (stored as vec2)
  45423. * @param uniform defines the webGL uniform location where to store the value
  45424. * @param array defines the array of float32 to store
  45425. */
  45426. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45427. /**
  45428. * Set the value of an uniform to an array of float32 (stored as vec3)
  45429. * @param uniform defines the webGL uniform location where to store the value
  45430. * @param array defines the array of float32 to store
  45431. */
  45432. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45433. /**
  45434. * Set the value of an uniform to an array of float32 (stored as vec4)
  45435. * @param uniform defines the webGL uniform location where to store the value
  45436. * @param array defines the array of float32 to store
  45437. */
  45438. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45439. /**
  45440. * Set the value of an uniform to an array of number
  45441. * @param uniform defines the webGL uniform location where to store the value
  45442. * @param array defines the array of number to store
  45443. */
  45444. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45445. /**
  45446. * Set the value of an uniform to an array of number (stored as vec2)
  45447. * @param uniform defines the webGL uniform location where to store the value
  45448. * @param array defines the array of number to store
  45449. */
  45450. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45451. /**
  45452. * Set the value of an uniform to an array of number (stored as vec3)
  45453. * @param uniform defines the webGL uniform location where to store the value
  45454. * @param array defines the array of number to store
  45455. */
  45456. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45457. /**
  45458. * Set the value of an uniform to an array of number (stored as vec4)
  45459. * @param uniform defines the webGL uniform location where to store the value
  45460. * @param array defines the array of number to store
  45461. */
  45462. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45463. /**
  45464. * Set the value of an uniform to an array of float32 (stored as matrices)
  45465. * @param uniform defines the webGL uniform location where to store the value
  45466. * @param matrices defines the array of float32 to store
  45467. */
  45468. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45469. /**
  45470. * Set the value of an uniform to a matrix (3x3)
  45471. * @param uniform defines the webGL uniform location where to store the value
  45472. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45473. */
  45474. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45475. /**
  45476. * Set the value of an uniform to a matrix (2x2)
  45477. * @param uniform defines the webGL uniform location where to store the value
  45478. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45479. */
  45480. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45481. /**
  45482. * Set the value of an uniform to a number (float)
  45483. * @param uniform defines the webGL uniform location where to store the value
  45484. * @param value defines the float number to store
  45485. */
  45486. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45487. /**
  45488. * Set the value of an uniform to a vec2
  45489. * @param uniform defines the webGL uniform location where to store the value
  45490. * @param x defines the 1st component of the value
  45491. * @param y defines the 2nd component of the value
  45492. */
  45493. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45494. /**
  45495. * Set the value of an uniform to a vec3
  45496. * @param uniform defines the webGL uniform location where to store the value
  45497. * @param x defines the 1st component of the value
  45498. * @param y defines the 2nd component of the value
  45499. * @param z defines the 3rd component of the value
  45500. */
  45501. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45502. /**
  45503. * Set the value of an uniform to a boolean
  45504. * @param uniform defines the webGL uniform location where to store the value
  45505. * @param bool defines the boolean to store
  45506. */
  45507. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45508. /**
  45509. * Set the value of an uniform to a vec4
  45510. * @param uniform defines the webGL uniform location where to store the value
  45511. * @param x defines the 1st component of the value
  45512. * @param y defines the 2nd component of the value
  45513. * @param z defines the 3rd component of the value
  45514. * @param w defines the 4th component of the value
  45515. */
  45516. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45517. /**
  45518. * Sets the current alpha mode
  45519. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45520. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45521. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45522. */
  45523. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45524. /**
  45525. * Bind webGl buffers directly to the webGL context
  45526. * @param vertexBuffers defines the vertex buffer to bind
  45527. * @param indexBuffer defines the index buffer to bind
  45528. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45529. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45530. * @param effect defines the effect associated with the vertex buffer
  45531. */
  45532. bindBuffers(vertexBuffers: {
  45533. [key: string]: VertexBuffer;
  45534. }, indexBuffer: DataBuffer, effect: Effect): void;
  45535. /**
  45536. * Force the entire cache to be cleared
  45537. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45538. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45539. */
  45540. wipeCaches(bruteForce?: boolean): void;
  45541. /**
  45542. * Send a draw order
  45543. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45544. * @param indexStart defines the starting index
  45545. * @param indexCount defines the number of index to draw
  45546. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45547. */
  45548. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45549. /**
  45550. * Draw a list of indexed primitives
  45551. * @param fillMode defines the primitive to use
  45552. * @param indexStart defines the starting index
  45553. * @param indexCount defines the number of index to draw
  45554. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45555. */
  45556. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45557. /**
  45558. * Draw a list of unindexed primitives
  45559. * @param fillMode defines the primitive to use
  45560. * @param verticesStart defines the index of first vertex to draw
  45561. * @param verticesCount defines the count of vertices to draw
  45562. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45563. */
  45564. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45565. /** @hidden */
  45566. _createTexture(): WebGLTexture;
  45567. /** @hidden */
  45568. _releaseTexture(texture: InternalTexture): void;
  45569. /**
  45570. * Usually called from Texture.ts.
  45571. * Passed information to create a WebGLTexture
  45572. * @param urlArg defines a value which contains one of the following:
  45573. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45574. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45575. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45576. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45577. * @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)
  45578. * @param scene needed for loading to the correct scene
  45579. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45580. * @param onLoad optional callback to be called upon successful completion
  45581. * @param onError optional callback to be called upon failure
  45582. * @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
  45583. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45584. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45585. * @param forcedExtension defines the extension to use to pick the right loader
  45586. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45587. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45588. */
  45589. 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;
  45590. /**
  45591. * Creates a new render target texture
  45592. * @param size defines the size of the texture
  45593. * @param options defines the options used to create the texture
  45594. * @returns a new render target texture stored in an InternalTexture
  45595. */
  45596. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45597. /**
  45598. * Update the sampling mode of a given texture
  45599. * @param samplingMode defines the required sampling mode
  45600. * @param texture defines the texture to update
  45601. */
  45602. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45603. /**
  45604. * Binds the frame buffer to the specified texture.
  45605. * @param texture The texture to render to or null for the default canvas
  45606. * @param faceIndex The face of the texture to render to in case of cube texture
  45607. * @param requiredWidth The width of the target to render to
  45608. * @param requiredHeight The height of the target to render to
  45609. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45610. * @param depthStencilTexture The depth stencil texture to use to render
  45611. * @param lodLevel defines le lod level to bind to the frame buffer
  45612. */
  45613. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45614. /**
  45615. * Unbind the current render target texture from the webGL context
  45616. * @param texture defines the render target texture to unbind
  45617. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45618. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45619. */
  45620. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45621. /**
  45622. * Creates a dynamic vertex buffer
  45623. * @param vertices the data for the dynamic vertex buffer
  45624. * @returns the new WebGL dynamic buffer
  45625. */
  45626. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45627. /**
  45628. * Update the content of a dynamic texture
  45629. * @param texture defines the texture to update
  45630. * @param canvas defines the canvas containing the source
  45631. * @param invertY defines if data must be stored with Y axis inverted
  45632. * @param premulAlpha defines if alpha is stored as premultiplied
  45633. * @param format defines the format of the data
  45634. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45635. */
  45636. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45637. /**
  45638. * Gets a boolean indicating if all created effects are ready
  45639. * @returns true if all effects are ready
  45640. */
  45641. areAllEffectsReady(): boolean;
  45642. /**
  45643. * @hidden
  45644. * Get the current error code of the webGL context
  45645. * @returns the error code
  45646. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45647. */
  45648. getError(): number;
  45649. /** @hidden */
  45650. _getUnpackAlignement(): number;
  45651. /** @hidden */
  45652. _unpackFlipY(value: boolean): void;
  45653. /**
  45654. * Update a dynamic index buffer
  45655. * @param indexBuffer defines the target index buffer
  45656. * @param indices defines the data to update
  45657. * @param offset defines the offset in the target index buffer where update should start
  45658. */
  45659. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45660. /**
  45661. * Updates a dynamic vertex buffer.
  45662. * @param vertexBuffer the vertex buffer to update
  45663. * @param vertices the data used to update the vertex buffer
  45664. * @param byteOffset the byte offset of the data (optional)
  45665. * @param byteLength the byte length of the data (optional)
  45666. */
  45667. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45668. /** @hidden */
  45669. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45670. /** @hidden */
  45671. _bindTexture(channel: number, texture: InternalTexture): void;
  45672. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45673. /**
  45674. * 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
  45675. */
  45676. releaseEffects(): void;
  45677. displayLoadingUI(): void;
  45678. hideLoadingUI(): void;
  45679. /** @hidden */
  45680. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45681. /** @hidden */
  45682. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45683. /** @hidden */
  45684. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45685. /** @hidden */
  45686. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45687. }
  45688. }
  45689. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45690. import { Nullable, int } from "babylonjs/types";
  45691. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45692. /** @hidden */
  45693. export class _OcclusionDataStorage {
  45694. /** @hidden */
  45695. occlusionInternalRetryCounter: number;
  45696. /** @hidden */
  45697. isOcclusionQueryInProgress: boolean;
  45698. /** @hidden */
  45699. isOccluded: boolean;
  45700. /** @hidden */
  45701. occlusionRetryCount: number;
  45702. /** @hidden */
  45703. occlusionType: number;
  45704. /** @hidden */
  45705. occlusionQueryAlgorithmType: number;
  45706. }
  45707. module "babylonjs/Engines/engine" {
  45708. interface Engine {
  45709. /**
  45710. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45711. * @return the new query
  45712. */
  45713. createQuery(): WebGLQuery;
  45714. /**
  45715. * Delete and release a webGL query
  45716. * @param query defines the query to delete
  45717. * @return the current engine
  45718. */
  45719. deleteQuery(query: WebGLQuery): Engine;
  45720. /**
  45721. * Check if a given query has resolved and got its value
  45722. * @param query defines the query to check
  45723. * @returns true if the query got its value
  45724. */
  45725. isQueryResultAvailable(query: WebGLQuery): boolean;
  45726. /**
  45727. * Gets the value of a given query
  45728. * @param query defines the query to check
  45729. * @returns the value of the query
  45730. */
  45731. getQueryResult(query: WebGLQuery): number;
  45732. /**
  45733. * Initiates an occlusion query
  45734. * @param algorithmType defines the algorithm to use
  45735. * @param query defines the query to use
  45736. * @returns the current engine
  45737. * @see http://doc.babylonjs.com/features/occlusionquery
  45738. */
  45739. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45740. /**
  45741. * Ends an occlusion query
  45742. * @see http://doc.babylonjs.com/features/occlusionquery
  45743. * @param algorithmType defines the algorithm to use
  45744. * @returns the current engine
  45745. */
  45746. endOcclusionQuery(algorithmType: number): Engine;
  45747. /**
  45748. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45749. * Please note that only one query can be issued at a time
  45750. * @returns a time token used to track the time span
  45751. */
  45752. startTimeQuery(): Nullable<_TimeToken>;
  45753. /**
  45754. * Ends a time query
  45755. * @param token defines the token used to measure the time span
  45756. * @returns the time spent (in ns)
  45757. */
  45758. endTimeQuery(token: _TimeToken): int;
  45759. /** @hidden */
  45760. _currentNonTimestampToken: Nullable<_TimeToken>;
  45761. /** @hidden */
  45762. _createTimeQuery(): WebGLQuery;
  45763. /** @hidden */
  45764. _deleteTimeQuery(query: WebGLQuery): void;
  45765. /** @hidden */
  45766. _getGlAlgorithmType(algorithmType: number): number;
  45767. /** @hidden */
  45768. _getTimeQueryResult(query: WebGLQuery): any;
  45769. /** @hidden */
  45770. _getTimeQueryAvailability(query: WebGLQuery): any;
  45771. }
  45772. }
  45773. module "babylonjs/Meshes/abstractMesh" {
  45774. interface AbstractMesh {
  45775. /**
  45776. * Backing filed
  45777. * @hidden
  45778. */
  45779. __occlusionDataStorage: _OcclusionDataStorage;
  45780. /**
  45781. * Access property
  45782. * @hidden
  45783. */
  45784. _occlusionDataStorage: _OcclusionDataStorage;
  45785. /**
  45786. * 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.
  45787. * The default value is -1 which means don't break the query and wait till the result
  45788. * @see http://doc.babylonjs.com/features/occlusionquery
  45789. */
  45790. occlusionRetryCount: number;
  45791. /**
  45792. * 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:
  45793. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45794. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45795. * * 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.
  45796. * @see http://doc.babylonjs.com/features/occlusionquery
  45797. */
  45798. occlusionType: number;
  45799. /**
  45800. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45801. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45802. * * 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.
  45803. * @see http://doc.babylonjs.com/features/occlusionquery
  45804. */
  45805. occlusionQueryAlgorithmType: number;
  45806. /**
  45807. * 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
  45808. * @see http://doc.babylonjs.com/features/occlusionquery
  45809. */
  45810. isOccluded: boolean;
  45811. /**
  45812. * Flag to check the progress status of the query
  45813. * @see http://doc.babylonjs.com/features/occlusionquery
  45814. */
  45815. isOcclusionQueryInProgress: boolean;
  45816. }
  45817. }
  45818. }
  45819. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45820. import { Nullable } from "babylonjs/types";
  45821. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45822. /** @hidden */
  45823. export var _forceTransformFeedbackToBundle: boolean;
  45824. module "babylonjs/Engines/engine" {
  45825. interface Engine {
  45826. /**
  45827. * Creates a webGL transform feedback object
  45828. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45829. * @returns the webGL transform feedback object
  45830. */
  45831. createTransformFeedback(): WebGLTransformFeedback;
  45832. /**
  45833. * Delete a webGL transform feedback object
  45834. * @param value defines the webGL transform feedback object to delete
  45835. */
  45836. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45837. /**
  45838. * Bind a webGL transform feedback object to the webgl context
  45839. * @param value defines the webGL transform feedback object to bind
  45840. */
  45841. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45842. /**
  45843. * Begins a transform feedback operation
  45844. * @param usePoints defines if points or triangles must be used
  45845. */
  45846. beginTransformFeedback(usePoints: boolean): void;
  45847. /**
  45848. * Ends a transform feedback operation
  45849. */
  45850. endTransformFeedback(): void;
  45851. /**
  45852. * Specify the varyings to use with transform feedback
  45853. * @param program defines the associated webGL program
  45854. * @param value defines the list of strings representing the varying names
  45855. */
  45856. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45857. /**
  45858. * Bind a webGL buffer for a transform feedback operation
  45859. * @param value defines the webGL buffer to bind
  45860. */
  45861. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45862. }
  45863. }
  45864. }
  45865. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45866. import { Scene } from "babylonjs/scene";
  45867. import { Engine } from "babylonjs/Engines/engine";
  45868. import { Texture } from "babylonjs/Materials/Textures/texture";
  45869. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45870. import "babylonjs/Engines/Extensions/engine.multiRender";
  45871. /**
  45872. * Creation options of the multi render target texture.
  45873. */
  45874. export interface IMultiRenderTargetOptions {
  45875. /**
  45876. * Define if the texture needs to create mip maps after render.
  45877. */
  45878. generateMipMaps?: boolean;
  45879. /**
  45880. * Define the types of all the draw buffers we want to create
  45881. */
  45882. types?: number[];
  45883. /**
  45884. * Define the sampling modes of all the draw buffers we want to create
  45885. */
  45886. samplingModes?: number[];
  45887. /**
  45888. * Define if a depth buffer is required
  45889. */
  45890. generateDepthBuffer?: boolean;
  45891. /**
  45892. * Define if a stencil buffer is required
  45893. */
  45894. generateStencilBuffer?: boolean;
  45895. /**
  45896. * Define if a depth texture is required instead of a depth buffer
  45897. */
  45898. generateDepthTexture?: boolean;
  45899. /**
  45900. * Define the number of desired draw buffers
  45901. */
  45902. textureCount?: number;
  45903. /**
  45904. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45905. */
  45906. doNotChangeAspectRatio?: boolean;
  45907. /**
  45908. * Define the default type of the buffers we are creating
  45909. */
  45910. defaultType?: number;
  45911. }
  45912. /**
  45913. * A multi render target, like a render target provides the ability to render to a texture.
  45914. * Unlike the render target, it can render to several draw buffers in one draw.
  45915. * This is specially interesting in deferred rendering or for any effects requiring more than
  45916. * just one color from a single pass.
  45917. */
  45918. export class MultiRenderTarget extends RenderTargetTexture {
  45919. private _internalTextures;
  45920. private _textures;
  45921. private _multiRenderTargetOptions;
  45922. /**
  45923. * Get if draw buffers are currently supported by the used hardware and browser.
  45924. */
  45925. readonly isSupported: boolean;
  45926. /**
  45927. * Get the list of textures generated by the multi render target.
  45928. */
  45929. readonly textures: Texture[];
  45930. /**
  45931. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45932. */
  45933. readonly depthTexture: Texture;
  45934. /**
  45935. * Set the wrapping mode on U of all the textures we are rendering to.
  45936. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45937. */
  45938. wrapU: number;
  45939. /**
  45940. * Set the wrapping mode on V of all the textures we are rendering to.
  45941. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45942. */
  45943. wrapV: number;
  45944. /**
  45945. * Instantiate a new multi render target texture.
  45946. * A multi render target, like a render target provides the ability to render to a texture.
  45947. * Unlike the render target, it can render to several draw buffers in one draw.
  45948. * This is specially interesting in deferred rendering or for any effects requiring more than
  45949. * just one color from a single pass.
  45950. * @param name Define the name of the texture
  45951. * @param size Define the size of the buffers to render to
  45952. * @param count Define the number of target we are rendering into
  45953. * @param scene Define the scene the texture belongs to
  45954. * @param options Define the options used to create the multi render target
  45955. */
  45956. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45957. /** @hidden */
  45958. _rebuild(): void;
  45959. private _createInternalTextures;
  45960. private _createTextures;
  45961. /**
  45962. * Define the number of samples used if MSAA is enabled.
  45963. */
  45964. samples: number;
  45965. /**
  45966. * Resize all the textures in the multi render target.
  45967. * Be carrefull as it will recreate all the data in the new texture.
  45968. * @param size Define the new size
  45969. */
  45970. resize(size: any): void;
  45971. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45972. /**
  45973. * Dispose the render targets and their associated resources
  45974. */
  45975. dispose(): void;
  45976. /**
  45977. * Release all the underlying texture used as draw buffers.
  45978. */
  45979. releaseInternalTextures(): void;
  45980. }
  45981. }
  45982. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45983. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45984. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45985. import { Nullable } from "babylonjs/types";
  45986. module "babylonjs/Engines/thinEngine" {
  45987. interface ThinEngine {
  45988. /**
  45989. * Unbind a list of render target textures from the webGL context
  45990. * This is used only when drawBuffer extension or webGL2 are active
  45991. * @param textures defines the render target textures to unbind
  45992. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45993. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45994. */
  45995. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45996. /**
  45997. * Create a multi render target texture
  45998. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45999. * @param size defines the size of the texture
  46000. * @param options defines the creation options
  46001. * @returns the cube texture as an InternalTexture
  46002. */
  46003. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46004. /**
  46005. * Update the sample count for a given multiple render target texture
  46006. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46007. * @param textures defines the textures to update
  46008. * @param samples defines the sample count to set
  46009. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46010. */
  46011. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46012. }
  46013. }
  46014. }
  46015. declare module "babylonjs/Engines/Extensions/index" {
  46016. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46017. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46018. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46019. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46020. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46021. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46022. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46023. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46024. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46025. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46026. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46027. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46028. }
  46029. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46030. import { Nullable } from "babylonjs/types";
  46031. /**
  46032. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46033. */
  46034. export interface CubeMapInfo {
  46035. /**
  46036. * The pixel array for the front face.
  46037. * This is stored in format, left to right, up to down format.
  46038. */
  46039. front: Nullable<ArrayBufferView>;
  46040. /**
  46041. * The pixel array for the back face.
  46042. * This is stored in format, left to right, up to down format.
  46043. */
  46044. back: Nullable<ArrayBufferView>;
  46045. /**
  46046. * The pixel array for the left face.
  46047. * This is stored in format, left to right, up to down format.
  46048. */
  46049. left: Nullable<ArrayBufferView>;
  46050. /**
  46051. * The pixel array for the right face.
  46052. * This is stored in format, left to right, up to down format.
  46053. */
  46054. right: Nullable<ArrayBufferView>;
  46055. /**
  46056. * The pixel array for the up face.
  46057. * This is stored in format, left to right, up to down format.
  46058. */
  46059. up: Nullable<ArrayBufferView>;
  46060. /**
  46061. * The pixel array for the down face.
  46062. * This is stored in format, left to right, up to down format.
  46063. */
  46064. down: Nullable<ArrayBufferView>;
  46065. /**
  46066. * The size of the cubemap stored.
  46067. *
  46068. * Each faces will be size * size pixels.
  46069. */
  46070. size: number;
  46071. /**
  46072. * The format of the texture.
  46073. *
  46074. * RGBA, RGB.
  46075. */
  46076. format: number;
  46077. /**
  46078. * The type of the texture data.
  46079. *
  46080. * UNSIGNED_INT, FLOAT.
  46081. */
  46082. type: number;
  46083. /**
  46084. * Specifies whether the texture is in gamma space.
  46085. */
  46086. gammaSpace: boolean;
  46087. }
  46088. /**
  46089. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46090. */
  46091. export class PanoramaToCubeMapTools {
  46092. private static FACE_FRONT;
  46093. private static FACE_BACK;
  46094. private static FACE_RIGHT;
  46095. private static FACE_LEFT;
  46096. private static FACE_DOWN;
  46097. private static FACE_UP;
  46098. /**
  46099. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46100. *
  46101. * @param float32Array The source data.
  46102. * @param inputWidth The width of the input panorama.
  46103. * @param inputHeight The height of the input panorama.
  46104. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46105. * @return The cubemap data
  46106. */
  46107. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46108. private static CreateCubemapTexture;
  46109. private static CalcProjectionSpherical;
  46110. }
  46111. }
  46112. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46113. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46114. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46115. import { Nullable } from "babylonjs/types";
  46116. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46117. /**
  46118. * Helper class dealing with the extraction of spherical polynomial dataArray
  46119. * from a cube map.
  46120. */
  46121. export class CubeMapToSphericalPolynomialTools {
  46122. private static FileFaces;
  46123. /**
  46124. * Converts a texture to the according Spherical Polynomial data.
  46125. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46126. *
  46127. * @param texture The texture to extract the information from.
  46128. * @return The Spherical Polynomial data.
  46129. */
  46130. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46131. /**
  46132. * Converts a cubemap to the according Spherical Polynomial data.
  46133. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46134. *
  46135. * @param cubeInfo The Cube map to extract the information from.
  46136. * @return The Spherical Polynomial data.
  46137. */
  46138. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46139. }
  46140. }
  46141. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46142. import { Nullable } from "babylonjs/types";
  46143. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46144. module "babylonjs/Materials/Textures/baseTexture" {
  46145. interface BaseTexture {
  46146. /**
  46147. * Get the polynomial representation of the texture data.
  46148. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46149. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46150. */
  46151. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46152. }
  46153. }
  46154. }
  46155. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46156. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46157. /** @hidden */
  46158. export var rgbdEncodePixelShader: {
  46159. name: string;
  46160. shader: string;
  46161. };
  46162. }
  46163. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46164. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46165. /** @hidden */
  46166. export var rgbdDecodePixelShader: {
  46167. name: string;
  46168. shader: string;
  46169. };
  46170. }
  46171. declare module "babylonjs/Misc/environmentTextureTools" {
  46172. import { Nullable } from "babylonjs/types";
  46173. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46174. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46175. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46176. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46177. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46178. import "babylonjs/Shaders/rgbdEncode.fragment";
  46179. import "babylonjs/Shaders/rgbdDecode.fragment";
  46180. /**
  46181. * Raw texture data and descriptor sufficient for WebGL texture upload
  46182. */
  46183. export interface EnvironmentTextureInfo {
  46184. /**
  46185. * Version of the environment map
  46186. */
  46187. version: number;
  46188. /**
  46189. * Width of image
  46190. */
  46191. width: number;
  46192. /**
  46193. * Irradiance information stored in the file.
  46194. */
  46195. irradiance: any;
  46196. /**
  46197. * Specular information stored in the file.
  46198. */
  46199. specular: any;
  46200. }
  46201. /**
  46202. * Defines One Image in the file. It requires only the position in the file
  46203. * as well as the length.
  46204. */
  46205. interface BufferImageData {
  46206. /**
  46207. * Length of the image data.
  46208. */
  46209. length: number;
  46210. /**
  46211. * Position of the data from the null terminator delimiting the end of the JSON.
  46212. */
  46213. position: number;
  46214. }
  46215. /**
  46216. * Defines the specular data enclosed in the file.
  46217. * This corresponds to the version 1 of the data.
  46218. */
  46219. export interface EnvironmentTextureSpecularInfoV1 {
  46220. /**
  46221. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46222. */
  46223. specularDataPosition?: number;
  46224. /**
  46225. * This contains all the images data needed to reconstruct the cubemap.
  46226. */
  46227. mipmaps: Array<BufferImageData>;
  46228. /**
  46229. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46230. */
  46231. lodGenerationScale: number;
  46232. }
  46233. /**
  46234. * Sets of helpers addressing the serialization and deserialization of environment texture
  46235. * stored in a BabylonJS env file.
  46236. * Those files are usually stored as .env files.
  46237. */
  46238. export class EnvironmentTextureTools {
  46239. /**
  46240. * Magic number identifying the env file.
  46241. */
  46242. private static _MagicBytes;
  46243. /**
  46244. * Gets the environment info from an env file.
  46245. * @param data The array buffer containing the .env bytes.
  46246. * @returns the environment file info (the json header) if successfully parsed.
  46247. */
  46248. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46249. /**
  46250. * Creates an environment texture from a loaded cube texture.
  46251. * @param texture defines the cube texture to convert in env file
  46252. * @return a promise containing the environment data if succesfull.
  46253. */
  46254. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46255. /**
  46256. * Creates a JSON representation of the spherical data.
  46257. * @param texture defines the texture containing the polynomials
  46258. * @return the JSON representation of the spherical info
  46259. */
  46260. private static _CreateEnvTextureIrradiance;
  46261. /**
  46262. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46263. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46264. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46265. * @return the views described by info providing access to the underlying buffer
  46266. */
  46267. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46268. /**
  46269. * Uploads the texture info contained in the env file to the GPU.
  46270. * @param texture defines the internal texture to upload to
  46271. * @param arrayBuffer defines the buffer cotaining the data to load
  46272. * @param info defines the texture info retrieved through the GetEnvInfo method
  46273. * @returns a promise
  46274. */
  46275. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46276. /**
  46277. * Uploads the levels of image data to the GPU.
  46278. * @param texture defines the internal texture to upload to
  46279. * @param imageData defines the array buffer views of image data [mipmap][face]
  46280. * @returns a promise
  46281. */
  46282. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46283. /**
  46284. * Uploads spherical polynomials information to the texture.
  46285. * @param texture defines the texture we are trying to upload the information to
  46286. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46287. */
  46288. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46289. /** @hidden */
  46290. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46291. }
  46292. }
  46293. declare module "babylonjs/Maths/math.vertexFormat" {
  46294. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46295. /**
  46296. * Contains position and normal vectors for a vertex
  46297. */
  46298. export class PositionNormalVertex {
  46299. /** the position of the vertex (defaut: 0,0,0) */
  46300. position: Vector3;
  46301. /** the normal of the vertex (defaut: 0,1,0) */
  46302. normal: Vector3;
  46303. /**
  46304. * Creates a PositionNormalVertex
  46305. * @param position the position of the vertex (defaut: 0,0,0)
  46306. * @param normal the normal of the vertex (defaut: 0,1,0)
  46307. */
  46308. constructor(
  46309. /** the position of the vertex (defaut: 0,0,0) */
  46310. position?: Vector3,
  46311. /** the normal of the vertex (defaut: 0,1,0) */
  46312. normal?: Vector3);
  46313. /**
  46314. * Clones the PositionNormalVertex
  46315. * @returns the cloned PositionNormalVertex
  46316. */
  46317. clone(): PositionNormalVertex;
  46318. }
  46319. /**
  46320. * Contains position, normal and uv vectors for a vertex
  46321. */
  46322. export class PositionNormalTextureVertex {
  46323. /** the position of the vertex (defaut: 0,0,0) */
  46324. position: Vector3;
  46325. /** the normal of the vertex (defaut: 0,1,0) */
  46326. normal: Vector3;
  46327. /** the uv of the vertex (default: 0,0) */
  46328. uv: Vector2;
  46329. /**
  46330. * Creates a PositionNormalTextureVertex
  46331. * @param position the position of the vertex (defaut: 0,0,0)
  46332. * @param normal the normal of the vertex (defaut: 0,1,0)
  46333. * @param uv the uv of the vertex (default: 0,0)
  46334. */
  46335. constructor(
  46336. /** the position of the vertex (defaut: 0,0,0) */
  46337. position?: Vector3,
  46338. /** the normal of the vertex (defaut: 0,1,0) */
  46339. normal?: Vector3,
  46340. /** the uv of the vertex (default: 0,0) */
  46341. uv?: Vector2);
  46342. /**
  46343. * Clones the PositionNormalTextureVertex
  46344. * @returns the cloned PositionNormalTextureVertex
  46345. */
  46346. clone(): PositionNormalTextureVertex;
  46347. }
  46348. }
  46349. declare module "babylonjs/Maths/math" {
  46350. export * from "babylonjs/Maths/math.axis";
  46351. export * from "babylonjs/Maths/math.color";
  46352. export * from "babylonjs/Maths/math.constants";
  46353. export * from "babylonjs/Maths/math.frustum";
  46354. export * from "babylonjs/Maths/math.path";
  46355. export * from "babylonjs/Maths/math.plane";
  46356. export * from "babylonjs/Maths/math.size";
  46357. export * from "babylonjs/Maths/math.vector";
  46358. export * from "babylonjs/Maths/math.vertexFormat";
  46359. export * from "babylonjs/Maths/math.viewport";
  46360. }
  46361. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46362. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46363. /** @hidden */
  46364. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46365. private _genericAttributeLocation;
  46366. private _varyingLocationCount;
  46367. private _varyingLocationMap;
  46368. private _replacements;
  46369. private _textureCount;
  46370. private _uniforms;
  46371. lineProcessor(line: string): string;
  46372. attributeProcessor(attribute: string): string;
  46373. varyingProcessor(varying: string, isFragment: boolean): string;
  46374. uniformProcessor(uniform: string): string;
  46375. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46376. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46377. }
  46378. }
  46379. declare module "babylonjs/Engines/nativeEngine" {
  46380. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46381. import { Engine } from "babylonjs/Engines/engine";
  46382. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46383. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46384. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46385. import { Effect } from "babylonjs/Materials/effect";
  46386. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46387. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46388. import { Scene } from "babylonjs/scene";
  46389. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46390. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46391. /**
  46392. * Container for accessors for natively-stored mesh data buffers.
  46393. */
  46394. class NativeDataBuffer extends DataBuffer {
  46395. /**
  46396. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46397. */
  46398. nativeIndexBuffer?: any;
  46399. /**
  46400. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46401. */
  46402. nativeVertexBuffer?: any;
  46403. }
  46404. /** @hidden */
  46405. export class NativeEngine extends Engine {
  46406. private readonly _native;
  46407. getHardwareScalingLevel(): number;
  46408. constructor();
  46409. /**
  46410. * Can be used to override the current requestAnimationFrame requester.
  46411. * @hidden
  46412. */
  46413. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  46414. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46415. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46416. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46417. recordVertexArrayObject(vertexBuffers: {
  46418. [key: string]: VertexBuffer;
  46419. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46420. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46421. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46422. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46423. /**
  46424. * Draw a list of indexed primitives
  46425. * @param fillMode defines the primitive to use
  46426. * @param indexStart defines the starting index
  46427. * @param indexCount defines the number of index to draw
  46428. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46429. */
  46430. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46431. /**
  46432. * Draw a list of unindexed primitives
  46433. * @param fillMode defines the primitive to use
  46434. * @param verticesStart defines the index of first vertex to draw
  46435. * @param verticesCount defines the count of vertices to draw
  46436. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46437. */
  46438. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46439. createPipelineContext(): IPipelineContext;
  46440. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46441. /** @hidden */
  46442. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46443. /** @hidden */
  46444. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46445. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46446. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46447. protected _setProgram(program: WebGLProgram): void;
  46448. _releaseEffect(effect: Effect): void;
  46449. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46450. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46451. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46452. bindSamplers(effect: Effect): void;
  46453. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46454. getRenderWidth(useScreen?: boolean): number;
  46455. getRenderHeight(useScreen?: boolean): number;
  46456. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46457. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46458. /**
  46459. * Set the z offset to apply to current rendering
  46460. * @param value defines the offset to apply
  46461. */
  46462. setZOffset(value: number): void;
  46463. /**
  46464. * Gets the current value of the zOffset
  46465. * @returns the current zOffset state
  46466. */
  46467. getZOffset(): number;
  46468. /**
  46469. * Enable or disable depth buffering
  46470. * @param enable defines the state to set
  46471. */
  46472. setDepthBuffer(enable: boolean): void;
  46473. /**
  46474. * Gets a boolean indicating if depth writing is enabled
  46475. * @returns the current depth writing state
  46476. */
  46477. getDepthWrite(): boolean;
  46478. /**
  46479. * Enable or disable depth writing
  46480. * @param enable defines the state to set
  46481. */
  46482. setDepthWrite(enable: boolean): void;
  46483. /**
  46484. * Enable or disable color writing
  46485. * @param enable defines the state to set
  46486. */
  46487. setColorWrite(enable: boolean): void;
  46488. /**
  46489. * Gets a boolean indicating if color writing is enabled
  46490. * @returns the current color writing state
  46491. */
  46492. getColorWrite(): boolean;
  46493. /**
  46494. * Sets alpha constants used by some alpha blending modes
  46495. * @param r defines the red component
  46496. * @param g defines the green component
  46497. * @param b defines the blue component
  46498. * @param a defines the alpha component
  46499. */
  46500. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46501. /**
  46502. * Sets the current alpha mode
  46503. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46504. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46505. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46506. */
  46507. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46508. /**
  46509. * Gets the current alpha mode
  46510. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46511. * @returns the current alpha mode
  46512. */
  46513. getAlphaMode(): number;
  46514. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46515. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46516. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46517. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46518. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46519. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46520. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46521. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46522. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46523. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46524. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46525. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46526. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46527. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46528. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46529. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46530. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46531. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46532. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46533. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46534. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46535. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46536. wipeCaches(bruteForce?: boolean): void;
  46537. _createTexture(): WebGLTexture;
  46538. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46539. /**
  46540. * Usually called from BABYLON.Texture.ts.
  46541. * Passed information to create a WebGLTexture
  46542. * @param urlArg defines a value which contains one of the following:
  46543. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46544. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46545. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46546. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46547. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46548. * @param scene needed for loading to the correct scene
  46549. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46550. * @param onLoad optional callback to be called upon successful completion
  46551. * @param onError optional callback to be called upon failure
  46552. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46553. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46554. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46555. * @param forcedExtension defines the extension to use to pick the right loader
  46556. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46557. */
  46558. 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;
  46559. /**
  46560. * Creates a cube texture
  46561. * @param rootUrl defines the url where the files to load is located
  46562. * @param scene defines the current scene
  46563. * @param files defines the list of files to load (1 per face)
  46564. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46565. * @param onLoad defines an optional callback raised when the texture is loaded
  46566. * @param onError defines an optional callback raised if there is an issue to load the texture
  46567. * @param format defines the format of the data
  46568. * @param forcedExtension defines the extension to use to pick the right loader
  46569. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46570. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46571. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46572. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46573. * @returns the cube texture as an InternalTexture
  46574. */
  46575. 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;
  46576. private _getSamplingFilter;
  46577. private static _GetNativeTextureFormat;
  46578. createRenderTargetTexture(size: number | {
  46579. width: number;
  46580. height: number;
  46581. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46582. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46583. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46584. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46585. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46586. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46587. /**
  46588. * Updates a dynamic vertex buffer.
  46589. * @param vertexBuffer the vertex buffer to update
  46590. * @param data the data used to update the vertex buffer
  46591. * @param byteOffset the byte offset of the data (optional)
  46592. * @param byteLength the byte length of the data (optional)
  46593. */
  46594. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46595. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46596. private _updateAnisotropicLevel;
  46597. private _getAddressMode;
  46598. /** @hidden */
  46599. _bindTexture(channel: number, texture: InternalTexture): void;
  46600. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46601. releaseEffects(): void;
  46602. /** @hidden */
  46603. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46604. /** @hidden */
  46605. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46606. /** @hidden */
  46607. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46608. /** @hidden */
  46609. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46610. }
  46611. }
  46612. declare module "babylonjs/Engines/index" {
  46613. export * from "babylonjs/Engines/constants";
  46614. export * from "babylonjs/Engines/engineCapabilities";
  46615. export * from "babylonjs/Engines/instancingAttributeInfo";
  46616. export * from "babylonjs/Engines/thinEngine";
  46617. export * from "babylonjs/Engines/engine";
  46618. export * from "babylonjs/Engines/engineStore";
  46619. export * from "babylonjs/Engines/nullEngine";
  46620. export * from "babylonjs/Engines/Extensions/index";
  46621. export * from "babylonjs/Engines/IPipelineContext";
  46622. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46623. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46624. export * from "babylonjs/Engines/nativeEngine";
  46625. }
  46626. declare module "babylonjs/Events/clipboardEvents" {
  46627. /**
  46628. * Gather the list of clipboard event types as constants.
  46629. */
  46630. export class ClipboardEventTypes {
  46631. /**
  46632. * The clipboard event is fired when a copy command is active (pressed).
  46633. */
  46634. static readonly COPY: number;
  46635. /**
  46636. * The clipboard event is fired when a cut command is active (pressed).
  46637. */
  46638. static readonly CUT: number;
  46639. /**
  46640. * The clipboard event is fired when a paste command is active (pressed).
  46641. */
  46642. static readonly PASTE: number;
  46643. }
  46644. /**
  46645. * This class is used to store clipboard related info for the onClipboardObservable event.
  46646. */
  46647. export class ClipboardInfo {
  46648. /**
  46649. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46650. */
  46651. type: number;
  46652. /**
  46653. * Defines the related dom event
  46654. */
  46655. event: ClipboardEvent;
  46656. /**
  46657. *Creates an instance of ClipboardInfo.
  46658. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46659. * @param event Defines the related dom event
  46660. */
  46661. constructor(
  46662. /**
  46663. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46664. */
  46665. type: number,
  46666. /**
  46667. * Defines the related dom event
  46668. */
  46669. event: ClipboardEvent);
  46670. /**
  46671. * Get the clipboard event's type from the keycode.
  46672. * @param keyCode Defines the keyCode for the current keyboard event.
  46673. * @return {number}
  46674. */
  46675. static GetTypeFromCharacter(keyCode: number): number;
  46676. }
  46677. }
  46678. declare module "babylonjs/Events/index" {
  46679. export * from "babylonjs/Events/keyboardEvents";
  46680. export * from "babylonjs/Events/pointerEvents";
  46681. export * from "babylonjs/Events/clipboardEvents";
  46682. }
  46683. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46684. import { Scene } from "babylonjs/scene";
  46685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46686. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46687. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46688. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46689. /**
  46690. * Google Daydream controller
  46691. */
  46692. export class DaydreamController extends WebVRController {
  46693. /**
  46694. * Base Url for the controller model.
  46695. */
  46696. static MODEL_BASE_URL: string;
  46697. /**
  46698. * File name for the controller model.
  46699. */
  46700. static MODEL_FILENAME: string;
  46701. /**
  46702. * Gamepad Id prefix used to identify Daydream Controller.
  46703. */
  46704. static readonly GAMEPAD_ID_PREFIX: string;
  46705. /**
  46706. * Creates a new DaydreamController from a gamepad
  46707. * @param vrGamepad the gamepad that the controller should be created from
  46708. */
  46709. constructor(vrGamepad: any);
  46710. /**
  46711. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46712. * @param scene scene in which to add meshes
  46713. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46714. */
  46715. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46716. /**
  46717. * Called once for each button that changed state since the last frame
  46718. * @param buttonIdx Which button index changed
  46719. * @param state New state of the button
  46720. * @param changes Which properties on the state changed since last frame
  46721. */
  46722. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46723. }
  46724. }
  46725. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46726. import { Scene } from "babylonjs/scene";
  46727. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46728. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46729. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46730. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46731. /**
  46732. * Gear VR Controller
  46733. */
  46734. export class GearVRController extends WebVRController {
  46735. /**
  46736. * Base Url for the controller model.
  46737. */
  46738. static MODEL_BASE_URL: string;
  46739. /**
  46740. * File name for the controller model.
  46741. */
  46742. static MODEL_FILENAME: string;
  46743. /**
  46744. * Gamepad Id prefix used to identify this controller.
  46745. */
  46746. static readonly GAMEPAD_ID_PREFIX: string;
  46747. private readonly _buttonIndexToObservableNameMap;
  46748. /**
  46749. * Creates a new GearVRController from a gamepad
  46750. * @param vrGamepad the gamepad that the controller should be created from
  46751. */
  46752. constructor(vrGamepad: any);
  46753. /**
  46754. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46755. * @param scene scene in which to add meshes
  46756. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46757. */
  46758. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46759. /**
  46760. * Called once for each button that changed state since the last frame
  46761. * @param buttonIdx Which button index changed
  46762. * @param state New state of the button
  46763. * @param changes Which properties on the state changed since last frame
  46764. */
  46765. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46766. }
  46767. }
  46768. declare module "babylonjs/Gamepads/Controllers/index" {
  46769. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46770. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46771. export * from "babylonjs/Gamepads/Controllers/genericController";
  46772. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46773. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46774. export * from "babylonjs/Gamepads/Controllers/viveController";
  46775. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46776. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46777. }
  46778. declare module "babylonjs/Gamepads/index" {
  46779. export * from "babylonjs/Gamepads/Controllers/index";
  46780. export * from "babylonjs/Gamepads/gamepad";
  46781. export * from "babylonjs/Gamepads/gamepadManager";
  46782. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46783. export * from "babylonjs/Gamepads/xboxGamepad";
  46784. export * from "babylonjs/Gamepads/dualShockGamepad";
  46785. }
  46786. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46787. import { Scene } from "babylonjs/scene";
  46788. import { Vector4 } from "babylonjs/Maths/math.vector";
  46789. import { Color4 } from "babylonjs/Maths/math.color";
  46790. import { Mesh } from "babylonjs/Meshes/mesh";
  46791. import { Nullable } from "babylonjs/types";
  46792. /**
  46793. * Class containing static functions to help procedurally build meshes
  46794. */
  46795. export class PolyhedronBuilder {
  46796. /**
  46797. * Creates a polyhedron mesh
  46798. * * 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
  46799. * * The parameter `size` (positive float, default 1) sets the polygon size
  46800. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46801. * * 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`
  46802. * * 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
  46803. * * 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)`)
  46804. * * 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
  46805. * * 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
  46806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46807. * * 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
  46808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46809. * @param name defines the name of the mesh
  46810. * @param options defines the options used to create the mesh
  46811. * @param scene defines the hosting scene
  46812. * @returns the polyhedron mesh
  46813. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46814. */
  46815. static CreatePolyhedron(name: string, options: {
  46816. type?: number;
  46817. size?: number;
  46818. sizeX?: number;
  46819. sizeY?: number;
  46820. sizeZ?: number;
  46821. custom?: any;
  46822. faceUV?: Vector4[];
  46823. faceColors?: Color4[];
  46824. flat?: boolean;
  46825. updatable?: boolean;
  46826. sideOrientation?: number;
  46827. frontUVs?: Vector4;
  46828. backUVs?: Vector4;
  46829. }, scene?: Nullable<Scene>): Mesh;
  46830. }
  46831. }
  46832. declare module "babylonjs/Gizmos/scaleGizmo" {
  46833. import { Observable } from "babylonjs/Misc/observable";
  46834. import { Nullable } from "babylonjs/types";
  46835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46836. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46837. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46838. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46839. /**
  46840. * Gizmo that enables scaling a mesh along 3 axis
  46841. */
  46842. export class ScaleGizmo extends Gizmo {
  46843. /**
  46844. * Internal gizmo used for interactions on the x axis
  46845. */
  46846. xGizmo: AxisScaleGizmo;
  46847. /**
  46848. * Internal gizmo used for interactions on the y axis
  46849. */
  46850. yGizmo: AxisScaleGizmo;
  46851. /**
  46852. * Internal gizmo used for interactions on the z axis
  46853. */
  46854. zGizmo: AxisScaleGizmo;
  46855. /**
  46856. * Internal gizmo used to scale all axis equally
  46857. */
  46858. uniformScaleGizmo: AxisScaleGizmo;
  46859. private _meshAttached;
  46860. private _updateGizmoRotationToMatchAttachedMesh;
  46861. private _snapDistance;
  46862. private _scaleRatio;
  46863. private _uniformScalingMesh;
  46864. private _octahedron;
  46865. /** Fires an event when any of it's sub gizmos are dragged */
  46866. onDragStartObservable: Observable<unknown>;
  46867. /** Fires an event when any of it's sub gizmos are released from dragging */
  46868. onDragEndObservable: Observable<unknown>;
  46869. attachedMesh: Nullable<AbstractMesh>;
  46870. /**
  46871. * Creates a ScaleGizmo
  46872. * @param gizmoLayer The utility layer the gizmo will be added to
  46873. */
  46874. constructor(gizmoLayer?: UtilityLayerRenderer);
  46875. updateGizmoRotationToMatchAttachedMesh: boolean;
  46876. /**
  46877. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46878. */
  46879. snapDistance: number;
  46880. /**
  46881. * Ratio for the scale of the gizmo (Default: 1)
  46882. */
  46883. scaleRatio: number;
  46884. /**
  46885. * Disposes of the gizmo
  46886. */
  46887. dispose(): void;
  46888. }
  46889. }
  46890. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46891. import { Observable } from "babylonjs/Misc/observable";
  46892. import { Nullable } from "babylonjs/types";
  46893. import { Vector3 } from "babylonjs/Maths/math.vector";
  46894. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46895. import { Mesh } from "babylonjs/Meshes/mesh";
  46896. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46897. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46898. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46899. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46900. import { Color3 } from "babylonjs/Maths/math.color";
  46901. /**
  46902. * Single axis scale gizmo
  46903. */
  46904. export class AxisScaleGizmo extends Gizmo {
  46905. /**
  46906. * Drag behavior responsible for the gizmos dragging interactions
  46907. */
  46908. dragBehavior: PointerDragBehavior;
  46909. private _pointerObserver;
  46910. /**
  46911. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46912. */
  46913. snapDistance: number;
  46914. /**
  46915. * Event that fires each time the gizmo snaps to a new location.
  46916. * * snapDistance is the the change in distance
  46917. */
  46918. onSnapObservable: Observable<{
  46919. snapDistance: number;
  46920. }>;
  46921. /**
  46922. * If the scaling operation should be done on all axis (default: false)
  46923. */
  46924. uniformScaling: boolean;
  46925. private _isEnabled;
  46926. private _parent;
  46927. private _arrow;
  46928. private _coloredMaterial;
  46929. private _hoverMaterial;
  46930. /**
  46931. * Creates an AxisScaleGizmo
  46932. * @param gizmoLayer The utility layer the gizmo will be added to
  46933. * @param dragAxis The axis which the gizmo will be able to scale on
  46934. * @param color The color of the gizmo
  46935. */
  46936. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46937. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46938. /**
  46939. * If the gizmo is enabled
  46940. */
  46941. isEnabled: boolean;
  46942. /**
  46943. * Disposes of the gizmo
  46944. */
  46945. dispose(): void;
  46946. /**
  46947. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46948. * @param mesh The mesh to replace the default mesh of the gizmo
  46949. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46950. */
  46951. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46952. }
  46953. }
  46954. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46955. import { Observable } from "babylonjs/Misc/observable";
  46956. import { Nullable } from "babylonjs/types";
  46957. import { Vector3 } from "babylonjs/Maths/math.vector";
  46958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46959. import { Mesh } from "babylonjs/Meshes/mesh";
  46960. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46961. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46962. import { Color3 } from "babylonjs/Maths/math.color";
  46963. import "babylonjs/Meshes/Builders/boxBuilder";
  46964. /**
  46965. * Bounding box gizmo
  46966. */
  46967. export class BoundingBoxGizmo extends Gizmo {
  46968. private _lineBoundingBox;
  46969. private _rotateSpheresParent;
  46970. private _scaleBoxesParent;
  46971. private _boundingDimensions;
  46972. private _renderObserver;
  46973. private _pointerObserver;
  46974. private _scaleDragSpeed;
  46975. private _tmpQuaternion;
  46976. private _tmpVector;
  46977. private _tmpRotationMatrix;
  46978. /**
  46979. * 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)
  46980. */
  46981. ignoreChildren: boolean;
  46982. /**
  46983. * 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)
  46984. */
  46985. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46986. /**
  46987. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46988. */
  46989. rotationSphereSize: number;
  46990. /**
  46991. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46992. */
  46993. scaleBoxSize: number;
  46994. /**
  46995. * 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)
  46996. */
  46997. fixedDragMeshScreenSize: boolean;
  46998. /**
  46999. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47000. */
  47001. fixedDragMeshScreenSizeDistanceFactor: number;
  47002. /**
  47003. * Fired when a rotation sphere or scale box is dragged
  47004. */
  47005. onDragStartObservable: Observable<{}>;
  47006. /**
  47007. * Fired when a scale box is dragged
  47008. */
  47009. onScaleBoxDragObservable: Observable<{}>;
  47010. /**
  47011. * Fired when a scale box drag is ended
  47012. */
  47013. onScaleBoxDragEndObservable: Observable<{}>;
  47014. /**
  47015. * Fired when a rotation sphere is dragged
  47016. */
  47017. onRotationSphereDragObservable: Observable<{}>;
  47018. /**
  47019. * Fired when a rotation sphere drag is ended
  47020. */
  47021. onRotationSphereDragEndObservable: Observable<{}>;
  47022. /**
  47023. * 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)
  47024. */
  47025. scalePivot: Nullable<Vector3>;
  47026. /**
  47027. * Mesh used as a pivot to rotate the attached mesh
  47028. */
  47029. private _anchorMesh;
  47030. private _existingMeshScale;
  47031. private _dragMesh;
  47032. private pointerDragBehavior;
  47033. private coloredMaterial;
  47034. private hoverColoredMaterial;
  47035. /**
  47036. * Sets the color of the bounding box gizmo
  47037. * @param color the color to set
  47038. */
  47039. setColor(color: Color3): void;
  47040. /**
  47041. * Creates an BoundingBoxGizmo
  47042. * @param gizmoLayer The utility layer the gizmo will be added to
  47043. * @param color The color of the gizmo
  47044. */
  47045. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47046. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47047. private _selectNode;
  47048. /**
  47049. * Updates the bounding box information for the Gizmo
  47050. */
  47051. updateBoundingBox(): void;
  47052. private _updateRotationSpheres;
  47053. private _updateScaleBoxes;
  47054. /**
  47055. * Enables rotation on the specified axis and disables rotation on the others
  47056. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47057. */
  47058. setEnabledRotationAxis(axis: string): void;
  47059. /**
  47060. * Enables/disables scaling
  47061. * @param enable if scaling should be enabled
  47062. */
  47063. setEnabledScaling(enable: boolean): void;
  47064. private _updateDummy;
  47065. /**
  47066. * Enables a pointer drag behavior on the bounding box of the gizmo
  47067. */
  47068. enableDragBehavior(): void;
  47069. /**
  47070. * Disposes of the gizmo
  47071. */
  47072. dispose(): void;
  47073. /**
  47074. * 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)
  47075. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47076. * @returns the bounding box mesh with the passed in mesh as a child
  47077. */
  47078. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47079. /**
  47080. * CustomMeshes are not supported by this gizmo
  47081. * @param mesh The mesh to replace the default mesh of the gizmo
  47082. */
  47083. setCustomMesh(mesh: Mesh): void;
  47084. }
  47085. }
  47086. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47087. import { Observable } from "babylonjs/Misc/observable";
  47088. import { Nullable } from "babylonjs/types";
  47089. import { Vector3 } from "babylonjs/Maths/math.vector";
  47090. import { Color3 } from "babylonjs/Maths/math.color";
  47091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47092. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47093. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47094. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47095. import "babylonjs/Meshes/Builders/linesBuilder";
  47096. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47097. /**
  47098. * Single plane rotation gizmo
  47099. */
  47100. export class PlaneRotationGizmo extends Gizmo {
  47101. /**
  47102. * Drag behavior responsible for the gizmos dragging interactions
  47103. */
  47104. dragBehavior: PointerDragBehavior;
  47105. private _pointerObserver;
  47106. /**
  47107. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47108. */
  47109. snapDistance: number;
  47110. /**
  47111. * Event that fires each time the gizmo snaps to a new location.
  47112. * * snapDistance is the the change in distance
  47113. */
  47114. onSnapObservable: Observable<{
  47115. snapDistance: number;
  47116. }>;
  47117. private _isEnabled;
  47118. private _parent;
  47119. /**
  47120. * Creates a PlaneRotationGizmo
  47121. * @param gizmoLayer The utility layer the gizmo will be added to
  47122. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47123. * @param color The color of the gizmo
  47124. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47125. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47126. */
  47127. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47128. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47129. /**
  47130. * If the gizmo is enabled
  47131. */
  47132. isEnabled: boolean;
  47133. /**
  47134. * Disposes of the gizmo
  47135. */
  47136. dispose(): void;
  47137. }
  47138. }
  47139. declare module "babylonjs/Gizmos/rotationGizmo" {
  47140. import { Observable } from "babylonjs/Misc/observable";
  47141. import { Nullable } from "babylonjs/types";
  47142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47143. import { Mesh } from "babylonjs/Meshes/mesh";
  47144. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47145. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47146. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47147. /**
  47148. * Gizmo that enables rotating a mesh along 3 axis
  47149. */
  47150. export class RotationGizmo extends Gizmo {
  47151. /**
  47152. * Internal gizmo used for interactions on the x axis
  47153. */
  47154. xGizmo: PlaneRotationGizmo;
  47155. /**
  47156. * Internal gizmo used for interactions on the y axis
  47157. */
  47158. yGizmo: PlaneRotationGizmo;
  47159. /**
  47160. * Internal gizmo used for interactions on the z axis
  47161. */
  47162. zGizmo: PlaneRotationGizmo;
  47163. /** Fires an event when any of it's sub gizmos are dragged */
  47164. onDragStartObservable: Observable<unknown>;
  47165. /** Fires an event when any of it's sub gizmos are released from dragging */
  47166. onDragEndObservable: Observable<unknown>;
  47167. private _meshAttached;
  47168. attachedMesh: Nullable<AbstractMesh>;
  47169. /**
  47170. * Creates a RotationGizmo
  47171. * @param gizmoLayer The utility layer the gizmo will be added to
  47172. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47173. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47174. */
  47175. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47176. updateGizmoRotationToMatchAttachedMesh: boolean;
  47177. /**
  47178. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47179. */
  47180. snapDistance: number;
  47181. /**
  47182. * Ratio for the scale of the gizmo (Default: 1)
  47183. */
  47184. scaleRatio: number;
  47185. /**
  47186. * Disposes of the gizmo
  47187. */
  47188. dispose(): void;
  47189. /**
  47190. * CustomMeshes are not supported by this gizmo
  47191. * @param mesh The mesh to replace the default mesh of the gizmo
  47192. */
  47193. setCustomMesh(mesh: Mesh): void;
  47194. }
  47195. }
  47196. declare module "babylonjs/Gizmos/gizmoManager" {
  47197. import { Observable } from "babylonjs/Misc/observable";
  47198. import { Nullable } from "babylonjs/types";
  47199. import { Scene, IDisposable } from "babylonjs/scene";
  47200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47201. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47202. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47203. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47204. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47205. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47206. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47207. /**
  47208. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47209. */
  47210. export class GizmoManager implements IDisposable {
  47211. private scene;
  47212. /**
  47213. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47214. */
  47215. gizmos: {
  47216. positionGizmo: Nullable<PositionGizmo>;
  47217. rotationGizmo: Nullable<RotationGizmo>;
  47218. scaleGizmo: Nullable<ScaleGizmo>;
  47219. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47220. };
  47221. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47222. clearGizmoOnEmptyPointerEvent: boolean;
  47223. /** Fires an event when the manager is attached to a mesh */
  47224. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47225. private _gizmosEnabled;
  47226. private _pointerObserver;
  47227. private _attachedMesh;
  47228. private _boundingBoxColor;
  47229. private _defaultUtilityLayer;
  47230. private _defaultKeepDepthUtilityLayer;
  47231. /**
  47232. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47233. */
  47234. boundingBoxDragBehavior: SixDofDragBehavior;
  47235. /**
  47236. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47237. */
  47238. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47239. /**
  47240. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47241. */
  47242. usePointerToAttachGizmos: boolean;
  47243. /**
  47244. * Utility layer that the bounding box gizmo belongs to
  47245. */
  47246. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47247. /**
  47248. * Utility layer that all gizmos besides bounding box belong to
  47249. */
  47250. readonly utilityLayer: UtilityLayerRenderer;
  47251. /**
  47252. * Instatiates a gizmo manager
  47253. * @param scene the scene to overlay the gizmos on top of
  47254. */
  47255. constructor(scene: Scene);
  47256. /**
  47257. * Attaches a set of gizmos to the specified mesh
  47258. * @param mesh The mesh the gizmo's should be attached to
  47259. */
  47260. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47261. /**
  47262. * If the position gizmo is enabled
  47263. */
  47264. positionGizmoEnabled: boolean;
  47265. /**
  47266. * If the rotation gizmo is enabled
  47267. */
  47268. rotationGizmoEnabled: boolean;
  47269. /**
  47270. * If the scale gizmo is enabled
  47271. */
  47272. scaleGizmoEnabled: boolean;
  47273. /**
  47274. * If the boundingBox gizmo is enabled
  47275. */
  47276. boundingBoxGizmoEnabled: boolean;
  47277. /**
  47278. * Disposes of the gizmo manager
  47279. */
  47280. dispose(): void;
  47281. }
  47282. }
  47283. declare module "babylonjs/Lights/directionalLight" {
  47284. import { Camera } from "babylonjs/Cameras/camera";
  47285. import { Scene } from "babylonjs/scene";
  47286. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47288. import { Light } from "babylonjs/Lights/light";
  47289. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47290. import { Effect } from "babylonjs/Materials/effect";
  47291. /**
  47292. * A directional light is defined by a direction (what a surprise!).
  47293. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47294. * 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.
  47295. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47296. */
  47297. export class DirectionalLight extends ShadowLight {
  47298. private _shadowFrustumSize;
  47299. /**
  47300. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47301. */
  47302. /**
  47303. * Specifies a fix frustum size for the shadow generation.
  47304. */
  47305. shadowFrustumSize: number;
  47306. private _shadowOrthoScale;
  47307. /**
  47308. * Gets the shadow projection scale against the optimal computed one.
  47309. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47310. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47311. */
  47312. /**
  47313. * Sets the shadow projection scale against the optimal computed one.
  47314. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47315. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47316. */
  47317. shadowOrthoScale: number;
  47318. /**
  47319. * Automatically compute the projection matrix to best fit (including all the casters)
  47320. * on each frame.
  47321. */
  47322. autoUpdateExtends: boolean;
  47323. private _orthoLeft;
  47324. private _orthoRight;
  47325. private _orthoTop;
  47326. private _orthoBottom;
  47327. /**
  47328. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47329. * The directional light is emitted from everywhere in the given direction.
  47330. * It can cast shadows.
  47331. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47332. * @param name The friendly name of the light
  47333. * @param direction The direction of the light
  47334. * @param scene The scene the light belongs to
  47335. */
  47336. constructor(name: string, direction: Vector3, scene: Scene);
  47337. /**
  47338. * Returns the string "DirectionalLight".
  47339. * @return The class name
  47340. */
  47341. getClassName(): string;
  47342. /**
  47343. * Returns the integer 1.
  47344. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47345. */
  47346. getTypeID(): number;
  47347. /**
  47348. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47349. * Returns the DirectionalLight Shadow projection matrix.
  47350. */
  47351. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47352. /**
  47353. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47354. * Returns the DirectionalLight Shadow projection matrix.
  47355. */
  47356. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47357. /**
  47358. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47359. * Returns the DirectionalLight Shadow projection matrix.
  47360. */
  47361. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47362. protected _buildUniformLayout(): void;
  47363. /**
  47364. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47365. * @param effect The effect to update
  47366. * @param lightIndex The index of the light in the effect to update
  47367. * @returns The directional light
  47368. */
  47369. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47370. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47371. /**
  47372. * Gets the minZ used for shadow according to both the scene and the light.
  47373. *
  47374. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47375. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47376. * @param activeCamera The camera we are returning the min for
  47377. * @returns the depth min z
  47378. */
  47379. getDepthMinZ(activeCamera: Camera): number;
  47380. /**
  47381. * Gets the maxZ used for shadow according to both the scene and the light.
  47382. *
  47383. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47384. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47385. * @param activeCamera The camera we are returning the max for
  47386. * @returns the depth max z
  47387. */
  47388. getDepthMaxZ(activeCamera: Camera): number;
  47389. /**
  47390. * Prepares the list of defines specific to the light type.
  47391. * @param defines the list of defines
  47392. * @param lightIndex defines the index of the light for the effect
  47393. */
  47394. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47395. }
  47396. }
  47397. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47398. import { Mesh } from "babylonjs/Meshes/mesh";
  47399. /**
  47400. * Class containing static functions to help procedurally build meshes
  47401. */
  47402. export class HemisphereBuilder {
  47403. /**
  47404. * Creates a hemisphere mesh
  47405. * @param name defines the name of the mesh
  47406. * @param options defines the options used to create the mesh
  47407. * @param scene defines the hosting scene
  47408. * @returns the hemisphere mesh
  47409. */
  47410. static CreateHemisphere(name: string, options: {
  47411. segments?: number;
  47412. diameter?: number;
  47413. sideOrientation?: number;
  47414. }, scene: any): Mesh;
  47415. }
  47416. }
  47417. declare module "babylonjs/Lights/spotLight" {
  47418. import { Nullable } from "babylonjs/types";
  47419. import { Scene } from "babylonjs/scene";
  47420. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47422. import { Effect } from "babylonjs/Materials/effect";
  47423. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47424. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47425. /**
  47426. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47427. * These values define a cone of light starting from the position, emitting toward the direction.
  47428. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47429. * and the exponent defines the speed of the decay of the light with distance (reach).
  47430. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47431. */
  47432. export class SpotLight extends ShadowLight {
  47433. private _angle;
  47434. private _innerAngle;
  47435. private _cosHalfAngle;
  47436. private _lightAngleScale;
  47437. private _lightAngleOffset;
  47438. /**
  47439. * Gets the cone angle of the spot light in Radians.
  47440. */
  47441. /**
  47442. * Sets the cone angle of the spot light in Radians.
  47443. */
  47444. angle: number;
  47445. /**
  47446. * Only used in gltf falloff mode, this defines the angle where
  47447. * the directional falloff will start before cutting at angle which could be seen
  47448. * as outer angle.
  47449. */
  47450. /**
  47451. * Only used in gltf falloff mode, this defines the angle where
  47452. * the directional falloff will start before cutting at angle which could be seen
  47453. * as outer angle.
  47454. */
  47455. innerAngle: number;
  47456. private _shadowAngleScale;
  47457. /**
  47458. * Allows scaling the angle of the light for shadow generation only.
  47459. */
  47460. /**
  47461. * Allows scaling the angle of the light for shadow generation only.
  47462. */
  47463. shadowAngleScale: number;
  47464. /**
  47465. * The light decay speed with the distance from the emission spot.
  47466. */
  47467. exponent: number;
  47468. private _projectionTextureMatrix;
  47469. /**
  47470. * Allows reading the projecton texture
  47471. */
  47472. readonly projectionTextureMatrix: Matrix;
  47473. protected _projectionTextureLightNear: number;
  47474. /**
  47475. * Gets the near clip of the Spotlight for texture projection.
  47476. */
  47477. /**
  47478. * Sets the near clip of the Spotlight for texture projection.
  47479. */
  47480. projectionTextureLightNear: number;
  47481. protected _projectionTextureLightFar: number;
  47482. /**
  47483. * Gets the far clip of the Spotlight for texture projection.
  47484. */
  47485. /**
  47486. * Sets the far clip of the Spotlight for texture projection.
  47487. */
  47488. projectionTextureLightFar: number;
  47489. protected _projectionTextureUpDirection: Vector3;
  47490. /**
  47491. * Gets the Up vector of the Spotlight for texture projection.
  47492. */
  47493. /**
  47494. * Sets the Up vector of the Spotlight for texture projection.
  47495. */
  47496. projectionTextureUpDirection: Vector3;
  47497. private _projectionTexture;
  47498. /**
  47499. * Gets the projection texture of the light.
  47500. */
  47501. /**
  47502. * Sets the projection texture of the light.
  47503. */
  47504. projectionTexture: Nullable<BaseTexture>;
  47505. private _projectionTextureViewLightDirty;
  47506. private _projectionTextureProjectionLightDirty;
  47507. private _projectionTextureDirty;
  47508. private _projectionTextureViewTargetVector;
  47509. private _projectionTextureViewLightMatrix;
  47510. private _projectionTextureProjectionLightMatrix;
  47511. private _projectionTextureScalingMatrix;
  47512. /**
  47513. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47514. * It can cast shadows.
  47515. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47516. * @param name The light friendly name
  47517. * @param position The position of the spot light in the scene
  47518. * @param direction The direction of the light in the scene
  47519. * @param angle The cone angle of the light in Radians
  47520. * @param exponent The light decay speed with the distance from the emission spot
  47521. * @param scene The scene the lights belongs to
  47522. */
  47523. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47524. /**
  47525. * Returns the string "SpotLight".
  47526. * @returns the class name
  47527. */
  47528. getClassName(): string;
  47529. /**
  47530. * Returns the integer 2.
  47531. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47532. */
  47533. getTypeID(): number;
  47534. /**
  47535. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47536. */
  47537. protected _setDirection(value: Vector3): void;
  47538. /**
  47539. * Overrides the position setter to recompute the projection texture view light Matrix.
  47540. */
  47541. protected _setPosition(value: Vector3): void;
  47542. /**
  47543. * 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.
  47544. * Returns the SpotLight.
  47545. */
  47546. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47547. protected _computeProjectionTextureViewLightMatrix(): void;
  47548. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47549. /**
  47550. * Main function for light texture projection matrix computing.
  47551. */
  47552. protected _computeProjectionTextureMatrix(): void;
  47553. protected _buildUniformLayout(): void;
  47554. private _computeAngleValues;
  47555. /**
  47556. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47557. * @param effect The effect to update
  47558. * @param lightIndex The index of the light in the effect to update
  47559. * @returns The spot light
  47560. */
  47561. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47562. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47563. /**
  47564. * Disposes the light and the associated resources.
  47565. */
  47566. dispose(): void;
  47567. /**
  47568. * Prepares the list of defines specific to the light type.
  47569. * @param defines the list of defines
  47570. * @param lightIndex defines the index of the light for the effect
  47571. */
  47572. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47573. }
  47574. }
  47575. declare module "babylonjs/Gizmos/lightGizmo" {
  47576. import { Nullable } from "babylonjs/types";
  47577. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47578. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47579. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47580. import { Light } from "babylonjs/Lights/light";
  47581. /**
  47582. * Gizmo that enables viewing a light
  47583. */
  47584. export class LightGizmo extends Gizmo {
  47585. private _lightMesh;
  47586. private _material;
  47587. private cachedPosition;
  47588. private cachedForward;
  47589. /**
  47590. * Creates a LightGizmo
  47591. * @param gizmoLayer The utility layer the gizmo will be added to
  47592. */
  47593. constructor(gizmoLayer?: UtilityLayerRenderer);
  47594. private _light;
  47595. /**
  47596. * The light that the gizmo is attached to
  47597. */
  47598. light: Nullable<Light>;
  47599. /**
  47600. * Gets the material used to render the light gizmo
  47601. */
  47602. readonly material: StandardMaterial;
  47603. /**
  47604. * @hidden
  47605. * Updates the gizmo to match the attached mesh's position/rotation
  47606. */
  47607. protected _update(): void;
  47608. private static _Scale;
  47609. /**
  47610. * Creates the lines for a light mesh
  47611. */
  47612. private static _createLightLines;
  47613. /**
  47614. * Disposes of the light gizmo
  47615. */
  47616. dispose(): void;
  47617. private static _CreateHemisphericLightMesh;
  47618. private static _CreatePointLightMesh;
  47619. private static _CreateSpotLightMesh;
  47620. private static _CreateDirectionalLightMesh;
  47621. }
  47622. }
  47623. declare module "babylonjs/Gizmos/index" {
  47624. export * from "babylonjs/Gizmos/axisDragGizmo";
  47625. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47626. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47627. export * from "babylonjs/Gizmos/gizmo";
  47628. export * from "babylonjs/Gizmos/gizmoManager";
  47629. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47630. export * from "babylonjs/Gizmos/positionGizmo";
  47631. export * from "babylonjs/Gizmos/rotationGizmo";
  47632. export * from "babylonjs/Gizmos/scaleGizmo";
  47633. export * from "babylonjs/Gizmos/lightGizmo";
  47634. export * from "babylonjs/Gizmos/planeDragGizmo";
  47635. }
  47636. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47637. /** @hidden */
  47638. export var backgroundFragmentDeclaration: {
  47639. name: string;
  47640. shader: string;
  47641. };
  47642. }
  47643. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47644. /** @hidden */
  47645. export var backgroundUboDeclaration: {
  47646. name: string;
  47647. shader: string;
  47648. };
  47649. }
  47650. declare module "babylonjs/Shaders/background.fragment" {
  47651. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47652. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47653. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47654. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47655. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47656. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47657. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47658. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47659. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47660. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47661. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47662. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47663. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47664. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47665. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47666. /** @hidden */
  47667. export var backgroundPixelShader: {
  47668. name: string;
  47669. shader: string;
  47670. };
  47671. }
  47672. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47673. /** @hidden */
  47674. export var backgroundVertexDeclaration: {
  47675. name: string;
  47676. shader: string;
  47677. };
  47678. }
  47679. declare module "babylonjs/Shaders/background.vertex" {
  47680. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47681. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47682. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47683. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47684. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47685. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47686. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47687. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47688. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47689. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47690. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47691. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47692. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47693. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47694. /** @hidden */
  47695. export var backgroundVertexShader: {
  47696. name: string;
  47697. shader: string;
  47698. };
  47699. }
  47700. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47701. import { Nullable, int, float } from "babylonjs/types";
  47702. import { Scene } from "babylonjs/scene";
  47703. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47704. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47706. import { Mesh } from "babylonjs/Meshes/mesh";
  47707. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47708. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47709. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47710. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47711. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47712. import { Color3 } from "babylonjs/Maths/math.color";
  47713. import "babylonjs/Shaders/background.fragment";
  47714. import "babylonjs/Shaders/background.vertex";
  47715. /**
  47716. * Background material used to create an efficient environement around your scene.
  47717. */
  47718. export class BackgroundMaterial extends PushMaterial {
  47719. /**
  47720. * Standard reflectance value at parallel view angle.
  47721. */
  47722. static StandardReflectance0: number;
  47723. /**
  47724. * Standard reflectance value at grazing angle.
  47725. */
  47726. static StandardReflectance90: number;
  47727. protected _primaryColor: Color3;
  47728. /**
  47729. * Key light Color (multiply against the environement texture)
  47730. */
  47731. primaryColor: Color3;
  47732. protected __perceptualColor: Nullable<Color3>;
  47733. /**
  47734. * Experimental Internal Use Only.
  47735. *
  47736. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47737. * This acts as a helper to set the primary color to a more "human friendly" value.
  47738. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47739. * output color as close as possible from the chosen value.
  47740. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47741. * part of lighting setup.)
  47742. */
  47743. _perceptualColor: Nullable<Color3>;
  47744. protected _primaryColorShadowLevel: float;
  47745. /**
  47746. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47747. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47748. */
  47749. primaryColorShadowLevel: float;
  47750. protected _primaryColorHighlightLevel: float;
  47751. /**
  47752. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47753. * The primary color is used at the level chosen to define what the white area would look.
  47754. */
  47755. primaryColorHighlightLevel: float;
  47756. protected _reflectionTexture: Nullable<BaseTexture>;
  47757. /**
  47758. * Reflection Texture used in the material.
  47759. * Should be author in a specific way for the best result (refer to the documentation).
  47760. */
  47761. reflectionTexture: Nullable<BaseTexture>;
  47762. protected _reflectionBlur: float;
  47763. /**
  47764. * Reflection Texture level of blur.
  47765. *
  47766. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47767. * texture twice.
  47768. */
  47769. reflectionBlur: float;
  47770. protected _diffuseTexture: Nullable<BaseTexture>;
  47771. /**
  47772. * Diffuse Texture used in the material.
  47773. * Should be author in a specific way for the best result (refer to the documentation).
  47774. */
  47775. diffuseTexture: Nullable<BaseTexture>;
  47776. protected _shadowLights: Nullable<IShadowLight[]>;
  47777. /**
  47778. * Specify the list of lights casting shadow on the material.
  47779. * All scene shadow lights will be included if null.
  47780. */
  47781. shadowLights: Nullable<IShadowLight[]>;
  47782. protected _shadowLevel: float;
  47783. /**
  47784. * Helps adjusting the shadow to a softer level if required.
  47785. * 0 means black shadows and 1 means no shadows.
  47786. */
  47787. shadowLevel: float;
  47788. protected _sceneCenter: Vector3;
  47789. /**
  47790. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47791. * It is usually zero but might be interesting to modify according to your setup.
  47792. */
  47793. sceneCenter: Vector3;
  47794. protected _opacityFresnel: boolean;
  47795. /**
  47796. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47797. * This helps ensuring a nice transition when the camera goes under the ground.
  47798. */
  47799. opacityFresnel: boolean;
  47800. protected _reflectionFresnel: boolean;
  47801. /**
  47802. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47803. * This helps adding a mirror texture on the ground.
  47804. */
  47805. reflectionFresnel: boolean;
  47806. protected _reflectionFalloffDistance: number;
  47807. /**
  47808. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47809. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47810. */
  47811. reflectionFalloffDistance: number;
  47812. protected _reflectionAmount: number;
  47813. /**
  47814. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47815. */
  47816. reflectionAmount: number;
  47817. protected _reflectionReflectance0: number;
  47818. /**
  47819. * This specifies the weight of the reflection at grazing angle.
  47820. */
  47821. reflectionReflectance0: number;
  47822. protected _reflectionReflectance90: number;
  47823. /**
  47824. * This specifies the weight of the reflection at a perpendicular point of view.
  47825. */
  47826. reflectionReflectance90: number;
  47827. /**
  47828. * Sets the reflection reflectance fresnel values according to the default standard
  47829. * empirically know to work well :-)
  47830. */
  47831. reflectionStandardFresnelWeight: number;
  47832. protected _useRGBColor: boolean;
  47833. /**
  47834. * Helps to directly use the maps channels instead of their level.
  47835. */
  47836. useRGBColor: boolean;
  47837. protected _enableNoise: boolean;
  47838. /**
  47839. * This helps reducing the banding effect that could occur on the background.
  47840. */
  47841. enableNoise: boolean;
  47842. /**
  47843. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47844. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47845. * Recommended to be keep at 1.0 except for special cases.
  47846. */
  47847. fovMultiplier: number;
  47848. private _fovMultiplier;
  47849. /**
  47850. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47851. */
  47852. useEquirectangularFOV: boolean;
  47853. private _maxSimultaneousLights;
  47854. /**
  47855. * Number of Simultaneous lights allowed on the material.
  47856. */
  47857. maxSimultaneousLights: int;
  47858. /**
  47859. * Default configuration related to image processing available in the Background Material.
  47860. */
  47861. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47862. /**
  47863. * Keep track of the image processing observer to allow dispose and replace.
  47864. */
  47865. private _imageProcessingObserver;
  47866. /**
  47867. * Attaches a new image processing configuration to the PBR Material.
  47868. * @param configuration (if null the scene configuration will be use)
  47869. */
  47870. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47871. /**
  47872. * Gets the image processing configuration used either in this material.
  47873. */
  47874. /**
  47875. * Sets the Default image processing configuration used either in the this material.
  47876. *
  47877. * If sets to null, the scene one is in use.
  47878. */
  47879. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47880. /**
  47881. * Gets wether the color curves effect is enabled.
  47882. */
  47883. /**
  47884. * Sets wether the color curves effect is enabled.
  47885. */
  47886. cameraColorCurvesEnabled: boolean;
  47887. /**
  47888. * Gets wether the color grading effect is enabled.
  47889. */
  47890. /**
  47891. * Gets wether the color grading effect is enabled.
  47892. */
  47893. cameraColorGradingEnabled: boolean;
  47894. /**
  47895. * Gets wether tonemapping is enabled or not.
  47896. */
  47897. /**
  47898. * Sets wether tonemapping is enabled or not
  47899. */
  47900. cameraToneMappingEnabled: boolean;
  47901. /**
  47902. * The camera exposure used on this material.
  47903. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47904. * This corresponds to a photographic exposure.
  47905. */
  47906. /**
  47907. * The camera exposure used on this material.
  47908. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47909. * This corresponds to a photographic exposure.
  47910. */
  47911. cameraExposure: float;
  47912. /**
  47913. * Gets The camera contrast used on this material.
  47914. */
  47915. /**
  47916. * Sets The camera contrast used on this material.
  47917. */
  47918. cameraContrast: float;
  47919. /**
  47920. * Gets the Color Grading 2D Lookup Texture.
  47921. */
  47922. /**
  47923. * Sets the Color Grading 2D Lookup Texture.
  47924. */
  47925. cameraColorGradingTexture: Nullable<BaseTexture>;
  47926. /**
  47927. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47928. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47929. * 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;
  47930. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47931. */
  47932. /**
  47933. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47934. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47935. * 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;
  47936. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47937. */
  47938. cameraColorCurves: Nullable<ColorCurves>;
  47939. /**
  47940. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47941. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47942. */
  47943. switchToBGR: boolean;
  47944. private _renderTargets;
  47945. private _reflectionControls;
  47946. private _white;
  47947. private _primaryShadowColor;
  47948. private _primaryHighlightColor;
  47949. /**
  47950. * Instantiates a Background Material in the given scene
  47951. * @param name The friendly name of the material
  47952. * @param scene The scene to add the material to
  47953. */
  47954. constructor(name: string, scene: Scene);
  47955. /**
  47956. * Gets a boolean indicating that current material needs to register RTT
  47957. */
  47958. readonly hasRenderTargetTextures: boolean;
  47959. /**
  47960. * The entire material has been created in order to prevent overdraw.
  47961. * @returns false
  47962. */
  47963. needAlphaTesting(): boolean;
  47964. /**
  47965. * The entire material has been created in order to prevent overdraw.
  47966. * @returns true if blending is enable
  47967. */
  47968. needAlphaBlending(): boolean;
  47969. /**
  47970. * Checks wether the material is ready to be rendered for a given mesh.
  47971. * @param mesh The mesh to render
  47972. * @param subMesh The submesh to check against
  47973. * @param useInstances Specify wether or not the material is used with instances
  47974. * @returns true if all the dependencies are ready (Textures, Effects...)
  47975. */
  47976. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47977. /**
  47978. * Compute the primary color according to the chosen perceptual color.
  47979. */
  47980. private _computePrimaryColorFromPerceptualColor;
  47981. /**
  47982. * Compute the highlights and shadow colors according to their chosen levels.
  47983. */
  47984. private _computePrimaryColors;
  47985. /**
  47986. * Build the uniform buffer used in the material.
  47987. */
  47988. buildUniformLayout(): void;
  47989. /**
  47990. * Unbind the material.
  47991. */
  47992. unbind(): void;
  47993. /**
  47994. * Bind only the world matrix to the material.
  47995. * @param world The world matrix to bind.
  47996. */
  47997. bindOnlyWorldMatrix(world: Matrix): void;
  47998. /**
  47999. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48000. * @param world The world matrix to bind.
  48001. * @param subMesh The submesh to bind for.
  48002. */
  48003. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48004. /**
  48005. * Checks to see if a texture is used in the material.
  48006. * @param texture - Base texture to use.
  48007. * @returns - Boolean specifying if a texture is used in the material.
  48008. */
  48009. hasTexture(texture: BaseTexture): boolean;
  48010. /**
  48011. * Dispose the material.
  48012. * @param forceDisposeEffect Force disposal of the associated effect.
  48013. * @param forceDisposeTextures Force disposal of the associated textures.
  48014. */
  48015. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48016. /**
  48017. * Clones the material.
  48018. * @param name The cloned name.
  48019. * @returns The cloned material.
  48020. */
  48021. clone(name: string): BackgroundMaterial;
  48022. /**
  48023. * Serializes the current material to its JSON representation.
  48024. * @returns The JSON representation.
  48025. */
  48026. serialize(): any;
  48027. /**
  48028. * Gets the class name of the material
  48029. * @returns "BackgroundMaterial"
  48030. */
  48031. getClassName(): string;
  48032. /**
  48033. * Parse a JSON input to create back a background material.
  48034. * @param source The JSON data to parse
  48035. * @param scene The scene to create the parsed material in
  48036. * @param rootUrl The root url of the assets the material depends upon
  48037. * @returns the instantiated BackgroundMaterial.
  48038. */
  48039. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48040. }
  48041. }
  48042. declare module "babylonjs/Helpers/environmentHelper" {
  48043. import { Observable } from "babylonjs/Misc/observable";
  48044. import { Nullable } from "babylonjs/types";
  48045. import { Scene } from "babylonjs/scene";
  48046. import { Vector3 } from "babylonjs/Maths/math.vector";
  48047. import { Color3 } from "babylonjs/Maths/math.color";
  48048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48049. import { Mesh } from "babylonjs/Meshes/mesh";
  48050. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48051. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48052. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48053. import "babylonjs/Meshes/Builders/planeBuilder";
  48054. import "babylonjs/Meshes/Builders/boxBuilder";
  48055. /**
  48056. * Represents the different options available during the creation of
  48057. * a Environment helper.
  48058. *
  48059. * This can control the default ground, skybox and image processing setup of your scene.
  48060. */
  48061. export interface IEnvironmentHelperOptions {
  48062. /**
  48063. * Specifies wether or not to create a ground.
  48064. * True by default.
  48065. */
  48066. createGround: boolean;
  48067. /**
  48068. * Specifies the ground size.
  48069. * 15 by default.
  48070. */
  48071. groundSize: number;
  48072. /**
  48073. * The texture used on the ground for the main color.
  48074. * Comes from the BabylonJS CDN by default.
  48075. *
  48076. * Remarks: Can be either a texture or a url.
  48077. */
  48078. groundTexture: string | BaseTexture;
  48079. /**
  48080. * The color mixed in the ground texture by default.
  48081. * BabylonJS clearColor by default.
  48082. */
  48083. groundColor: Color3;
  48084. /**
  48085. * Specifies the ground opacity.
  48086. * 1 by default.
  48087. */
  48088. groundOpacity: number;
  48089. /**
  48090. * Enables the ground to receive shadows.
  48091. * True by default.
  48092. */
  48093. enableGroundShadow: boolean;
  48094. /**
  48095. * Helps preventing the shadow to be fully black on the ground.
  48096. * 0.5 by default.
  48097. */
  48098. groundShadowLevel: number;
  48099. /**
  48100. * Creates a mirror texture attach to the ground.
  48101. * false by default.
  48102. */
  48103. enableGroundMirror: boolean;
  48104. /**
  48105. * Specifies the ground mirror size ratio.
  48106. * 0.3 by default as the default kernel is 64.
  48107. */
  48108. groundMirrorSizeRatio: number;
  48109. /**
  48110. * Specifies the ground mirror blur kernel size.
  48111. * 64 by default.
  48112. */
  48113. groundMirrorBlurKernel: number;
  48114. /**
  48115. * Specifies the ground mirror visibility amount.
  48116. * 1 by default
  48117. */
  48118. groundMirrorAmount: number;
  48119. /**
  48120. * Specifies the ground mirror reflectance weight.
  48121. * This uses the standard weight of the background material to setup the fresnel effect
  48122. * of the mirror.
  48123. * 1 by default.
  48124. */
  48125. groundMirrorFresnelWeight: number;
  48126. /**
  48127. * Specifies the ground mirror Falloff distance.
  48128. * This can helps reducing the size of the reflection.
  48129. * 0 by Default.
  48130. */
  48131. groundMirrorFallOffDistance: number;
  48132. /**
  48133. * Specifies the ground mirror texture type.
  48134. * Unsigned Int by Default.
  48135. */
  48136. groundMirrorTextureType: number;
  48137. /**
  48138. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48139. * the shown objects.
  48140. */
  48141. groundYBias: number;
  48142. /**
  48143. * Specifies wether or not to create a skybox.
  48144. * True by default.
  48145. */
  48146. createSkybox: boolean;
  48147. /**
  48148. * Specifies the skybox size.
  48149. * 20 by default.
  48150. */
  48151. skyboxSize: number;
  48152. /**
  48153. * The texture used on the skybox for the main color.
  48154. * Comes from the BabylonJS CDN by default.
  48155. *
  48156. * Remarks: Can be either a texture or a url.
  48157. */
  48158. skyboxTexture: string | BaseTexture;
  48159. /**
  48160. * The color mixed in the skybox texture by default.
  48161. * BabylonJS clearColor by default.
  48162. */
  48163. skyboxColor: Color3;
  48164. /**
  48165. * The background rotation around the Y axis of the scene.
  48166. * This helps aligning the key lights of your scene with the background.
  48167. * 0 by default.
  48168. */
  48169. backgroundYRotation: number;
  48170. /**
  48171. * Compute automatically the size of the elements to best fit with the scene.
  48172. */
  48173. sizeAuto: boolean;
  48174. /**
  48175. * Default position of the rootMesh if autoSize is not true.
  48176. */
  48177. rootPosition: Vector3;
  48178. /**
  48179. * Sets up the image processing in the scene.
  48180. * true by default.
  48181. */
  48182. setupImageProcessing: boolean;
  48183. /**
  48184. * The texture used as your environment texture in the scene.
  48185. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48186. *
  48187. * Remarks: Can be either a texture or a url.
  48188. */
  48189. environmentTexture: string | BaseTexture;
  48190. /**
  48191. * The value of the exposure to apply to the scene.
  48192. * 0.6 by default if setupImageProcessing is true.
  48193. */
  48194. cameraExposure: number;
  48195. /**
  48196. * The value of the contrast to apply to the scene.
  48197. * 1.6 by default if setupImageProcessing is true.
  48198. */
  48199. cameraContrast: number;
  48200. /**
  48201. * Specifies wether or not tonemapping should be enabled in the scene.
  48202. * true by default if setupImageProcessing is true.
  48203. */
  48204. toneMappingEnabled: boolean;
  48205. }
  48206. /**
  48207. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48208. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48209. * It also helps with the default setup of your imageProcessing configuration.
  48210. */
  48211. export class EnvironmentHelper {
  48212. /**
  48213. * Default ground texture URL.
  48214. */
  48215. private static _groundTextureCDNUrl;
  48216. /**
  48217. * Default skybox texture URL.
  48218. */
  48219. private static _skyboxTextureCDNUrl;
  48220. /**
  48221. * Default environment texture URL.
  48222. */
  48223. private static _environmentTextureCDNUrl;
  48224. /**
  48225. * Creates the default options for the helper.
  48226. */
  48227. private static _getDefaultOptions;
  48228. private _rootMesh;
  48229. /**
  48230. * Gets the root mesh created by the helper.
  48231. */
  48232. readonly rootMesh: Mesh;
  48233. private _skybox;
  48234. /**
  48235. * Gets the skybox created by the helper.
  48236. */
  48237. readonly skybox: Nullable<Mesh>;
  48238. private _skyboxTexture;
  48239. /**
  48240. * Gets the skybox texture created by the helper.
  48241. */
  48242. readonly skyboxTexture: Nullable<BaseTexture>;
  48243. private _skyboxMaterial;
  48244. /**
  48245. * Gets the skybox material created by the helper.
  48246. */
  48247. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48248. private _ground;
  48249. /**
  48250. * Gets the ground mesh created by the helper.
  48251. */
  48252. readonly ground: Nullable<Mesh>;
  48253. private _groundTexture;
  48254. /**
  48255. * Gets the ground texture created by the helper.
  48256. */
  48257. readonly groundTexture: Nullable<BaseTexture>;
  48258. private _groundMirror;
  48259. /**
  48260. * Gets the ground mirror created by the helper.
  48261. */
  48262. readonly groundMirror: Nullable<MirrorTexture>;
  48263. /**
  48264. * Gets the ground mirror render list to helps pushing the meshes
  48265. * you wish in the ground reflection.
  48266. */
  48267. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48268. private _groundMaterial;
  48269. /**
  48270. * Gets the ground material created by the helper.
  48271. */
  48272. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48273. /**
  48274. * Stores the creation options.
  48275. */
  48276. private readonly _scene;
  48277. private _options;
  48278. /**
  48279. * This observable will be notified with any error during the creation of the environment,
  48280. * mainly texture creation errors.
  48281. */
  48282. onErrorObservable: Observable<{
  48283. message?: string;
  48284. exception?: any;
  48285. }>;
  48286. /**
  48287. * constructor
  48288. * @param options Defines the options we want to customize the helper
  48289. * @param scene The scene to add the material to
  48290. */
  48291. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48292. /**
  48293. * Updates the background according to the new options
  48294. * @param options
  48295. */
  48296. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48297. /**
  48298. * Sets the primary color of all the available elements.
  48299. * @param color the main color to affect to the ground and the background
  48300. */
  48301. setMainColor(color: Color3): void;
  48302. /**
  48303. * Setup the image processing according to the specified options.
  48304. */
  48305. private _setupImageProcessing;
  48306. /**
  48307. * Setup the environment texture according to the specified options.
  48308. */
  48309. private _setupEnvironmentTexture;
  48310. /**
  48311. * Setup the background according to the specified options.
  48312. */
  48313. private _setupBackground;
  48314. /**
  48315. * Get the scene sizes according to the setup.
  48316. */
  48317. private _getSceneSize;
  48318. /**
  48319. * Setup the ground according to the specified options.
  48320. */
  48321. private _setupGround;
  48322. /**
  48323. * Setup the ground material according to the specified options.
  48324. */
  48325. private _setupGroundMaterial;
  48326. /**
  48327. * Setup the ground diffuse texture according to the specified options.
  48328. */
  48329. private _setupGroundDiffuseTexture;
  48330. /**
  48331. * Setup the ground mirror texture according to the specified options.
  48332. */
  48333. private _setupGroundMirrorTexture;
  48334. /**
  48335. * Setup the ground to receive the mirror texture.
  48336. */
  48337. private _setupMirrorInGroundMaterial;
  48338. /**
  48339. * Setup the skybox according to the specified options.
  48340. */
  48341. private _setupSkybox;
  48342. /**
  48343. * Setup the skybox material according to the specified options.
  48344. */
  48345. private _setupSkyboxMaterial;
  48346. /**
  48347. * Setup the skybox reflection texture according to the specified options.
  48348. */
  48349. private _setupSkyboxReflectionTexture;
  48350. private _errorHandler;
  48351. /**
  48352. * Dispose all the elements created by the Helper.
  48353. */
  48354. dispose(): void;
  48355. }
  48356. }
  48357. declare module "babylonjs/Helpers/photoDome" {
  48358. import { Observable } from "babylonjs/Misc/observable";
  48359. import { Nullable } from "babylonjs/types";
  48360. import { Scene } from "babylonjs/scene";
  48361. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48362. import { Mesh } from "babylonjs/Meshes/mesh";
  48363. import { Texture } from "babylonjs/Materials/Textures/texture";
  48364. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48365. import "babylonjs/Meshes/Builders/sphereBuilder";
  48366. /**
  48367. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48368. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48369. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48370. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48371. */
  48372. export class PhotoDome extends TransformNode {
  48373. /**
  48374. * Define the image as a Monoscopic panoramic 360 image.
  48375. */
  48376. static readonly MODE_MONOSCOPIC: number;
  48377. /**
  48378. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48379. */
  48380. static readonly MODE_TOPBOTTOM: number;
  48381. /**
  48382. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48383. */
  48384. static readonly MODE_SIDEBYSIDE: number;
  48385. private _useDirectMapping;
  48386. /**
  48387. * The texture being displayed on the sphere
  48388. */
  48389. protected _photoTexture: Texture;
  48390. /**
  48391. * Gets or sets the texture being displayed on the sphere
  48392. */
  48393. photoTexture: Texture;
  48394. /**
  48395. * Observable raised when an error occured while loading the 360 image
  48396. */
  48397. onLoadErrorObservable: Observable<string>;
  48398. /**
  48399. * The skybox material
  48400. */
  48401. protected _material: BackgroundMaterial;
  48402. /**
  48403. * The surface used for the skybox
  48404. */
  48405. protected _mesh: Mesh;
  48406. /**
  48407. * Gets the mesh used for the skybox.
  48408. */
  48409. readonly mesh: Mesh;
  48410. /**
  48411. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48412. * Also see the options.resolution property.
  48413. */
  48414. fovMultiplier: number;
  48415. private _imageMode;
  48416. /**
  48417. * Gets or set the current video mode for the video. It can be:
  48418. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48419. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48420. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48421. */
  48422. imageMode: number;
  48423. /**
  48424. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48425. * @param name Element's name, child elements will append suffixes for their own names.
  48426. * @param urlsOfPhoto defines the url of the photo to display
  48427. * @param options defines an object containing optional or exposed sub element properties
  48428. * @param onError defines a callback called when an error occured while loading the texture
  48429. */
  48430. constructor(name: string, urlOfPhoto: string, options: {
  48431. resolution?: number;
  48432. size?: number;
  48433. useDirectMapping?: boolean;
  48434. faceForward?: boolean;
  48435. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48436. private _onBeforeCameraRenderObserver;
  48437. private _changeImageMode;
  48438. /**
  48439. * Releases resources associated with this node.
  48440. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48441. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48442. */
  48443. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48444. }
  48445. }
  48446. declare module "babylonjs/Misc/rgbdTextureTools" {
  48447. import "babylonjs/Shaders/rgbdDecode.fragment";
  48448. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48449. import { Texture } from "babylonjs/Materials/Textures/texture";
  48450. /**
  48451. * Class used to host RGBD texture specific utilities
  48452. */
  48453. export class RGBDTextureTools {
  48454. /**
  48455. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48456. * @param texture the texture to expand.
  48457. */
  48458. static ExpandRGBDTexture(texture: Texture): void;
  48459. }
  48460. }
  48461. declare module "babylonjs/Misc/brdfTextureTools" {
  48462. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48463. import { Scene } from "babylonjs/scene";
  48464. /**
  48465. * Class used to host texture specific utilities
  48466. */
  48467. export class BRDFTextureTools {
  48468. /**
  48469. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48470. * @param scene defines the hosting scene
  48471. * @returns the environment BRDF texture
  48472. */
  48473. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48474. private static _environmentBRDFBase64Texture;
  48475. }
  48476. }
  48477. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48478. import { Nullable } from "babylonjs/types";
  48479. import { Color3 } from "babylonjs/Maths/math.color";
  48480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48481. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48482. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48483. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48484. import { Engine } from "babylonjs/Engines/engine";
  48485. import { Scene } from "babylonjs/scene";
  48486. /**
  48487. * @hidden
  48488. */
  48489. export interface IMaterialClearCoatDefines {
  48490. CLEARCOAT: boolean;
  48491. CLEARCOAT_DEFAULTIOR: boolean;
  48492. CLEARCOAT_TEXTURE: boolean;
  48493. CLEARCOAT_TEXTUREDIRECTUV: number;
  48494. CLEARCOAT_BUMP: boolean;
  48495. CLEARCOAT_BUMPDIRECTUV: number;
  48496. CLEARCOAT_TINT: boolean;
  48497. CLEARCOAT_TINT_TEXTURE: boolean;
  48498. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48499. /** @hidden */
  48500. _areTexturesDirty: boolean;
  48501. }
  48502. /**
  48503. * Define the code related to the clear coat parameters of the pbr material.
  48504. */
  48505. export class PBRClearCoatConfiguration {
  48506. /**
  48507. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48508. * The default fits with a polyurethane material.
  48509. */
  48510. private static readonly _DefaultIndexOfRefraction;
  48511. private _isEnabled;
  48512. /**
  48513. * Defines if the clear coat is enabled in the material.
  48514. */
  48515. isEnabled: boolean;
  48516. /**
  48517. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48518. */
  48519. intensity: number;
  48520. /**
  48521. * Defines the clear coat layer roughness.
  48522. */
  48523. roughness: number;
  48524. private _indexOfRefraction;
  48525. /**
  48526. * Defines the index of refraction of the clear coat.
  48527. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48528. * The default fits with a polyurethane material.
  48529. * Changing the default value is more performance intensive.
  48530. */
  48531. indexOfRefraction: number;
  48532. private _texture;
  48533. /**
  48534. * Stores the clear coat values in a texture.
  48535. */
  48536. texture: Nullable<BaseTexture>;
  48537. private _bumpTexture;
  48538. /**
  48539. * Define the clear coat specific bump texture.
  48540. */
  48541. bumpTexture: Nullable<BaseTexture>;
  48542. private _isTintEnabled;
  48543. /**
  48544. * Defines if the clear coat tint is enabled in the material.
  48545. */
  48546. isTintEnabled: boolean;
  48547. /**
  48548. * Defines the clear coat tint of the material.
  48549. * This is only use if tint is enabled
  48550. */
  48551. tintColor: Color3;
  48552. /**
  48553. * Defines the distance at which the tint color should be found in the
  48554. * clear coat media.
  48555. * This is only use if tint is enabled
  48556. */
  48557. tintColorAtDistance: number;
  48558. /**
  48559. * Defines the clear coat layer thickness.
  48560. * This is only use if tint is enabled
  48561. */
  48562. tintThickness: number;
  48563. private _tintTexture;
  48564. /**
  48565. * Stores the clear tint values in a texture.
  48566. * rgb is tint
  48567. * a is a thickness factor
  48568. */
  48569. tintTexture: Nullable<BaseTexture>;
  48570. /** @hidden */
  48571. private _internalMarkAllSubMeshesAsTexturesDirty;
  48572. /** @hidden */
  48573. _markAllSubMeshesAsTexturesDirty(): void;
  48574. /**
  48575. * Instantiate a new istance of clear coat configuration.
  48576. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48577. */
  48578. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48579. /**
  48580. * Gets wehter the submesh is ready to be used or not.
  48581. * @param defines the list of "defines" to update.
  48582. * @param scene defines the scene the material belongs to.
  48583. * @param engine defines the engine the material belongs to.
  48584. * @param disableBumpMap defines wether the material disables bump or not.
  48585. * @returns - boolean indicating that the submesh is ready or not.
  48586. */
  48587. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48588. /**
  48589. * Checks to see if a texture is used in the material.
  48590. * @param defines the list of "defines" to update.
  48591. * @param scene defines the scene to the material belongs to.
  48592. */
  48593. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48594. /**
  48595. * Binds the material data.
  48596. * @param uniformBuffer defines the Uniform buffer to fill in.
  48597. * @param scene defines the scene the material belongs to.
  48598. * @param engine defines the engine the material belongs to.
  48599. * @param disableBumpMap defines wether the material disables bump or not.
  48600. * @param isFrozen defines wether the material is frozen or not.
  48601. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48602. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48603. */
  48604. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48605. /**
  48606. * Checks to see if a texture is used in the material.
  48607. * @param texture - Base texture to use.
  48608. * @returns - Boolean specifying if a texture is used in the material.
  48609. */
  48610. hasTexture(texture: BaseTexture): boolean;
  48611. /**
  48612. * Returns an array of the actively used textures.
  48613. * @param activeTextures Array of BaseTextures
  48614. */
  48615. getActiveTextures(activeTextures: BaseTexture[]): void;
  48616. /**
  48617. * Returns the animatable textures.
  48618. * @param animatables Array of animatable textures.
  48619. */
  48620. getAnimatables(animatables: IAnimatable[]): void;
  48621. /**
  48622. * Disposes the resources of the material.
  48623. * @param forceDisposeTextures - Forces the disposal of all textures.
  48624. */
  48625. dispose(forceDisposeTextures?: boolean): void;
  48626. /**
  48627. * Get the current class name of the texture useful for serialization or dynamic coding.
  48628. * @returns "PBRClearCoatConfiguration"
  48629. */
  48630. getClassName(): string;
  48631. /**
  48632. * Add fallbacks to the effect fallbacks list.
  48633. * @param defines defines the Base texture to use.
  48634. * @param fallbacks defines the current fallback list.
  48635. * @param currentRank defines the current fallback rank.
  48636. * @returns the new fallback rank.
  48637. */
  48638. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48639. /**
  48640. * Add the required uniforms to the current list.
  48641. * @param uniforms defines the current uniform list.
  48642. */
  48643. static AddUniforms(uniforms: string[]): void;
  48644. /**
  48645. * Add the required samplers to the current list.
  48646. * @param samplers defines the current sampler list.
  48647. */
  48648. static AddSamplers(samplers: string[]): void;
  48649. /**
  48650. * Add the required uniforms to the current buffer.
  48651. * @param uniformBuffer defines the current uniform buffer.
  48652. */
  48653. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48654. /**
  48655. * Makes a duplicate of the current configuration into another one.
  48656. * @param clearCoatConfiguration define the config where to copy the info
  48657. */
  48658. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48659. /**
  48660. * Serializes this clear coat configuration.
  48661. * @returns - An object with the serialized config.
  48662. */
  48663. serialize(): any;
  48664. /**
  48665. * Parses a anisotropy Configuration from a serialized object.
  48666. * @param source - Serialized object.
  48667. * @param scene Defines the scene we are parsing for
  48668. * @param rootUrl Defines the rootUrl to load from
  48669. */
  48670. parse(source: any, scene: Scene, rootUrl: string): void;
  48671. }
  48672. }
  48673. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48674. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48676. import { Vector2 } from "babylonjs/Maths/math.vector";
  48677. import { Scene } from "babylonjs/scene";
  48678. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48679. import { Nullable } from "babylonjs/types";
  48680. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48681. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48682. /**
  48683. * @hidden
  48684. */
  48685. export interface IMaterialAnisotropicDefines {
  48686. ANISOTROPIC: boolean;
  48687. ANISOTROPIC_TEXTURE: boolean;
  48688. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48689. MAINUV1: boolean;
  48690. _areTexturesDirty: boolean;
  48691. _needUVs: boolean;
  48692. }
  48693. /**
  48694. * Define the code related to the anisotropic parameters of the pbr material.
  48695. */
  48696. export class PBRAnisotropicConfiguration {
  48697. private _isEnabled;
  48698. /**
  48699. * Defines if the anisotropy is enabled in the material.
  48700. */
  48701. isEnabled: boolean;
  48702. /**
  48703. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48704. */
  48705. intensity: number;
  48706. /**
  48707. * Defines if the effect is along the tangents, bitangents or in between.
  48708. * By default, the effect is "strectching" the highlights along the tangents.
  48709. */
  48710. direction: Vector2;
  48711. private _texture;
  48712. /**
  48713. * Stores the anisotropy values in a texture.
  48714. * rg is direction (like normal from -1 to 1)
  48715. * b is a intensity
  48716. */
  48717. texture: Nullable<BaseTexture>;
  48718. /** @hidden */
  48719. private _internalMarkAllSubMeshesAsTexturesDirty;
  48720. /** @hidden */
  48721. _markAllSubMeshesAsTexturesDirty(): void;
  48722. /**
  48723. * Instantiate a new istance of anisotropy configuration.
  48724. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48725. */
  48726. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48727. /**
  48728. * Specifies that the submesh is ready to be used.
  48729. * @param defines the list of "defines" to update.
  48730. * @param scene defines the scene the material belongs to.
  48731. * @returns - boolean indicating that the submesh is ready or not.
  48732. */
  48733. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48734. /**
  48735. * Checks to see if a texture is used in the material.
  48736. * @param defines the list of "defines" to update.
  48737. * @param mesh the mesh we are preparing the defines for.
  48738. * @param scene defines the scene the material belongs to.
  48739. */
  48740. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48741. /**
  48742. * Binds the material data.
  48743. * @param uniformBuffer defines the Uniform buffer to fill in.
  48744. * @param scene defines the scene the material belongs to.
  48745. * @param isFrozen defines wether the material is frozen or not.
  48746. */
  48747. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48748. /**
  48749. * Checks to see if a texture is used in the material.
  48750. * @param texture - Base texture to use.
  48751. * @returns - Boolean specifying if a texture is used in the material.
  48752. */
  48753. hasTexture(texture: BaseTexture): boolean;
  48754. /**
  48755. * Returns an array of the actively used textures.
  48756. * @param activeTextures Array of BaseTextures
  48757. */
  48758. getActiveTextures(activeTextures: BaseTexture[]): void;
  48759. /**
  48760. * Returns the animatable textures.
  48761. * @param animatables Array of animatable textures.
  48762. */
  48763. getAnimatables(animatables: IAnimatable[]): void;
  48764. /**
  48765. * Disposes the resources of the material.
  48766. * @param forceDisposeTextures - Forces the disposal of all textures.
  48767. */
  48768. dispose(forceDisposeTextures?: boolean): void;
  48769. /**
  48770. * Get the current class name of the texture useful for serialization or dynamic coding.
  48771. * @returns "PBRAnisotropicConfiguration"
  48772. */
  48773. getClassName(): string;
  48774. /**
  48775. * Add fallbacks to the effect fallbacks list.
  48776. * @param defines defines the Base texture to use.
  48777. * @param fallbacks defines the current fallback list.
  48778. * @param currentRank defines the current fallback rank.
  48779. * @returns the new fallback rank.
  48780. */
  48781. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48782. /**
  48783. * Add the required uniforms to the current list.
  48784. * @param uniforms defines the current uniform list.
  48785. */
  48786. static AddUniforms(uniforms: string[]): void;
  48787. /**
  48788. * Add the required uniforms to the current buffer.
  48789. * @param uniformBuffer defines the current uniform buffer.
  48790. */
  48791. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48792. /**
  48793. * Add the required samplers to the current list.
  48794. * @param samplers defines the current sampler list.
  48795. */
  48796. static AddSamplers(samplers: string[]): void;
  48797. /**
  48798. * Makes a duplicate of the current configuration into another one.
  48799. * @param anisotropicConfiguration define the config where to copy the info
  48800. */
  48801. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48802. /**
  48803. * Serializes this anisotropy configuration.
  48804. * @returns - An object with the serialized config.
  48805. */
  48806. serialize(): any;
  48807. /**
  48808. * Parses a anisotropy Configuration from a serialized object.
  48809. * @param source - Serialized object.
  48810. * @param scene Defines the scene we are parsing for
  48811. * @param rootUrl Defines the rootUrl to load from
  48812. */
  48813. parse(source: any, scene: Scene, rootUrl: string): void;
  48814. }
  48815. }
  48816. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48817. import { Scene } from "babylonjs/scene";
  48818. /**
  48819. * @hidden
  48820. */
  48821. export interface IMaterialBRDFDefines {
  48822. BRDF_V_HEIGHT_CORRELATED: boolean;
  48823. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48824. SPHERICAL_HARMONICS: boolean;
  48825. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48826. /** @hidden */
  48827. _areMiscDirty: boolean;
  48828. }
  48829. /**
  48830. * Define the code related to the BRDF parameters of the pbr material.
  48831. */
  48832. export class PBRBRDFConfiguration {
  48833. /**
  48834. * Default value used for the energy conservation.
  48835. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48836. */
  48837. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48838. /**
  48839. * Default value used for the Smith Visibility Height Correlated mode.
  48840. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48841. */
  48842. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48843. /**
  48844. * Default value used for the IBL diffuse part.
  48845. * This can help switching back to the polynomials mode globally which is a tiny bit
  48846. * less GPU intensive at the drawback of a lower quality.
  48847. */
  48848. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48849. /**
  48850. * Default value used for activating energy conservation for the specular workflow.
  48851. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48852. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48853. */
  48854. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48855. private _useEnergyConservation;
  48856. /**
  48857. * Defines if the material uses energy conservation.
  48858. */
  48859. useEnergyConservation: boolean;
  48860. private _useSmithVisibilityHeightCorrelated;
  48861. /**
  48862. * LEGACY Mode set to false
  48863. * Defines if the material uses height smith correlated visibility term.
  48864. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48865. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48866. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48867. * Not relying on height correlated will also disable energy conservation.
  48868. */
  48869. useSmithVisibilityHeightCorrelated: boolean;
  48870. private _useSphericalHarmonics;
  48871. /**
  48872. * LEGACY Mode set to false
  48873. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48874. * diffuse part of the IBL.
  48875. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48876. * to the ground truth.
  48877. */
  48878. useSphericalHarmonics: boolean;
  48879. private _useSpecularGlossinessInputEnergyConservation;
  48880. /**
  48881. * Defines if the material uses energy conservation, when the specular workflow is active.
  48882. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48883. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48884. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48885. */
  48886. useSpecularGlossinessInputEnergyConservation: boolean;
  48887. /** @hidden */
  48888. private _internalMarkAllSubMeshesAsMiscDirty;
  48889. /** @hidden */
  48890. _markAllSubMeshesAsMiscDirty(): void;
  48891. /**
  48892. * Instantiate a new istance of clear coat configuration.
  48893. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48894. */
  48895. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48896. /**
  48897. * Checks to see if a texture is used in the material.
  48898. * @param defines the list of "defines" to update.
  48899. */
  48900. prepareDefines(defines: IMaterialBRDFDefines): void;
  48901. /**
  48902. * Get the current class name of the texture useful for serialization or dynamic coding.
  48903. * @returns "PBRClearCoatConfiguration"
  48904. */
  48905. getClassName(): string;
  48906. /**
  48907. * Makes a duplicate of the current configuration into another one.
  48908. * @param brdfConfiguration define the config where to copy the info
  48909. */
  48910. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48911. /**
  48912. * Serializes this BRDF configuration.
  48913. * @returns - An object with the serialized config.
  48914. */
  48915. serialize(): any;
  48916. /**
  48917. * Parses a anisotropy Configuration from a serialized object.
  48918. * @param source - Serialized object.
  48919. * @param scene Defines the scene we are parsing for
  48920. * @param rootUrl Defines the rootUrl to load from
  48921. */
  48922. parse(source: any, scene: Scene, rootUrl: string): void;
  48923. }
  48924. }
  48925. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48926. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48927. import { Color3 } from "babylonjs/Maths/math.color";
  48928. import { Scene } from "babylonjs/scene";
  48929. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48930. import { Nullable } from "babylonjs/types";
  48931. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48932. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48933. /**
  48934. * @hidden
  48935. */
  48936. export interface IMaterialSheenDefines {
  48937. SHEEN: boolean;
  48938. SHEEN_TEXTURE: boolean;
  48939. SHEEN_TEXTUREDIRECTUV: number;
  48940. SHEEN_LINKWITHALBEDO: boolean;
  48941. /** @hidden */
  48942. _areTexturesDirty: boolean;
  48943. }
  48944. /**
  48945. * Define the code related to the Sheen parameters of the pbr material.
  48946. */
  48947. export class PBRSheenConfiguration {
  48948. private _isEnabled;
  48949. /**
  48950. * Defines if the material uses sheen.
  48951. */
  48952. isEnabled: boolean;
  48953. private _linkSheenWithAlbedo;
  48954. /**
  48955. * Defines if the sheen is linked to the sheen color.
  48956. */
  48957. linkSheenWithAlbedo: boolean;
  48958. /**
  48959. * Defines the sheen intensity.
  48960. */
  48961. intensity: number;
  48962. /**
  48963. * Defines the sheen color.
  48964. */
  48965. color: Color3;
  48966. private _texture;
  48967. /**
  48968. * Stores the sheen tint values in a texture.
  48969. * rgb is tint
  48970. * a is a intensity
  48971. */
  48972. texture: Nullable<BaseTexture>;
  48973. /** @hidden */
  48974. private _internalMarkAllSubMeshesAsTexturesDirty;
  48975. /** @hidden */
  48976. _markAllSubMeshesAsTexturesDirty(): void;
  48977. /**
  48978. * Instantiate a new istance of clear coat configuration.
  48979. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48980. */
  48981. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48982. /**
  48983. * Specifies that the submesh is ready to be used.
  48984. * @param defines the list of "defines" to update.
  48985. * @param scene defines the scene the material belongs to.
  48986. * @returns - boolean indicating that the submesh is ready or not.
  48987. */
  48988. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48989. /**
  48990. * Checks to see if a texture is used in the material.
  48991. * @param defines the list of "defines" to update.
  48992. * @param scene defines the scene the material belongs to.
  48993. */
  48994. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48995. /**
  48996. * Binds the material data.
  48997. * @param uniformBuffer defines the Uniform buffer to fill in.
  48998. * @param scene defines the scene the material belongs to.
  48999. * @param isFrozen defines wether the material is frozen or not.
  49000. */
  49001. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49002. /**
  49003. * Checks to see if a texture is used in the material.
  49004. * @param texture - Base texture to use.
  49005. * @returns - Boolean specifying if a texture is used in the material.
  49006. */
  49007. hasTexture(texture: BaseTexture): boolean;
  49008. /**
  49009. * Returns an array of the actively used textures.
  49010. * @param activeTextures Array of BaseTextures
  49011. */
  49012. getActiveTextures(activeTextures: BaseTexture[]): void;
  49013. /**
  49014. * Returns the animatable textures.
  49015. * @param animatables Array of animatable textures.
  49016. */
  49017. getAnimatables(animatables: IAnimatable[]): void;
  49018. /**
  49019. * Disposes the resources of the material.
  49020. * @param forceDisposeTextures - Forces the disposal of all textures.
  49021. */
  49022. dispose(forceDisposeTextures?: boolean): void;
  49023. /**
  49024. * Get the current class name of the texture useful for serialization or dynamic coding.
  49025. * @returns "PBRSheenConfiguration"
  49026. */
  49027. getClassName(): string;
  49028. /**
  49029. * Add fallbacks to the effect fallbacks list.
  49030. * @param defines defines the Base texture to use.
  49031. * @param fallbacks defines the current fallback list.
  49032. * @param currentRank defines the current fallback rank.
  49033. * @returns the new fallback rank.
  49034. */
  49035. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49036. /**
  49037. * Add the required uniforms to the current list.
  49038. * @param uniforms defines the current uniform list.
  49039. */
  49040. static AddUniforms(uniforms: string[]): void;
  49041. /**
  49042. * Add the required uniforms to the current buffer.
  49043. * @param uniformBuffer defines the current uniform buffer.
  49044. */
  49045. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49046. /**
  49047. * Add the required samplers to the current list.
  49048. * @param samplers defines the current sampler list.
  49049. */
  49050. static AddSamplers(samplers: string[]): void;
  49051. /**
  49052. * Makes a duplicate of the current configuration into another one.
  49053. * @param sheenConfiguration define the config where to copy the info
  49054. */
  49055. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49056. /**
  49057. * Serializes this BRDF configuration.
  49058. * @returns - An object with the serialized config.
  49059. */
  49060. serialize(): any;
  49061. /**
  49062. * Parses a anisotropy Configuration from a serialized object.
  49063. * @param source - Serialized object.
  49064. * @param scene Defines the scene we are parsing for
  49065. * @param rootUrl Defines the rootUrl to load from
  49066. */
  49067. parse(source: any, scene: Scene, rootUrl: string): void;
  49068. }
  49069. }
  49070. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49071. import { Nullable } from "babylonjs/types";
  49072. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49073. import { Color3 } from "babylonjs/Maths/math.color";
  49074. import { SmartArray } from "babylonjs/Misc/smartArray";
  49075. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49076. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49077. import { Effect } from "babylonjs/Materials/effect";
  49078. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49079. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49080. import { Engine } from "babylonjs/Engines/engine";
  49081. import { Scene } from "babylonjs/scene";
  49082. /**
  49083. * @hidden
  49084. */
  49085. export interface IMaterialSubSurfaceDefines {
  49086. SUBSURFACE: boolean;
  49087. SS_REFRACTION: boolean;
  49088. SS_TRANSLUCENCY: boolean;
  49089. SS_SCATERRING: boolean;
  49090. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49091. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49092. SS_REFRACTIONMAP_3D: boolean;
  49093. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49094. SS_LODINREFRACTIONALPHA: boolean;
  49095. SS_GAMMAREFRACTION: boolean;
  49096. SS_RGBDREFRACTION: boolean;
  49097. SS_LINEARSPECULARREFRACTION: boolean;
  49098. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49099. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49100. /** @hidden */
  49101. _areTexturesDirty: boolean;
  49102. }
  49103. /**
  49104. * Define the code related to the sub surface parameters of the pbr material.
  49105. */
  49106. export class PBRSubSurfaceConfiguration {
  49107. private _isRefractionEnabled;
  49108. /**
  49109. * Defines if the refraction is enabled in the material.
  49110. */
  49111. isRefractionEnabled: boolean;
  49112. private _isTranslucencyEnabled;
  49113. /**
  49114. * Defines if the translucency is enabled in the material.
  49115. */
  49116. isTranslucencyEnabled: boolean;
  49117. private _isScatteringEnabled;
  49118. /**
  49119. * Defines the refraction intensity of the material.
  49120. * The refraction when enabled replaces the Diffuse part of the material.
  49121. * The intensity helps transitionning between diffuse and refraction.
  49122. */
  49123. refractionIntensity: number;
  49124. /**
  49125. * Defines the translucency intensity of the material.
  49126. * When translucency has been enabled, this defines how much of the "translucency"
  49127. * is addded to the diffuse part of the material.
  49128. */
  49129. translucencyIntensity: number;
  49130. /**
  49131. * Defines the scattering intensity of the material.
  49132. * When scattering has been enabled, this defines how much of the "scattered light"
  49133. * is addded to the diffuse part of the material.
  49134. */
  49135. scatteringIntensity: number;
  49136. private _thicknessTexture;
  49137. /**
  49138. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49139. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49140. * 0 would mean minimumThickness
  49141. * 1 would mean maximumThickness
  49142. * The other channels might be use as a mask to vary the different effects intensity.
  49143. */
  49144. thicknessTexture: Nullable<BaseTexture>;
  49145. private _refractionTexture;
  49146. /**
  49147. * Defines the texture to use for refraction.
  49148. */
  49149. refractionTexture: Nullable<BaseTexture>;
  49150. private _indexOfRefraction;
  49151. /**
  49152. * Defines the index of refraction used in the material.
  49153. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49154. */
  49155. indexOfRefraction: number;
  49156. private _invertRefractionY;
  49157. /**
  49158. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49159. */
  49160. invertRefractionY: boolean;
  49161. private _linkRefractionWithTransparency;
  49162. /**
  49163. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49164. * Materials half opaque for instance using refraction could benefit from this control.
  49165. */
  49166. linkRefractionWithTransparency: boolean;
  49167. /**
  49168. * Defines the minimum thickness stored in the thickness map.
  49169. * If no thickness map is defined, this value will be used to simulate thickness.
  49170. */
  49171. minimumThickness: number;
  49172. /**
  49173. * Defines the maximum thickness stored in the thickness map.
  49174. */
  49175. maximumThickness: number;
  49176. /**
  49177. * Defines the volume tint of the material.
  49178. * This is used for both translucency and scattering.
  49179. */
  49180. tintColor: Color3;
  49181. /**
  49182. * Defines the distance at which the tint color should be found in the media.
  49183. * This is used for refraction only.
  49184. */
  49185. tintColorAtDistance: number;
  49186. /**
  49187. * Defines how far each channel transmit through the media.
  49188. * It is defined as a color to simplify it selection.
  49189. */
  49190. diffusionDistance: Color3;
  49191. private _useMaskFromThicknessTexture;
  49192. /**
  49193. * Stores the intensity of the different subsurface effects in the thickness texture.
  49194. * * the green channel is the translucency intensity.
  49195. * * the blue channel is the scattering intensity.
  49196. * * the alpha channel is the refraction intensity.
  49197. */
  49198. useMaskFromThicknessTexture: boolean;
  49199. /** @hidden */
  49200. private _internalMarkAllSubMeshesAsTexturesDirty;
  49201. /** @hidden */
  49202. _markAllSubMeshesAsTexturesDirty(): void;
  49203. /**
  49204. * Instantiate a new istance of sub surface configuration.
  49205. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49206. */
  49207. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49208. /**
  49209. * Gets wehter the submesh is ready to be used or not.
  49210. * @param defines the list of "defines" to update.
  49211. * @param scene defines the scene the material belongs to.
  49212. * @returns - boolean indicating that the submesh is ready or not.
  49213. */
  49214. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49215. /**
  49216. * Checks to see if a texture is used in the material.
  49217. * @param defines the list of "defines" to update.
  49218. * @param scene defines the scene to the material belongs to.
  49219. */
  49220. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49221. /**
  49222. * Binds the material data.
  49223. * @param uniformBuffer defines the Uniform buffer to fill in.
  49224. * @param scene defines the scene the material belongs to.
  49225. * @param engine defines the engine the material belongs to.
  49226. * @param isFrozen defines wether the material is frozen or not.
  49227. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49228. */
  49229. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49230. /**
  49231. * Unbinds the material from the mesh.
  49232. * @param activeEffect defines the effect that should be unbound from.
  49233. * @returns true if unbound, otherwise false
  49234. */
  49235. unbind(activeEffect: Effect): boolean;
  49236. /**
  49237. * Returns the texture used for refraction or null if none is used.
  49238. * @param scene defines the scene the material belongs to.
  49239. * @returns - Refraction texture if present. If no refraction texture and refraction
  49240. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49241. */
  49242. private _getRefractionTexture;
  49243. /**
  49244. * Returns true if alpha blending should be disabled.
  49245. */
  49246. readonly disableAlphaBlending: boolean;
  49247. /**
  49248. * Fills the list of render target textures.
  49249. * @param renderTargets the list of render targets to update
  49250. */
  49251. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49252. /**
  49253. * Checks to see if a texture is used in the material.
  49254. * @param texture - Base texture to use.
  49255. * @returns - Boolean specifying if a texture is used in the material.
  49256. */
  49257. hasTexture(texture: BaseTexture): boolean;
  49258. /**
  49259. * Gets a boolean indicating that current material needs to register RTT
  49260. * @returns true if this uses a render target otherwise false.
  49261. */
  49262. hasRenderTargetTextures(): boolean;
  49263. /**
  49264. * Returns an array of the actively used textures.
  49265. * @param activeTextures Array of BaseTextures
  49266. */
  49267. getActiveTextures(activeTextures: BaseTexture[]): void;
  49268. /**
  49269. * Returns the animatable textures.
  49270. * @param animatables Array of animatable textures.
  49271. */
  49272. getAnimatables(animatables: IAnimatable[]): void;
  49273. /**
  49274. * Disposes the resources of the material.
  49275. * @param forceDisposeTextures - Forces the disposal of all textures.
  49276. */
  49277. dispose(forceDisposeTextures?: boolean): void;
  49278. /**
  49279. * Get the current class name of the texture useful for serialization or dynamic coding.
  49280. * @returns "PBRSubSurfaceConfiguration"
  49281. */
  49282. getClassName(): string;
  49283. /**
  49284. * Add fallbacks to the effect fallbacks list.
  49285. * @param defines defines the Base texture to use.
  49286. * @param fallbacks defines the current fallback list.
  49287. * @param currentRank defines the current fallback rank.
  49288. * @returns the new fallback rank.
  49289. */
  49290. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49291. /**
  49292. * Add the required uniforms to the current list.
  49293. * @param uniforms defines the current uniform list.
  49294. */
  49295. static AddUniforms(uniforms: string[]): void;
  49296. /**
  49297. * Add the required samplers to the current list.
  49298. * @param samplers defines the current sampler list.
  49299. */
  49300. static AddSamplers(samplers: string[]): void;
  49301. /**
  49302. * Add the required uniforms to the current buffer.
  49303. * @param uniformBuffer defines the current uniform buffer.
  49304. */
  49305. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49306. /**
  49307. * Makes a duplicate of the current configuration into another one.
  49308. * @param configuration define the config where to copy the info
  49309. */
  49310. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49311. /**
  49312. * Serializes this Sub Surface configuration.
  49313. * @returns - An object with the serialized config.
  49314. */
  49315. serialize(): any;
  49316. /**
  49317. * Parses a anisotropy Configuration from a serialized object.
  49318. * @param source - Serialized object.
  49319. * @param scene Defines the scene we are parsing for
  49320. * @param rootUrl Defines the rootUrl to load from
  49321. */
  49322. parse(source: any, scene: Scene, rootUrl: string): void;
  49323. }
  49324. }
  49325. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49326. /** @hidden */
  49327. export var pbrFragmentDeclaration: {
  49328. name: string;
  49329. shader: string;
  49330. };
  49331. }
  49332. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49333. /** @hidden */
  49334. export var pbrUboDeclaration: {
  49335. name: string;
  49336. shader: string;
  49337. };
  49338. }
  49339. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49340. /** @hidden */
  49341. export var pbrFragmentExtraDeclaration: {
  49342. name: string;
  49343. shader: string;
  49344. };
  49345. }
  49346. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49347. /** @hidden */
  49348. export var pbrFragmentSamplersDeclaration: {
  49349. name: string;
  49350. shader: string;
  49351. };
  49352. }
  49353. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49354. /** @hidden */
  49355. export var pbrHelperFunctions: {
  49356. name: string;
  49357. shader: string;
  49358. };
  49359. }
  49360. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49361. /** @hidden */
  49362. export var harmonicsFunctions: {
  49363. name: string;
  49364. shader: string;
  49365. };
  49366. }
  49367. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49368. /** @hidden */
  49369. export var pbrDirectLightingSetupFunctions: {
  49370. name: string;
  49371. shader: string;
  49372. };
  49373. }
  49374. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49375. /** @hidden */
  49376. export var pbrDirectLightingFalloffFunctions: {
  49377. name: string;
  49378. shader: string;
  49379. };
  49380. }
  49381. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49382. /** @hidden */
  49383. export var pbrBRDFFunctions: {
  49384. name: string;
  49385. shader: string;
  49386. };
  49387. }
  49388. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49389. /** @hidden */
  49390. export var pbrDirectLightingFunctions: {
  49391. name: string;
  49392. shader: string;
  49393. };
  49394. }
  49395. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49396. /** @hidden */
  49397. export var pbrIBLFunctions: {
  49398. name: string;
  49399. shader: string;
  49400. };
  49401. }
  49402. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49403. /** @hidden */
  49404. export var pbrDebug: {
  49405. name: string;
  49406. shader: string;
  49407. };
  49408. }
  49409. declare module "babylonjs/Shaders/pbr.fragment" {
  49410. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49411. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49412. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49413. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49414. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49415. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49416. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49417. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49418. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49419. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49420. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49421. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49422. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49423. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49424. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49425. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49426. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49427. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49428. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49429. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49430. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49431. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49432. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49433. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49434. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49435. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49436. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49437. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49438. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49439. /** @hidden */
  49440. export var pbrPixelShader: {
  49441. name: string;
  49442. shader: string;
  49443. };
  49444. }
  49445. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49446. /** @hidden */
  49447. export var pbrVertexDeclaration: {
  49448. name: string;
  49449. shader: string;
  49450. };
  49451. }
  49452. declare module "babylonjs/Shaders/pbr.vertex" {
  49453. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49454. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49455. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49456. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49457. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49458. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49459. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49460. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49461. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49462. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49463. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49464. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49465. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49466. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49467. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49468. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49469. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49470. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49471. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49472. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49473. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49474. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49475. /** @hidden */
  49476. export var pbrVertexShader: {
  49477. name: string;
  49478. shader: string;
  49479. };
  49480. }
  49481. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49482. import { Nullable } from "babylonjs/types";
  49483. import { Scene } from "babylonjs/scene";
  49484. import { Matrix } from "babylonjs/Maths/math.vector";
  49485. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49487. import { Mesh } from "babylonjs/Meshes/mesh";
  49488. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49489. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49490. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49491. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49492. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49493. import { Color3 } from "babylonjs/Maths/math.color";
  49494. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49495. import { Material } from "babylonjs/Materials/material";
  49496. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49497. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49498. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49499. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49500. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49501. import "babylonjs/Shaders/pbr.fragment";
  49502. import "babylonjs/Shaders/pbr.vertex";
  49503. /**
  49504. * Manages the defines for the PBR Material.
  49505. * @hidden
  49506. */
  49507. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49508. PBR: boolean;
  49509. MAINUV1: boolean;
  49510. MAINUV2: boolean;
  49511. UV1: boolean;
  49512. UV2: boolean;
  49513. ALBEDO: boolean;
  49514. ALBEDODIRECTUV: number;
  49515. VERTEXCOLOR: boolean;
  49516. AMBIENT: boolean;
  49517. AMBIENTDIRECTUV: number;
  49518. AMBIENTINGRAYSCALE: boolean;
  49519. OPACITY: boolean;
  49520. VERTEXALPHA: boolean;
  49521. OPACITYDIRECTUV: number;
  49522. OPACITYRGB: boolean;
  49523. ALPHATEST: boolean;
  49524. DEPTHPREPASS: boolean;
  49525. ALPHABLEND: boolean;
  49526. ALPHAFROMALBEDO: boolean;
  49527. ALPHATESTVALUE: string;
  49528. SPECULAROVERALPHA: boolean;
  49529. RADIANCEOVERALPHA: boolean;
  49530. ALPHAFRESNEL: boolean;
  49531. LINEARALPHAFRESNEL: boolean;
  49532. PREMULTIPLYALPHA: boolean;
  49533. EMISSIVE: boolean;
  49534. EMISSIVEDIRECTUV: number;
  49535. REFLECTIVITY: boolean;
  49536. REFLECTIVITYDIRECTUV: number;
  49537. SPECULARTERM: boolean;
  49538. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49539. MICROSURFACEAUTOMATIC: boolean;
  49540. LODBASEDMICROSFURACE: boolean;
  49541. MICROSURFACEMAP: boolean;
  49542. MICROSURFACEMAPDIRECTUV: number;
  49543. METALLICWORKFLOW: boolean;
  49544. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49545. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49546. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49547. AOSTOREINMETALMAPRED: boolean;
  49548. ENVIRONMENTBRDF: boolean;
  49549. ENVIRONMENTBRDF_RGBD: boolean;
  49550. NORMAL: boolean;
  49551. TANGENT: boolean;
  49552. BUMP: boolean;
  49553. BUMPDIRECTUV: number;
  49554. OBJECTSPACE_NORMALMAP: boolean;
  49555. PARALLAX: boolean;
  49556. PARALLAXOCCLUSION: boolean;
  49557. NORMALXYSCALE: boolean;
  49558. LIGHTMAP: boolean;
  49559. LIGHTMAPDIRECTUV: number;
  49560. USELIGHTMAPASSHADOWMAP: boolean;
  49561. GAMMALIGHTMAP: boolean;
  49562. RGBDLIGHTMAP: boolean;
  49563. REFLECTION: boolean;
  49564. REFLECTIONMAP_3D: boolean;
  49565. REFLECTIONMAP_SPHERICAL: boolean;
  49566. REFLECTIONMAP_PLANAR: boolean;
  49567. REFLECTIONMAP_CUBIC: boolean;
  49568. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49569. REFLECTIONMAP_PROJECTION: boolean;
  49570. REFLECTIONMAP_SKYBOX: boolean;
  49571. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49572. REFLECTIONMAP_EXPLICIT: boolean;
  49573. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49574. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49575. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49576. INVERTCUBICMAP: boolean;
  49577. USESPHERICALFROMREFLECTIONMAP: boolean;
  49578. USEIRRADIANCEMAP: boolean;
  49579. SPHERICAL_HARMONICS: boolean;
  49580. USESPHERICALINVERTEX: boolean;
  49581. REFLECTIONMAP_OPPOSITEZ: boolean;
  49582. LODINREFLECTIONALPHA: boolean;
  49583. GAMMAREFLECTION: boolean;
  49584. RGBDREFLECTION: boolean;
  49585. LINEARSPECULARREFLECTION: boolean;
  49586. RADIANCEOCCLUSION: boolean;
  49587. HORIZONOCCLUSION: boolean;
  49588. INSTANCES: boolean;
  49589. NUM_BONE_INFLUENCERS: number;
  49590. BonesPerMesh: number;
  49591. BONETEXTURE: boolean;
  49592. NONUNIFORMSCALING: boolean;
  49593. MORPHTARGETS: boolean;
  49594. MORPHTARGETS_NORMAL: boolean;
  49595. MORPHTARGETS_TANGENT: boolean;
  49596. MORPHTARGETS_UV: boolean;
  49597. NUM_MORPH_INFLUENCERS: number;
  49598. IMAGEPROCESSING: boolean;
  49599. VIGNETTE: boolean;
  49600. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49601. VIGNETTEBLENDMODEOPAQUE: boolean;
  49602. TONEMAPPING: boolean;
  49603. TONEMAPPING_ACES: boolean;
  49604. CONTRAST: boolean;
  49605. COLORCURVES: boolean;
  49606. COLORGRADING: boolean;
  49607. COLORGRADING3D: boolean;
  49608. SAMPLER3DGREENDEPTH: boolean;
  49609. SAMPLER3DBGRMAP: boolean;
  49610. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49611. EXPOSURE: boolean;
  49612. MULTIVIEW: boolean;
  49613. USEPHYSICALLIGHTFALLOFF: boolean;
  49614. USEGLTFLIGHTFALLOFF: boolean;
  49615. TWOSIDEDLIGHTING: boolean;
  49616. SHADOWFLOAT: boolean;
  49617. CLIPPLANE: boolean;
  49618. CLIPPLANE2: boolean;
  49619. CLIPPLANE3: boolean;
  49620. CLIPPLANE4: boolean;
  49621. POINTSIZE: boolean;
  49622. FOG: boolean;
  49623. LOGARITHMICDEPTH: boolean;
  49624. FORCENORMALFORWARD: boolean;
  49625. SPECULARAA: boolean;
  49626. CLEARCOAT: boolean;
  49627. CLEARCOAT_DEFAULTIOR: boolean;
  49628. CLEARCOAT_TEXTURE: boolean;
  49629. CLEARCOAT_TEXTUREDIRECTUV: number;
  49630. CLEARCOAT_BUMP: boolean;
  49631. CLEARCOAT_BUMPDIRECTUV: number;
  49632. CLEARCOAT_TINT: boolean;
  49633. CLEARCOAT_TINT_TEXTURE: boolean;
  49634. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49635. ANISOTROPIC: boolean;
  49636. ANISOTROPIC_TEXTURE: boolean;
  49637. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49638. BRDF_V_HEIGHT_CORRELATED: boolean;
  49639. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49640. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49641. SHEEN: boolean;
  49642. SHEEN_TEXTURE: boolean;
  49643. SHEEN_TEXTUREDIRECTUV: number;
  49644. SHEEN_LINKWITHALBEDO: boolean;
  49645. SUBSURFACE: boolean;
  49646. SS_REFRACTION: boolean;
  49647. SS_TRANSLUCENCY: boolean;
  49648. SS_SCATERRING: boolean;
  49649. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49650. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49651. SS_REFRACTIONMAP_3D: boolean;
  49652. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49653. SS_LODINREFRACTIONALPHA: boolean;
  49654. SS_GAMMAREFRACTION: boolean;
  49655. SS_RGBDREFRACTION: boolean;
  49656. SS_LINEARSPECULARREFRACTION: boolean;
  49657. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49658. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49659. UNLIT: boolean;
  49660. DEBUGMODE: number;
  49661. /**
  49662. * Initializes the PBR Material defines.
  49663. */
  49664. constructor();
  49665. /**
  49666. * Resets the PBR Material defines.
  49667. */
  49668. reset(): void;
  49669. }
  49670. /**
  49671. * The Physically based material base class of BJS.
  49672. *
  49673. * This offers the main features of a standard PBR material.
  49674. * For more information, please refer to the documentation :
  49675. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49676. */
  49677. export abstract class PBRBaseMaterial extends PushMaterial {
  49678. /**
  49679. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49680. */
  49681. static readonly PBRMATERIAL_OPAQUE: number;
  49682. /**
  49683. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49684. */
  49685. static readonly PBRMATERIAL_ALPHATEST: number;
  49686. /**
  49687. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49688. */
  49689. static readonly PBRMATERIAL_ALPHABLEND: number;
  49690. /**
  49691. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49692. * They are also discarded below the alpha cutoff threshold to improve performances.
  49693. */
  49694. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49695. /**
  49696. * Defines the default value of how much AO map is occluding the analytical lights
  49697. * (point spot...).
  49698. */
  49699. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49700. /**
  49701. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49702. */
  49703. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49704. /**
  49705. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49706. * to enhance interoperability with other engines.
  49707. */
  49708. static readonly LIGHTFALLOFF_GLTF: number;
  49709. /**
  49710. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49711. * to enhance interoperability with other materials.
  49712. */
  49713. static readonly LIGHTFALLOFF_STANDARD: number;
  49714. /**
  49715. * Intensity of the direct lights e.g. the four lights available in your scene.
  49716. * This impacts both the direct diffuse and specular highlights.
  49717. */
  49718. protected _directIntensity: number;
  49719. /**
  49720. * Intensity of the emissive part of the material.
  49721. * This helps controlling the emissive effect without modifying the emissive color.
  49722. */
  49723. protected _emissiveIntensity: number;
  49724. /**
  49725. * Intensity of the environment e.g. how much the environment will light the object
  49726. * either through harmonics for rough material or through the refelction for shiny ones.
  49727. */
  49728. protected _environmentIntensity: number;
  49729. /**
  49730. * This is a special control allowing the reduction of the specular highlights coming from the
  49731. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49732. */
  49733. protected _specularIntensity: number;
  49734. /**
  49735. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49736. */
  49737. private _lightingInfos;
  49738. /**
  49739. * Debug Control allowing disabling the bump map on this material.
  49740. */
  49741. protected _disableBumpMap: boolean;
  49742. /**
  49743. * AKA Diffuse Texture in standard nomenclature.
  49744. */
  49745. protected _albedoTexture: Nullable<BaseTexture>;
  49746. /**
  49747. * AKA Occlusion Texture in other nomenclature.
  49748. */
  49749. protected _ambientTexture: Nullable<BaseTexture>;
  49750. /**
  49751. * AKA Occlusion Texture Intensity in other nomenclature.
  49752. */
  49753. protected _ambientTextureStrength: number;
  49754. /**
  49755. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49756. * 1 means it completely occludes it
  49757. * 0 mean it has no impact
  49758. */
  49759. protected _ambientTextureImpactOnAnalyticalLights: number;
  49760. /**
  49761. * Stores the alpha values in a texture.
  49762. */
  49763. protected _opacityTexture: Nullable<BaseTexture>;
  49764. /**
  49765. * Stores the reflection values in a texture.
  49766. */
  49767. protected _reflectionTexture: Nullable<BaseTexture>;
  49768. /**
  49769. * Stores the emissive values in a texture.
  49770. */
  49771. protected _emissiveTexture: Nullable<BaseTexture>;
  49772. /**
  49773. * AKA Specular texture in other nomenclature.
  49774. */
  49775. protected _reflectivityTexture: Nullable<BaseTexture>;
  49776. /**
  49777. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49778. */
  49779. protected _metallicTexture: Nullable<BaseTexture>;
  49780. /**
  49781. * Specifies the metallic scalar of the metallic/roughness workflow.
  49782. * Can also be used to scale the metalness values of the metallic texture.
  49783. */
  49784. protected _metallic: Nullable<number>;
  49785. /**
  49786. * Specifies the roughness scalar of the metallic/roughness workflow.
  49787. * Can also be used to scale the roughness values of the metallic texture.
  49788. */
  49789. protected _roughness: Nullable<number>;
  49790. /**
  49791. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49792. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49793. */
  49794. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49795. /**
  49796. * Stores surface normal data used to displace a mesh in a texture.
  49797. */
  49798. protected _bumpTexture: Nullable<BaseTexture>;
  49799. /**
  49800. * Stores the pre-calculated light information of a mesh in a texture.
  49801. */
  49802. protected _lightmapTexture: Nullable<BaseTexture>;
  49803. /**
  49804. * The color of a material in ambient lighting.
  49805. */
  49806. protected _ambientColor: Color3;
  49807. /**
  49808. * AKA Diffuse Color in other nomenclature.
  49809. */
  49810. protected _albedoColor: Color3;
  49811. /**
  49812. * AKA Specular Color in other nomenclature.
  49813. */
  49814. protected _reflectivityColor: Color3;
  49815. /**
  49816. * The color applied when light is reflected from a material.
  49817. */
  49818. protected _reflectionColor: Color3;
  49819. /**
  49820. * The color applied when light is emitted from a material.
  49821. */
  49822. protected _emissiveColor: Color3;
  49823. /**
  49824. * AKA Glossiness in other nomenclature.
  49825. */
  49826. protected _microSurface: number;
  49827. /**
  49828. * Specifies that the material will use the light map as a show map.
  49829. */
  49830. protected _useLightmapAsShadowmap: boolean;
  49831. /**
  49832. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49833. * makes the reflect vector face the model (under horizon).
  49834. */
  49835. protected _useHorizonOcclusion: boolean;
  49836. /**
  49837. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49838. * too much the area relying on ambient texture to define their ambient occlusion.
  49839. */
  49840. protected _useRadianceOcclusion: boolean;
  49841. /**
  49842. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49843. */
  49844. protected _useAlphaFromAlbedoTexture: boolean;
  49845. /**
  49846. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49847. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49848. */
  49849. protected _useSpecularOverAlpha: boolean;
  49850. /**
  49851. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49852. */
  49853. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49854. /**
  49855. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49856. */
  49857. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49858. /**
  49859. * Specifies if the metallic texture contains the roughness information in its green channel.
  49860. */
  49861. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49862. /**
  49863. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49864. */
  49865. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49866. /**
  49867. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49868. */
  49869. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49870. /**
  49871. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49872. */
  49873. protected _useAmbientInGrayScale: boolean;
  49874. /**
  49875. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49876. * The material will try to infer what glossiness each pixel should be.
  49877. */
  49878. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49879. /**
  49880. * Defines the falloff type used in this material.
  49881. * It by default is Physical.
  49882. */
  49883. protected _lightFalloff: number;
  49884. /**
  49885. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49886. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49887. */
  49888. protected _useRadianceOverAlpha: boolean;
  49889. /**
  49890. * Allows using an object space normal map (instead of tangent space).
  49891. */
  49892. protected _useObjectSpaceNormalMap: boolean;
  49893. /**
  49894. * Allows using the bump map in parallax mode.
  49895. */
  49896. protected _useParallax: boolean;
  49897. /**
  49898. * Allows using the bump map in parallax occlusion mode.
  49899. */
  49900. protected _useParallaxOcclusion: boolean;
  49901. /**
  49902. * Controls the scale bias of the parallax mode.
  49903. */
  49904. protected _parallaxScaleBias: number;
  49905. /**
  49906. * If sets to true, disables all the lights affecting the material.
  49907. */
  49908. protected _disableLighting: boolean;
  49909. /**
  49910. * Number of Simultaneous lights allowed on the material.
  49911. */
  49912. protected _maxSimultaneousLights: number;
  49913. /**
  49914. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49915. */
  49916. protected _invertNormalMapX: boolean;
  49917. /**
  49918. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49919. */
  49920. protected _invertNormalMapY: boolean;
  49921. /**
  49922. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49923. */
  49924. protected _twoSidedLighting: boolean;
  49925. /**
  49926. * Defines the alpha limits in alpha test mode.
  49927. */
  49928. protected _alphaCutOff: number;
  49929. /**
  49930. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49931. */
  49932. protected _forceAlphaTest: boolean;
  49933. /**
  49934. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49935. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49936. */
  49937. protected _useAlphaFresnel: boolean;
  49938. /**
  49939. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49940. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49941. */
  49942. protected _useLinearAlphaFresnel: boolean;
  49943. /**
  49944. * The transparency mode of the material.
  49945. */
  49946. protected _transparencyMode: Nullable<number>;
  49947. /**
  49948. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49949. * from cos thetav and roughness:
  49950. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49951. */
  49952. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49953. /**
  49954. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49955. */
  49956. protected _forceIrradianceInFragment: boolean;
  49957. /**
  49958. * Force normal to face away from face.
  49959. */
  49960. protected _forceNormalForward: boolean;
  49961. /**
  49962. * Enables specular anti aliasing in the PBR shader.
  49963. * It will both interacts on the Geometry for analytical and IBL lighting.
  49964. * It also prefilter the roughness map based on the bump values.
  49965. */
  49966. protected _enableSpecularAntiAliasing: boolean;
  49967. /**
  49968. * Default configuration related to image processing available in the PBR Material.
  49969. */
  49970. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49971. /**
  49972. * Keep track of the image processing observer to allow dispose and replace.
  49973. */
  49974. private _imageProcessingObserver;
  49975. /**
  49976. * Attaches a new image processing configuration to the PBR Material.
  49977. * @param configuration
  49978. */
  49979. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49980. /**
  49981. * Stores the available render targets.
  49982. */
  49983. private _renderTargets;
  49984. /**
  49985. * Sets the global ambient color for the material used in lighting calculations.
  49986. */
  49987. private _globalAmbientColor;
  49988. /**
  49989. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49990. */
  49991. private _useLogarithmicDepth;
  49992. /**
  49993. * If set to true, no lighting calculations will be applied.
  49994. */
  49995. private _unlit;
  49996. private _debugMode;
  49997. /**
  49998. * @hidden
  49999. * This is reserved for the inspector.
  50000. * Defines the material debug mode.
  50001. * It helps seeing only some components of the material while troubleshooting.
  50002. */
  50003. debugMode: number;
  50004. /**
  50005. * @hidden
  50006. * This is reserved for the inspector.
  50007. * Specify from where on screen the debug mode should start.
  50008. * The value goes from -1 (full screen) to 1 (not visible)
  50009. * It helps with side by side comparison against the final render
  50010. * This defaults to -1
  50011. */
  50012. private debugLimit;
  50013. /**
  50014. * @hidden
  50015. * This is reserved for the inspector.
  50016. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50017. * You can use the factor to better multiply the final value.
  50018. */
  50019. private debugFactor;
  50020. /**
  50021. * Defines the clear coat layer parameters for the material.
  50022. */
  50023. readonly clearCoat: PBRClearCoatConfiguration;
  50024. /**
  50025. * Defines the anisotropic parameters for the material.
  50026. */
  50027. readonly anisotropy: PBRAnisotropicConfiguration;
  50028. /**
  50029. * Defines the BRDF parameters for the material.
  50030. */
  50031. readonly brdf: PBRBRDFConfiguration;
  50032. /**
  50033. * Defines the Sheen parameters for the material.
  50034. */
  50035. readonly sheen: PBRSheenConfiguration;
  50036. /**
  50037. * Defines the SubSurface parameters for the material.
  50038. */
  50039. readonly subSurface: PBRSubSurfaceConfiguration;
  50040. /**
  50041. * Custom callback helping to override the default shader used in the material.
  50042. */
  50043. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50044. protected _rebuildInParallel: boolean;
  50045. /**
  50046. * Instantiates a new PBRMaterial instance.
  50047. *
  50048. * @param name The material name
  50049. * @param scene The scene the material will be use in.
  50050. */
  50051. constructor(name: string, scene: Scene);
  50052. /**
  50053. * Gets a boolean indicating that current material needs to register RTT
  50054. */
  50055. readonly hasRenderTargetTextures: boolean;
  50056. /**
  50057. * Gets the name of the material class.
  50058. */
  50059. getClassName(): string;
  50060. /**
  50061. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50062. */
  50063. /**
  50064. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50065. */
  50066. useLogarithmicDepth: boolean;
  50067. /**
  50068. * Gets the current transparency mode.
  50069. */
  50070. /**
  50071. * Sets the transparency mode of the material.
  50072. *
  50073. * | Value | Type | Description |
  50074. * | ----- | ----------------------------------- | ----------- |
  50075. * | 0 | OPAQUE | |
  50076. * | 1 | ALPHATEST | |
  50077. * | 2 | ALPHABLEND | |
  50078. * | 3 | ALPHATESTANDBLEND | |
  50079. *
  50080. */
  50081. transparencyMode: Nullable<number>;
  50082. /**
  50083. * Returns true if alpha blending should be disabled.
  50084. */
  50085. private readonly _disableAlphaBlending;
  50086. /**
  50087. * Specifies whether or not this material should be rendered in alpha blend mode.
  50088. */
  50089. needAlphaBlending(): boolean;
  50090. /**
  50091. * Specifies if the mesh will require alpha blending.
  50092. * @param mesh - BJS mesh.
  50093. */
  50094. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50095. /**
  50096. * Specifies whether or not this material should be rendered in alpha test mode.
  50097. */
  50098. needAlphaTesting(): boolean;
  50099. /**
  50100. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50101. */
  50102. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50103. /**
  50104. * Gets the texture used for the alpha test.
  50105. */
  50106. getAlphaTestTexture(): Nullable<BaseTexture>;
  50107. /**
  50108. * Specifies that the submesh is ready to be used.
  50109. * @param mesh - BJS mesh.
  50110. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50111. * @param useInstances - Specifies that instances should be used.
  50112. * @returns - boolean indicating that the submesh is ready or not.
  50113. */
  50114. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50115. /**
  50116. * Specifies if the material uses metallic roughness workflow.
  50117. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50118. */
  50119. isMetallicWorkflow(): boolean;
  50120. private _prepareEffect;
  50121. private _prepareDefines;
  50122. /**
  50123. * Force shader compilation
  50124. */
  50125. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  50126. clipPlane: boolean;
  50127. }>): void;
  50128. /**
  50129. * Initializes the uniform buffer layout for the shader.
  50130. */
  50131. buildUniformLayout(): void;
  50132. /**
  50133. * Unbinds the material from the mesh
  50134. */
  50135. unbind(): void;
  50136. /**
  50137. * Binds the submesh data.
  50138. * @param world - The world matrix.
  50139. * @param mesh - The BJS mesh.
  50140. * @param subMesh - A submesh of the BJS mesh.
  50141. */
  50142. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50143. /**
  50144. * Returns the animatable textures.
  50145. * @returns - Array of animatable textures.
  50146. */
  50147. getAnimatables(): IAnimatable[];
  50148. /**
  50149. * Returns the texture used for reflections.
  50150. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50151. */
  50152. private _getReflectionTexture;
  50153. /**
  50154. * Returns an array of the actively used textures.
  50155. * @returns - Array of BaseTextures
  50156. */
  50157. getActiveTextures(): BaseTexture[];
  50158. /**
  50159. * Checks to see if a texture is used in the material.
  50160. * @param texture - Base texture to use.
  50161. * @returns - Boolean specifying if a texture is used in the material.
  50162. */
  50163. hasTexture(texture: BaseTexture): boolean;
  50164. /**
  50165. * Disposes the resources of the material.
  50166. * @param forceDisposeEffect - Forces the disposal of effects.
  50167. * @param forceDisposeTextures - Forces the disposal of all textures.
  50168. */
  50169. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50170. }
  50171. }
  50172. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50173. import { Nullable } from "babylonjs/types";
  50174. import { Scene } from "babylonjs/scene";
  50175. import { Color3 } from "babylonjs/Maths/math.color";
  50176. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50177. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50178. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50179. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50180. /**
  50181. * The Physically based material of BJS.
  50182. *
  50183. * This offers the main features of a standard PBR material.
  50184. * For more information, please refer to the documentation :
  50185. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50186. */
  50187. export class PBRMaterial extends PBRBaseMaterial {
  50188. /**
  50189. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50190. */
  50191. static readonly PBRMATERIAL_OPAQUE: number;
  50192. /**
  50193. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50194. */
  50195. static readonly PBRMATERIAL_ALPHATEST: number;
  50196. /**
  50197. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50198. */
  50199. static readonly PBRMATERIAL_ALPHABLEND: number;
  50200. /**
  50201. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50202. * They are also discarded below the alpha cutoff threshold to improve performances.
  50203. */
  50204. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50205. /**
  50206. * Defines the default value of how much AO map is occluding the analytical lights
  50207. * (point spot...).
  50208. */
  50209. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50210. /**
  50211. * Intensity of the direct lights e.g. the four lights available in your scene.
  50212. * This impacts both the direct diffuse and specular highlights.
  50213. */
  50214. directIntensity: number;
  50215. /**
  50216. * Intensity of the emissive part of the material.
  50217. * This helps controlling the emissive effect without modifying the emissive color.
  50218. */
  50219. emissiveIntensity: number;
  50220. /**
  50221. * Intensity of the environment e.g. how much the environment will light the object
  50222. * either through harmonics for rough material or through the refelction for shiny ones.
  50223. */
  50224. environmentIntensity: number;
  50225. /**
  50226. * This is a special control allowing the reduction of the specular highlights coming from the
  50227. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50228. */
  50229. specularIntensity: number;
  50230. /**
  50231. * Debug Control allowing disabling the bump map on this material.
  50232. */
  50233. disableBumpMap: boolean;
  50234. /**
  50235. * AKA Diffuse Texture in standard nomenclature.
  50236. */
  50237. albedoTexture: BaseTexture;
  50238. /**
  50239. * AKA Occlusion Texture in other nomenclature.
  50240. */
  50241. ambientTexture: BaseTexture;
  50242. /**
  50243. * AKA Occlusion Texture Intensity in other nomenclature.
  50244. */
  50245. ambientTextureStrength: number;
  50246. /**
  50247. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50248. * 1 means it completely occludes it
  50249. * 0 mean it has no impact
  50250. */
  50251. ambientTextureImpactOnAnalyticalLights: number;
  50252. /**
  50253. * Stores the alpha values in a texture.
  50254. */
  50255. opacityTexture: BaseTexture;
  50256. /**
  50257. * Stores the reflection values in a texture.
  50258. */
  50259. reflectionTexture: Nullable<BaseTexture>;
  50260. /**
  50261. * Stores the emissive values in a texture.
  50262. */
  50263. emissiveTexture: BaseTexture;
  50264. /**
  50265. * AKA Specular texture in other nomenclature.
  50266. */
  50267. reflectivityTexture: BaseTexture;
  50268. /**
  50269. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50270. */
  50271. metallicTexture: BaseTexture;
  50272. /**
  50273. * Specifies the metallic scalar of the metallic/roughness workflow.
  50274. * Can also be used to scale the metalness values of the metallic texture.
  50275. */
  50276. metallic: Nullable<number>;
  50277. /**
  50278. * Specifies the roughness scalar of the metallic/roughness workflow.
  50279. * Can also be used to scale the roughness values of the metallic texture.
  50280. */
  50281. roughness: Nullable<number>;
  50282. /**
  50283. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50284. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50285. */
  50286. microSurfaceTexture: BaseTexture;
  50287. /**
  50288. * Stores surface normal data used to displace a mesh in a texture.
  50289. */
  50290. bumpTexture: BaseTexture;
  50291. /**
  50292. * Stores the pre-calculated light information of a mesh in a texture.
  50293. */
  50294. lightmapTexture: BaseTexture;
  50295. /**
  50296. * Stores the refracted light information in a texture.
  50297. */
  50298. refractionTexture: Nullable<BaseTexture>;
  50299. /**
  50300. * The color of a material in ambient lighting.
  50301. */
  50302. ambientColor: Color3;
  50303. /**
  50304. * AKA Diffuse Color in other nomenclature.
  50305. */
  50306. albedoColor: Color3;
  50307. /**
  50308. * AKA Specular Color in other nomenclature.
  50309. */
  50310. reflectivityColor: Color3;
  50311. /**
  50312. * The color reflected from the material.
  50313. */
  50314. reflectionColor: Color3;
  50315. /**
  50316. * The color emitted from the material.
  50317. */
  50318. emissiveColor: Color3;
  50319. /**
  50320. * AKA Glossiness in other nomenclature.
  50321. */
  50322. microSurface: number;
  50323. /**
  50324. * source material index of refraction (IOR)' / 'destination material IOR.
  50325. */
  50326. indexOfRefraction: number;
  50327. /**
  50328. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50329. */
  50330. invertRefractionY: boolean;
  50331. /**
  50332. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50333. * Materials half opaque for instance using refraction could benefit from this control.
  50334. */
  50335. linkRefractionWithTransparency: boolean;
  50336. /**
  50337. * If true, the light map contains occlusion information instead of lighting info.
  50338. */
  50339. useLightmapAsShadowmap: boolean;
  50340. /**
  50341. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50342. */
  50343. useAlphaFromAlbedoTexture: boolean;
  50344. /**
  50345. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50346. */
  50347. forceAlphaTest: boolean;
  50348. /**
  50349. * Defines the alpha limits in alpha test mode.
  50350. */
  50351. alphaCutOff: number;
  50352. /**
  50353. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50354. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50355. */
  50356. useSpecularOverAlpha: boolean;
  50357. /**
  50358. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50359. */
  50360. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50361. /**
  50362. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50363. */
  50364. useRoughnessFromMetallicTextureAlpha: boolean;
  50365. /**
  50366. * Specifies if the metallic texture contains the roughness information in its green channel.
  50367. */
  50368. useRoughnessFromMetallicTextureGreen: boolean;
  50369. /**
  50370. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50371. */
  50372. useMetallnessFromMetallicTextureBlue: boolean;
  50373. /**
  50374. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50375. */
  50376. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50377. /**
  50378. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50379. */
  50380. useAmbientInGrayScale: boolean;
  50381. /**
  50382. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50383. * The material will try to infer what glossiness each pixel should be.
  50384. */
  50385. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50386. /**
  50387. * BJS is using an harcoded light falloff based on a manually sets up range.
  50388. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50389. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50390. */
  50391. /**
  50392. * BJS is using an harcoded light falloff based on a manually sets up range.
  50393. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50394. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50395. */
  50396. usePhysicalLightFalloff: boolean;
  50397. /**
  50398. * In order to support the falloff compatibility with gltf, a special mode has been added
  50399. * to reproduce the gltf light falloff.
  50400. */
  50401. /**
  50402. * In order to support the falloff compatibility with gltf, a special mode has been added
  50403. * to reproduce the gltf light falloff.
  50404. */
  50405. useGLTFLightFalloff: boolean;
  50406. /**
  50407. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50408. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50409. */
  50410. useRadianceOverAlpha: boolean;
  50411. /**
  50412. * Allows using an object space normal map (instead of tangent space).
  50413. */
  50414. useObjectSpaceNormalMap: boolean;
  50415. /**
  50416. * Allows using the bump map in parallax mode.
  50417. */
  50418. useParallax: boolean;
  50419. /**
  50420. * Allows using the bump map in parallax occlusion mode.
  50421. */
  50422. useParallaxOcclusion: boolean;
  50423. /**
  50424. * Controls the scale bias of the parallax mode.
  50425. */
  50426. parallaxScaleBias: number;
  50427. /**
  50428. * If sets to true, disables all the lights affecting the material.
  50429. */
  50430. disableLighting: boolean;
  50431. /**
  50432. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50433. */
  50434. forceIrradianceInFragment: boolean;
  50435. /**
  50436. * Number of Simultaneous lights allowed on the material.
  50437. */
  50438. maxSimultaneousLights: number;
  50439. /**
  50440. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50441. */
  50442. invertNormalMapX: boolean;
  50443. /**
  50444. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50445. */
  50446. invertNormalMapY: boolean;
  50447. /**
  50448. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50449. */
  50450. twoSidedLighting: boolean;
  50451. /**
  50452. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50453. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50454. */
  50455. useAlphaFresnel: boolean;
  50456. /**
  50457. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50458. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50459. */
  50460. useLinearAlphaFresnel: boolean;
  50461. /**
  50462. * Let user defines the brdf lookup texture used for IBL.
  50463. * A default 8bit version is embedded but you could point at :
  50464. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50465. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50466. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50467. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50468. */
  50469. environmentBRDFTexture: Nullable<BaseTexture>;
  50470. /**
  50471. * Force normal to face away from face.
  50472. */
  50473. forceNormalForward: boolean;
  50474. /**
  50475. * Enables specular anti aliasing in the PBR shader.
  50476. * It will both interacts on the Geometry for analytical and IBL lighting.
  50477. * It also prefilter the roughness map based on the bump values.
  50478. */
  50479. enableSpecularAntiAliasing: boolean;
  50480. /**
  50481. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50482. * makes the reflect vector face the model (under horizon).
  50483. */
  50484. useHorizonOcclusion: boolean;
  50485. /**
  50486. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50487. * too much the area relying on ambient texture to define their ambient occlusion.
  50488. */
  50489. useRadianceOcclusion: boolean;
  50490. /**
  50491. * If set to true, no lighting calculations will be applied.
  50492. */
  50493. unlit: boolean;
  50494. /**
  50495. * Gets the image processing configuration used either in this material.
  50496. */
  50497. /**
  50498. * Sets the Default image processing configuration used either in the this material.
  50499. *
  50500. * If sets to null, the scene one is in use.
  50501. */
  50502. imageProcessingConfiguration: ImageProcessingConfiguration;
  50503. /**
  50504. * Gets wether the color curves effect is enabled.
  50505. */
  50506. /**
  50507. * Sets wether the color curves effect is enabled.
  50508. */
  50509. cameraColorCurvesEnabled: boolean;
  50510. /**
  50511. * Gets wether the color grading effect is enabled.
  50512. */
  50513. /**
  50514. * Gets wether the color grading effect is enabled.
  50515. */
  50516. cameraColorGradingEnabled: boolean;
  50517. /**
  50518. * Gets wether tonemapping is enabled or not.
  50519. */
  50520. /**
  50521. * Sets wether tonemapping is enabled or not
  50522. */
  50523. cameraToneMappingEnabled: boolean;
  50524. /**
  50525. * The camera exposure used on this material.
  50526. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50527. * This corresponds to a photographic exposure.
  50528. */
  50529. /**
  50530. * The camera exposure used on this material.
  50531. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50532. * This corresponds to a photographic exposure.
  50533. */
  50534. cameraExposure: number;
  50535. /**
  50536. * Gets The camera contrast used on this material.
  50537. */
  50538. /**
  50539. * Sets The camera contrast used on this material.
  50540. */
  50541. cameraContrast: number;
  50542. /**
  50543. * Gets the Color Grading 2D Lookup Texture.
  50544. */
  50545. /**
  50546. * Sets the Color Grading 2D Lookup Texture.
  50547. */
  50548. cameraColorGradingTexture: Nullable<BaseTexture>;
  50549. /**
  50550. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50551. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50552. * 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;
  50553. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50554. */
  50555. /**
  50556. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50557. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50558. * 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;
  50559. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50560. */
  50561. cameraColorCurves: Nullable<ColorCurves>;
  50562. /**
  50563. * Instantiates a new PBRMaterial instance.
  50564. *
  50565. * @param name The material name
  50566. * @param scene The scene the material will be use in.
  50567. */
  50568. constructor(name: string, scene: Scene);
  50569. /**
  50570. * Returns the name of this material class.
  50571. */
  50572. getClassName(): string;
  50573. /**
  50574. * Makes a duplicate of the current material.
  50575. * @param name - name to use for the new material.
  50576. */
  50577. clone(name: string): PBRMaterial;
  50578. /**
  50579. * Serializes this PBR Material.
  50580. * @returns - An object with the serialized material.
  50581. */
  50582. serialize(): any;
  50583. /**
  50584. * Parses a PBR Material from a serialized object.
  50585. * @param source - Serialized object.
  50586. * @param scene - BJS scene instance.
  50587. * @param rootUrl - url for the scene object
  50588. * @returns - PBRMaterial
  50589. */
  50590. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50591. }
  50592. }
  50593. declare module "babylonjs/Misc/dds" {
  50594. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50595. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50596. import { Nullable } from "babylonjs/types";
  50597. import { Scene } from "babylonjs/scene";
  50598. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50599. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50600. /**
  50601. * Direct draw surface info
  50602. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50603. */
  50604. export interface DDSInfo {
  50605. /**
  50606. * Width of the texture
  50607. */
  50608. width: number;
  50609. /**
  50610. * Width of the texture
  50611. */
  50612. height: number;
  50613. /**
  50614. * Number of Mipmaps for the texture
  50615. * @see https://en.wikipedia.org/wiki/Mipmap
  50616. */
  50617. mipmapCount: number;
  50618. /**
  50619. * If the textures format is a known fourCC format
  50620. * @see https://www.fourcc.org/
  50621. */
  50622. isFourCC: boolean;
  50623. /**
  50624. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50625. */
  50626. isRGB: boolean;
  50627. /**
  50628. * If the texture is a lumincance format
  50629. */
  50630. isLuminance: boolean;
  50631. /**
  50632. * If this is a cube texture
  50633. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50634. */
  50635. isCube: boolean;
  50636. /**
  50637. * If the texture is a compressed format eg. FOURCC_DXT1
  50638. */
  50639. isCompressed: boolean;
  50640. /**
  50641. * The dxgiFormat of the texture
  50642. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50643. */
  50644. dxgiFormat: number;
  50645. /**
  50646. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50647. */
  50648. textureType: number;
  50649. /**
  50650. * Sphericle polynomial created for the dds texture
  50651. */
  50652. sphericalPolynomial?: SphericalPolynomial;
  50653. }
  50654. /**
  50655. * Class used to provide DDS decompression tools
  50656. */
  50657. export class DDSTools {
  50658. /**
  50659. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50660. */
  50661. static StoreLODInAlphaChannel: boolean;
  50662. /**
  50663. * Gets DDS information from an array buffer
  50664. * @param arrayBuffer defines the array buffer to read data from
  50665. * @returns the DDS information
  50666. */
  50667. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50668. private static _FloatView;
  50669. private static _Int32View;
  50670. private static _ToHalfFloat;
  50671. private static _FromHalfFloat;
  50672. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50673. private static _GetHalfFloatRGBAArrayBuffer;
  50674. private static _GetFloatRGBAArrayBuffer;
  50675. private static _GetFloatAsUIntRGBAArrayBuffer;
  50676. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50677. private static _GetRGBAArrayBuffer;
  50678. private static _ExtractLongWordOrder;
  50679. private static _GetRGBArrayBuffer;
  50680. private static _GetLuminanceArrayBuffer;
  50681. /**
  50682. * Uploads DDS Levels to a Babylon Texture
  50683. * @hidden
  50684. */
  50685. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50686. }
  50687. module "babylonjs/Engines/thinEngine" {
  50688. interface ThinEngine {
  50689. /**
  50690. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50691. * @param rootUrl defines the url where the file to load is located
  50692. * @param scene defines the current scene
  50693. * @param lodScale defines scale to apply to the mip map selection
  50694. * @param lodOffset defines offset to apply to the mip map selection
  50695. * @param onLoad defines an optional callback raised when the texture is loaded
  50696. * @param onError defines an optional callback raised if there is an issue to load the texture
  50697. * @param format defines the format of the data
  50698. * @param forcedExtension defines the extension to use to pick the right loader
  50699. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50700. * @returns the cube texture as an InternalTexture
  50701. */
  50702. 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;
  50703. }
  50704. }
  50705. }
  50706. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50707. import { Nullable } from "babylonjs/types";
  50708. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50709. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50710. /**
  50711. * Implementation of the DDS Texture Loader.
  50712. * @hidden
  50713. */
  50714. export class _DDSTextureLoader implements IInternalTextureLoader {
  50715. /**
  50716. * Defines wether the loader supports cascade loading the different faces.
  50717. */
  50718. readonly supportCascades: boolean;
  50719. /**
  50720. * This returns if the loader support the current file information.
  50721. * @param extension defines the file extension of the file being loaded
  50722. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50723. * @param fallback defines the fallback internal texture if any
  50724. * @param isBase64 defines whether the texture is encoded as a base64
  50725. * @param isBuffer defines whether the texture data are stored as a buffer
  50726. * @returns true if the loader can load the specified file
  50727. */
  50728. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50729. /**
  50730. * Transform the url before loading if required.
  50731. * @param rootUrl the url of the texture
  50732. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50733. * @returns the transformed texture
  50734. */
  50735. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50736. /**
  50737. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50738. * @param rootUrl the url of the texture
  50739. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50740. * @returns the fallback texture
  50741. */
  50742. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50743. /**
  50744. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50745. * @param data contains the texture data
  50746. * @param texture defines the BabylonJS internal texture
  50747. * @param createPolynomials will be true if polynomials have been requested
  50748. * @param onLoad defines the callback to trigger once the texture is ready
  50749. * @param onError defines the callback to trigger in case of error
  50750. */
  50751. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50752. /**
  50753. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50754. * @param data contains the texture data
  50755. * @param texture defines the BabylonJS internal texture
  50756. * @param callback defines the method to call once ready to upload
  50757. */
  50758. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50759. }
  50760. }
  50761. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50762. import { Nullable } from "babylonjs/types";
  50763. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50764. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50765. /**
  50766. * Implementation of the ENV Texture Loader.
  50767. * @hidden
  50768. */
  50769. export class _ENVTextureLoader implements IInternalTextureLoader {
  50770. /**
  50771. * Defines wether the loader supports cascade loading the different faces.
  50772. */
  50773. readonly supportCascades: boolean;
  50774. /**
  50775. * This returns if the loader support the current file information.
  50776. * @param extension defines the file extension of the file being loaded
  50777. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50778. * @param fallback defines the fallback internal texture if any
  50779. * @param isBase64 defines whether the texture is encoded as a base64
  50780. * @param isBuffer defines whether the texture data are stored as a buffer
  50781. * @returns true if the loader can load the specified file
  50782. */
  50783. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50784. /**
  50785. * Transform the url before loading if required.
  50786. * @param rootUrl the url of the texture
  50787. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50788. * @returns the transformed texture
  50789. */
  50790. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50791. /**
  50792. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50793. * @param rootUrl the url of the texture
  50794. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50795. * @returns the fallback texture
  50796. */
  50797. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50798. /**
  50799. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50800. * @param data contains the texture data
  50801. * @param texture defines the BabylonJS internal texture
  50802. * @param createPolynomials will be true if polynomials have been requested
  50803. * @param onLoad defines the callback to trigger once the texture is ready
  50804. * @param onError defines the callback to trigger in case of error
  50805. */
  50806. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50807. /**
  50808. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50809. * @param data contains the texture data
  50810. * @param texture defines the BabylonJS internal texture
  50811. * @param callback defines the method to call once ready to upload
  50812. */
  50813. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50814. }
  50815. }
  50816. declare module "babylonjs/Misc/khronosTextureContainer" {
  50817. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50818. /**
  50819. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50820. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50821. */
  50822. export class KhronosTextureContainer {
  50823. /** contents of the KTX container file */
  50824. arrayBuffer: any;
  50825. private static HEADER_LEN;
  50826. private static COMPRESSED_2D;
  50827. private static COMPRESSED_3D;
  50828. private static TEX_2D;
  50829. private static TEX_3D;
  50830. /**
  50831. * Gets the openGL type
  50832. */
  50833. glType: number;
  50834. /**
  50835. * Gets the openGL type size
  50836. */
  50837. glTypeSize: number;
  50838. /**
  50839. * Gets the openGL format
  50840. */
  50841. glFormat: number;
  50842. /**
  50843. * Gets the openGL internal format
  50844. */
  50845. glInternalFormat: number;
  50846. /**
  50847. * Gets the base internal format
  50848. */
  50849. glBaseInternalFormat: number;
  50850. /**
  50851. * Gets image width in pixel
  50852. */
  50853. pixelWidth: number;
  50854. /**
  50855. * Gets image height in pixel
  50856. */
  50857. pixelHeight: number;
  50858. /**
  50859. * Gets image depth in pixels
  50860. */
  50861. pixelDepth: number;
  50862. /**
  50863. * Gets the number of array elements
  50864. */
  50865. numberOfArrayElements: number;
  50866. /**
  50867. * Gets the number of faces
  50868. */
  50869. numberOfFaces: number;
  50870. /**
  50871. * Gets the number of mipmap levels
  50872. */
  50873. numberOfMipmapLevels: number;
  50874. /**
  50875. * Gets the bytes of key value data
  50876. */
  50877. bytesOfKeyValueData: number;
  50878. /**
  50879. * Gets the load type
  50880. */
  50881. loadType: number;
  50882. /**
  50883. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50884. */
  50885. isInvalid: boolean;
  50886. /**
  50887. * Creates a new KhronosTextureContainer
  50888. * @param arrayBuffer contents of the KTX container file
  50889. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50890. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50891. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50892. */
  50893. constructor(
  50894. /** contents of the KTX container file */
  50895. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50896. /**
  50897. * Uploads KTX content to a Babylon Texture.
  50898. * It is assumed that the texture has already been created & is currently bound
  50899. * @hidden
  50900. */
  50901. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50902. private _upload2DCompressedLevels;
  50903. }
  50904. }
  50905. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50906. import { Nullable } from "babylonjs/types";
  50907. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50908. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50909. /**
  50910. * Implementation of the KTX Texture Loader.
  50911. * @hidden
  50912. */
  50913. export class _KTXTextureLoader implements IInternalTextureLoader {
  50914. /**
  50915. * Defines wether the loader supports cascade loading the different faces.
  50916. */
  50917. readonly supportCascades: boolean;
  50918. /**
  50919. * This returns if the loader support the current file information.
  50920. * @param extension defines the file extension of the file being loaded
  50921. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50922. * @param fallback defines the fallback internal texture if any
  50923. * @param isBase64 defines whether the texture is encoded as a base64
  50924. * @param isBuffer defines whether the texture data are stored as a buffer
  50925. * @returns true if the loader can load the specified file
  50926. */
  50927. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50928. /**
  50929. * Transform the url before loading if required.
  50930. * @param rootUrl the url of the texture
  50931. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50932. * @returns the transformed texture
  50933. */
  50934. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50935. /**
  50936. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50937. * @param rootUrl the url of the texture
  50938. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50939. * @returns the fallback texture
  50940. */
  50941. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50942. /**
  50943. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50944. * @param data contains the texture data
  50945. * @param texture defines the BabylonJS internal texture
  50946. * @param createPolynomials will be true if polynomials have been requested
  50947. * @param onLoad defines the callback to trigger once the texture is ready
  50948. * @param onError defines the callback to trigger in case of error
  50949. */
  50950. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50951. /**
  50952. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50953. * @param data contains the texture data
  50954. * @param texture defines the BabylonJS internal texture
  50955. * @param callback defines the method to call once ready to upload
  50956. */
  50957. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50958. }
  50959. }
  50960. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50961. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50962. import { Scene } from "babylonjs/scene";
  50963. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50964. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50965. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50966. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50967. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50968. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50970. /**
  50971. * Options for the default xr helper
  50972. */
  50973. export class WebXRDefaultExperienceOptions {
  50974. /**
  50975. * Floor meshes that should be used for teleporting
  50976. */
  50977. floorMeshes: Array<AbstractMesh>;
  50978. }
  50979. /**
  50980. * Default experience which provides a similar setup to the previous webVRExperience
  50981. */
  50982. export class WebXRDefaultExperience {
  50983. /**
  50984. * Base experience
  50985. */
  50986. baseExperience: WebXRExperienceHelper;
  50987. /**
  50988. * Input experience extension
  50989. */
  50990. input: WebXRInput;
  50991. /**
  50992. * Loads the controller models
  50993. */
  50994. controllerModelLoader: WebXRControllerModelLoader;
  50995. /**
  50996. * Enables laser pointer and selection
  50997. */
  50998. pointerSelection: WebXRControllerPointerSelection;
  50999. /**
  51000. * Enables teleportation
  51001. */
  51002. teleportation: WebXRControllerTeleportation;
  51003. /**
  51004. * Enables ui for enetering/exiting xr
  51005. */
  51006. enterExitUI: WebXREnterExitUI;
  51007. /**
  51008. * Default output canvas xr should render to
  51009. */
  51010. outputCanvas: WebXRManagedOutputCanvas;
  51011. /**
  51012. * Creates the default xr experience
  51013. * @param scene scene
  51014. * @param options options for basic configuration
  51015. * @returns resulting WebXRDefaultExperience
  51016. */
  51017. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51018. private constructor();
  51019. /**
  51020. * DIsposes of the experience helper
  51021. */
  51022. dispose(): void;
  51023. }
  51024. }
  51025. declare module "babylonjs/Helpers/sceneHelpers" {
  51026. import { Nullable } from "babylonjs/types";
  51027. import { Mesh } from "babylonjs/Meshes/mesh";
  51028. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51029. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51030. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51031. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51032. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51033. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51034. import "babylonjs/Meshes/Builders/boxBuilder";
  51035. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51036. /** @hidden */
  51037. export var _forceSceneHelpersToBundle: boolean;
  51038. module "babylonjs/scene" {
  51039. interface Scene {
  51040. /**
  51041. * Creates a default light for the scene.
  51042. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51043. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51044. */
  51045. createDefaultLight(replace?: boolean): void;
  51046. /**
  51047. * Creates a default camera for the scene.
  51048. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51049. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51050. * @param replace has default false, when true replaces the active camera in the scene
  51051. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51052. */
  51053. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51054. /**
  51055. * Creates a default camera and a default light.
  51056. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51057. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51058. * @param replace has the default false, when true replaces the active camera/light in the scene
  51059. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51060. */
  51061. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51062. /**
  51063. * Creates a new sky box
  51064. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51065. * @param environmentTexture defines the texture to use as environment texture
  51066. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51067. * @param scale defines the overall scale of the skybox
  51068. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51069. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51070. * @returns a new mesh holding the sky box
  51071. */
  51072. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51073. /**
  51074. * Creates a new environment
  51075. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51076. * @param options defines the options you can use to configure the environment
  51077. * @returns the new EnvironmentHelper
  51078. */
  51079. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51080. /**
  51081. * Creates a new VREXperienceHelper
  51082. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51083. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51084. * @returns a new VREXperienceHelper
  51085. */
  51086. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51087. /**
  51088. * Creates a new WebXRDefaultExperience
  51089. * @see http://doc.babylonjs.com/how_to/webxr
  51090. * @param options experience options
  51091. * @returns a promise for a new WebXRDefaultExperience
  51092. */
  51093. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51094. }
  51095. }
  51096. }
  51097. declare module "babylonjs/Helpers/videoDome" {
  51098. import { Scene } from "babylonjs/scene";
  51099. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51100. import { Mesh } from "babylonjs/Meshes/mesh";
  51101. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51102. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51103. import "babylonjs/Meshes/Builders/sphereBuilder";
  51104. /**
  51105. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51106. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51107. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51108. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51109. */
  51110. export class VideoDome extends TransformNode {
  51111. /**
  51112. * Define the video source as a Monoscopic panoramic 360 video.
  51113. */
  51114. static readonly MODE_MONOSCOPIC: number;
  51115. /**
  51116. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51117. */
  51118. static readonly MODE_TOPBOTTOM: number;
  51119. /**
  51120. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51121. */
  51122. static readonly MODE_SIDEBYSIDE: number;
  51123. private _halfDome;
  51124. private _useDirectMapping;
  51125. /**
  51126. * The video texture being displayed on the sphere
  51127. */
  51128. protected _videoTexture: VideoTexture;
  51129. /**
  51130. * Gets the video texture being displayed on the sphere
  51131. */
  51132. readonly videoTexture: VideoTexture;
  51133. /**
  51134. * The skybox material
  51135. */
  51136. protected _material: BackgroundMaterial;
  51137. /**
  51138. * The surface used for the skybox
  51139. */
  51140. protected _mesh: Mesh;
  51141. /**
  51142. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51143. */
  51144. private _halfDomeMask;
  51145. /**
  51146. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51147. * Also see the options.resolution property.
  51148. */
  51149. fovMultiplier: number;
  51150. private _videoMode;
  51151. /**
  51152. * Gets or set the current video mode for the video. It can be:
  51153. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51154. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51155. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51156. */
  51157. videoMode: number;
  51158. /**
  51159. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51160. *
  51161. */
  51162. /**
  51163. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51164. */
  51165. halfDome: boolean;
  51166. /**
  51167. * Oberserver used in Stereoscopic VR Mode.
  51168. */
  51169. private _onBeforeCameraRenderObserver;
  51170. /**
  51171. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51172. * @param name Element's name, child elements will append suffixes for their own names.
  51173. * @param urlsOrVideo defines the url(s) or the video element to use
  51174. * @param options An object containing optional or exposed sub element properties
  51175. */
  51176. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51177. resolution?: number;
  51178. clickToPlay?: boolean;
  51179. autoPlay?: boolean;
  51180. loop?: boolean;
  51181. size?: number;
  51182. poster?: string;
  51183. faceForward?: boolean;
  51184. useDirectMapping?: boolean;
  51185. halfDomeMode?: boolean;
  51186. }, scene: Scene);
  51187. private _changeVideoMode;
  51188. /**
  51189. * Releases resources associated with this node.
  51190. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51191. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51192. */
  51193. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51194. }
  51195. }
  51196. declare module "babylonjs/Helpers/index" {
  51197. export * from "babylonjs/Helpers/environmentHelper";
  51198. export * from "babylonjs/Helpers/photoDome";
  51199. export * from "babylonjs/Helpers/sceneHelpers";
  51200. export * from "babylonjs/Helpers/videoDome";
  51201. }
  51202. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51203. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51204. import { IDisposable } from "babylonjs/scene";
  51205. import { Engine } from "babylonjs/Engines/engine";
  51206. /**
  51207. * This class can be used to get instrumentation data from a Babylon engine
  51208. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51209. */
  51210. export class EngineInstrumentation implements IDisposable {
  51211. /**
  51212. * Define the instrumented engine.
  51213. */
  51214. engine: Engine;
  51215. private _captureGPUFrameTime;
  51216. private _gpuFrameTimeToken;
  51217. private _gpuFrameTime;
  51218. private _captureShaderCompilationTime;
  51219. private _shaderCompilationTime;
  51220. private _onBeginFrameObserver;
  51221. private _onEndFrameObserver;
  51222. private _onBeforeShaderCompilationObserver;
  51223. private _onAfterShaderCompilationObserver;
  51224. /**
  51225. * Gets the perf counter used for GPU frame time
  51226. */
  51227. readonly gpuFrameTimeCounter: PerfCounter;
  51228. /**
  51229. * Gets the GPU frame time capture status
  51230. */
  51231. /**
  51232. * Enable or disable the GPU frame time capture
  51233. */
  51234. captureGPUFrameTime: boolean;
  51235. /**
  51236. * Gets the perf counter used for shader compilation time
  51237. */
  51238. readonly shaderCompilationTimeCounter: PerfCounter;
  51239. /**
  51240. * Gets the shader compilation time capture status
  51241. */
  51242. /**
  51243. * Enable or disable the shader compilation time capture
  51244. */
  51245. captureShaderCompilationTime: boolean;
  51246. /**
  51247. * Instantiates a new engine instrumentation.
  51248. * This class can be used to get instrumentation data from a Babylon engine
  51249. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51250. * @param engine Defines the engine to instrument
  51251. */
  51252. constructor(
  51253. /**
  51254. * Define the instrumented engine.
  51255. */
  51256. engine: Engine);
  51257. /**
  51258. * Dispose and release associated resources.
  51259. */
  51260. dispose(): void;
  51261. }
  51262. }
  51263. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51264. import { Scene, IDisposable } from "babylonjs/scene";
  51265. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51266. /**
  51267. * This class can be used to get instrumentation data from a Babylon engine
  51268. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51269. */
  51270. export class SceneInstrumentation implements IDisposable {
  51271. /**
  51272. * Defines the scene to instrument
  51273. */
  51274. scene: Scene;
  51275. private _captureActiveMeshesEvaluationTime;
  51276. private _activeMeshesEvaluationTime;
  51277. private _captureRenderTargetsRenderTime;
  51278. private _renderTargetsRenderTime;
  51279. private _captureFrameTime;
  51280. private _frameTime;
  51281. private _captureRenderTime;
  51282. private _renderTime;
  51283. private _captureInterFrameTime;
  51284. private _interFrameTime;
  51285. private _captureParticlesRenderTime;
  51286. private _particlesRenderTime;
  51287. private _captureSpritesRenderTime;
  51288. private _spritesRenderTime;
  51289. private _capturePhysicsTime;
  51290. private _physicsTime;
  51291. private _captureAnimationsTime;
  51292. private _animationsTime;
  51293. private _captureCameraRenderTime;
  51294. private _cameraRenderTime;
  51295. private _onBeforeActiveMeshesEvaluationObserver;
  51296. private _onAfterActiveMeshesEvaluationObserver;
  51297. private _onBeforeRenderTargetsRenderObserver;
  51298. private _onAfterRenderTargetsRenderObserver;
  51299. private _onAfterRenderObserver;
  51300. private _onBeforeDrawPhaseObserver;
  51301. private _onAfterDrawPhaseObserver;
  51302. private _onBeforeAnimationsObserver;
  51303. private _onBeforeParticlesRenderingObserver;
  51304. private _onAfterParticlesRenderingObserver;
  51305. private _onBeforeSpritesRenderingObserver;
  51306. private _onAfterSpritesRenderingObserver;
  51307. private _onBeforePhysicsObserver;
  51308. private _onAfterPhysicsObserver;
  51309. private _onAfterAnimationsObserver;
  51310. private _onBeforeCameraRenderObserver;
  51311. private _onAfterCameraRenderObserver;
  51312. /**
  51313. * Gets the perf counter used for active meshes evaluation time
  51314. */
  51315. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51316. /**
  51317. * Gets the active meshes evaluation time capture status
  51318. */
  51319. /**
  51320. * Enable or disable the active meshes evaluation time capture
  51321. */
  51322. captureActiveMeshesEvaluationTime: boolean;
  51323. /**
  51324. * Gets the perf counter used for render targets render time
  51325. */
  51326. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51327. /**
  51328. * Gets the render targets render time capture status
  51329. */
  51330. /**
  51331. * Enable or disable the render targets render time capture
  51332. */
  51333. captureRenderTargetsRenderTime: boolean;
  51334. /**
  51335. * Gets the perf counter used for particles render time
  51336. */
  51337. readonly particlesRenderTimeCounter: PerfCounter;
  51338. /**
  51339. * Gets the particles render time capture status
  51340. */
  51341. /**
  51342. * Enable or disable the particles render time capture
  51343. */
  51344. captureParticlesRenderTime: boolean;
  51345. /**
  51346. * Gets the perf counter used for sprites render time
  51347. */
  51348. readonly spritesRenderTimeCounter: PerfCounter;
  51349. /**
  51350. * Gets the sprites render time capture status
  51351. */
  51352. /**
  51353. * Enable or disable the sprites render time capture
  51354. */
  51355. captureSpritesRenderTime: boolean;
  51356. /**
  51357. * Gets the perf counter used for physics time
  51358. */
  51359. readonly physicsTimeCounter: PerfCounter;
  51360. /**
  51361. * Gets the physics time capture status
  51362. */
  51363. /**
  51364. * Enable or disable the physics time capture
  51365. */
  51366. capturePhysicsTime: boolean;
  51367. /**
  51368. * Gets the perf counter used for animations time
  51369. */
  51370. readonly animationsTimeCounter: PerfCounter;
  51371. /**
  51372. * Gets the animations time capture status
  51373. */
  51374. /**
  51375. * Enable or disable the animations time capture
  51376. */
  51377. captureAnimationsTime: boolean;
  51378. /**
  51379. * Gets the perf counter used for frame time capture
  51380. */
  51381. readonly frameTimeCounter: PerfCounter;
  51382. /**
  51383. * Gets the frame time capture status
  51384. */
  51385. /**
  51386. * Enable or disable the frame time capture
  51387. */
  51388. captureFrameTime: boolean;
  51389. /**
  51390. * Gets the perf counter used for inter-frames time capture
  51391. */
  51392. readonly interFrameTimeCounter: PerfCounter;
  51393. /**
  51394. * Gets the inter-frames time capture status
  51395. */
  51396. /**
  51397. * Enable or disable the inter-frames time capture
  51398. */
  51399. captureInterFrameTime: boolean;
  51400. /**
  51401. * Gets the perf counter used for render time capture
  51402. */
  51403. readonly renderTimeCounter: PerfCounter;
  51404. /**
  51405. * Gets the render time capture status
  51406. */
  51407. /**
  51408. * Enable or disable the render time capture
  51409. */
  51410. captureRenderTime: boolean;
  51411. /**
  51412. * Gets the perf counter used for camera render time capture
  51413. */
  51414. readonly cameraRenderTimeCounter: PerfCounter;
  51415. /**
  51416. * Gets the camera render time capture status
  51417. */
  51418. /**
  51419. * Enable or disable the camera render time capture
  51420. */
  51421. captureCameraRenderTime: boolean;
  51422. /**
  51423. * Gets the perf counter used for draw calls
  51424. */
  51425. readonly drawCallsCounter: PerfCounter;
  51426. /**
  51427. * Instantiates a new scene instrumentation.
  51428. * This class can be used to get instrumentation data from a Babylon engine
  51429. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51430. * @param scene Defines the scene to instrument
  51431. */
  51432. constructor(
  51433. /**
  51434. * Defines the scene to instrument
  51435. */
  51436. scene: Scene);
  51437. /**
  51438. * Dispose and release associated resources.
  51439. */
  51440. dispose(): void;
  51441. }
  51442. }
  51443. declare module "babylonjs/Instrumentation/index" {
  51444. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51445. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51446. export * from "babylonjs/Instrumentation/timeToken";
  51447. }
  51448. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51449. /** @hidden */
  51450. export var glowMapGenerationPixelShader: {
  51451. name: string;
  51452. shader: string;
  51453. };
  51454. }
  51455. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51456. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51457. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51458. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51459. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51460. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51461. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51462. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51463. /** @hidden */
  51464. export var glowMapGenerationVertexShader: {
  51465. name: string;
  51466. shader: string;
  51467. };
  51468. }
  51469. declare module "babylonjs/Layers/effectLayer" {
  51470. import { Observable } from "babylonjs/Misc/observable";
  51471. import { Nullable } from "babylonjs/types";
  51472. import { Camera } from "babylonjs/Cameras/camera";
  51473. import { Scene } from "babylonjs/scene";
  51474. import { ISize } from "babylonjs/Maths/math.size";
  51475. import { Color4 } from "babylonjs/Maths/math.color";
  51476. import { Engine } from "babylonjs/Engines/engine";
  51477. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51479. import { Mesh } from "babylonjs/Meshes/mesh";
  51480. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51481. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51482. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51483. import { Effect } from "babylonjs/Materials/effect";
  51484. import { Material } from "babylonjs/Materials/material";
  51485. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51486. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51487. /**
  51488. * Effect layer options. This helps customizing the behaviour
  51489. * of the effect layer.
  51490. */
  51491. export interface IEffectLayerOptions {
  51492. /**
  51493. * Multiplication factor apply to the canvas size to compute the render target size
  51494. * used to generated the objects (the smaller the faster).
  51495. */
  51496. mainTextureRatio: number;
  51497. /**
  51498. * Enforces a fixed size texture to ensure effect stability across devices.
  51499. */
  51500. mainTextureFixedSize?: number;
  51501. /**
  51502. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51503. */
  51504. alphaBlendingMode: number;
  51505. /**
  51506. * The camera attached to the layer.
  51507. */
  51508. camera: Nullable<Camera>;
  51509. /**
  51510. * The rendering group to draw the layer in.
  51511. */
  51512. renderingGroupId: number;
  51513. }
  51514. /**
  51515. * The effect layer Helps adding post process effect blended with the main pass.
  51516. *
  51517. * This can be for instance use to generate glow or higlight effects on the scene.
  51518. *
  51519. * The effect layer class can not be used directly and is intented to inherited from to be
  51520. * customized per effects.
  51521. */
  51522. export abstract class EffectLayer {
  51523. private _vertexBuffers;
  51524. private _indexBuffer;
  51525. private _cachedDefines;
  51526. private _effectLayerMapGenerationEffect;
  51527. private _effectLayerOptions;
  51528. private _mergeEffect;
  51529. protected _scene: Scene;
  51530. protected _engine: Engine;
  51531. protected _maxSize: number;
  51532. protected _mainTextureDesiredSize: ISize;
  51533. protected _mainTexture: RenderTargetTexture;
  51534. protected _shouldRender: boolean;
  51535. protected _postProcesses: PostProcess[];
  51536. protected _textures: BaseTexture[];
  51537. protected _emissiveTextureAndColor: {
  51538. texture: Nullable<BaseTexture>;
  51539. color: Color4;
  51540. };
  51541. /**
  51542. * The name of the layer
  51543. */
  51544. name: string;
  51545. /**
  51546. * The clear color of the texture used to generate the glow map.
  51547. */
  51548. neutralColor: Color4;
  51549. /**
  51550. * Specifies wether the highlight layer is enabled or not.
  51551. */
  51552. isEnabled: boolean;
  51553. /**
  51554. * Gets the camera attached to the layer.
  51555. */
  51556. readonly camera: Nullable<Camera>;
  51557. /**
  51558. * Gets the rendering group id the layer should render in.
  51559. */
  51560. renderingGroupId: number;
  51561. /**
  51562. * An event triggered when the effect layer has been disposed.
  51563. */
  51564. onDisposeObservable: Observable<EffectLayer>;
  51565. /**
  51566. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51567. */
  51568. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51569. /**
  51570. * An event triggered when the generated texture is being merged in the scene.
  51571. */
  51572. onBeforeComposeObservable: Observable<EffectLayer>;
  51573. /**
  51574. * An event triggered when the generated texture has been merged in the scene.
  51575. */
  51576. onAfterComposeObservable: Observable<EffectLayer>;
  51577. /**
  51578. * An event triggered when the efffect layer changes its size.
  51579. */
  51580. onSizeChangedObservable: Observable<EffectLayer>;
  51581. /** @hidden */
  51582. static _SceneComponentInitialization: (scene: Scene) => void;
  51583. /**
  51584. * Instantiates a new effect Layer and references it in the scene.
  51585. * @param name The name of the layer
  51586. * @param scene The scene to use the layer in
  51587. */
  51588. constructor(
  51589. /** The Friendly of the effect in the scene */
  51590. name: string, scene: Scene);
  51591. /**
  51592. * Get the effect name of the layer.
  51593. * @return The effect name
  51594. */
  51595. abstract getEffectName(): string;
  51596. /**
  51597. * Checks for the readiness of the element composing the layer.
  51598. * @param subMesh the mesh to check for
  51599. * @param useInstances specify wether or not to use instances to render the mesh
  51600. * @return true if ready otherwise, false
  51601. */
  51602. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51603. /**
  51604. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51605. * @returns true if the effect requires stencil during the main canvas render pass.
  51606. */
  51607. abstract needStencil(): boolean;
  51608. /**
  51609. * Create the merge effect. This is the shader use to blit the information back
  51610. * to the main canvas at the end of the scene rendering.
  51611. * @returns The effect containing the shader used to merge the effect on the main canvas
  51612. */
  51613. protected abstract _createMergeEffect(): Effect;
  51614. /**
  51615. * Creates the render target textures and post processes used in the effect layer.
  51616. */
  51617. protected abstract _createTextureAndPostProcesses(): void;
  51618. /**
  51619. * Implementation specific of rendering the generating effect on the main canvas.
  51620. * @param effect The effect used to render through
  51621. */
  51622. protected abstract _internalRender(effect: Effect): void;
  51623. /**
  51624. * Sets the required values for both the emissive texture and and the main color.
  51625. */
  51626. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51627. /**
  51628. * Free any resources and references associated to a mesh.
  51629. * Internal use
  51630. * @param mesh The mesh to free.
  51631. */
  51632. abstract _disposeMesh(mesh: Mesh): void;
  51633. /**
  51634. * Serializes this layer (Glow or Highlight for example)
  51635. * @returns a serialized layer object
  51636. */
  51637. abstract serialize?(): any;
  51638. /**
  51639. * Initializes the effect layer with the required options.
  51640. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51641. */
  51642. protected _init(options: Partial<IEffectLayerOptions>): void;
  51643. /**
  51644. * Generates the index buffer of the full screen quad blending to the main canvas.
  51645. */
  51646. private _generateIndexBuffer;
  51647. /**
  51648. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51649. */
  51650. private _generateVertexBuffer;
  51651. /**
  51652. * Sets the main texture desired size which is the closest power of two
  51653. * of the engine canvas size.
  51654. */
  51655. private _setMainTextureSize;
  51656. /**
  51657. * Creates the main texture for the effect layer.
  51658. */
  51659. protected _createMainTexture(): void;
  51660. /**
  51661. * Adds specific effects defines.
  51662. * @param defines The defines to add specifics to.
  51663. */
  51664. protected _addCustomEffectDefines(defines: string[]): void;
  51665. /**
  51666. * Checks for the readiness of the element composing the layer.
  51667. * @param subMesh the mesh to check for
  51668. * @param useInstances specify wether or not to use instances to render the mesh
  51669. * @param emissiveTexture the associated emissive texture used to generate the glow
  51670. * @return true if ready otherwise, false
  51671. */
  51672. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51673. /**
  51674. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51675. */
  51676. render(): void;
  51677. /**
  51678. * Determine if a given mesh will be used in the current effect.
  51679. * @param mesh mesh to test
  51680. * @returns true if the mesh will be used
  51681. */
  51682. hasMesh(mesh: AbstractMesh): boolean;
  51683. /**
  51684. * Returns true if the layer contains information to display, otherwise false.
  51685. * @returns true if the glow layer should be rendered
  51686. */
  51687. shouldRender(): boolean;
  51688. /**
  51689. * Returns true if the mesh should render, otherwise false.
  51690. * @param mesh The mesh to render
  51691. * @returns true if it should render otherwise false
  51692. */
  51693. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51694. /**
  51695. * Returns true if the mesh can be rendered, otherwise false.
  51696. * @param mesh The mesh to render
  51697. * @param material The material used on the mesh
  51698. * @returns true if it can be rendered otherwise false
  51699. */
  51700. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51701. /**
  51702. * Returns true if the mesh should render, otherwise false.
  51703. * @param mesh The mesh to render
  51704. * @returns true if it should render otherwise false
  51705. */
  51706. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51707. /**
  51708. * Renders the submesh passed in parameter to the generation map.
  51709. */
  51710. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51711. /**
  51712. * Rebuild the required buffers.
  51713. * @hidden Internal use only.
  51714. */
  51715. _rebuild(): void;
  51716. /**
  51717. * Dispose only the render target textures and post process.
  51718. */
  51719. private _disposeTextureAndPostProcesses;
  51720. /**
  51721. * Dispose the highlight layer and free resources.
  51722. */
  51723. dispose(): void;
  51724. /**
  51725. * Gets the class name of the effect layer
  51726. * @returns the string with the class name of the effect layer
  51727. */
  51728. getClassName(): string;
  51729. /**
  51730. * Creates an effect layer from parsed effect layer data
  51731. * @param parsedEffectLayer defines effect layer data
  51732. * @param scene defines the current scene
  51733. * @param rootUrl defines the root URL containing the effect layer information
  51734. * @returns a parsed effect Layer
  51735. */
  51736. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51737. }
  51738. }
  51739. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51740. import { Scene } from "babylonjs/scene";
  51741. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51742. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51743. import { AbstractScene } from "babylonjs/abstractScene";
  51744. module "babylonjs/abstractScene" {
  51745. interface AbstractScene {
  51746. /**
  51747. * The list of effect layers (highlights/glow) added to the scene
  51748. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51749. * @see http://doc.babylonjs.com/how_to/glow_layer
  51750. */
  51751. effectLayers: Array<EffectLayer>;
  51752. /**
  51753. * Removes the given effect layer from this scene.
  51754. * @param toRemove defines the effect layer to remove
  51755. * @returns the index of the removed effect layer
  51756. */
  51757. removeEffectLayer(toRemove: EffectLayer): number;
  51758. /**
  51759. * Adds the given effect layer to this scene
  51760. * @param newEffectLayer defines the effect layer to add
  51761. */
  51762. addEffectLayer(newEffectLayer: EffectLayer): void;
  51763. }
  51764. }
  51765. /**
  51766. * Defines the layer scene component responsible to manage any effect layers
  51767. * in a given scene.
  51768. */
  51769. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51770. /**
  51771. * The component name helpfull to identify the component in the list of scene components.
  51772. */
  51773. readonly name: string;
  51774. /**
  51775. * The scene the component belongs to.
  51776. */
  51777. scene: Scene;
  51778. private _engine;
  51779. private _renderEffects;
  51780. private _needStencil;
  51781. private _previousStencilState;
  51782. /**
  51783. * Creates a new instance of the component for the given scene
  51784. * @param scene Defines the scene to register the component in
  51785. */
  51786. constructor(scene: Scene);
  51787. /**
  51788. * Registers the component in a given scene
  51789. */
  51790. register(): void;
  51791. /**
  51792. * Rebuilds the elements related to this component in case of
  51793. * context lost for instance.
  51794. */
  51795. rebuild(): void;
  51796. /**
  51797. * Serializes the component data to the specified json object
  51798. * @param serializationObject The object to serialize to
  51799. */
  51800. serialize(serializationObject: any): void;
  51801. /**
  51802. * Adds all the elements from the container to the scene
  51803. * @param container the container holding the elements
  51804. */
  51805. addFromContainer(container: AbstractScene): void;
  51806. /**
  51807. * Removes all the elements in the container from the scene
  51808. * @param container contains the elements to remove
  51809. * @param dispose if the removed element should be disposed (default: false)
  51810. */
  51811. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51812. /**
  51813. * Disposes the component and the associated ressources.
  51814. */
  51815. dispose(): void;
  51816. private _isReadyForMesh;
  51817. private _renderMainTexture;
  51818. private _setStencil;
  51819. private _setStencilBack;
  51820. private _draw;
  51821. private _drawCamera;
  51822. private _drawRenderingGroup;
  51823. }
  51824. }
  51825. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51826. /** @hidden */
  51827. export var glowMapMergePixelShader: {
  51828. name: string;
  51829. shader: string;
  51830. };
  51831. }
  51832. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51833. /** @hidden */
  51834. export var glowMapMergeVertexShader: {
  51835. name: string;
  51836. shader: string;
  51837. };
  51838. }
  51839. declare module "babylonjs/Layers/glowLayer" {
  51840. import { Nullable } from "babylonjs/types";
  51841. import { Camera } from "babylonjs/Cameras/camera";
  51842. import { Scene } from "babylonjs/scene";
  51843. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51844. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51845. import { Mesh } from "babylonjs/Meshes/mesh";
  51846. import { Texture } from "babylonjs/Materials/Textures/texture";
  51847. import { Effect } from "babylonjs/Materials/effect";
  51848. import { Material } from "babylonjs/Materials/material";
  51849. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51850. import { Color4 } from "babylonjs/Maths/math.color";
  51851. import "babylonjs/Shaders/glowMapMerge.fragment";
  51852. import "babylonjs/Shaders/glowMapMerge.vertex";
  51853. import "babylonjs/Layers/effectLayerSceneComponent";
  51854. module "babylonjs/abstractScene" {
  51855. interface AbstractScene {
  51856. /**
  51857. * Return a the first highlight layer of the scene with a given name.
  51858. * @param name The name of the highlight layer to look for.
  51859. * @return The highlight layer if found otherwise null.
  51860. */
  51861. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51862. }
  51863. }
  51864. /**
  51865. * Glow layer options. This helps customizing the behaviour
  51866. * of the glow layer.
  51867. */
  51868. export interface IGlowLayerOptions {
  51869. /**
  51870. * Multiplication factor apply to the canvas size to compute the render target size
  51871. * used to generated the glowing objects (the smaller the faster).
  51872. */
  51873. mainTextureRatio: number;
  51874. /**
  51875. * Enforces a fixed size texture to ensure resize independant blur.
  51876. */
  51877. mainTextureFixedSize?: number;
  51878. /**
  51879. * How big is the kernel of the blur texture.
  51880. */
  51881. blurKernelSize: number;
  51882. /**
  51883. * The camera attached to the layer.
  51884. */
  51885. camera: Nullable<Camera>;
  51886. /**
  51887. * Enable MSAA by chosing the number of samples.
  51888. */
  51889. mainTextureSamples?: number;
  51890. /**
  51891. * The rendering group to draw the layer in.
  51892. */
  51893. renderingGroupId: number;
  51894. }
  51895. /**
  51896. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51897. *
  51898. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51899. * glowy meshes to your scene.
  51900. *
  51901. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51902. */
  51903. export class GlowLayer extends EffectLayer {
  51904. /**
  51905. * Effect Name of the layer.
  51906. */
  51907. static readonly EffectName: string;
  51908. /**
  51909. * The default blur kernel size used for the glow.
  51910. */
  51911. static DefaultBlurKernelSize: number;
  51912. /**
  51913. * The default texture size ratio used for the glow.
  51914. */
  51915. static DefaultTextureRatio: number;
  51916. /**
  51917. * Sets the kernel size of the blur.
  51918. */
  51919. /**
  51920. * Gets the kernel size of the blur.
  51921. */
  51922. blurKernelSize: number;
  51923. /**
  51924. * Sets the glow intensity.
  51925. */
  51926. /**
  51927. * Gets the glow intensity.
  51928. */
  51929. intensity: number;
  51930. private _options;
  51931. private _intensity;
  51932. private _horizontalBlurPostprocess1;
  51933. private _verticalBlurPostprocess1;
  51934. private _horizontalBlurPostprocess2;
  51935. private _verticalBlurPostprocess2;
  51936. private _blurTexture1;
  51937. private _blurTexture2;
  51938. private _postProcesses1;
  51939. private _postProcesses2;
  51940. private _includedOnlyMeshes;
  51941. private _excludedMeshes;
  51942. /**
  51943. * Callback used to let the user override the color selection on a per mesh basis
  51944. */
  51945. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51946. /**
  51947. * Callback used to let the user override the texture selection on a per mesh basis
  51948. */
  51949. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51950. /**
  51951. * Instantiates a new glow Layer and references it to the scene.
  51952. * @param name The name of the layer
  51953. * @param scene The scene to use the layer in
  51954. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51955. */
  51956. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51957. /**
  51958. * Get the effect name of the layer.
  51959. * @return The effect name
  51960. */
  51961. getEffectName(): string;
  51962. /**
  51963. * Create the merge effect. This is the shader use to blit the information back
  51964. * to the main canvas at the end of the scene rendering.
  51965. */
  51966. protected _createMergeEffect(): Effect;
  51967. /**
  51968. * Creates the render target textures and post processes used in the glow layer.
  51969. */
  51970. protected _createTextureAndPostProcesses(): void;
  51971. /**
  51972. * Checks for the readiness of the element composing the layer.
  51973. * @param subMesh the mesh to check for
  51974. * @param useInstances specify wether or not to use instances to render the mesh
  51975. * @param emissiveTexture the associated emissive texture used to generate the glow
  51976. * @return true if ready otherwise, false
  51977. */
  51978. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51979. /**
  51980. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51981. */
  51982. needStencil(): boolean;
  51983. /**
  51984. * Returns true if the mesh can be rendered, otherwise false.
  51985. * @param mesh The mesh to render
  51986. * @param material The material used on the mesh
  51987. * @returns true if it can be rendered otherwise false
  51988. */
  51989. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51990. /**
  51991. * Implementation specific of rendering the generating effect on the main canvas.
  51992. * @param effect The effect used to render through
  51993. */
  51994. protected _internalRender(effect: Effect): void;
  51995. /**
  51996. * Sets the required values for both the emissive texture and and the main color.
  51997. */
  51998. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51999. /**
  52000. * Returns true if the mesh should render, otherwise false.
  52001. * @param mesh The mesh to render
  52002. * @returns true if it should render otherwise false
  52003. */
  52004. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52005. /**
  52006. * Adds specific effects defines.
  52007. * @param defines The defines to add specifics to.
  52008. */
  52009. protected _addCustomEffectDefines(defines: string[]): void;
  52010. /**
  52011. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52012. * @param mesh The mesh to exclude from the glow layer
  52013. */
  52014. addExcludedMesh(mesh: Mesh): void;
  52015. /**
  52016. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52017. * @param mesh The mesh to remove
  52018. */
  52019. removeExcludedMesh(mesh: Mesh): void;
  52020. /**
  52021. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52022. * @param mesh The mesh to include in the glow layer
  52023. */
  52024. addIncludedOnlyMesh(mesh: Mesh): void;
  52025. /**
  52026. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52027. * @param mesh The mesh to remove
  52028. */
  52029. removeIncludedOnlyMesh(mesh: Mesh): void;
  52030. /**
  52031. * Determine if a given mesh will be used in the glow layer
  52032. * @param mesh The mesh to test
  52033. * @returns true if the mesh will be highlighted by the current glow layer
  52034. */
  52035. hasMesh(mesh: AbstractMesh): boolean;
  52036. /**
  52037. * Free any resources and references associated to a mesh.
  52038. * Internal use
  52039. * @param mesh The mesh to free.
  52040. * @hidden
  52041. */
  52042. _disposeMesh(mesh: Mesh): void;
  52043. /**
  52044. * Gets the class name of the effect layer
  52045. * @returns the string with the class name of the effect layer
  52046. */
  52047. getClassName(): string;
  52048. /**
  52049. * Serializes this glow layer
  52050. * @returns a serialized glow layer object
  52051. */
  52052. serialize(): any;
  52053. /**
  52054. * Creates a Glow Layer from parsed glow layer data
  52055. * @param parsedGlowLayer defines glow layer data
  52056. * @param scene defines the current scene
  52057. * @param rootUrl defines the root URL containing the glow layer information
  52058. * @returns a parsed Glow Layer
  52059. */
  52060. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52061. }
  52062. }
  52063. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52064. /** @hidden */
  52065. export var glowBlurPostProcessPixelShader: {
  52066. name: string;
  52067. shader: string;
  52068. };
  52069. }
  52070. declare module "babylonjs/Layers/highlightLayer" {
  52071. import { Observable } from "babylonjs/Misc/observable";
  52072. import { Nullable } from "babylonjs/types";
  52073. import { Camera } from "babylonjs/Cameras/camera";
  52074. import { Scene } from "babylonjs/scene";
  52075. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52077. import { Mesh } from "babylonjs/Meshes/mesh";
  52078. import { Effect } from "babylonjs/Materials/effect";
  52079. import { Material } from "babylonjs/Materials/material";
  52080. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52081. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52082. import "babylonjs/Shaders/glowMapMerge.fragment";
  52083. import "babylonjs/Shaders/glowMapMerge.vertex";
  52084. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52085. module "babylonjs/abstractScene" {
  52086. interface AbstractScene {
  52087. /**
  52088. * Return a the first highlight layer of the scene with a given name.
  52089. * @param name The name of the highlight layer to look for.
  52090. * @return The highlight layer if found otherwise null.
  52091. */
  52092. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52093. }
  52094. }
  52095. /**
  52096. * Highlight layer options. This helps customizing the behaviour
  52097. * of the highlight layer.
  52098. */
  52099. export interface IHighlightLayerOptions {
  52100. /**
  52101. * Multiplication factor apply to the canvas size to compute the render target size
  52102. * used to generated the glowing objects (the smaller the faster).
  52103. */
  52104. mainTextureRatio: number;
  52105. /**
  52106. * Enforces a fixed size texture to ensure resize independant blur.
  52107. */
  52108. mainTextureFixedSize?: number;
  52109. /**
  52110. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52111. * of the picture to blur (the smaller the faster).
  52112. */
  52113. blurTextureSizeRatio: number;
  52114. /**
  52115. * How big in texel of the blur texture is the vertical blur.
  52116. */
  52117. blurVerticalSize: number;
  52118. /**
  52119. * How big in texel of the blur texture is the horizontal blur.
  52120. */
  52121. blurHorizontalSize: number;
  52122. /**
  52123. * Alpha blending mode used to apply the blur. Default is combine.
  52124. */
  52125. alphaBlendingMode: number;
  52126. /**
  52127. * The camera attached to the layer.
  52128. */
  52129. camera: Nullable<Camera>;
  52130. /**
  52131. * Should we display highlight as a solid stroke?
  52132. */
  52133. isStroke?: boolean;
  52134. /**
  52135. * The rendering group to draw the layer in.
  52136. */
  52137. renderingGroupId: number;
  52138. }
  52139. /**
  52140. * The highlight layer Helps adding a glow effect around a mesh.
  52141. *
  52142. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  52143. * glowy meshes to your scene.
  52144. *
  52145. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52146. */
  52147. export class HighlightLayer extends EffectLayer {
  52148. name: string;
  52149. /**
  52150. * Effect Name of the highlight layer.
  52151. */
  52152. static readonly EffectName: string;
  52153. /**
  52154. * The neutral color used during the preparation of the glow effect.
  52155. * This is black by default as the blend operation is a blend operation.
  52156. */
  52157. static NeutralColor: Color4;
  52158. /**
  52159. * Stencil value used for glowing meshes.
  52160. */
  52161. static GlowingMeshStencilReference: number;
  52162. /**
  52163. * Stencil value used for the other meshes in the scene.
  52164. */
  52165. static NormalMeshStencilReference: number;
  52166. /**
  52167. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52168. */
  52169. innerGlow: boolean;
  52170. /**
  52171. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52172. */
  52173. outerGlow: boolean;
  52174. /**
  52175. * Specifies the horizontal size of the blur.
  52176. */
  52177. /**
  52178. * Gets the horizontal size of the blur.
  52179. */
  52180. blurHorizontalSize: number;
  52181. /**
  52182. * Specifies the vertical size of the blur.
  52183. */
  52184. /**
  52185. * Gets the vertical size of the blur.
  52186. */
  52187. blurVerticalSize: number;
  52188. /**
  52189. * An event triggered when the highlight layer is being blurred.
  52190. */
  52191. onBeforeBlurObservable: Observable<HighlightLayer>;
  52192. /**
  52193. * An event triggered when the highlight layer has been blurred.
  52194. */
  52195. onAfterBlurObservable: Observable<HighlightLayer>;
  52196. private _instanceGlowingMeshStencilReference;
  52197. private _options;
  52198. private _downSamplePostprocess;
  52199. private _horizontalBlurPostprocess;
  52200. private _verticalBlurPostprocess;
  52201. private _blurTexture;
  52202. private _meshes;
  52203. private _excludedMeshes;
  52204. /**
  52205. * Instantiates a new highlight Layer and references it to the scene..
  52206. * @param name The name of the layer
  52207. * @param scene The scene to use the layer in
  52208. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52209. */
  52210. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52211. /**
  52212. * Get the effect name of the layer.
  52213. * @return The effect name
  52214. */
  52215. getEffectName(): string;
  52216. /**
  52217. * Create the merge effect. This is the shader use to blit the information back
  52218. * to the main canvas at the end of the scene rendering.
  52219. */
  52220. protected _createMergeEffect(): Effect;
  52221. /**
  52222. * Creates the render target textures and post processes used in the highlight layer.
  52223. */
  52224. protected _createTextureAndPostProcesses(): void;
  52225. /**
  52226. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52227. */
  52228. needStencil(): boolean;
  52229. /**
  52230. * Checks for the readiness of the element composing the layer.
  52231. * @param subMesh the mesh to check for
  52232. * @param useInstances specify wether or not to use instances to render the mesh
  52233. * @param emissiveTexture the associated emissive texture used to generate the glow
  52234. * @return true if ready otherwise, false
  52235. */
  52236. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52237. /**
  52238. * Implementation specific of rendering the generating effect on the main canvas.
  52239. * @param effect The effect used to render through
  52240. */
  52241. protected _internalRender(effect: Effect): void;
  52242. /**
  52243. * Returns true if the layer contains information to display, otherwise false.
  52244. */
  52245. shouldRender(): boolean;
  52246. /**
  52247. * Returns true if the mesh should render, otherwise false.
  52248. * @param mesh The mesh to render
  52249. * @returns true if it should render otherwise false
  52250. */
  52251. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52252. /**
  52253. * Sets the required values for both the emissive texture and and the main color.
  52254. */
  52255. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52256. /**
  52257. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52258. * @param mesh The mesh to exclude from the highlight layer
  52259. */
  52260. addExcludedMesh(mesh: Mesh): void;
  52261. /**
  52262. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52263. * @param mesh The mesh to highlight
  52264. */
  52265. removeExcludedMesh(mesh: Mesh): void;
  52266. /**
  52267. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52268. * @param mesh mesh to test
  52269. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52270. */
  52271. hasMesh(mesh: AbstractMesh): boolean;
  52272. /**
  52273. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52274. * @param mesh The mesh to highlight
  52275. * @param color The color of the highlight
  52276. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52277. */
  52278. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52279. /**
  52280. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52281. * @param mesh The mesh to highlight
  52282. */
  52283. removeMesh(mesh: Mesh): void;
  52284. /**
  52285. * Force the stencil to the normal expected value for none glowing parts
  52286. */
  52287. private _defaultStencilReference;
  52288. /**
  52289. * Free any resources and references associated to a mesh.
  52290. * Internal use
  52291. * @param mesh The mesh to free.
  52292. * @hidden
  52293. */
  52294. _disposeMesh(mesh: Mesh): void;
  52295. /**
  52296. * Dispose the highlight layer and free resources.
  52297. */
  52298. dispose(): void;
  52299. /**
  52300. * Gets the class name of the effect layer
  52301. * @returns the string with the class name of the effect layer
  52302. */
  52303. getClassName(): string;
  52304. /**
  52305. * Serializes this Highlight layer
  52306. * @returns a serialized Highlight layer object
  52307. */
  52308. serialize(): any;
  52309. /**
  52310. * Creates a Highlight layer from parsed Highlight layer data
  52311. * @param parsedHightlightLayer defines the Highlight layer data
  52312. * @param scene defines the current scene
  52313. * @param rootUrl defines the root URL containing the Highlight layer information
  52314. * @returns a parsed Highlight layer
  52315. */
  52316. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52317. }
  52318. }
  52319. declare module "babylonjs/Layers/layerSceneComponent" {
  52320. import { Scene } from "babylonjs/scene";
  52321. import { ISceneComponent } from "babylonjs/sceneComponent";
  52322. import { Layer } from "babylonjs/Layers/layer";
  52323. import { AbstractScene } from "babylonjs/abstractScene";
  52324. module "babylonjs/abstractScene" {
  52325. interface AbstractScene {
  52326. /**
  52327. * The list of layers (background and foreground) of the scene
  52328. */
  52329. layers: Array<Layer>;
  52330. }
  52331. }
  52332. /**
  52333. * Defines the layer scene component responsible to manage any layers
  52334. * in a given scene.
  52335. */
  52336. export class LayerSceneComponent implements ISceneComponent {
  52337. /**
  52338. * The component name helpfull to identify the component in the list of scene components.
  52339. */
  52340. readonly name: string;
  52341. /**
  52342. * The scene the component belongs to.
  52343. */
  52344. scene: Scene;
  52345. private _engine;
  52346. /**
  52347. * Creates a new instance of the component for the given scene
  52348. * @param scene Defines the scene to register the component in
  52349. */
  52350. constructor(scene: Scene);
  52351. /**
  52352. * Registers the component in a given scene
  52353. */
  52354. register(): void;
  52355. /**
  52356. * Rebuilds the elements related to this component in case of
  52357. * context lost for instance.
  52358. */
  52359. rebuild(): void;
  52360. /**
  52361. * Disposes the component and the associated ressources.
  52362. */
  52363. dispose(): void;
  52364. private _draw;
  52365. private _drawCameraPredicate;
  52366. private _drawCameraBackground;
  52367. private _drawCameraForeground;
  52368. private _drawRenderTargetPredicate;
  52369. private _drawRenderTargetBackground;
  52370. private _drawRenderTargetForeground;
  52371. /**
  52372. * Adds all the elements from the container to the scene
  52373. * @param container the container holding the elements
  52374. */
  52375. addFromContainer(container: AbstractScene): void;
  52376. /**
  52377. * Removes all the elements in the container from the scene
  52378. * @param container contains the elements to remove
  52379. * @param dispose if the removed element should be disposed (default: false)
  52380. */
  52381. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52382. }
  52383. }
  52384. declare module "babylonjs/Shaders/layer.fragment" {
  52385. /** @hidden */
  52386. export var layerPixelShader: {
  52387. name: string;
  52388. shader: string;
  52389. };
  52390. }
  52391. declare module "babylonjs/Shaders/layer.vertex" {
  52392. /** @hidden */
  52393. export var layerVertexShader: {
  52394. name: string;
  52395. shader: string;
  52396. };
  52397. }
  52398. declare module "babylonjs/Layers/layer" {
  52399. import { Observable } from "babylonjs/Misc/observable";
  52400. import { Nullable } from "babylonjs/types";
  52401. import { Scene } from "babylonjs/scene";
  52402. import { Vector2 } from "babylonjs/Maths/math.vector";
  52403. import { Color4 } from "babylonjs/Maths/math.color";
  52404. import { Texture } from "babylonjs/Materials/Textures/texture";
  52405. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52406. import "babylonjs/Shaders/layer.fragment";
  52407. import "babylonjs/Shaders/layer.vertex";
  52408. /**
  52409. * This represents a full screen 2d layer.
  52410. * This can be useful to display a picture in the background of your scene for instance.
  52411. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52412. */
  52413. export class Layer {
  52414. /**
  52415. * Define the name of the layer.
  52416. */
  52417. name: string;
  52418. /**
  52419. * Define the texture the layer should display.
  52420. */
  52421. texture: Nullable<Texture>;
  52422. /**
  52423. * Is the layer in background or foreground.
  52424. */
  52425. isBackground: boolean;
  52426. /**
  52427. * Define the color of the layer (instead of texture).
  52428. */
  52429. color: Color4;
  52430. /**
  52431. * Define the scale of the layer in order to zoom in out of the texture.
  52432. */
  52433. scale: Vector2;
  52434. /**
  52435. * Define an offset for the layer in order to shift the texture.
  52436. */
  52437. offset: Vector2;
  52438. /**
  52439. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52440. */
  52441. alphaBlendingMode: number;
  52442. /**
  52443. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52444. * Alpha test will not mix with the background color in case of transparency.
  52445. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52446. */
  52447. alphaTest: boolean;
  52448. /**
  52449. * Define a mask to restrict the layer to only some of the scene cameras.
  52450. */
  52451. layerMask: number;
  52452. /**
  52453. * Define the list of render target the layer is visible into.
  52454. */
  52455. renderTargetTextures: RenderTargetTexture[];
  52456. /**
  52457. * Define if the layer is only used in renderTarget or if it also
  52458. * renders in the main frame buffer of the canvas.
  52459. */
  52460. renderOnlyInRenderTargetTextures: boolean;
  52461. private _scene;
  52462. private _vertexBuffers;
  52463. private _indexBuffer;
  52464. private _effect;
  52465. private _alphaTestEffect;
  52466. /**
  52467. * An event triggered when the layer is disposed.
  52468. */
  52469. onDisposeObservable: Observable<Layer>;
  52470. private _onDisposeObserver;
  52471. /**
  52472. * Back compatibility with callback before the onDisposeObservable existed.
  52473. * The set callback will be triggered when the layer has been disposed.
  52474. */
  52475. onDispose: () => void;
  52476. /**
  52477. * An event triggered before rendering the scene
  52478. */
  52479. onBeforeRenderObservable: Observable<Layer>;
  52480. private _onBeforeRenderObserver;
  52481. /**
  52482. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52483. * The set callback will be triggered just before rendering the layer.
  52484. */
  52485. onBeforeRender: () => void;
  52486. /**
  52487. * An event triggered after rendering the scene
  52488. */
  52489. onAfterRenderObservable: Observable<Layer>;
  52490. private _onAfterRenderObserver;
  52491. /**
  52492. * Back compatibility with callback before the onAfterRenderObservable existed.
  52493. * The set callback will be triggered just after rendering the layer.
  52494. */
  52495. onAfterRender: () => void;
  52496. /**
  52497. * Instantiates a new layer.
  52498. * This represents a full screen 2d layer.
  52499. * This can be useful to display a picture in the background of your scene for instance.
  52500. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52501. * @param name Define the name of the layer in the scene
  52502. * @param imgUrl Define the url of the texture to display in the layer
  52503. * @param scene Define the scene the layer belongs to
  52504. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52505. * @param color Defines a color for the layer
  52506. */
  52507. constructor(
  52508. /**
  52509. * Define the name of the layer.
  52510. */
  52511. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52512. private _createIndexBuffer;
  52513. /** @hidden */
  52514. _rebuild(): void;
  52515. /**
  52516. * Renders the layer in the scene.
  52517. */
  52518. render(): void;
  52519. /**
  52520. * Disposes and releases the associated ressources.
  52521. */
  52522. dispose(): void;
  52523. }
  52524. }
  52525. declare module "babylonjs/Layers/index" {
  52526. export * from "babylonjs/Layers/effectLayer";
  52527. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52528. export * from "babylonjs/Layers/glowLayer";
  52529. export * from "babylonjs/Layers/highlightLayer";
  52530. export * from "babylonjs/Layers/layer";
  52531. export * from "babylonjs/Layers/layerSceneComponent";
  52532. }
  52533. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52534. /** @hidden */
  52535. export var lensFlarePixelShader: {
  52536. name: string;
  52537. shader: string;
  52538. };
  52539. }
  52540. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52541. /** @hidden */
  52542. export var lensFlareVertexShader: {
  52543. name: string;
  52544. shader: string;
  52545. };
  52546. }
  52547. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52548. import { Scene } from "babylonjs/scene";
  52549. import { Vector3 } from "babylonjs/Maths/math.vector";
  52550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52551. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52552. import "babylonjs/Shaders/lensFlare.fragment";
  52553. import "babylonjs/Shaders/lensFlare.vertex";
  52554. import { Viewport } from "babylonjs/Maths/math.viewport";
  52555. /**
  52556. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52557. * It is usually composed of several `lensFlare`.
  52558. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52559. */
  52560. export class LensFlareSystem {
  52561. /**
  52562. * Define the name of the lens flare system
  52563. */
  52564. name: string;
  52565. /**
  52566. * List of lens flares used in this system.
  52567. */
  52568. lensFlares: LensFlare[];
  52569. /**
  52570. * Define a limit from the border the lens flare can be visible.
  52571. */
  52572. borderLimit: number;
  52573. /**
  52574. * Define a viewport border we do not want to see the lens flare in.
  52575. */
  52576. viewportBorder: number;
  52577. /**
  52578. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52579. */
  52580. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52581. /**
  52582. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52583. */
  52584. layerMask: number;
  52585. /**
  52586. * Define the id of the lens flare system in the scene.
  52587. * (equal to name by default)
  52588. */
  52589. id: string;
  52590. private _scene;
  52591. private _emitter;
  52592. private _vertexBuffers;
  52593. private _indexBuffer;
  52594. private _effect;
  52595. private _positionX;
  52596. private _positionY;
  52597. private _isEnabled;
  52598. /** @hidden */
  52599. static _SceneComponentInitialization: (scene: Scene) => void;
  52600. /**
  52601. * Instantiates a lens flare system.
  52602. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52603. * It is usually composed of several `lensFlare`.
  52604. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52605. * @param name Define the name of the lens flare system in the scene
  52606. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52607. * @param scene Define the scene the lens flare system belongs to
  52608. */
  52609. constructor(
  52610. /**
  52611. * Define the name of the lens flare system
  52612. */
  52613. name: string, emitter: any, scene: Scene);
  52614. /**
  52615. * Define if the lens flare system is enabled.
  52616. */
  52617. isEnabled: boolean;
  52618. /**
  52619. * Get the scene the effects belongs to.
  52620. * @returns the scene holding the lens flare system
  52621. */
  52622. getScene(): Scene;
  52623. /**
  52624. * Get the emitter of the lens flare system.
  52625. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52626. * @returns the emitter of the lens flare system
  52627. */
  52628. getEmitter(): any;
  52629. /**
  52630. * Set the emitter of the lens flare system.
  52631. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52632. * @param newEmitter Define the new emitter of the system
  52633. */
  52634. setEmitter(newEmitter: any): void;
  52635. /**
  52636. * Get the lens flare system emitter position.
  52637. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52638. * @returns the position
  52639. */
  52640. getEmitterPosition(): Vector3;
  52641. /**
  52642. * @hidden
  52643. */
  52644. computeEffectivePosition(globalViewport: Viewport): boolean;
  52645. /** @hidden */
  52646. _isVisible(): boolean;
  52647. /**
  52648. * @hidden
  52649. */
  52650. render(): boolean;
  52651. /**
  52652. * Dispose and release the lens flare with its associated resources.
  52653. */
  52654. dispose(): void;
  52655. /**
  52656. * Parse a lens flare system from a JSON repressentation
  52657. * @param parsedLensFlareSystem Define the JSON to parse
  52658. * @param scene Define the scene the parsed system should be instantiated in
  52659. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52660. * @returns the parsed system
  52661. */
  52662. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52663. /**
  52664. * Serialize the current Lens Flare System into a JSON representation.
  52665. * @returns the serialized JSON
  52666. */
  52667. serialize(): any;
  52668. }
  52669. }
  52670. declare module "babylonjs/LensFlares/lensFlare" {
  52671. import { Nullable } from "babylonjs/types";
  52672. import { Color3 } from "babylonjs/Maths/math.color";
  52673. import { Texture } from "babylonjs/Materials/Textures/texture";
  52674. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52675. /**
  52676. * This represents one of the lens effect in a `lensFlareSystem`.
  52677. * It controls one of the indiviual texture used in the effect.
  52678. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52679. */
  52680. export class LensFlare {
  52681. /**
  52682. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52683. */
  52684. size: number;
  52685. /**
  52686. * 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.
  52687. */
  52688. position: number;
  52689. /**
  52690. * Define the lens color.
  52691. */
  52692. color: Color3;
  52693. /**
  52694. * Define the lens texture.
  52695. */
  52696. texture: Nullable<Texture>;
  52697. /**
  52698. * Define the alpha mode to render this particular lens.
  52699. */
  52700. alphaMode: number;
  52701. private _system;
  52702. /**
  52703. * Creates a new Lens Flare.
  52704. * This represents one of the lens effect in a `lensFlareSystem`.
  52705. * It controls one of the indiviual texture used in the effect.
  52706. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52707. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52708. * @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.
  52709. * @param color Define the lens color
  52710. * @param imgUrl Define the lens texture url
  52711. * @param system Define the `lensFlareSystem` this flare is part of
  52712. * @returns The newly created Lens Flare
  52713. */
  52714. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52715. /**
  52716. * Instantiates a new Lens Flare.
  52717. * This represents one of the lens effect in a `lensFlareSystem`.
  52718. * It controls one of the indiviual texture used in the effect.
  52719. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52720. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52721. * @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.
  52722. * @param color Define the lens color
  52723. * @param imgUrl Define the lens texture url
  52724. * @param system Define the `lensFlareSystem` this flare is part of
  52725. */
  52726. constructor(
  52727. /**
  52728. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52729. */
  52730. size: number,
  52731. /**
  52732. * 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.
  52733. */
  52734. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52735. /**
  52736. * Dispose and release the lens flare with its associated resources.
  52737. */
  52738. dispose(): void;
  52739. }
  52740. }
  52741. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52742. import { Nullable } from "babylonjs/types";
  52743. import { Scene } from "babylonjs/scene";
  52744. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52745. import { AbstractScene } from "babylonjs/abstractScene";
  52746. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52747. module "babylonjs/abstractScene" {
  52748. interface AbstractScene {
  52749. /**
  52750. * The list of lens flare system added to the scene
  52751. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52752. */
  52753. lensFlareSystems: Array<LensFlareSystem>;
  52754. /**
  52755. * Removes the given lens flare system from this scene.
  52756. * @param toRemove The lens flare system to remove
  52757. * @returns The index of the removed lens flare system
  52758. */
  52759. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52760. /**
  52761. * Adds the given lens flare system to this scene
  52762. * @param newLensFlareSystem The lens flare system to add
  52763. */
  52764. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52765. /**
  52766. * Gets a lens flare system using its name
  52767. * @param name defines the name to look for
  52768. * @returns the lens flare system or null if not found
  52769. */
  52770. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52771. /**
  52772. * Gets a lens flare system using its id
  52773. * @param id defines the id to look for
  52774. * @returns the lens flare system or null if not found
  52775. */
  52776. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52777. }
  52778. }
  52779. /**
  52780. * Defines the lens flare scene component responsible to manage any lens flares
  52781. * in a given scene.
  52782. */
  52783. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52784. /**
  52785. * The component name helpfull to identify the component in the list of scene components.
  52786. */
  52787. readonly name: string;
  52788. /**
  52789. * The scene the component belongs to.
  52790. */
  52791. scene: Scene;
  52792. /**
  52793. * Creates a new instance of the component for the given scene
  52794. * @param scene Defines the scene to register the component in
  52795. */
  52796. constructor(scene: Scene);
  52797. /**
  52798. * Registers the component in a given scene
  52799. */
  52800. register(): void;
  52801. /**
  52802. * Rebuilds the elements related to this component in case of
  52803. * context lost for instance.
  52804. */
  52805. rebuild(): void;
  52806. /**
  52807. * Adds all the elements from the container to the scene
  52808. * @param container the container holding the elements
  52809. */
  52810. addFromContainer(container: AbstractScene): void;
  52811. /**
  52812. * Removes all the elements in the container from the scene
  52813. * @param container contains the elements to remove
  52814. * @param dispose if the removed element should be disposed (default: false)
  52815. */
  52816. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52817. /**
  52818. * Serializes the component data to the specified json object
  52819. * @param serializationObject The object to serialize to
  52820. */
  52821. serialize(serializationObject: any): void;
  52822. /**
  52823. * Disposes the component and the associated ressources.
  52824. */
  52825. dispose(): void;
  52826. private _draw;
  52827. }
  52828. }
  52829. declare module "babylonjs/LensFlares/index" {
  52830. export * from "babylonjs/LensFlares/lensFlare";
  52831. export * from "babylonjs/LensFlares/lensFlareSystem";
  52832. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52833. }
  52834. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52835. import { Scene } from "babylonjs/scene";
  52836. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52837. import { AbstractScene } from "babylonjs/abstractScene";
  52838. /**
  52839. * Defines the shadow generator component responsible to manage any shadow generators
  52840. * in a given scene.
  52841. */
  52842. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52843. /**
  52844. * The component name helpfull to identify the component in the list of scene components.
  52845. */
  52846. readonly name: string;
  52847. /**
  52848. * The scene the component belongs to.
  52849. */
  52850. scene: Scene;
  52851. /**
  52852. * Creates a new instance of the component for the given scene
  52853. * @param scene Defines the scene to register the component in
  52854. */
  52855. constructor(scene: Scene);
  52856. /**
  52857. * Registers the component in a given scene
  52858. */
  52859. register(): void;
  52860. /**
  52861. * Rebuilds the elements related to this component in case of
  52862. * context lost for instance.
  52863. */
  52864. rebuild(): void;
  52865. /**
  52866. * Serializes the component data to the specified json object
  52867. * @param serializationObject The object to serialize to
  52868. */
  52869. serialize(serializationObject: any): void;
  52870. /**
  52871. * Adds all the elements from the container to the scene
  52872. * @param container the container holding the elements
  52873. */
  52874. addFromContainer(container: AbstractScene): void;
  52875. /**
  52876. * Removes all the elements in the container from the scene
  52877. * @param container contains the elements to remove
  52878. * @param dispose if the removed element should be disposed (default: false)
  52879. */
  52880. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52881. /**
  52882. * Rebuilds the elements related to this component in case of
  52883. * context lost for instance.
  52884. */
  52885. dispose(): void;
  52886. private _gatherRenderTargets;
  52887. }
  52888. }
  52889. declare module "babylonjs/Lights/Shadows/index" {
  52890. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52891. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52892. }
  52893. declare module "babylonjs/Lights/pointLight" {
  52894. import { Scene } from "babylonjs/scene";
  52895. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52897. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52898. import { Effect } from "babylonjs/Materials/effect";
  52899. /**
  52900. * A point light is a light defined by an unique point in world space.
  52901. * The light is emitted in every direction from this point.
  52902. * A good example of a point light is a standard light bulb.
  52903. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52904. */
  52905. export class PointLight extends ShadowLight {
  52906. private _shadowAngle;
  52907. /**
  52908. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52909. * This specifies what angle the shadow will use to be created.
  52910. *
  52911. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52912. */
  52913. /**
  52914. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52915. * This specifies what angle the shadow will use to be created.
  52916. *
  52917. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52918. */
  52919. shadowAngle: number;
  52920. /**
  52921. * Gets the direction if it has been set.
  52922. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52923. */
  52924. /**
  52925. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52926. */
  52927. direction: Vector3;
  52928. /**
  52929. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52930. * A PointLight emits the light in every direction.
  52931. * It can cast shadows.
  52932. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52933. * ```javascript
  52934. * var pointLight = new PointLight("pl", camera.position, scene);
  52935. * ```
  52936. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52937. * @param name The light friendly name
  52938. * @param position The position of the point light in the scene
  52939. * @param scene The scene the lights belongs to
  52940. */
  52941. constructor(name: string, position: Vector3, scene: Scene);
  52942. /**
  52943. * Returns the string "PointLight"
  52944. * @returns the class name
  52945. */
  52946. getClassName(): string;
  52947. /**
  52948. * Returns the integer 0.
  52949. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52950. */
  52951. getTypeID(): number;
  52952. /**
  52953. * Specifies wether or not the shadowmap should be a cube texture.
  52954. * @returns true if the shadowmap needs to be a cube texture.
  52955. */
  52956. needCube(): boolean;
  52957. /**
  52958. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52959. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52960. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52961. */
  52962. getShadowDirection(faceIndex?: number): Vector3;
  52963. /**
  52964. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52965. * - fov = PI / 2
  52966. * - aspect ratio : 1.0
  52967. * - z-near and far equal to the active camera minZ and maxZ.
  52968. * Returns the PointLight.
  52969. */
  52970. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52971. protected _buildUniformLayout(): void;
  52972. /**
  52973. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52974. * @param effect The effect to update
  52975. * @param lightIndex The index of the light in the effect to update
  52976. * @returns The point light
  52977. */
  52978. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52979. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52980. /**
  52981. * Prepares the list of defines specific to the light type.
  52982. * @param defines the list of defines
  52983. * @param lightIndex defines the index of the light for the effect
  52984. */
  52985. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52986. }
  52987. }
  52988. declare module "babylonjs/Lights/index" {
  52989. export * from "babylonjs/Lights/light";
  52990. export * from "babylonjs/Lights/shadowLight";
  52991. export * from "babylonjs/Lights/Shadows/index";
  52992. export * from "babylonjs/Lights/directionalLight";
  52993. export * from "babylonjs/Lights/hemisphericLight";
  52994. export * from "babylonjs/Lights/pointLight";
  52995. export * from "babylonjs/Lights/spotLight";
  52996. }
  52997. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52998. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52999. /**
  53000. * Header information of HDR texture files.
  53001. */
  53002. export interface HDRInfo {
  53003. /**
  53004. * The height of the texture in pixels.
  53005. */
  53006. height: number;
  53007. /**
  53008. * The width of the texture in pixels.
  53009. */
  53010. width: number;
  53011. /**
  53012. * The index of the beginning of the data in the binary file.
  53013. */
  53014. dataPosition: number;
  53015. }
  53016. /**
  53017. * This groups tools to convert HDR texture to native colors array.
  53018. */
  53019. export class HDRTools {
  53020. private static Ldexp;
  53021. private static Rgbe2float;
  53022. private static readStringLine;
  53023. /**
  53024. * Reads header information from an RGBE texture stored in a native array.
  53025. * More information on this format are available here:
  53026. * https://en.wikipedia.org/wiki/RGBE_image_format
  53027. *
  53028. * @param uint8array The binary file stored in native array.
  53029. * @return The header information.
  53030. */
  53031. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53032. /**
  53033. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53034. * This RGBE texture needs to store the information as a panorama.
  53035. *
  53036. * More information on this format are available here:
  53037. * https://en.wikipedia.org/wiki/RGBE_image_format
  53038. *
  53039. * @param buffer The binary file stored in an array buffer.
  53040. * @param size The expected size of the extracted cubemap.
  53041. * @return The Cube Map information.
  53042. */
  53043. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53044. /**
  53045. * Returns the pixels data extracted from an RGBE texture.
  53046. * This pixels will be stored left to right up to down in the R G B order in one array.
  53047. *
  53048. * More information on this format are available here:
  53049. * https://en.wikipedia.org/wiki/RGBE_image_format
  53050. *
  53051. * @param uint8array The binary file stored in an array buffer.
  53052. * @param hdrInfo The header information of the file.
  53053. * @return The pixels data in RGB right to left up to down order.
  53054. */
  53055. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53056. private static RGBE_ReadPixels_RLE;
  53057. }
  53058. }
  53059. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53060. import { Nullable } from "babylonjs/types";
  53061. import { Scene } from "babylonjs/scene";
  53062. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53063. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53064. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53065. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53066. /**
  53067. * This represents a texture coming from an HDR input.
  53068. *
  53069. * The only supported format is currently panorama picture stored in RGBE format.
  53070. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53071. */
  53072. export class HDRCubeTexture extends BaseTexture {
  53073. private static _facesMapping;
  53074. private _generateHarmonics;
  53075. private _noMipmap;
  53076. private _textureMatrix;
  53077. private _size;
  53078. private _onLoad;
  53079. private _onError;
  53080. /**
  53081. * The texture URL.
  53082. */
  53083. url: string;
  53084. /**
  53085. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53086. */
  53087. coordinatesMode: number;
  53088. protected _isBlocking: boolean;
  53089. /**
  53090. * Sets wether or not the texture is blocking during loading.
  53091. */
  53092. /**
  53093. * Gets wether or not the texture is blocking during loading.
  53094. */
  53095. isBlocking: boolean;
  53096. protected _rotationY: number;
  53097. /**
  53098. * Sets texture matrix rotation angle around Y axis in radians.
  53099. */
  53100. /**
  53101. * Gets texture matrix rotation angle around Y axis radians.
  53102. */
  53103. rotationY: number;
  53104. /**
  53105. * Gets or sets the center of the bounding box associated with the cube texture
  53106. * It must define where the camera used to render the texture was set
  53107. */
  53108. boundingBoxPosition: Vector3;
  53109. private _boundingBoxSize;
  53110. /**
  53111. * Gets or sets the size of the bounding box associated with the cube texture
  53112. * When defined, the cubemap will switch to local mode
  53113. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53114. * @example https://www.babylonjs-playground.com/#RNASML
  53115. */
  53116. boundingBoxSize: Vector3;
  53117. /**
  53118. * Instantiates an HDRTexture from the following parameters.
  53119. *
  53120. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53121. * @param scene The scene the texture will be used in
  53122. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53123. * @param noMipmap Forces to not generate the mipmap if true
  53124. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53125. * @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)
  53126. * @param reserved Reserved flag for internal use.
  53127. */
  53128. 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>);
  53129. /**
  53130. * Get the current class name of the texture useful for serialization or dynamic coding.
  53131. * @returns "HDRCubeTexture"
  53132. */
  53133. getClassName(): string;
  53134. /**
  53135. * Occurs when the file is raw .hdr file.
  53136. */
  53137. private loadTexture;
  53138. clone(): HDRCubeTexture;
  53139. delayLoad(): void;
  53140. /**
  53141. * Get the texture reflection matrix used to rotate/transform the reflection.
  53142. * @returns the reflection matrix
  53143. */
  53144. getReflectionTextureMatrix(): Matrix;
  53145. /**
  53146. * Set the texture reflection matrix used to rotate/transform the reflection.
  53147. * @param value Define the reflection matrix to set
  53148. */
  53149. setReflectionTextureMatrix(value: Matrix): void;
  53150. /**
  53151. * Parses a JSON representation of an HDR Texture in order to create the texture
  53152. * @param parsedTexture Define the JSON representation
  53153. * @param scene Define the scene the texture should be created in
  53154. * @param rootUrl Define the root url in case we need to load relative dependencies
  53155. * @returns the newly created texture after parsing
  53156. */
  53157. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53158. serialize(): any;
  53159. }
  53160. }
  53161. declare module "babylonjs/Physics/physicsEngine" {
  53162. import { Nullable } from "babylonjs/types";
  53163. import { Vector3 } from "babylonjs/Maths/math.vector";
  53164. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53165. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53166. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53167. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53168. /**
  53169. * Class used to control physics engine
  53170. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53171. */
  53172. export class PhysicsEngine implements IPhysicsEngine {
  53173. private _physicsPlugin;
  53174. /**
  53175. * Global value used to control the smallest number supported by the simulation
  53176. */
  53177. static Epsilon: number;
  53178. private _impostors;
  53179. private _joints;
  53180. /**
  53181. * Gets the gravity vector used by the simulation
  53182. */
  53183. gravity: Vector3;
  53184. /**
  53185. * Factory used to create the default physics plugin.
  53186. * @returns The default physics plugin
  53187. */
  53188. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53189. /**
  53190. * Creates a new Physics Engine
  53191. * @param gravity defines the gravity vector used by the simulation
  53192. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53193. */
  53194. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53195. /**
  53196. * Sets the gravity vector used by the simulation
  53197. * @param gravity defines the gravity vector to use
  53198. */
  53199. setGravity(gravity: Vector3): void;
  53200. /**
  53201. * Set the time step of the physics engine.
  53202. * Default is 1/60.
  53203. * To slow it down, enter 1/600 for example.
  53204. * To speed it up, 1/30
  53205. * @param newTimeStep defines the new timestep to apply to this world.
  53206. */
  53207. setTimeStep(newTimeStep?: number): void;
  53208. /**
  53209. * Get the time step of the physics engine.
  53210. * @returns the current time step
  53211. */
  53212. getTimeStep(): number;
  53213. /**
  53214. * Release all resources
  53215. */
  53216. dispose(): void;
  53217. /**
  53218. * Gets the name of the current physics plugin
  53219. * @returns the name of the plugin
  53220. */
  53221. getPhysicsPluginName(): string;
  53222. /**
  53223. * Adding a new impostor for the impostor tracking.
  53224. * This will be done by the impostor itself.
  53225. * @param impostor the impostor to add
  53226. */
  53227. addImpostor(impostor: PhysicsImpostor): void;
  53228. /**
  53229. * Remove an impostor from the engine.
  53230. * This impostor and its mesh will not longer be updated by the physics engine.
  53231. * @param impostor the impostor to remove
  53232. */
  53233. removeImpostor(impostor: PhysicsImpostor): void;
  53234. /**
  53235. * Add a joint to the physics engine
  53236. * @param mainImpostor defines the main impostor to which the joint is added.
  53237. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53238. * @param joint defines the joint that will connect both impostors.
  53239. */
  53240. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53241. /**
  53242. * Removes a joint from the simulation
  53243. * @param mainImpostor defines the impostor used with the joint
  53244. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53245. * @param joint defines the joint to remove
  53246. */
  53247. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53248. /**
  53249. * Called by the scene. No need to call it.
  53250. * @param delta defines the timespam between frames
  53251. */
  53252. _step(delta: number): void;
  53253. /**
  53254. * Gets the current plugin used to run the simulation
  53255. * @returns current plugin
  53256. */
  53257. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53258. /**
  53259. * Gets the list of physic impostors
  53260. * @returns an array of PhysicsImpostor
  53261. */
  53262. getImpostors(): Array<PhysicsImpostor>;
  53263. /**
  53264. * Gets the impostor for a physics enabled object
  53265. * @param object defines the object impersonated by the impostor
  53266. * @returns the PhysicsImpostor or null if not found
  53267. */
  53268. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53269. /**
  53270. * Gets the impostor for a physics body object
  53271. * @param body defines physics body used by the impostor
  53272. * @returns the PhysicsImpostor or null if not found
  53273. */
  53274. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53275. /**
  53276. * Does a raycast in the physics world
  53277. * @param from when should the ray start?
  53278. * @param to when should the ray end?
  53279. * @returns PhysicsRaycastResult
  53280. */
  53281. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53282. }
  53283. }
  53284. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53285. import { Nullable } from "babylonjs/types";
  53286. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53288. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53289. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53290. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53291. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53292. /** @hidden */
  53293. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53294. private _useDeltaForWorldStep;
  53295. world: any;
  53296. name: string;
  53297. private _physicsMaterials;
  53298. private _fixedTimeStep;
  53299. private _cannonRaycastResult;
  53300. private _raycastResult;
  53301. private _physicsBodysToRemoveAfterStep;
  53302. BJSCANNON: any;
  53303. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53304. setGravity(gravity: Vector3): void;
  53305. setTimeStep(timeStep: number): void;
  53306. getTimeStep(): number;
  53307. executeStep(delta: number): void;
  53308. private _removeMarkedPhysicsBodiesFromWorld;
  53309. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53310. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53311. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53312. private _processChildMeshes;
  53313. removePhysicsBody(impostor: PhysicsImpostor): void;
  53314. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53315. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53316. private _addMaterial;
  53317. private _checkWithEpsilon;
  53318. private _createShape;
  53319. private _createHeightmap;
  53320. private _minus90X;
  53321. private _plus90X;
  53322. private _tmpPosition;
  53323. private _tmpDeltaPosition;
  53324. private _tmpUnityRotation;
  53325. private _updatePhysicsBodyTransformation;
  53326. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53327. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53328. isSupported(): boolean;
  53329. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53330. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53331. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53332. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53333. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53334. getBodyMass(impostor: PhysicsImpostor): number;
  53335. getBodyFriction(impostor: PhysicsImpostor): number;
  53336. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53337. getBodyRestitution(impostor: PhysicsImpostor): number;
  53338. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53339. sleepBody(impostor: PhysicsImpostor): void;
  53340. wakeUpBody(impostor: PhysicsImpostor): void;
  53341. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53342. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53343. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53344. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53345. getRadius(impostor: PhysicsImpostor): number;
  53346. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53347. dispose(): void;
  53348. private _extendNamespace;
  53349. /**
  53350. * Does a raycast in the physics world
  53351. * @param from when should the ray start?
  53352. * @param to when should the ray end?
  53353. * @returns PhysicsRaycastResult
  53354. */
  53355. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53356. }
  53357. }
  53358. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53359. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53360. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53361. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53363. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53364. import { Nullable } from "babylonjs/types";
  53365. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53366. /** @hidden */
  53367. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53368. world: any;
  53369. name: string;
  53370. BJSOIMO: any;
  53371. private _raycastResult;
  53372. constructor(iterations?: number, oimoInjection?: any);
  53373. setGravity(gravity: Vector3): void;
  53374. setTimeStep(timeStep: number): void;
  53375. getTimeStep(): number;
  53376. private _tmpImpostorsArray;
  53377. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53378. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53379. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53380. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53381. private _tmpPositionVector;
  53382. removePhysicsBody(impostor: PhysicsImpostor): void;
  53383. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53384. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53385. isSupported(): boolean;
  53386. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53387. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53388. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53389. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53390. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53391. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53392. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53393. getBodyMass(impostor: PhysicsImpostor): number;
  53394. getBodyFriction(impostor: PhysicsImpostor): number;
  53395. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53396. getBodyRestitution(impostor: PhysicsImpostor): number;
  53397. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53398. sleepBody(impostor: PhysicsImpostor): void;
  53399. wakeUpBody(impostor: PhysicsImpostor): void;
  53400. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53401. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53402. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53403. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53404. getRadius(impostor: PhysicsImpostor): number;
  53405. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53406. dispose(): void;
  53407. /**
  53408. * Does a raycast in the physics world
  53409. * @param from when should the ray start?
  53410. * @param to when should the ray end?
  53411. * @returns PhysicsRaycastResult
  53412. */
  53413. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53414. }
  53415. }
  53416. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53417. import { Nullable } from "babylonjs/types";
  53418. import { Scene } from "babylonjs/scene";
  53419. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53420. import { Color4 } from "babylonjs/Maths/math.color";
  53421. import { Mesh } from "babylonjs/Meshes/mesh";
  53422. /**
  53423. * Class containing static functions to help procedurally build meshes
  53424. */
  53425. export class RibbonBuilder {
  53426. /**
  53427. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53428. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53429. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53430. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53431. * * 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
  53432. * * 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
  53433. * * 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
  53434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53435. * * 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
  53436. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53437. * * 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
  53438. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53439. * * 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
  53440. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53442. * @param name defines the name of the mesh
  53443. * @param options defines the options used to create the mesh
  53444. * @param scene defines the hosting scene
  53445. * @returns the ribbon mesh
  53446. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53447. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53448. */
  53449. static CreateRibbon(name: string, options: {
  53450. pathArray: Vector3[][];
  53451. closeArray?: boolean;
  53452. closePath?: boolean;
  53453. offset?: number;
  53454. updatable?: boolean;
  53455. sideOrientation?: number;
  53456. frontUVs?: Vector4;
  53457. backUVs?: Vector4;
  53458. instance?: Mesh;
  53459. invertUV?: boolean;
  53460. uvs?: Vector2[];
  53461. colors?: Color4[];
  53462. }, scene?: Nullable<Scene>): Mesh;
  53463. }
  53464. }
  53465. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53466. import { Nullable } from "babylonjs/types";
  53467. import { Scene } from "babylonjs/scene";
  53468. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53469. import { Mesh } from "babylonjs/Meshes/mesh";
  53470. /**
  53471. * Class containing static functions to help procedurally build meshes
  53472. */
  53473. export class ShapeBuilder {
  53474. /**
  53475. * 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.
  53476. * * 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.
  53477. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53478. * * 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.
  53479. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53480. * * 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
  53481. * * 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
  53482. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53484. * * 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
  53485. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53487. * @param name defines the name of the mesh
  53488. * @param options defines the options used to create the mesh
  53489. * @param scene defines the hosting scene
  53490. * @returns the extruded shape mesh
  53491. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53492. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53493. */
  53494. static ExtrudeShape(name: string, options: {
  53495. shape: Vector3[];
  53496. path: Vector3[];
  53497. scale?: number;
  53498. rotation?: number;
  53499. cap?: number;
  53500. updatable?: boolean;
  53501. sideOrientation?: number;
  53502. frontUVs?: Vector4;
  53503. backUVs?: Vector4;
  53504. instance?: Mesh;
  53505. invertUV?: boolean;
  53506. }, scene?: Nullable<Scene>): Mesh;
  53507. /**
  53508. * Creates an custom extruded shape mesh.
  53509. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53510. * * 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.
  53511. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53512. * * 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
  53513. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53514. * * 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
  53515. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53516. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53517. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53518. * * 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
  53519. * * 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
  53520. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53522. * * 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
  53523. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53525. * @param name defines the name of the mesh
  53526. * @param options defines the options used to create the mesh
  53527. * @param scene defines the hosting scene
  53528. * @returns the custom extruded shape mesh
  53529. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53530. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53531. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53532. */
  53533. static ExtrudeShapeCustom(name: string, options: {
  53534. shape: Vector3[];
  53535. path: Vector3[];
  53536. scaleFunction?: any;
  53537. rotationFunction?: any;
  53538. ribbonCloseArray?: boolean;
  53539. ribbonClosePath?: boolean;
  53540. cap?: number;
  53541. updatable?: boolean;
  53542. sideOrientation?: number;
  53543. frontUVs?: Vector4;
  53544. backUVs?: Vector4;
  53545. instance?: Mesh;
  53546. invertUV?: boolean;
  53547. }, scene?: Nullable<Scene>): Mesh;
  53548. private static _ExtrudeShapeGeneric;
  53549. }
  53550. }
  53551. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53552. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53553. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53554. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53555. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53556. import { Nullable } from "babylonjs/types";
  53557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53558. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53559. /**
  53560. * AmmoJS Physics plugin
  53561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53562. * @see https://github.com/kripken/ammo.js/
  53563. */
  53564. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53565. private _useDeltaForWorldStep;
  53566. /**
  53567. * Reference to the Ammo library
  53568. */
  53569. bjsAMMO: any;
  53570. /**
  53571. * Created ammoJS world which physics bodies are added to
  53572. */
  53573. world: any;
  53574. /**
  53575. * Name of the plugin
  53576. */
  53577. name: string;
  53578. private _timeStep;
  53579. private _fixedTimeStep;
  53580. private _maxSteps;
  53581. private _tmpQuaternion;
  53582. private _tmpAmmoTransform;
  53583. private _tmpAmmoQuaternion;
  53584. private _tmpAmmoConcreteContactResultCallback;
  53585. private _collisionConfiguration;
  53586. private _dispatcher;
  53587. private _overlappingPairCache;
  53588. private _solver;
  53589. private _softBodySolver;
  53590. private _tmpAmmoVectorA;
  53591. private _tmpAmmoVectorB;
  53592. private _tmpAmmoVectorC;
  53593. private _tmpAmmoVectorD;
  53594. private _tmpContactCallbackResult;
  53595. private _tmpAmmoVectorRCA;
  53596. private _tmpAmmoVectorRCB;
  53597. private _raycastResult;
  53598. private static readonly DISABLE_COLLISION_FLAG;
  53599. private static readonly KINEMATIC_FLAG;
  53600. private static readonly DISABLE_DEACTIVATION_FLAG;
  53601. /**
  53602. * Initializes the ammoJS plugin
  53603. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53604. * @param ammoInjection can be used to inject your own ammo reference
  53605. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53606. */
  53607. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53608. /**
  53609. * Sets the gravity of the physics world (m/(s^2))
  53610. * @param gravity Gravity to set
  53611. */
  53612. setGravity(gravity: Vector3): void;
  53613. /**
  53614. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53615. * @param timeStep timestep to use in seconds
  53616. */
  53617. setTimeStep(timeStep: number): void;
  53618. /**
  53619. * 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)
  53620. * @param fixedTimeStep fixedTimeStep to use in seconds
  53621. */
  53622. setFixedTimeStep(fixedTimeStep: number): void;
  53623. /**
  53624. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53625. * @param maxSteps the maximum number of steps by the physics engine per frame
  53626. */
  53627. setMaxSteps(maxSteps: number): void;
  53628. /**
  53629. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53630. * @returns the current timestep in seconds
  53631. */
  53632. getTimeStep(): number;
  53633. private _isImpostorInContact;
  53634. private _isImpostorPairInContact;
  53635. private _stepSimulation;
  53636. /**
  53637. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53638. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53639. * After the step the babylon meshes are set to the position of the physics imposters
  53640. * @param delta amount of time to step forward
  53641. * @param impostors array of imposters to update before/after the step
  53642. */
  53643. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53644. /**
  53645. * Update babylon mesh to match physics world object
  53646. * @param impostor imposter to match
  53647. */
  53648. private _afterSoftStep;
  53649. /**
  53650. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53651. * @param impostor imposter to match
  53652. */
  53653. private _ropeStep;
  53654. /**
  53655. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53656. * @param impostor imposter to match
  53657. */
  53658. private _softbodyOrClothStep;
  53659. private _tmpVector;
  53660. private _tmpMatrix;
  53661. /**
  53662. * Applies an impulse on the imposter
  53663. * @param impostor imposter to apply impulse to
  53664. * @param force amount of force to be applied to the imposter
  53665. * @param contactPoint the location to apply the impulse on the imposter
  53666. */
  53667. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53668. /**
  53669. * Applies a force on the imposter
  53670. * @param impostor imposter to apply force
  53671. * @param force amount of force to be applied to the imposter
  53672. * @param contactPoint the location to apply the force on the imposter
  53673. */
  53674. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53675. /**
  53676. * Creates a physics body using the plugin
  53677. * @param impostor the imposter to create the physics body on
  53678. */
  53679. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53680. /**
  53681. * Removes the physics body from the imposter and disposes of the body's memory
  53682. * @param impostor imposter to remove the physics body from
  53683. */
  53684. removePhysicsBody(impostor: PhysicsImpostor): void;
  53685. /**
  53686. * Generates a joint
  53687. * @param impostorJoint the imposter joint to create the joint with
  53688. */
  53689. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53690. /**
  53691. * Removes a joint
  53692. * @param impostorJoint the imposter joint to remove the joint from
  53693. */
  53694. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53695. private _addMeshVerts;
  53696. /**
  53697. * Initialise the soft body vertices to match its object's (mesh) vertices
  53698. * Softbody vertices (nodes) are in world space and to match this
  53699. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53700. * @param impostor to create the softbody for
  53701. */
  53702. private _softVertexData;
  53703. /**
  53704. * Create an impostor's soft body
  53705. * @param impostor to create the softbody for
  53706. */
  53707. private _createSoftbody;
  53708. /**
  53709. * Create cloth for an impostor
  53710. * @param impostor to create the softbody for
  53711. */
  53712. private _createCloth;
  53713. /**
  53714. * Create rope for an impostor
  53715. * @param impostor to create the softbody for
  53716. */
  53717. private _createRope;
  53718. private _addHullVerts;
  53719. private _createShape;
  53720. /**
  53721. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53722. * @param impostor imposter containing the physics body and babylon object
  53723. */
  53724. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53725. /**
  53726. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53727. * @param impostor imposter containing the physics body and babylon object
  53728. * @param newPosition new position
  53729. * @param newRotation new rotation
  53730. */
  53731. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53732. /**
  53733. * If this plugin is supported
  53734. * @returns true if its supported
  53735. */
  53736. isSupported(): boolean;
  53737. /**
  53738. * Sets the linear velocity of the physics body
  53739. * @param impostor imposter to set the velocity on
  53740. * @param velocity velocity to set
  53741. */
  53742. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53743. /**
  53744. * Sets the angular velocity of the physics body
  53745. * @param impostor imposter to set the velocity on
  53746. * @param velocity velocity to set
  53747. */
  53748. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53749. /**
  53750. * gets the linear velocity
  53751. * @param impostor imposter to get linear velocity from
  53752. * @returns linear velocity
  53753. */
  53754. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53755. /**
  53756. * gets the angular velocity
  53757. * @param impostor imposter to get angular velocity from
  53758. * @returns angular velocity
  53759. */
  53760. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53761. /**
  53762. * Sets the mass of physics body
  53763. * @param impostor imposter to set the mass on
  53764. * @param mass mass to set
  53765. */
  53766. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53767. /**
  53768. * Gets the mass of the physics body
  53769. * @param impostor imposter to get the mass from
  53770. * @returns mass
  53771. */
  53772. getBodyMass(impostor: PhysicsImpostor): number;
  53773. /**
  53774. * Gets friction of the impostor
  53775. * @param impostor impostor to get friction from
  53776. * @returns friction value
  53777. */
  53778. getBodyFriction(impostor: PhysicsImpostor): number;
  53779. /**
  53780. * Sets friction of the impostor
  53781. * @param impostor impostor to set friction on
  53782. * @param friction friction value
  53783. */
  53784. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53785. /**
  53786. * Gets restitution of the impostor
  53787. * @param impostor impostor to get restitution from
  53788. * @returns restitution value
  53789. */
  53790. getBodyRestitution(impostor: PhysicsImpostor): number;
  53791. /**
  53792. * Sets resitution of the impostor
  53793. * @param impostor impostor to set resitution on
  53794. * @param restitution resitution value
  53795. */
  53796. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53797. /**
  53798. * Gets pressure inside the impostor
  53799. * @param impostor impostor to get pressure from
  53800. * @returns pressure value
  53801. */
  53802. getBodyPressure(impostor: PhysicsImpostor): number;
  53803. /**
  53804. * Sets pressure inside a soft body impostor
  53805. * Cloth and rope must remain 0 pressure
  53806. * @param impostor impostor to set pressure on
  53807. * @param pressure pressure value
  53808. */
  53809. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53810. /**
  53811. * Gets stiffness of the impostor
  53812. * @param impostor impostor to get stiffness from
  53813. * @returns pressure value
  53814. */
  53815. getBodyStiffness(impostor: PhysicsImpostor): number;
  53816. /**
  53817. * Sets stiffness of the impostor
  53818. * @param impostor impostor to set stiffness on
  53819. * @param stiffness stiffness value from 0 to 1
  53820. */
  53821. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53822. /**
  53823. * Gets velocityIterations of the impostor
  53824. * @param impostor impostor to get velocity iterations from
  53825. * @returns velocityIterations value
  53826. */
  53827. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53828. /**
  53829. * Sets velocityIterations of the impostor
  53830. * @param impostor impostor to set velocity iterations on
  53831. * @param velocityIterations velocityIterations value
  53832. */
  53833. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53834. /**
  53835. * Gets positionIterations of the impostor
  53836. * @param impostor impostor to get position iterations from
  53837. * @returns positionIterations value
  53838. */
  53839. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53840. /**
  53841. * Sets positionIterations of the impostor
  53842. * @param impostor impostor to set position on
  53843. * @param positionIterations positionIterations value
  53844. */
  53845. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53846. /**
  53847. * Append an anchor to a cloth object
  53848. * @param impostor is the cloth impostor to add anchor to
  53849. * @param otherImpostor is the rigid impostor to anchor to
  53850. * @param width ratio across width from 0 to 1
  53851. * @param height ratio up height from 0 to 1
  53852. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53853. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53854. */
  53855. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53856. /**
  53857. * Append an hook to a rope object
  53858. * @param impostor is the rope impostor to add hook to
  53859. * @param otherImpostor is the rigid impostor to hook to
  53860. * @param length ratio along the rope from 0 to 1
  53861. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53862. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53863. */
  53864. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53865. /**
  53866. * Sleeps the physics body and stops it from being active
  53867. * @param impostor impostor to sleep
  53868. */
  53869. sleepBody(impostor: PhysicsImpostor): void;
  53870. /**
  53871. * Activates the physics body
  53872. * @param impostor impostor to activate
  53873. */
  53874. wakeUpBody(impostor: PhysicsImpostor): void;
  53875. /**
  53876. * Updates the distance parameters of the joint
  53877. * @param joint joint to update
  53878. * @param maxDistance maximum distance of the joint
  53879. * @param minDistance minimum distance of the joint
  53880. */
  53881. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53882. /**
  53883. * Sets a motor on the joint
  53884. * @param joint joint to set motor on
  53885. * @param speed speed of the motor
  53886. * @param maxForce maximum force of the motor
  53887. * @param motorIndex index of the motor
  53888. */
  53889. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53890. /**
  53891. * Sets the motors limit
  53892. * @param joint joint to set limit on
  53893. * @param upperLimit upper limit
  53894. * @param lowerLimit lower limit
  53895. */
  53896. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53897. /**
  53898. * Syncs the position and rotation of a mesh with the impostor
  53899. * @param mesh mesh to sync
  53900. * @param impostor impostor to update the mesh with
  53901. */
  53902. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53903. /**
  53904. * Gets the radius of the impostor
  53905. * @param impostor impostor to get radius from
  53906. * @returns the radius
  53907. */
  53908. getRadius(impostor: PhysicsImpostor): number;
  53909. /**
  53910. * Gets the box size of the impostor
  53911. * @param impostor impostor to get box size from
  53912. * @param result the resulting box size
  53913. */
  53914. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53915. /**
  53916. * Disposes of the impostor
  53917. */
  53918. dispose(): void;
  53919. /**
  53920. * Does a raycast in the physics world
  53921. * @param from when should the ray start?
  53922. * @param to when should the ray end?
  53923. * @returns PhysicsRaycastResult
  53924. */
  53925. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53926. }
  53927. }
  53928. declare module "babylonjs/Probes/reflectionProbe" {
  53929. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53930. import { Vector3 } from "babylonjs/Maths/math.vector";
  53931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53932. import { Nullable } from "babylonjs/types";
  53933. import { Scene } from "babylonjs/scene";
  53934. module "babylonjs/abstractScene" {
  53935. interface AbstractScene {
  53936. /**
  53937. * The list of reflection probes added to the scene
  53938. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53939. */
  53940. reflectionProbes: Array<ReflectionProbe>;
  53941. /**
  53942. * Removes the given reflection probe from this scene.
  53943. * @param toRemove The reflection probe to remove
  53944. * @returns The index of the removed reflection probe
  53945. */
  53946. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53947. /**
  53948. * Adds the given reflection probe to this scene.
  53949. * @param newReflectionProbe The reflection probe to add
  53950. */
  53951. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53952. }
  53953. }
  53954. /**
  53955. * Class used to generate realtime reflection / refraction cube textures
  53956. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53957. */
  53958. export class ReflectionProbe {
  53959. /** defines the name of the probe */
  53960. name: string;
  53961. private _scene;
  53962. private _renderTargetTexture;
  53963. private _projectionMatrix;
  53964. private _viewMatrix;
  53965. private _target;
  53966. private _add;
  53967. private _attachedMesh;
  53968. private _invertYAxis;
  53969. /** Gets or sets probe position (center of the cube map) */
  53970. position: Vector3;
  53971. /**
  53972. * Creates a new reflection probe
  53973. * @param name defines the name of the probe
  53974. * @param size defines the texture resolution (for each face)
  53975. * @param scene defines the hosting scene
  53976. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53977. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53978. */
  53979. constructor(
  53980. /** defines the name of the probe */
  53981. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53982. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53983. samples: number;
  53984. /** Gets or sets the refresh rate to use (on every frame by default) */
  53985. refreshRate: number;
  53986. /**
  53987. * Gets the hosting scene
  53988. * @returns a Scene
  53989. */
  53990. getScene(): Scene;
  53991. /** Gets the internal CubeTexture used to render to */
  53992. readonly cubeTexture: RenderTargetTexture;
  53993. /** Gets the list of meshes to render */
  53994. readonly renderList: Nullable<AbstractMesh[]>;
  53995. /**
  53996. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53997. * @param mesh defines the mesh to attach to
  53998. */
  53999. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54000. /**
  54001. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54002. * @param renderingGroupId The rendering group id corresponding to its index
  54003. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54004. */
  54005. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54006. /**
  54007. * Clean all associated resources
  54008. */
  54009. dispose(): void;
  54010. /**
  54011. * Converts the reflection probe information to a readable string for debug purpose.
  54012. * @param fullDetails Supports for multiple levels of logging within scene loading
  54013. * @returns the human readable reflection probe info
  54014. */
  54015. toString(fullDetails?: boolean): string;
  54016. /**
  54017. * Get the class name of the relfection probe.
  54018. * @returns "ReflectionProbe"
  54019. */
  54020. getClassName(): string;
  54021. /**
  54022. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54023. * @returns The JSON representation of the texture
  54024. */
  54025. serialize(): any;
  54026. /**
  54027. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54028. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54029. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54030. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54031. * @returns The parsed reflection probe if successful
  54032. */
  54033. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54034. }
  54035. }
  54036. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54037. /** @hidden */
  54038. export var _BabylonLoaderRegistered: boolean;
  54039. }
  54040. declare module "babylonjs/Loading/Plugins/index" {
  54041. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54042. }
  54043. declare module "babylonjs/Loading/index" {
  54044. export * from "babylonjs/Loading/loadingScreen";
  54045. export * from "babylonjs/Loading/Plugins/index";
  54046. export * from "babylonjs/Loading/sceneLoader";
  54047. export * from "babylonjs/Loading/sceneLoaderFlags";
  54048. }
  54049. declare module "babylonjs/Materials/Background/index" {
  54050. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54051. }
  54052. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54053. import { Scene } from "babylonjs/scene";
  54054. import { Color3 } from "babylonjs/Maths/math.color";
  54055. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54056. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54057. /**
  54058. * The Physically based simple base material of BJS.
  54059. *
  54060. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54061. * It is used as the base class for both the specGloss and metalRough conventions.
  54062. */
  54063. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54064. /**
  54065. * Number of Simultaneous lights allowed on the material.
  54066. */
  54067. maxSimultaneousLights: number;
  54068. /**
  54069. * If sets to true, disables all the lights affecting the material.
  54070. */
  54071. disableLighting: boolean;
  54072. /**
  54073. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54074. */
  54075. environmentTexture: BaseTexture;
  54076. /**
  54077. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54078. */
  54079. invertNormalMapX: boolean;
  54080. /**
  54081. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54082. */
  54083. invertNormalMapY: boolean;
  54084. /**
  54085. * Normal map used in the model.
  54086. */
  54087. normalTexture: BaseTexture;
  54088. /**
  54089. * Emissivie color used to self-illuminate the model.
  54090. */
  54091. emissiveColor: Color3;
  54092. /**
  54093. * Emissivie texture used to self-illuminate the model.
  54094. */
  54095. emissiveTexture: BaseTexture;
  54096. /**
  54097. * Occlusion Channel Strenght.
  54098. */
  54099. occlusionStrength: number;
  54100. /**
  54101. * Occlusion Texture of the material (adding extra occlusion effects).
  54102. */
  54103. occlusionTexture: BaseTexture;
  54104. /**
  54105. * Defines the alpha limits in alpha test mode.
  54106. */
  54107. alphaCutOff: number;
  54108. /**
  54109. * Gets the current double sided mode.
  54110. */
  54111. /**
  54112. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54113. */
  54114. doubleSided: boolean;
  54115. /**
  54116. * Stores the pre-calculated light information of a mesh in a texture.
  54117. */
  54118. lightmapTexture: BaseTexture;
  54119. /**
  54120. * If true, the light map contains occlusion information instead of lighting info.
  54121. */
  54122. useLightmapAsShadowmap: boolean;
  54123. /**
  54124. * Instantiates a new PBRMaterial instance.
  54125. *
  54126. * @param name The material name
  54127. * @param scene The scene the material will be use in.
  54128. */
  54129. constructor(name: string, scene: Scene);
  54130. getClassName(): string;
  54131. }
  54132. }
  54133. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54134. import { Scene } from "babylonjs/scene";
  54135. import { Color3 } from "babylonjs/Maths/math.color";
  54136. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54137. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54138. /**
  54139. * The PBR material of BJS following the metal roughness convention.
  54140. *
  54141. * This fits to the PBR convention in the GLTF definition:
  54142. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54143. */
  54144. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54145. /**
  54146. * The base color has two different interpretations depending on the value of metalness.
  54147. * When the material is a metal, the base color is the specific measured reflectance value
  54148. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54149. * of the material.
  54150. */
  54151. baseColor: Color3;
  54152. /**
  54153. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54154. * well as opacity information in the alpha channel.
  54155. */
  54156. baseTexture: BaseTexture;
  54157. /**
  54158. * Specifies the metallic scalar value of the material.
  54159. * Can also be used to scale the metalness values of the metallic texture.
  54160. */
  54161. metallic: number;
  54162. /**
  54163. * Specifies the roughness scalar value of the material.
  54164. * Can also be used to scale the roughness values of the metallic texture.
  54165. */
  54166. roughness: number;
  54167. /**
  54168. * Texture containing both the metallic value in the B channel and the
  54169. * roughness value in the G channel to keep better precision.
  54170. */
  54171. metallicRoughnessTexture: BaseTexture;
  54172. /**
  54173. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54174. *
  54175. * @param name The material name
  54176. * @param scene The scene the material will be use in.
  54177. */
  54178. constructor(name: string, scene: Scene);
  54179. /**
  54180. * Return the currrent class name of the material.
  54181. */
  54182. getClassName(): string;
  54183. /**
  54184. * Makes a duplicate of the current material.
  54185. * @param name - name to use for the new material.
  54186. */
  54187. clone(name: string): PBRMetallicRoughnessMaterial;
  54188. /**
  54189. * Serialize the material to a parsable JSON object.
  54190. */
  54191. serialize(): any;
  54192. /**
  54193. * Parses a JSON object correponding to the serialize function.
  54194. */
  54195. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54196. }
  54197. }
  54198. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54199. import { Scene } from "babylonjs/scene";
  54200. import { Color3 } from "babylonjs/Maths/math.color";
  54201. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54202. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54203. /**
  54204. * The PBR material of BJS following the specular glossiness convention.
  54205. *
  54206. * This fits to the PBR convention in the GLTF definition:
  54207. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54208. */
  54209. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54210. /**
  54211. * Specifies the diffuse color of the material.
  54212. */
  54213. diffuseColor: Color3;
  54214. /**
  54215. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54216. * channel.
  54217. */
  54218. diffuseTexture: BaseTexture;
  54219. /**
  54220. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54221. */
  54222. specularColor: Color3;
  54223. /**
  54224. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54225. */
  54226. glossiness: number;
  54227. /**
  54228. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54229. */
  54230. specularGlossinessTexture: BaseTexture;
  54231. /**
  54232. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54233. *
  54234. * @param name The material name
  54235. * @param scene The scene the material will be use in.
  54236. */
  54237. constructor(name: string, scene: Scene);
  54238. /**
  54239. * Return the currrent class name of the material.
  54240. */
  54241. getClassName(): string;
  54242. /**
  54243. * Makes a duplicate of the current material.
  54244. * @param name - name to use for the new material.
  54245. */
  54246. clone(name: string): PBRSpecularGlossinessMaterial;
  54247. /**
  54248. * Serialize the material to a parsable JSON object.
  54249. */
  54250. serialize(): any;
  54251. /**
  54252. * Parses a JSON object correponding to the serialize function.
  54253. */
  54254. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54255. }
  54256. }
  54257. declare module "babylonjs/Materials/PBR/index" {
  54258. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54259. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54260. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54261. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54262. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54263. }
  54264. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54265. import { Nullable } from "babylonjs/types";
  54266. import { Scene } from "babylonjs/scene";
  54267. import { Matrix } from "babylonjs/Maths/math.vector";
  54268. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54269. /**
  54270. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54271. * It can help converting any input color in a desired output one. This can then be used to create effects
  54272. * from sepia, black and white to sixties or futuristic rendering...
  54273. *
  54274. * The only supported format is currently 3dl.
  54275. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54276. */
  54277. export class ColorGradingTexture extends BaseTexture {
  54278. /**
  54279. * The current texture matrix. (will always be identity in color grading texture)
  54280. */
  54281. private _textureMatrix;
  54282. /**
  54283. * The texture URL.
  54284. */
  54285. url: string;
  54286. /**
  54287. * Empty line regex stored for GC.
  54288. */
  54289. private static _noneEmptyLineRegex;
  54290. private _engine;
  54291. /**
  54292. * Instantiates a ColorGradingTexture from the following parameters.
  54293. *
  54294. * @param url The location of the color gradind data (currently only supporting 3dl)
  54295. * @param scene The scene the texture will be used in
  54296. */
  54297. constructor(url: string, scene: Scene);
  54298. /**
  54299. * Returns the texture matrix used in most of the material.
  54300. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54301. */
  54302. getTextureMatrix(): Matrix;
  54303. /**
  54304. * Occurs when the file being loaded is a .3dl LUT file.
  54305. */
  54306. private load3dlTexture;
  54307. /**
  54308. * Starts the loading process of the texture.
  54309. */
  54310. private loadTexture;
  54311. /**
  54312. * Clones the color gradind texture.
  54313. */
  54314. clone(): ColorGradingTexture;
  54315. /**
  54316. * Called during delayed load for textures.
  54317. */
  54318. delayLoad(): void;
  54319. /**
  54320. * Parses a color grading texture serialized by Babylon.
  54321. * @param parsedTexture The texture information being parsedTexture
  54322. * @param scene The scene to load the texture in
  54323. * @param rootUrl The root url of the data assets to load
  54324. * @return A color gradind texture
  54325. */
  54326. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54327. /**
  54328. * Serializes the LUT texture to json format.
  54329. */
  54330. serialize(): any;
  54331. }
  54332. }
  54333. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54334. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54335. import { Scene } from "babylonjs/scene";
  54336. import { Nullable } from "babylonjs/types";
  54337. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54338. /**
  54339. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54340. */
  54341. export class EquiRectangularCubeTexture extends BaseTexture {
  54342. /** The six faces of the cube. */
  54343. private static _FacesMapping;
  54344. private _noMipmap;
  54345. private _onLoad;
  54346. private _onError;
  54347. /** The size of the cubemap. */
  54348. private _size;
  54349. /** The buffer of the image. */
  54350. private _buffer;
  54351. /** The width of the input image. */
  54352. private _width;
  54353. /** The height of the input image. */
  54354. private _height;
  54355. /** The URL to the image. */
  54356. url: string;
  54357. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54358. coordinatesMode: number;
  54359. /**
  54360. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54361. * @param url The location of the image
  54362. * @param scene The scene the texture will be used in
  54363. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54364. * @param noMipmap Forces to not generate the mipmap if true
  54365. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54366. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54367. * @param onLoad — defines a callback called when texture is loaded
  54368. * @param onError — defines a callback called if there is an error
  54369. */
  54370. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54371. /**
  54372. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54373. */
  54374. private loadImage;
  54375. /**
  54376. * Convert the image buffer into a cubemap and create a CubeTexture.
  54377. */
  54378. private loadTexture;
  54379. /**
  54380. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54381. * @param buffer The ArrayBuffer that should be converted.
  54382. * @returns The buffer as Float32Array.
  54383. */
  54384. private getFloat32ArrayFromArrayBuffer;
  54385. /**
  54386. * Get the current class name of the texture useful for serialization or dynamic coding.
  54387. * @returns "EquiRectangularCubeTexture"
  54388. */
  54389. getClassName(): string;
  54390. /**
  54391. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54392. * @returns A clone of the current EquiRectangularCubeTexture.
  54393. */
  54394. clone(): EquiRectangularCubeTexture;
  54395. }
  54396. }
  54397. declare module "babylonjs/Misc/tga" {
  54398. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54399. /**
  54400. * Based on jsTGALoader - Javascript loader for TGA file
  54401. * By Vincent Thibault
  54402. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54403. */
  54404. export class TGATools {
  54405. private static _TYPE_INDEXED;
  54406. private static _TYPE_RGB;
  54407. private static _TYPE_GREY;
  54408. private static _TYPE_RLE_INDEXED;
  54409. private static _TYPE_RLE_RGB;
  54410. private static _TYPE_RLE_GREY;
  54411. private static _ORIGIN_MASK;
  54412. private static _ORIGIN_SHIFT;
  54413. private static _ORIGIN_BL;
  54414. private static _ORIGIN_BR;
  54415. private static _ORIGIN_UL;
  54416. private static _ORIGIN_UR;
  54417. /**
  54418. * Gets the header of a TGA file
  54419. * @param data defines the TGA data
  54420. * @returns the header
  54421. */
  54422. static GetTGAHeader(data: Uint8Array): any;
  54423. /**
  54424. * Uploads TGA content to a Babylon Texture
  54425. * @hidden
  54426. */
  54427. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54428. /** @hidden */
  54429. 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;
  54430. /** @hidden */
  54431. 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;
  54432. /** @hidden */
  54433. 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;
  54434. /** @hidden */
  54435. 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;
  54436. /** @hidden */
  54437. 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;
  54438. /** @hidden */
  54439. 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;
  54440. }
  54441. }
  54442. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54443. import { Nullable } from "babylonjs/types";
  54444. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54445. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54446. /**
  54447. * Implementation of the TGA Texture Loader.
  54448. * @hidden
  54449. */
  54450. export class _TGATextureLoader implements IInternalTextureLoader {
  54451. /**
  54452. * Defines wether the loader supports cascade loading the different faces.
  54453. */
  54454. readonly supportCascades: boolean;
  54455. /**
  54456. * This returns if the loader support the current file information.
  54457. * @param extension defines the file extension of the file being loaded
  54458. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54459. * @param fallback defines the fallback internal texture if any
  54460. * @param isBase64 defines whether the texture is encoded as a base64
  54461. * @param isBuffer defines whether the texture data are stored as a buffer
  54462. * @returns true if the loader can load the specified file
  54463. */
  54464. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54465. /**
  54466. * Transform the url before loading if required.
  54467. * @param rootUrl the url of the texture
  54468. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54469. * @returns the transformed texture
  54470. */
  54471. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54472. /**
  54473. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54474. * @param rootUrl the url of the texture
  54475. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54476. * @returns the fallback texture
  54477. */
  54478. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54479. /**
  54480. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54481. * @param data contains the texture data
  54482. * @param texture defines the BabylonJS internal texture
  54483. * @param createPolynomials will be true if polynomials have been requested
  54484. * @param onLoad defines the callback to trigger once the texture is ready
  54485. * @param onError defines the callback to trigger in case of error
  54486. */
  54487. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54488. /**
  54489. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54490. * @param data contains the texture data
  54491. * @param texture defines the BabylonJS internal texture
  54492. * @param callback defines the method to call once ready to upload
  54493. */
  54494. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54495. }
  54496. }
  54497. declare module "babylonjs/Misc/basis" {
  54498. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54499. /**
  54500. * Info about the .basis files
  54501. */
  54502. class BasisFileInfo {
  54503. /**
  54504. * If the file has alpha
  54505. */
  54506. hasAlpha: boolean;
  54507. /**
  54508. * Info about each image of the basis file
  54509. */
  54510. images: Array<{
  54511. levels: Array<{
  54512. width: number;
  54513. height: number;
  54514. transcodedPixels: ArrayBufferView;
  54515. }>;
  54516. }>;
  54517. }
  54518. /**
  54519. * Result of transcoding a basis file
  54520. */
  54521. class TranscodeResult {
  54522. /**
  54523. * Info about the .basis file
  54524. */
  54525. fileInfo: BasisFileInfo;
  54526. /**
  54527. * Format to use when loading the file
  54528. */
  54529. format: number;
  54530. }
  54531. /**
  54532. * Configuration options for the Basis transcoder
  54533. */
  54534. export class BasisTranscodeConfiguration {
  54535. /**
  54536. * Supported compression formats used to determine the supported output format of the transcoder
  54537. */
  54538. supportedCompressionFormats?: {
  54539. /**
  54540. * etc1 compression format
  54541. */
  54542. etc1?: boolean;
  54543. /**
  54544. * s3tc compression format
  54545. */
  54546. s3tc?: boolean;
  54547. /**
  54548. * pvrtc compression format
  54549. */
  54550. pvrtc?: boolean;
  54551. /**
  54552. * etc2 compression format
  54553. */
  54554. etc2?: boolean;
  54555. };
  54556. /**
  54557. * If mipmap levels should be loaded for transcoded images (Default: true)
  54558. */
  54559. loadMipmapLevels?: boolean;
  54560. /**
  54561. * Index of a single image to load (Default: all images)
  54562. */
  54563. loadSingleImage?: number;
  54564. }
  54565. /**
  54566. * Used to load .Basis files
  54567. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54568. */
  54569. export class BasisTools {
  54570. private static _IgnoreSupportedFormats;
  54571. /**
  54572. * URL to use when loading the basis transcoder
  54573. */
  54574. static JSModuleURL: string;
  54575. /**
  54576. * URL to use when loading the wasm module for the transcoder
  54577. */
  54578. static WasmModuleURL: string;
  54579. /**
  54580. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54581. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54582. * @returns internal format corresponding to the Basis format
  54583. */
  54584. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54585. private static _WorkerPromise;
  54586. private static _Worker;
  54587. private static _actionId;
  54588. private static _CreateWorkerAsync;
  54589. /**
  54590. * Transcodes a loaded image file to compressed pixel data
  54591. * @param imageData image data to transcode
  54592. * @param config configuration options for the transcoding
  54593. * @returns a promise resulting in the transcoded image
  54594. */
  54595. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54596. /**
  54597. * Loads a texture from the transcode result
  54598. * @param texture texture load to
  54599. * @param transcodeResult the result of transcoding the basis file to load from
  54600. */
  54601. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54602. }
  54603. }
  54604. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54605. import { Nullable } from "babylonjs/types";
  54606. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54607. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54608. /**
  54609. * Loader for .basis file format
  54610. */
  54611. export class _BasisTextureLoader implements IInternalTextureLoader {
  54612. /**
  54613. * Defines whether the loader supports cascade loading the different faces.
  54614. */
  54615. readonly supportCascades: boolean;
  54616. /**
  54617. * This returns if the loader support the current file information.
  54618. * @param extension defines the file extension of the file being loaded
  54619. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54620. * @param fallback defines the fallback internal texture if any
  54621. * @param isBase64 defines whether the texture is encoded as a base64
  54622. * @param isBuffer defines whether the texture data are stored as a buffer
  54623. * @returns true if the loader can load the specified file
  54624. */
  54625. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54626. /**
  54627. * Transform the url before loading if required.
  54628. * @param rootUrl the url of the texture
  54629. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54630. * @returns the transformed texture
  54631. */
  54632. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54633. /**
  54634. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54635. * @param rootUrl the url of the texture
  54636. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54637. * @returns the fallback texture
  54638. */
  54639. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54640. /**
  54641. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54642. * @param data contains the texture data
  54643. * @param texture defines the BabylonJS internal texture
  54644. * @param createPolynomials will be true if polynomials have been requested
  54645. * @param onLoad defines the callback to trigger once the texture is ready
  54646. * @param onError defines the callback to trigger in case of error
  54647. */
  54648. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54649. /**
  54650. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54651. * @param data contains the texture data
  54652. * @param texture defines the BabylonJS internal texture
  54653. * @param callback defines the method to call once ready to upload
  54654. */
  54655. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54656. }
  54657. }
  54658. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54659. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54660. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54661. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54662. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54663. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54664. }
  54665. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54666. import { Scene } from "babylonjs/scene";
  54667. import { Texture } from "babylonjs/Materials/Textures/texture";
  54668. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54669. /**
  54670. * 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.
  54671. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54672. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54673. */
  54674. export class CustomProceduralTexture extends ProceduralTexture {
  54675. private _animate;
  54676. private _time;
  54677. private _config;
  54678. private _texturePath;
  54679. /**
  54680. * Instantiates a new Custom Procedural Texture.
  54681. * 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.
  54682. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54683. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54684. * @param name Define the name of the texture
  54685. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54686. * @param size Define the size of the texture to create
  54687. * @param scene Define the scene the texture belongs to
  54688. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54689. * @param generateMipMaps Define if the texture should creates mip maps or not
  54690. */
  54691. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54692. private _loadJson;
  54693. /**
  54694. * Is the texture ready to be used ? (rendered at least once)
  54695. * @returns true if ready, otherwise, false.
  54696. */
  54697. isReady(): boolean;
  54698. /**
  54699. * Render the texture to its associated render target.
  54700. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54701. */
  54702. render(useCameraPostProcess?: boolean): void;
  54703. /**
  54704. * Update the list of dependant textures samplers in the shader.
  54705. */
  54706. updateTextures(): void;
  54707. /**
  54708. * Update the uniform values of the procedural texture in the shader.
  54709. */
  54710. updateShaderUniforms(): void;
  54711. /**
  54712. * Define if the texture animates or not.
  54713. */
  54714. animate: boolean;
  54715. }
  54716. }
  54717. declare module "babylonjs/Shaders/noise.fragment" {
  54718. /** @hidden */
  54719. export var noisePixelShader: {
  54720. name: string;
  54721. shader: string;
  54722. };
  54723. }
  54724. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54725. import { Nullable } from "babylonjs/types";
  54726. import { Scene } from "babylonjs/scene";
  54727. import { Texture } from "babylonjs/Materials/Textures/texture";
  54728. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54729. import "babylonjs/Shaders/noise.fragment";
  54730. /**
  54731. * Class used to generate noise procedural textures
  54732. */
  54733. export class NoiseProceduralTexture extends ProceduralTexture {
  54734. private _time;
  54735. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54736. brightness: number;
  54737. /** Defines the number of octaves to process */
  54738. octaves: number;
  54739. /** Defines the level of persistence (0.8 by default) */
  54740. persistence: number;
  54741. /** Gets or sets animation speed factor (default is 1) */
  54742. animationSpeedFactor: number;
  54743. /**
  54744. * Creates a new NoiseProceduralTexture
  54745. * @param name defines the name fo the texture
  54746. * @param size defines the size of the texture (default is 256)
  54747. * @param scene defines the hosting scene
  54748. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54749. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54750. */
  54751. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54752. private _updateShaderUniforms;
  54753. protected _getDefines(): string;
  54754. /** Generate the current state of the procedural texture */
  54755. render(useCameraPostProcess?: boolean): void;
  54756. /**
  54757. * Serializes this noise procedural texture
  54758. * @returns a serialized noise procedural texture object
  54759. */
  54760. serialize(): any;
  54761. /**
  54762. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54763. * @param parsedTexture defines parsed texture data
  54764. * @param scene defines the current scene
  54765. * @param rootUrl defines the root URL containing noise procedural texture information
  54766. * @returns a parsed NoiseProceduralTexture
  54767. */
  54768. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54769. }
  54770. }
  54771. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54772. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54773. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54774. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54775. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54776. }
  54777. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54778. import { Nullable } from "babylonjs/types";
  54779. import { Scene } from "babylonjs/scene";
  54780. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54781. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54782. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54783. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54784. /**
  54785. * Raw cube texture where the raw buffers are passed in
  54786. */
  54787. export class RawCubeTexture extends CubeTexture {
  54788. /**
  54789. * Creates a cube texture where the raw buffers are passed in.
  54790. * @param scene defines the scene the texture is attached to
  54791. * @param data defines the array of data to use to create each face
  54792. * @param size defines the size of the textures
  54793. * @param format defines the format of the data
  54794. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54795. * @param generateMipMaps defines if the engine should generate the mip levels
  54796. * @param invertY defines if data must be stored with Y axis inverted
  54797. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54798. * @param compression defines the compression used (null by default)
  54799. */
  54800. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54801. /**
  54802. * Updates the raw cube texture.
  54803. * @param data defines the data to store
  54804. * @param format defines the data format
  54805. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54806. * @param invertY defines if data must be stored with Y axis inverted
  54807. * @param compression defines the compression used (null by default)
  54808. * @param level defines which level of the texture to update
  54809. */
  54810. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54811. /**
  54812. * Updates a raw cube texture with RGBD encoded data.
  54813. * @param data defines the array of data [mipmap][face] to use to create each face
  54814. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54815. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54816. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54817. * @returns a promsie that resolves when the operation is complete
  54818. */
  54819. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54820. /**
  54821. * Clones the raw cube texture.
  54822. * @return a new cube texture
  54823. */
  54824. clone(): CubeTexture;
  54825. /** @hidden */
  54826. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54827. }
  54828. }
  54829. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54830. import { Scene } from "babylonjs/scene";
  54831. import { Texture } from "babylonjs/Materials/Textures/texture";
  54832. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54833. /**
  54834. * Class used to store 3D textures containing user data
  54835. */
  54836. export class RawTexture3D extends Texture {
  54837. /** Gets or sets the texture format to use */
  54838. format: number;
  54839. private _engine;
  54840. /**
  54841. * Create a new RawTexture3D
  54842. * @param data defines the data of the texture
  54843. * @param width defines the width of the texture
  54844. * @param height defines the height of the texture
  54845. * @param depth defines the depth of the texture
  54846. * @param format defines the texture format to use
  54847. * @param scene defines the hosting scene
  54848. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54849. * @param invertY defines if texture must be stored with Y axis inverted
  54850. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54851. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54852. */
  54853. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54854. /** Gets or sets the texture format to use */
  54855. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54856. /**
  54857. * Update the texture with new data
  54858. * @param data defines the data to store in the texture
  54859. */
  54860. update(data: ArrayBufferView): void;
  54861. }
  54862. }
  54863. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54864. import { Scene } from "babylonjs/scene";
  54865. import { Plane } from "babylonjs/Maths/math.plane";
  54866. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54867. /**
  54868. * Creates a refraction texture used by refraction channel of the standard material.
  54869. * It is like a mirror but to see through a material.
  54870. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54871. */
  54872. export class RefractionTexture extends RenderTargetTexture {
  54873. /**
  54874. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54875. * 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.
  54876. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54877. */
  54878. refractionPlane: Plane;
  54879. /**
  54880. * Define how deep under the surface we should see.
  54881. */
  54882. depth: number;
  54883. /**
  54884. * Creates a refraction texture used by refraction channel of the standard material.
  54885. * It is like a mirror but to see through a material.
  54886. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54887. * @param name Define the texture name
  54888. * @param size Define the size of the underlying texture
  54889. * @param scene Define the scene the refraction belongs to
  54890. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54891. */
  54892. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54893. /**
  54894. * Clone the refraction texture.
  54895. * @returns the cloned texture
  54896. */
  54897. clone(): RefractionTexture;
  54898. /**
  54899. * Serialize the texture to a JSON representation you could use in Parse later on
  54900. * @returns the serialized JSON representation
  54901. */
  54902. serialize(): any;
  54903. }
  54904. }
  54905. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54906. import { Nullable } from "babylonjs/types";
  54907. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54908. import { Matrix } from "babylonjs/Maths/math.vector";
  54909. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54910. import "babylonjs/Engines/Extensions/engine.videoTexture";
  54911. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54912. import { Scene } from "babylonjs/scene";
  54913. /**
  54914. * Defines the options related to the creation of an HtmlElementTexture
  54915. */
  54916. export interface IHtmlElementTextureOptions {
  54917. /**
  54918. * Defines wether mip maps should be created or not.
  54919. */
  54920. generateMipMaps?: boolean;
  54921. /**
  54922. * Defines the sampling mode of the texture.
  54923. */
  54924. samplingMode?: number;
  54925. /**
  54926. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54927. */
  54928. engine: Nullable<ThinEngine>;
  54929. /**
  54930. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54931. */
  54932. scene: Nullable<Scene>;
  54933. }
  54934. /**
  54935. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54936. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54937. * is automatically managed.
  54938. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54939. * in your application.
  54940. *
  54941. * As the update is not automatic, you need to call them manually.
  54942. */
  54943. export class HtmlElementTexture extends BaseTexture {
  54944. /**
  54945. * The texture URL.
  54946. */
  54947. element: HTMLVideoElement | HTMLCanvasElement;
  54948. private static readonly DefaultOptions;
  54949. private _textureMatrix;
  54950. private _engine;
  54951. private _isVideo;
  54952. private _generateMipMaps;
  54953. private _samplingMode;
  54954. /**
  54955. * Instantiates a HtmlElementTexture from the following parameters.
  54956. *
  54957. * @param name Defines the name of the texture
  54958. * @param element Defines the video or canvas the texture is filled with
  54959. * @param options Defines the other none mandatory texture creation options
  54960. */
  54961. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54962. private _createInternalTexture;
  54963. /**
  54964. * Returns the texture matrix used in most of the material.
  54965. */
  54966. getTextureMatrix(): Matrix;
  54967. /**
  54968. * Updates the content of the texture.
  54969. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54970. */
  54971. update(invertY?: Nullable<boolean>): void;
  54972. }
  54973. }
  54974. declare module "babylonjs/Materials/Textures/index" {
  54975. export * from "babylonjs/Materials/Textures/baseTexture";
  54976. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  54977. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54978. export * from "babylonjs/Materials/Textures/cubeTexture";
  54979. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54980. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54981. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54982. export * from "babylonjs/Materials/Textures/internalTexture";
  54983. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54984. export * from "babylonjs/Materials/Textures/Loaders/index";
  54985. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54986. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54987. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54988. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54989. export * from "babylonjs/Materials/Textures/rawTexture";
  54990. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54991. export * from "babylonjs/Materials/Textures/refractionTexture";
  54992. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54993. export * from "babylonjs/Materials/Textures/texture";
  54994. export * from "babylonjs/Materials/Textures/videoTexture";
  54995. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54996. }
  54997. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  54998. /**
  54999. * Enum used to define the target of a block
  55000. */
  55001. export enum NodeMaterialBlockTargets {
  55002. /** Vertex shader */
  55003. Vertex = 1,
  55004. /** Fragment shader */
  55005. Fragment = 2,
  55006. /** Neutral */
  55007. Neutral = 4,
  55008. /** Vertex and Fragment */
  55009. VertexAndFragment = 3
  55010. }
  55011. }
  55012. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55013. /**
  55014. * Defines the kind of connection point for node based material
  55015. */
  55016. export enum NodeMaterialBlockConnectionPointTypes {
  55017. /** Float */
  55018. Float = 1,
  55019. /** Int */
  55020. Int = 2,
  55021. /** Vector2 */
  55022. Vector2 = 4,
  55023. /** Vector3 */
  55024. Vector3 = 8,
  55025. /** Vector4 */
  55026. Vector4 = 16,
  55027. /** Color3 */
  55028. Color3 = 32,
  55029. /** Color4 */
  55030. Color4 = 64,
  55031. /** Matrix */
  55032. Matrix = 128,
  55033. /** Detect type based on connection */
  55034. AutoDetect = 1024,
  55035. /** Output type that will be defined by input type */
  55036. BasedOnInput = 2048
  55037. }
  55038. }
  55039. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55040. /**
  55041. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55042. */
  55043. export enum NodeMaterialBlockConnectionPointMode {
  55044. /** Value is an uniform */
  55045. Uniform = 0,
  55046. /** Value is a mesh attribute */
  55047. Attribute = 1,
  55048. /** Value is a varying between vertex and fragment shaders */
  55049. Varying = 2,
  55050. /** Mode is undefined */
  55051. Undefined = 3
  55052. }
  55053. }
  55054. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55055. /**
  55056. * Enum used to define system values e.g. values automatically provided by the system
  55057. */
  55058. export enum NodeMaterialSystemValues {
  55059. /** World */
  55060. World = 1,
  55061. /** View */
  55062. View = 2,
  55063. /** Projection */
  55064. Projection = 3,
  55065. /** ViewProjection */
  55066. ViewProjection = 4,
  55067. /** WorldView */
  55068. WorldView = 5,
  55069. /** WorldViewProjection */
  55070. WorldViewProjection = 6,
  55071. /** CameraPosition */
  55072. CameraPosition = 7,
  55073. /** Fog Color */
  55074. FogColor = 8,
  55075. /** Delta time */
  55076. DeltaTime = 9
  55077. }
  55078. }
  55079. declare module "babylonjs/Materials/Node/Enums/index" {
  55080. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55081. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55082. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55083. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55084. }
  55085. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55086. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55087. /**
  55088. * Root class for all node material optimizers
  55089. */
  55090. export class NodeMaterialOptimizer {
  55091. /**
  55092. * Function used to optimize a NodeMaterial graph
  55093. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55094. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55095. */
  55096. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55097. }
  55098. }
  55099. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55100. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55101. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55102. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55103. import { Scene } from "babylonjs/scene";
  55104. /**
  55105. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55106. */
  55107. export class TransformBlock extends NodeMaterialBlock {
  55108. /**
  55109. * Defines the value to use to complement W value to transform it to a Vector4
  55110. */
  55111. complementW: number;
  55112. /**
  55113. * Defines the value to use to complement z value to transform it to a Vector4
  55114. */
  55115. complementZ: number;
  55116. /**
  55117. * Creates a new TransformBlock
  55118. * @param name defines the block name
  55119. */
  55120. constructor(name: string);
  55121. /**
  55122. * Gets the current class name
  55123. * @returns the class name
  55124. */
  55125. getClassName(): string;
  55126. /**
  55127. * Gets the vector input
  55128. */
  55129. readonly vector: NodeMaterialConnectionPoint;
  55130. /**
  55131. * Gets the output component
  55132. */
  55133. readonly output: NodeMaterialConnectionPoint;
  55134. /**
  55135. * Gets the matrix transform input
  55136. */
  55137. readonly transform: NodeMaterialConnectionPoint;
  55138. protected _buildBlock(state: NodeMaterialBuildState): this;
  55139. serialize(): any;
  55140. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55141. protected _dumpPropertiesCode(): string;
  55142. }
  55143. }
  55144. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55145. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55146. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55147. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55148. /**
  55149. * Block used to output the vertex position
  55150. */
  55151. export class VertexOutputBlock extends NodeMaterialBlock {
  55152. /**
  55153. * Creates a new VertexOutputBlock
  55154. * @param name defines the block name
  55155. */
  55156. constructor(name: string);
  55157. /**
  55158. * Gets the current class name
  55159. * @returns the class name
  55160. */
  55161. getClassName(): string;
  55162. /**
  55163. * Gets the vector input component
  55164. */
  55165. readonly vector: NodeMaterialConnectionPoint;
  55166. protected _buildBlock(state: NodeMaterialBuildState): this;
  55167. }
  55168. }
  55169. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55170. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55171. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55172. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55173. /**
  55174. * Block used to output the final color
  55175. */
  55176. export class FragmentOutputBlock extends NodeMaterialBlock {
  55177. /**
  55178. * Create a new FragmentOutputBlock
  55179. * @param name defines the block name
  55180. */
  55181. constructor(name: string);
  55182. /**
  55183. * Gets the current class name
  55184. * @returns the class name
  55185. */
  55186. getClassName(): string;
  55187. /**
  55188. * Gets the rgba input component
  55189. */
  55190. readonly rgba: NodeMaterialConnectionPoint;
  55191. /**
  55192. * Gets the rgb input component
  55193. */
  55194. readonly rgb: NodeMaterialConnectionPoint;
  55195. /**
  55196. * Gets the a input component
  55197. */
  55198. readonly a: NodeMaterialConnectionPoint;
  55199. protected _buildBlock(state: NodeMaterialBuildState): this;
  55200. }
  55201. }
  55202. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55203. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55204. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55205. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55206. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55207. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55208. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55209. import { Effect } from "babylonjs/Materials/effect";
  55210. import { Mesh } from "babylonjs/Meshes/mesh";
  55211. import { Nullable } from "babylonjs/types";
  55212. import { Scene } from "babylonjs/scene";
  55213. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55214. /**
  55215. * Block used to read a reflection texture from a sampler
  55216. */
  55217. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55218. private _define3DName;
  55219. private _defineCubicName;
  55220. private _defineExplicitName;
  55221. private _defineProjectionName;
  55222. private _defineLocalCubicName;
  55223. private _defineSphericalName;
  55224. private _definePlanarName;
  55225. private _defineEquirectangularName;
  55226. private _defineMirroredEquirectangularFixedName;
  55227. private _defineEquirectangularFixedName;
  55228. private _defineSkyboxName;
  55229. private _cubeSamplerName;
  55230. private _2DSamplerName;
  55231. private _positionUVWName;
  55232. private _directionWName;
  55233. private _reflectionCoordsName;
  55234. private _reflection2DCoordsName;
  55235. private _reflectionColorName;
  55236. private _reflectionMatrixName;
  55237. /**
  55238. * Gets or sets the texture associated with the node
  55239. */
  55240. texture: Nullable<BaseTexture>;
  55241. /**
  55242. * Create a new TextureBlock
  55243. * @param name defines the block name
  55244. */
  55245. constructor(name: string);
  55246. /**
  55247. * Gets the current class name
  55248. * @returns the class name
  55249. */
  55250. getClassName(): string;
  55251. /**
  55252. * Gets the world position input component
  55253. */
  55254. readonly position: NodeMaterialConnectionPoint;
  55255. /**
  55256. * Gets the world position input component
  55257. */
  55258. readonly worldPosition: NodeMaterialConnectionPoint;
  55259. /**
  55260. * Gets the world normal input component
  55261. */
  55262. readonly worldNormal: NodeMaterialConnectionPoint;
  55263. /**
  55264. * Gets the world input component
  55265. */
  55266. readonly world: NodeMaterialConnectionPoint;
  55267. /**
  55268. * Gets the camera (or eye) position component
  55269. */
  55270. readonly cameraPosition: NodeMaterialConnectionPoint;
  55271. /**
  55272. * Gets the view input component
  55273. */
  55274. readonly view: NodeMaterialConnectionPoint;
  55275. /**
  55276. * Gets the rgb output component
  55277. */
  55278. readonly rgb: NodeMaterialConnectionPoint;
  55279. /**
  55280. * Gets the r output component
  55281. */
  55282. readonly r: NodeMaterialConnectionPoint;
  55283. /**
  55284. * Gets the g output component
  55285. */
  55286. readonly g: NodeMaterialConnectionPoint;
  55287. /**
  55288. * Gets the b output component
  55289. */
  55290. readonly b: NodeMaterialConnectionPoint;
  55291. autoConfigure(material: NodeMaterial): void;
  55292. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55293. isReady(): boolean;
  55294. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55295. private _injectVertexCode;
  55296. private _writeOutput;
  55297. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55298. serialize(): any;
  55299. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55300. }
  55301. }
  55302. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55303. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55304. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55305. import { Scene } from "babylonjs/scene";
  55306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55307. import { Matrix } from "babylonjs/Maths/math.vector";
  55308. import { Mesh } from "babylonjs/Meshes/mesh";
  55309. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55310. import { Observable } from "babylonjs/Misc/observable";
  55311. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55312. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55313. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55314. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55315. import { Nullable } from "babylonjs/types";
  55316. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55317. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55318. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55319. /**
  55320. * Interface used to configure the node material editor
  55321. */
  55322. export interface INodeMaterialEditorOptions {
  55323. /** Define the URl to load node editor script */
  55324. editorURL?: string;
  55325. }
  55326. /** @hidden */
  55327. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55328. /** BONES */
  55329. NUM_BONE_INFLUENCERS: number;
  55330. BonesPerMesh: number;
  55331. BONETEXTURE: boolean;
  55332. /** MORPH TARGETS */
  55333. MORPHTARGETS: boolean;
  55334. MORPHTARGETS_NORMAL: boolean;
  55335. MORPHTARGETS_TANGENT: boolean;
  55336. MORPHTARGETS_UV: boolean;
  55337. NUM_MORPH_INFLUENCERS: number;
  55338. /** IMAGE PROCESSING */
  55339. IMAGEPROCESSING: boolean;
  55340. VIGNETTE: boolean;
  55341. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55342. VIGNETTEBLENDMODEOPAQUE: boolean;
  55343. TONEMAPPING: boolean;
  55344. TONEMAPPING_ACES: boolean;
  55345. CONTRAST: boolean;
  55346. EXPOSURE: boolean;
  55347. COLORCURVES: boolean;
  55348. COLORGRADING: boolean;
  55349. COLORGRADING3D: boolean;
  55350. SAMPLER3DGREENDEPTH: boolean;
  55351. SAMPLER3DBGRMAP: boolean;
  55352. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55353. /** MISC. */
  55354. BUMPDIRECTUV: number;
  55355. constructor();
  55356. setValue(name: string, value: boolean): void;
  55357. }
  55358. /**
  55359. * Class used to configure NodeMaterial
  55360. */
  55361. export interface INodeMaterialOptions {
  55362. /**
  55363. * Defines if blocks should emit comments
  55364. */
  55365. emitComments: boolean;
  55366. }
  55367. /**
  55368. * Class used to create a node based material built by assembling shader blocks
  55369. */
  55370. export class NodeMaterial extends PushMaterial {
  55371. private static _BuildIdGenerator;
  55372. private _options;
  55373. private _vertexCompilationState;
  55374. private _fragmentCompilationState;
  55375. private _sharedData;
  55376. private _buildId;
  55377. private _buildWasSuccessful;
  55378. private _cachedWorldViewMatrix;
  55379. private _cachedWorldViewProjectionMatrix;
  55380. private _optimizers;
  55381. private _animationFrame;
  55382. /** Define the URl to load node editor script */
  55383. static EditorURL: string;
  55384. private BJSNODEMATERIALEDITOR;
  55385. /** Get the inspector from bundle or global */
  55386. private _getGlobalNodeMaterialEditor;
  55387. /**
  55388. * 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)
  55389. */
  55390. ignoreAlpha: boolean;
  55391. /**
  55392. * Defines the maximum number of lights that can be used in the material
  55393. */
  55394. maxSimultaneousLights: number;
  55395. /**
  55396. * Observable raised when the material is built
  55397. */
  55398. onBuildObservable: Observable<NodeMaterial>;
  55399. /**
  55400. * Gets or sets the root nodes of the material vertex shader
  55401. */
  55402. _vertexOutputNodes: NodeMaterialBlock[];
  55403. /**
  55404. * Gets or sets the root nodes of the material fragment (pixel) shader
  55405. */
  55406. _fragmentOutputNodes: NodeMaterialBlock[];
  55407. /** Gets or sets options to control the node material overall behavior */
  55408. options: INodeMaterialOptions;
  55409. /**
  55410. * Default configuration related to image processing available in the standard Material.
  55411. */
  55412. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55413. /**
  55414. * Gets the image processing configuration used either in this material.
  55415. */
  55416. /**
  55417. * Sets the Default image processing configuration used either in the this material.
  55418. *
  55419. * If sets to null, the scene one is in use.
  55420. */
  55421. imageProcessingConfiguration: ImageProcessingConfiguration;
  55422. /**
  55423. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55424. */
  55425. attachedBlocks: NodeMaterialBlock[];
  55426. /**
  55427. * Create a new node based material
  55428. * @param name defines the material name
  55429. * @param scene defines the hosting scene
  55430. * @param options defines creation option
  55431. */
  55432. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55433. /**
  55434. * Gets the current class name of the material e.g. "NodeMaterial"
  55435. * @returns the class name
  55436. */
  55437. getClassName(): string;
  55438. /**
  55439. * Keep track of the image processing observer to allow dispose and replace.
  55440. */
  55441. private _imageProcessingObserver;
  55442. /**
  55443. * Attaches a new image processing configuration to the Standard Material.
  55444. * @param configuration
  55445. */
  55446. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55447. /**
  55448. * Get a block by its name
  55449. * @param name defines the name of the block to retrieve
  55450. * @returns the required block or null if not found
  55451. */
  55452. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55453. /**
  55454. * Get a block by its name
  55455. * @param predicate defines the predicate used to find the good candidate
  55456. * @returns the required block or null if not found
  55457. */
  55458. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55459. /**
  55460. * Get an input block by its name
  55461. * @param predicate defines the predicate used to find the good candidate
  55462. * @returns the required input block or null if not found
  55463. */
  55464. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55465. /**
  55466. * Gets the list of input blocks attached to this material
  55467. * @returns an array of InputBlocks
  55468. */
  55469. getInputBlocks(): InputBlock[];
  55470. /**
  55471. * Adds a new optimizer to the list of optimizers
  55472. * @param optimizer defines the optimizers to add
  55473. * @returns the current material
  55474. */
  55475. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55476. /**
  55477. * Remove an optimizer from the list of optimizers
  55478. * @param optimizer defines the optimizers to remove
  55479. * @returns the current material
  55480. */
  55481. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55482. /**
  55483. * Add a new block to the list of output nodes
  55484. * @param node defines the node to add
  55485. * @returns the current material
  55486. */
  55487. addOutputNode(node: NodeMaterialBlock): this;
  55488. /**
  55489. * Remove a block from the list of root nodes
  55490. * @param node defines the node to remove
  55491. * @returns the current material
  55492. */
  55493. removeOutputNode(node: NodeMaterialBlock): this;
  55494. private _addVertexOutputNode;
  55495. private _removeVertexOutputNode;
  55496. private _addFragmentOutputNode;
  55497. private _removeFragmentOutputNode;
  55498. /**
  55499. * Specifies if the material will require alpha blending
  55500. * @returns a boolean specifying if alpha blending is needed
  55501. */
  55502. needAlphaBlending(): boolean;
  55503. /**
  55504. * Specifies if this material should be rendered in alpha test mode
  55505. * @returns a boolean specifying if an alpha test is needed.
  55506. */
  55507. needAlphaTesting(): boolean;
  55508. private _initializeBlock;
  55509. private _resetDualBlocks;
  55510. /**
  55511. * Build the material and generates the inner effect
  55512. * @param verbose defines if the build should log activity
  55513. */
  55514. build(verbose?: boolean): void;
  55515. /**
  55516. * Runs an otpimization phase to try to improve the shader code
  55517. */
  55518. optimize(): void;
  55519. private _prepareDefinesForAttributes;
  55520. /**
  55521. * Get if the submesh is ready to be used and all its information available.
  55522. * Child classes can use it to update shaders
  55523. * @param mesh defines the mesh to check
  55524. * @param subMesh defines which submesh to check
  55525. * @param useInstances specifies that instances should be used
  55526. * @returns a boolean indicating that the submesh is ready or not
  55527. */
  55528. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55529. /**
  55530. * Get a string representing the shaders built by the current node graph
  55531. */
  55532. readonly compiledShaders: string;
  55533. /**
  55534. * Binds the world matrix to the material
  55535. * @param world defines the world transformation matrix
  55536. */
  55537. bindOnlyWorldMatrix(world: Matrix): void;
  55538. /**
  55539. * Binds the submesh to this material by preparing the effect and shader to draw
  55540. * @param world defines the world transformation matrix
  55541. * @param mesh defines the mesh containing the submesh
  55542. * @param subMesh defines the submesh to bind the material to
  55543. */
  55544. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55545. /**
  55546. * Gets the active textures from the material
  55547. * @returns an array of textures
  55548. */
  55549. getActiveTextures(): BaseTexture[];
  55550. /**
  55551. * Gets the list of texture blocks
  55552. * @returns an array of texture blocks
  55553. */
  55554. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55555. /**
  55556. * Specifies if the material uses a texture
  55557. * @param texture defines the texture to check against the material
  55558. * @returns a boolean specifying if the material uses the texture
  55559. */
  55560. hasTexture(texture: BaseTexture): boolean;
  55561. /**
  55562. * Disposes the material
  55563. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55564. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55565. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55566. */
  55567. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55568. /** Creates the node editor window. */
  55569. private _createNodeEditor;
  55570. /**
  55571. * Launch the node material editor
  55572. * @param config Define the configuration of the editor
  55573. * @return a promise fulfilled when the node editor is visible
  55574. */
  55575. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55576. /**
  55577. * Clear the current material
  55578. */
  55579. clear(): void;
  55580. /**
  55581. * Clear the current material and set it to a default state
  55582. */
  55583. setToDefault(): void;
  55584. /**
  55585. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55586. * @param url defines the url to load from
  55587. * @returns a promise that will fullfil when the material is fully loaded
  55588. */
  55589. loadAsync(url: string): Promise<unknown>;
  55590. private _gatherBlocks;
  55591. /**
  55592. * Generate a string containing the code declaration required to create an equivalent of this material
  55593. * @returns a string
  55594. */
  55595. generateCode(): string;
  55596. /**
  55597. * Serializes this material in a JSON representation
  55598. * @returns the serialized material object
  55599. */
  55600. serialize(): any;
  55601. private _restoreConnections;
  55602. /**
  55603. * Clear the current graph and load a new one from a serialization object
  55604. * @param source defines the JSON representation of the material
  55605. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55606. */
  55607. loadFromSerialization(source: any, rootUrl?: string): void;
  55608. /**
  55609. * Creates a node material from parsed material data
  55610. * @param source defines the JSON representation of the material
  55611. * @param scene defines the hosting scene
  55612. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55613. * @returns a new node material
  55614. */
  55615. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55616. /**
  55617. * Creates a new node material set to default basic configuration
  55618. * @param name defines the name of the material
  55619. * @param scene defines the hosting scene
  55620. * @returns a new NodeMaterial
  55621. */
  55622. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55623. }
  55624. }
  55625. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55626. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55627. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55628. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55629. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55631. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55632. import { Effect } from "babylonjs/Materials/effect";
  55633. import { Mesh } from "babylonjs/Meshes/mesh";
  55634. import { Nullable } from "babylonjs/types";
  55635. import { Texture } from "babylonjs/Materials/Textures/texture";
  55636. import { Scene } from "babylonjs/scene";
  55637. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55638. /**
  55639. * Block used to read a texture from a sampler
  55640. */
  55641. export class TextureBlock extends NodeMaterialBlock {
  55642. private _defineName;
  55643. private _linearDefineName;
  55644. private _samplerName;
  55645. private _transformedUVName;
  55646. private _textureTransformName;
  55647. private _textureInfoName;
  55648. private _mainUVName;
  55649. private _mainUVDefineName;
  55650. /**
  55651. * Gets or sets the texture associated with the node
  55652. */
  55653. texture: Nullable<Texture>;
  55654. /**
  55655. * Create a new TextureBlock
  55656. * @param name defines the block name
  55657. */
  55658. constructor(name: string);
  55659. /**
  55660. * Gets the current class name
  55661. * @returns the class name
  55662. */
  55663. getClassName(): string;
  55664. /**
  55665. * Gets the uv input component
  55666. */
  55667. readonly uv: NodeMaterialConnectionPoint;
  55668. /**
  55669. * Gets the rgba output component
  55670. */
  55671. readonly rgba: NodeMaterialConnectionPoint;
  55672. /**
  55673. * Gets the rgb output component
  55674. */
  55675. readonly rgb: NodeMaterialConnectionPoint;
  55676. /**
  55677. * Gets the r output component
  55678. */
  55679. readonly r: NodeMaterialConnectionPoint;
  55680. /**
  55681. * Gets the g output component
  55682. */
  55683. readonly g: NodeMaterialConnectionPoint;
  55684. /**
  55685. * Gets the b output component
  55686. */
  55687. readonly b: NodeMaterialConnectionPoint;
  55688. /**
  55689. * Gets the a output component
  55690. */
  55691. readonly a: NodeMaterialConnectionPoint;
  55692. readonly target: NodeMaterialBlockTargets;
  55693. autoConfigure(material: NodeMaterial): void;
  55694. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55695. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55696. isReady(): boolean;
  55697. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55698. private readonly _isMixed;
  55699. private _injectVertexCode;
  55700. private _writeOutput;
  55701. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55702. protected _dumpPropertiesCode(): string;
  55703. serialize(): any;
  55704. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55705. }
  55706. }
  55707. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55708. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55709. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55710. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55711. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55712. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55713. import { Scene } from "babylonjs/scene";
  55714. /**
  55715. * Class used to store shared data between 2 NodeMaterialBuildState
  55716. */
  55717. export class NodeMaterialBuildStateSharedData {
  55718. /**
  55719. * Gets the list of emitted varyings
  55720. */
  55721. temps: string[];
  55722. /**
  55723. * Gets the list of emitted varyings
  55724. */
  55725. varyings: string[];
  55726. /**
  55727. * Gets the varying declaration string
  55728. */
  55729. varyingDeclaration: string;
  55730. /**
  55731. * Input blocks
  55732. */
  55733. inputBlocks: InputBlock[];
  55734. /**
  55735. * Input blocks
  55736. */
  55737. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55738. /**
  55739. * Bindable blocks (Blocks that need to set data to the effect)
  55740. */
  55741. bindableBlocks: NodeMaterialBlock[];
  55742. /**
  55743. * List of blocks that can provide a compilation fallback
  55744. */
  55745. blocksWithFallbacks: NodeMaterialBlock[];
  55746. /**
  55747. * List of blocks that can provide a define update
  55748. */
  55749. blocksWithDefines: NodeMaterialBlock[];
  55750. /**
  55751. * List of blocks that can provide a repeatable content
  55752. */
  55753. repeatableContentBlocks: NodeMaterialBlock[];
  55754. /**
  55755. * List of blocks that can provide a dynamic list of uniforms
  55756. */
  55757. dynamicUniformBlocks: NodeMaterialBlock[];
  55758. /**
  55759. * List of blocks that can block the isReady function for the material
  55760. */
  55761. blockingBlocks: NodeMaterialBlock[];
  55762. /**
  55763. * Gets the list of animated inputs
  55764. */
  55765. animatedInputs: InputBlock[];
  55766. /**
  55767. * Build Id used to avoid multiple recompilations
  55768. */
  55769. buildId: number;
  55770. /** List of emitted variables */
  55771. variableNames: {
  55772. [key: string]: number;
  55773. };
  55774. /** List of emitted defines */
  55775. defineNames: {
  55776. [key: string]: number;
  55777. };
  55778. /** Should emit comments? */
  55779. emitComments: boolean;
  55780. /** Emit build activity */
  55781. verbose: boolean;
  55782. /** Gets or sets the hosting scene */
  55783. scene: Scene;
  55784. /**
  55785. * Gets the compilation hints emitted at compilation time
  55786. */
  55787. hints: {
  55788. needWorldViewMatrix: boolean;
  55789. needWorldViewProjectionMatrix: boolean;
  55790. needAlphaBlending: boolean;
  55791. needAlphaTesting: boolean;
  55792. };
  55793. /**
  55794. * List of compilation checks
  55795. */
  55796. checks: {
  55797. emitVertex: boolean;
  55798. emitFragment: boolean;
  55799. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55800. };
  55801. /** Creates a new shared data */
  55802. constructor();
  55803. /**
  55804. * Emits console errors and exceptions if there is a failing check
  55805. */
  55806. emitErrors(): void;
  55807. }
  55808. }
  55809. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55810. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55811. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55812. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55813. /**
  55814. * Class used to store node based material build state
  55815. */
  55816. export class NodeMaterialBuildState {
  55817. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55818. supportUniformBuffers: boolean;
  55819. /**
  55820. * Gets the list of emitted attributes
  55821. */
  55822. attributes: string[];
  55823. /**
  55824. * Gets the list of emitted uniforms
  55825. */
  55826. uniforms: string[];
  55827. /**
  55828. * Gets the list of emitted constants
  55829. */
  55830. constants: string[];
  55831. /**
  55832. * Gets the list of emitted uniform buffers
  55833. */
  55834. uniformBuffers: string[];
  55835. /**
  55836. * Gets the list of emitted samplers
  55837. */
  55838. samplers: string[];
  55839. /**
  55840. * Gets the list of emitted functions
  55841. */
  55842. functions: {
  55843. [key: string]: string;
  55844. };
  55845. /**
  55846. * Gets the list of emitted extensions
  55847. */
  55848. extensions: {
  55849. [key: string]: string;
  55850. };
  55851. /**
  55852. * Gets the target of the compilation state
  55853. */
  55854. target: NodeMaterialBlockTargets;
  55855. /**
  55856. * Gets the list of emitted counters
  55857. */
  55858. counters: {
  55859. [key: string]: number;
  55860. };
  55861. /**
  55862. * Shared data between multiple NodeMaterialBuildState instances
  55863. */
  55864. sharedData: NodeMaterialBuildStateSharedData;
  55865. /** @hidden */
  55866. _vertexState: NodeMaterialBuildState;
  55867. /** @hidden */
  55868. _attributeDeclaration: string;
  55869. /** @hidden */
  55870. _uniformDeclaration: string;
  55871. /** @hidden */
  55872. _constantDeclaration: string;
  55873. /** @hidden */
  55874. _samplerDeclaration: string;
  55875. /** @hidden */
  55876. _varyingTransfer: string;
  55877. private _repeatableContentAnchorIndex;
  55878. /** @hidden */
  55879. _builtCompilationString: string;
  55880. /**
  55881. * Gets the emitted compilation strings
  55882. */
  55883. compilationString: string;
  55884. /**
  55885. * Finalize the compilation strings
  55886. * @param state defines the current compilation state
  55887. */
  55888. finalize(state: NodeMaterialBuildState): void;
  55889. /** @hidden */
  55890. readonly _repeatableContentAnchor: string;
  55891. /** @hidden */
  55892. _getFreeVariableName(prefix: string): string;
  55893. /** @hidden */
  55894. _getFreeDefineName(prefix: string): string;
  55895. /** @hidden */
  55896. _excludeVariableName(name: string): void;
  55897. /** @hidden */
  55898. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55899. /** @hidden */
  55900. _emitExtension(name: string, extension: string): void;
  55901. /** @hidden */
  55902. _emitFunction(name: string, code: string, comments: string): void;
  55903. /** @hidden */
  55904. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55905. replaceStrings?: {
  55906. search: RegExp;
  55907. replace: string;
  55908. }[];
  55909. repeatKey?: string;
  55910. }): string;
  55911. /** @hidden */
  55912. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55913. repeatKey?: string;
  55914. removeAttributes?: boolean;
  55915. removeUniforms?: boolean;
  55916. removeVaryings?: boolean;
  55917. removeIfDef?: boolean;
  55918. replaceStrings?: {
  55919. search: RegExp;
  55920. replace: string;
  55921. }[];
  55922. }, storeKey?: string): void;
  55923. /** @hidden */
  55924. _registerTempVariable(name: string): boolean;
  55925. /** @hidden */
  55926. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55927. /** @hidden */
  55928. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55929. /** @hidden */
  55930. _emitFloat(value: number): string;
  55931. }
  55932. }
  55933. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55934. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55935. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55936. import { Nullable } from "babylonjs/types";
  55937. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55938. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55939. import { Effect } from "babylonjs/Materials/effect";
  55940. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55941. import { Mesh } from "babylonjs/Meshes/mesh";
  55942. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55943. import { Scene } from "babylonjs/scene";
  55944. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55945. /**
  55946. * Defines a block that can be used inside a node based material
  55947. */
  55948. export class NodeMaterialBlock {
  55949. private _buildId;
  55950. private _buildTarget;
  55951. private _target;
  55952. private _isFinalMerger;
  55953. private _isInput;
  55954. /** @hidden */
  55955. _codeVariableName: string;
  55956. /** @hidden */
  55957. _inputs: NodeMaterialConnectionPoint[];
  55958. /** @hidden */
  55959. _outputs: NodeMaterialConnectionPoint[];
  55960. /** @hidden */
  55961. _preparationId: number;
  55962. /**
  55963. * Gets or sets the name of the block
  55964. */
  55965. name: string;
  55966. /**
  55967. * Gets or sets the unique id of the node
  55968. */
  55969. uniqueId: number;
  55970. /**
  55971. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55972. */
  55973. readonly isFinalMerger: boolean;
  55974. /**
  55975. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55976. */
  55977. readonly isInput: boolean;
  55978. /**
  55979. * Gets or sets the build Id
  55980. */
  55981. buildId: number;
  55982. /**
  55983. * Gets or sets the target of the block
  55984. */
  55985. target: NodeMaterialBlockTargets;
  55986. /**
  55987. * Gets the list of input points
  55988. */
  55989. readonly inputs: NodeMaterialConnectionPoint[];
  55990. /** Gets the list of output points */
  55991. readonly outputs: NodeMaterialConnectionPoint[];
  55992. /**
  55993. * Find an input by its name
  55994. * @param name defines the name of the input to look for
  55995. * @returns the input or null if not found
  55996. */
  55997. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55998. /**
  55999. * Find an output by its name
  56000. * @param name defines the name of the outputto look for
  56001. * @returns the output or null if not found
  56002. */
  56003. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56004. /**
  56005. * Creates a new NodeMaterialBlock
  56006. * @param name defines the block name
  56007. * @param target defines the target of that block (Vertex by default)
  56008. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56009. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56010. */
  56011. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56012. /**
  56013. * Initialize the block and prepare the context for build
  56014. * @param state defines the state that will be used for the build
  56015. */
  56016. initialize(state: NodeMaterialBuildState): void;
  56017. /**
  56018. * Bind data to effect. Will only be called for blocks with isBindable === true
  56019. * @param effect defines the effect to bind data to
  56020. * @param nodeMaterial defines the hosting NodeMaterial
  56021. * @param mesh defines the mesh that will be rendered
  56022. */
  56023. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56024. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56025. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56026. protected _writeFloat(value: number): string;
  56027. /**
  56028. * Gets the current class name e.g. "NodeMaterialBlock"
  56029. * @returns the class name
  56030. */
  56031. getClassName(): string;
  56032. /**
  56033. * Register a new input. Must be called inside a block constructor
  56034. * @param name defines the connection point name
  56035. * @param type defines the connection point type
  56036. * @param isOptional defines a boolean indicating that this input can be omitted
  56037. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56038. * @returns the current block
  56039. */
  56040. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56041. /**
  56042. * Register a new output. Must be called inside a block constructor
  56043. * @param name defines the connection point name
  56044. * @param type defines the connection point type
  56045. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56046. * @returns the current block
  56047. */
  56048. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56049. /**
  56050. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56051. * @param forOutput defines an optional connection point to check compatibility with
  56052. * @returns the first available input or null
  56053. */
  56054. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56055. /**
  56056. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56057. * @param forBlock defines an optional block to check compatibility with
  56058. * @returns the first available input or null
  56059. */
  56060. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56061. /**
  56062. * Gets the sibling of the given output
  56063. * @param current defines the current output
  56064. * @returns the next output in the list or null
  56065. */
  56066. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56067. /**
  56068. * Connect current block with another block
  56069. * @param other defines the block to connect with
  56070. * @param options define the various options to help pick the right connections
  56071. * @returns the current block
  56072. */
  56073. connectTo(other: NodeMaterialBlock, options?: {
  56074. input?: string;
  56075. output?: string;
  56076. outputSwizzle?: string;
  56077. }): this | undefined;
  56078. protected _buildBlock(state: NodeMaterialBuildState): void;
  56079. /**
  56080. * Add uniforms, samplers and uniform buffers at compilation time
  56081. * @param state defines the state to update
  56082. * @param nodeMaterial defines the node material requesting the update
  56083. * @param defines defines the material defines to update
  56084. */
  56085. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56086. /**
  56087. * Add potential fallbacks if shader compilation fails
  56088. * @param mesh defines the mesh to be rendered
  56089. * @param fallbacks defines the current prioritized list of fallbacks
  56090. */
  56091. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56092. /**
  56093. * Initialize defines for shader compilation
  56094. * @param mesh defines the mesh to be rendered
  56095. * @param nodeMaterial defines the node material requesting the update
  56096. * @param defines defines the material defines to update
  56097. * @param useInstances specifies that instances should be used
  56098. */
  56099. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56100. /**
  56101. * Update defines for shader compilation
  56102. * @param mesh defines the mesh to be rendered
  56103. * @param nodeMaterial defines the node material requesting the update
  56104. * @param defines defines the material defines to update
  56105. * @param useInstances specifies that instances should be used
  56106. */
  56107. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56108. /**
  56109. * Lets the block try to connect some inputs automatically
  56110. * @param material defines the hosting NodeMaterial
  56111. */
  56112. autoConfigure(material: NodeMaterial): void;
  56113. /**
  56114. * Function called when a block is declared as repeatable content generator
  56115. * @param vertexShaderState defines the current compilation state for the vertex shader
  56116. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56117. * @param mesh defines the mesh to be rendered
  56118. * @param defines defines the material defines to update
  56119. */
  56120. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56121. /**
  56122. * Checks if the block is ready
  56123. * @param mesh defines the mesh to be rendered
  56124. * @param nodeMaterial defines the node material requesting the update
  56125. * @param defines defines the material defines to update
  56126. * @param useInstances specifies that instances should be used
  56127. * @returns true if the block is ready
  56128. */
  56129. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56130. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56131. private _processBuild;
  56132. /**
  56133. * Compile the current node and generate the shader code
  56134. * @param state defines the current compilation state (uniforms, samplers, current string)
  56135. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56136. * @returns true if already built
  56137. */
  56138. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56139. protected _inputRename(name: string): string;
  56140. protected _outputRename(name: string): string;
  56141. protected _dumpPropertiesCode(): string;
  56142. /** @hidden */
  56143. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56144. /**
  56145. * Clone the current block to a new identical block
  56146. * @param scene defines the hosting scene
  56147. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56148. * @returns a copy of the current block
  56149. */
  56150. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56151. /**
  56152. * Serializes this block in a JSON representation
  56153. * @returns the serialized block object
  56154. */
  56155. serialize(): any;
  56156. /** @hidden */
  56157. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56158. }
  56159. }
  56160. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56161. /**
  56162. * Enum defining the type of animations supported by InputBlock
  56163. */
  56164. export enum AnimatedInputBlockTypes {
  56165. /** No animation */
  56166. None = 0,
  56167. /** Time based animation. Will only work for floats */
  56168. Time = 1
  56169. }
  56170. }
  56171. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56172. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56173. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56174. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56175. import { Nullable } from "babylonjs/types";
  56176. import { Effect } from "babylonjs/Materials/effect";
  56177. import { Matrix } from "babylonjs/Maths/math.vector";
  56178. import { Scene } from "babylonjs/scene";
  56179. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56180. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56181. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56182. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56183. /**
  56184. * Block used to expose an input value
  56185. */
  56186. export class InputBlock extends NodeMaterialBlock {
  56187. private _mode;
  56188. private _associatedVariableName;
  56189. private _storedValue;
  56190. private _valueCallback;
  56191. private _type;
  56192. private _animationType;
  56193. /** Gets or set a value used to limit the range of float values */
  56194. min: number;
  56195. /** Gets or set a value used to limit the range of float values */
  56196. max: number;
  56197. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56198. matrixMode: number;
  56199. /** @hidden */
  56200. _systemValue: Nullable<NodeMaterialSystemValues>;
  56201. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56202. visibleInInspector: boolean;
  56203. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56204. isConstant: boolean;
  56205. /**
  56206. * Gets or sets the connection point type (default is float)
  56207. */
  56208. readonly type: NodeMaterialBlockConnectionPointTypes;
  56209. /**
  56210. * Creates a new InputBlock
  56211. * @param name defines the block name
  56212. * @param target defines the target of that block (Vertex by default)
  56213. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56214. */
  56215. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56216. /**
  56217. * Gets the output component
  56218. */
  56219. readonly output: NodeMaterialConnectionPoint;
  56220. /**
  56221. * Set the source of this connection point to a vertex attribute
  56222. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56223. * @returns the current connection point
  56224. */
  56225. setAsAttribute(attributeName?: string): InputBlock;
  56226. /**
  56227. * Set the source of this connection point to a system value
  56228. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56229. * @returns the current connection point
  56230. */
  56231. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56232. /**
  56233. * Gets or sets the value of that point.
  56234. * Please note that this value will be ignored if valueCallback is defined
  56235. */
  56236. value: any;
  56237. /**
  56238. * Gets or sets a callback used to get the value of that point.
  56239. * Please note that setting this value will force the connection point to ignore the value property
  56240. */
  56241. valueCallback: () => any;
  56242. /**
  56243. * Gets or sets the associated variable name in the shader
  56244. */
  56245. associatedVariableName: string;
  56246. /** Gets or sets the type of animation applied to the input */
  56247. animationType: AnimatedInputBlockTypes;
  56248. /**
  56249. * Gets a boolean indicating that this connection point not defined yet
  56250. */
  56251. readonly isUndefined: boolean;
  56252. /**
  56253. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56254. * In this case the connection point name must be the name of the uniform to use.
  56255. * Can only be set on inputs
  56256. */
  56257. isUniform: boolean;
  56258. /**
  56259. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56260. * In this case the connection point name must be the name of the attribute to use
  56261. * Can only be set on inputs
  56262. */
  56263. isAttribute: boolean;
  56264. /**
  56265. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56266. * Can only be set on exit points
  56267. */
  56268. isVarying: boolean;
  56269. /**
  56270. * Gets a boolean indicating that the current connection point is a system value
  56271. */
  56272. readonly isSystemValue: boolean;
  56273. /**
  56274. * Gets or sets the current well known value or null if not defined as a system value
  56275. */
  56276. systemValue: Nullable<NodeMaterialSystemValues>;
  56277. /**
  56278. * Gets the current class name
  56279. * @returns the class name
  56280. */
  56281. getClassName(): string;
  56282. /**
  56283. * Animate the input if animationType !== None
  56284. * @param scene defines the rendering scene
  56285. */
  56286. animate(scene: Scene): void;
  56287. private _emitDefine;
  56288. initialize(state: NodeMaterialBuildState): void;
  56289. /**
  56290. * Set the input block to its default value (based on its type)
  56291. */
  56292. setDefaultValue(): void;
  56293. private _emitConstant;
  56294. private _emit;
  56295. /** @hidden */
  56296. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56297. /** @hidden */
  56298. _transmit(effect: Effect, scene: Scene): void;
  56299. protected _buildBlock(state: NodeMaterialBuildState): void;
  56300. protected _dumpPropertiesCode(): string;
  56301. serialize(): any;
  56302. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56303. }
  56304. }
  56305. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56306. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56307. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56308. import { Nullable } from "babylonjs/types";
  56309. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56310. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56311. /**
  56312. * Defines a connection point for a block
  56313. */
  56314. export class NodeMaterialConnectionPoint {
  56315. /** @hidden */
  56316. _ownerBlock: NodeMaterialBlock;
  56317. /** @hidden */
  56318. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56319. private _endpoints;
  56320. private _associatedVariableName;
  56321. /** @hidden */
  56322. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56323. /** @hidden */
  56324. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56325. private _type;
  56326. /** @hidden */
  56327. _enforceAssociatedVariableName: boolean;
  56328. /**
  56329. * Gets or sets the additional types supported by this connection point
  56330. */
  56331. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56332. /**
  56333. * Gets or sets the additional types excluded by this connection point
  56334. */
  56335. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56336. /**
  56337. * Gets or sets the associated variable name in the shader
  56338. */
  56339. associatedVariableName: string;
  56340. /**
  56341. * Gets or sets the connection point type (default is float)
  56342. */
  56343. type: NodeMaterialBlockConnectionPointTypes;
  56344. /**
  56345. * Gets or sets the connection point name
  56346. */
  56347. name: string;
  56348. /**
  56349. * Gets or sets a boolean indicating that this connection point can be omitted
  56350. */
  56351. isOptional: boolean;
  56352. /**
  56353. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56354. */
  56355. define: string;
  56356. /** Gets or sets the target of that connection point */
  56357. target: NodeMaterialBlockTargets;
  56358. /**
  56359. * Gets a boolean indicating that the current point is connected
  56360. */
  56361. readonly isConnected: boolean;
  56362. /**
  56363. * Gets a boolean indicating that the current point is connected to an input block
  56364. */
  56365. readonly isConnectedToInputBlock: boolean;
  56366. /**
  56367. * Gets a the connected input block (if any)
  56368. */
  56369. readonly connectInputBlock: Nullable<InputBlock>;
  56370. /** Get the other side of the connection (if any) */
  56371. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56372. /** Get the block that owns this connection point */
  56373. readonly ownerBlock: NodeMaterialBlock;
  56374. /** Get the block connected on the other side of this connection (if any) */
  56375. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56376. /** Get the block connected on the endpoints of this connection (if any) */
  56377. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56378. /** Gets the list of connected endpoints */
  56379. readonly endpoints: NodeMaterialConnectionPoint[];
  56380. /** Gets a boolean indicating if that output point is connected to at least one input */
  56381. readonly hasEndpoints: boolean;
  56382. /**
  56383. * Creates a new connection point
  56384. * @param name defines the connection point name
  56385. * @param ownerBlock defines the block hosting this connection point
  56386. */
  56387. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56388. /**
  56389. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56390. * @returns the class name
  56391. */
  56392. getClassName(): string;
  56393. /**
  56394. * Gets an boolean indicating if the current point can be connected to another point
  56395. * @param connectionPoint defines the other connection point
  56396. * @returns true if the connection is possible
  56397. */
  56398. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56399. /**
  56400. * Connect this point to another connection point
  56401. * @param connectionPoint defines the other connection point
  56402. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56403. * @returns the current connection point
  56404. */
  56405. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56406. /**
  56407. * Disconnect this point from one of his endpoint
  56408. * @param endpoint defines the other connection point
  56409. * @returns the current connection point
  56410. */
  56411. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56412. /**
  56413. * Serializes this point in a JSON representation
  56414. * @returns the serialized point object
  56415. */
  56416. serialize(): any;
  56417. }
  56418. }
  56419. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56420. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56421. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56423. import { Mesh } from "babylonjs/Meshes/mesh";
  56424. import { Effect } from "babylonjs/Materials/effect";
  56425. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56426. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56427. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56428. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56429. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56430. /**
  56431. * Block used to add support for vertex skinning (bones)
  56432. */
  56433. export class BonesBlock extends NodeMaterialBlock {
  56434. /**
  56435. * Creates a new BonesBlock
  56436. * @param name defines the block name
  56437. */
  56438. constructor(name: string);
  56439. /**
  56440. * Initialize the block and prepare the context for build
  56441. * @param state defines the state that will be used for the build
  56442. */
  56443. initialize(state: NodeMaterialBuildState): void;
  56444. /**
  56445. * Gets the current class name
  56446. * @returns the class name
  56447. */
  56448. getClassName(): string;
  56449. /**
  56450. * Gets the matrix indices input component
  56451. */
  56452. readonly matricesIndices: NodeMaterialConnectionPoint;
  56453. /**
  56454. * Gets the matrix weights input component
  56455. */
  56456. readonly matricesWeights: NodeMaterialConnectionPoint;
  56457. /**
  56458. * Gets the extra matrix indices input component
  56459. */
  56460. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56461. /**
  56462. * Gets the extra matrix weights input component
  56463. */
  56464. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56465. /**
  56466. * Gets the world input component
  56467. */
  56468. readonly world: NodeMaterialConnectionPoint;
  56469. /**
  56470. * Gets the output component
  56471. */
  56472. readonly output: NodeMaterialConnectionPoint;
  56473. autoConfigure(material: NodeMaterial): void;
  56474. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56475. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56476. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56477. protected _buildBlock(state: NodeMaterialBuildState): this;
  56478. }
  56479. }
  56480. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56481. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56482. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56485. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56486. /**
  56487. * Block used to add support for instances
  56488. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56489. */
  56490. export class InstancesBlock extends NodeMaterialBlock {
  56491. /**
  56492. * Creates a new InstancesBlock
  56493. * @param name defines the block name
  56494. */
  56495. constructor(name: string);
  56496. /**
  56497. * Gets the current class name
  56498. * @returns the class name
  56499. */
  56500. getClassName(): string;
  56501. /**
  56502. * Gets the first world row input component
  56503. */
  56504. readonly world0: NodeMaterialConnectionPoint;
  56505. /**
  56506. * Gets the second world row input component
  56507. */
  56508. readonly world1: NodeMaterialConnectionPoint;
  56509. /**
  56510. * Gets the third world row input component
  56511. */
  56512. readonly world2: NodeMaterialConnectionPoint;
  56513. /**
  56514. * Gets the forth world row input component
  56515. */
  56516. readonly world3: NodeMaterialConnectionPoint;
  56517. /**
  56518. * Gets the world input component
  56519. */
  56520. readonly world: NodeMaterialConnectionPoint;
  56521. /**
  56522. * Gets the output component
  56523. */
  56524. readonly output: NodeMaterialConnectionPoint;
  56525. autoConfigure(material: NodeMaterial): void;
  56526. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56527. protected _buildBlock(state: NodeMaterialBuildState): this;
  56528. }
  56529. }
  56530. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56531. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56532. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56533. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56535. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56536. import { Effect } from "babylonjs/Materials/effect";
  56537. import { Mesh } from "babylonjs/Meshes/mesh";
  56538. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56539. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56540. /**
  56541. * Block used to add morph targets support to vertex shader
  56542. */
  56543. export class MorphTargetsBlock extends NodeMaterialBlock {
  56544. private _repeatableContentAnchor;
  56545. private _repeatebleContentGenerated;
  56546. /**
  56547. * Create a new MorphTargetsBlock
  56548. * @param name defines the block name
  56549. */
  56550. constructor(name: string);
  56551. /**
  56552. * Gets the current class name
  56553. * @returns the class name
  56554. */
  56555. getClassName(): string;
  56556. /**
  56557. * Gets the position input component
  56558. */
  56559. readonly position: NodeMaterialConnectionPoint;
  56560. /**
  56561. * Gets the normal input component
  56562. */
  56563. readonly normal: NodeMaterialConnectionPoint;
  56564. /**
  56565. * Gets the tangent input component
  56566. */
  56567. readonly tangent: NodeMaterialConnectionPoint;
  56568. /**
  56569. * Gets the tangent input component
  56570. */
  56571. readonly uv: NodeMaterialConnectionPoint;
  56572. /**
  56573. * Gets the position output component
  56574. */
  56575. readonly positionOutput: NodeMaterialConnectionPoint;
  56576. /**
  56577. * Gets the normal output component
  56578. */
  56579. readonly normalOutput: NodeMaterialConnectionPoint;
  56580. /**
  56581. * Gets the tangent output component
  56582. */
  56583. readonly tangentOutput: NodeMaterialConnectionPoint;
  56584. /**
  56585. * Gets the tangent output component
  56586. */
  56587. readonly uvOutput: NodeMaterialConnectionPoint;
  56588. initialize(state: NodeMaterialBuildState): void;
  56589. autoConfigure(material: NodeMaterial): void;
  56590. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56591. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56592. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56593. protected _buildBlock(state: NodeMaterialBuildState): this;
  56594. }
  56595. }
  56596. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56597. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56598. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56599. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56600. import { Nullable } from "babylonjs/types";
  56601. import { Scene } from "babylonjs/scene";
  56602. import { Effect } from "babylonjs/Materials/effect";
  56603. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56604. import { Mesh } from "babylonjs/Meshes/mesh";
  56605. import { Light } from "babylonjs/Lights/light";
  56606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56607. /**
  56608. * Block used to get data information from a light
  56609. */
  56610. export class LightInformationBlock extends NodeMaterialBlock {
  56611. private _lightDataUniformName;
  56612. private _lightColorUniformName;
  56613. private _lightTypeDefineName;
  56614. /**
  56615. * Gets or sets the light associated with this block
  56616. */
  56617. light: Nullable<Light>;
  56618. /**
  56619. * Creates a new LightInformationBlock
  56620. * @param name defines the block name
  56621. */
  56622. constructor(name: string);
  56623. /**
  56624. * Gets the current class name
  56625. * @returns the class name
  56626. */
  56627. getClassName(): string;
  56628. /**
  56629. * Gets the world position input component
  56630. */
  56631. readonly worldPosition: NodeMaterialConnectionPoint;
  56632. /**
  56633. * Gets the direction output component
  56634. */
  56635. readonly direction: NodeMaterialConnectionPoint;
  56636. /**
  56637. * Gets the direction output component
  56638. */
  56639. readonly color: NodeMaterialConnectionPoint;
  56640. /**
  56641. * Gets the direction output component
  56642. */
  56643. readonly intensity: NodeMaterialConnectionPoint;
  56644. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56645. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56646. protected _buildBlock(state: NodeMaterialBuildState): this;
  56647. serialize(): any;
  56648. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56649. }
  56650. }
  56651. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56652. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56653. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56654. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56655. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56656. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56657. }
  56658. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56659. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56660. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56661. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56663. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56664. import { Effect } from "babylonjs/Materials/effect";
  56665. import { Mesh } from "babylonjs/Meshes/mesh";
  56666. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56667. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56668. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56669. /**
  56670. * Block used to add image processing support to fragment shader
  56671. */
  56672. export class ImageProcessingBlock extends NodeMaterialBlock {
  56673. /**
  56674. * Create a new ImageProcessingBlock
  56675. * @param name defines the block name
  56676. */
  56677. constructor(name: string);
  56678. /**
  56679. * Gets the current class name
  56680. * @returns the class name
  56681. */
  56682. getClassName(): string;
  56683. /**
  56684. * Gets the color input component
  56685. */
  56686. readonly color: NodeMaterialConnectionPoint;
  56687. /**
  56688. * Gets the output component
  56689. */
  56690. readonly output: NodeMaterialConnectionPoint;
  56691. /**
  56692. * Initialize the block and prepare the context for build
  56693. * @param state defines the state that will be used for the build
  56694. */
  56695. initialize(state: NodeMaterialBuildState): void;
  56696. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56697. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56698. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56699. protected _buildBlock(state: NodeMaterialBuildState): this;
  56700. }
  56701. }
  56702. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56703. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56704. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56705. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56706. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56708. import { Effect } from "babylonjs/Materials/effect";
  56709. import { Mesh } from "babylonjs/Meshes/mesh";
  56710. import { Scene } from "babylonjs/scene";
  56711. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56712. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56713. /**
  56714. * Block used to pertub normals based on a normal map
  56715. */
  56716. export class PerturbNormalBlock extends NodeMaterialBlock {
  56717. private _tangentSpaceParameterName;
  56718. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56719. invertX: boolean;
  56720. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56721. invertY: boolean;
  56722. /**
  56723. * Create a new PerturbNormalBlock
  56724. * @param name defines the block name
  56725. */
  56726. constructor(name: string);
  56727. /**
  56728. * Gets the current class name
  56729. * @returns the class name
  56730. */
  56731. getClassName(): string;
  56732. /**
  56733. * Gets the world position input component
  56734. */
  56735. readonly worldPosition: NodeMaterialConnectionPoint;
  56736. /**
  56737. * Gets the world normal input component
  56738. */
  56739. readonly worldNormal: NodeMaterialConnectionPoint;
  56740. /**
  56741. * Gets the uv input component
  56742. */
  56743. readonly uv: NodeMaterialConnectionPoint;
  56744. /**
  56745. * Gets the normal map color input component
  56746. */
  56747. readonly normalMapColor: NodeMaterialConnectionPoint;
  56748. /**
  56749. * Gets the strength input component
  56750. */
  56751. readonly strength: NodeMaterialConnectionPoint;
  56752. /**
  56753. * Gets the output component
  56754. */
  56755. readonly output: NodeMaterialConnectionPoint;
  56756. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56757. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56758. autoConfigure(material: NodeMaterial): void;
  56759. protected _buildBlock(state: NodeMaterialBuildState): this;
  56760. protected _dumpPropertiesCode(): string;
  56761. serialize(): any;
  56762. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56763. }
  56764. }
  56765. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56766. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56767. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56768. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56769. /**
  56770. * Block used to discard a pixel if a value is smaller than a cutoff
  56771. */
  56772. export class DiscardBlock extends NodeMaterialBlock {
  56773. /**
  56774. * Create a new DiscardBlock
  56775. * @param name defines the block name
  56776. */
  56777. constructor(name: string);
  56778. /**
  56779. * Gets the current class name
  56780. * @returns the class name
  56781. */
  56782. getClassName(): string;
  56783. /**
  56784. * Gets the color input component
  56785. */
  56786. readonly value: NodeMaterialConnectionPoint;
  56787. /**
  56788. * Gets the cutoff input component
  56789. */
  56790. readonly cutoff: NodeMaterialConnectionPoint;
  56791. protected _buildBlock(state: NodeMaterialBuildState): this;
  56792. }
  56793. }
  56794. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56795. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56796. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56797. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56798. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56799. }
  56800. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56801. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56802. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56803. import { Mesh } from "babylonjs/Meshes/mesh";
  56804. import { Effect } from "babylonjs/Materials/effect";
  56805. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56807. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56808. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56809. /**
  56810. * Block used to add support for scene fog
  56811. */
  56812. export class FogBlock extends NodeMaterialBlock {
  56813. private _fogDistanceName;
  56814. private _fogParameters;
  56815. /**
  56816. * Create a new FogBlock
  56817. * @param name defines the block name
  56818. */
  56819. constructor(name: string);
  56820. /**
  56821. * Gets the current class name
  56822. * @returns the class name
  56823. */
  56824. getClassName(): string;
  56825. /**
  56826. * Gets the world position input component
  56827. */
  56828. readonly worldPosition: NodeMaterialConnectionPoint;
  56829. /**
  56830. * Gets the view input component
  56831. */
  56832. readonly view: NodeMaterialConnectionPoint;
  56833. /**
  56834. * Gets the color input component
  56835. */
  56836. readonly input: NodeMaterialConnectionPoint;
  56837. /**
  56838. * Gets the fog color input component
  56839. */
  56840. readonly fogColor: NodeMaterialConnectionPoint;
  56841. /**
  56842. * Gets the output component
  56843. */
  56844. readonly output: NodeMaterialConnectionPoint;
  56845. autoConfigure(material: NodeMaterial): void;
  56846. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56847. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56848. protected _buildBlock(state: NodeMaterialBuildState): this;
  56849. }
  56850. }
  56851. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56852. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56853. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56854. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56856. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56857. import { Effect } from "babylonjs/Materials/effect";
  56858. import { Mesh } from "babylonjs/Meshes/mesh";
  56859. import { Light } from "babylonjs/Lights/light";
  56860. import { Nullable } from "babylonjs/types";
  56861. import { Scene } from "babylonjs/scene";
  56862. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56863. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56864. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56865. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56866. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56867. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56868. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56869. /**
  56870. * Block used to add light in the fragment shader
  56871. */
  56872. export class LightBlock extends NodeMaterialBlock {
  56873. private _lightId;
  56874. /**
  56875. * Gets or sets the light associated with this block
  56876. */
  56877. light: Nullable<Light>;
  56878. /**
  56879. * Create a new LightBlock
  56880. * @param name defines the block name
  56881. */
  56882. constructor(name: string);
  56883. /**
  56884. * Gets the current class name
  56885. * @returns the class name
  56886. */
  56887. getClassName(): string;
  56888. /**
  56889. * Gets the world position input component
  56890. */
  56891. readonly worldPosition: NodeMaterialConnectionPoint;
  56892. /**
  56893. * Gets the world normal input component
  56894. */
  56895. readonly worldNormal: NodeMaterialConnectionPoint;
  56896. /**
  56897. * Gets the camera (or eye) position component
  56898. */
  56899. readonly cameraPosition: NodeMaterialConnectionPoint;
  56900. /**
  56901. * Gets the glossiness component
  56902. */
  56903. readonly glossiness: NodeMaterialConnectionPoint;
  56904. /**
  56905. * Gets the glossinness power component
  56906. */
  56907. readonly glossPower: NodeMaterialConnectionPoint;
  56908. /**
  56909. * Gets the diffuse color component
  56910. */
  56911. readonly diffuseColor: NodeMaterialConnectionPoint;
  56912. /**
  56913. * Gets the specular color component
  56914. */
  56915. readonly specularColor: NodeMaterialConnectionPoint;
  56916. /**
  56917. * Gets the diffuse output component
  56918. */
  56919. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56920. /**
  56921. * Gets the specular output component
  56922. */
  56923. readonly specularOutput: NodeMaterialConnectionPoint;
  56924. autoConfigure(material: NodeMaterial): void;
  56925. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56926. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56927. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56928. private _injectVertexCode;
  56929. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56930. serialize(): any;
  56931. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56932. }
  56933. }
  56934. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56935. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56936. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56937. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56938. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56939. }
  56940. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56941. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56942. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56943. }
  56944. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56945. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56946. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56947. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56948. /**
  56949. * Block used to multiply 2 values
  56950. */
  56951. export class MultiplyBlock extends NodeMaterialBlock {
  56952. /**
  56953. * Creates a new MultiplyBlock
  56954. * @param name defines the block name
  56955. */
  56956. constructor(name: string);
  56957. /**
  56958. * Gets the current class name
  56959. * @returns the class name
  56960. */
  56961. getClassName(): string;
  56962. /**
  56963. * Gets the left operand input component
  56964. */
  56965. readonly left: NodeMaterialConnectionPoint;
  56966. /**
  56967. * Gets the right operand input component
  56968. */
  56969. readonly right: NodeMaterialConnectionPoint;
  56970. /**
  56971. * Gets the output component
  56972. */
  56973. readonly output: NodeMaterialConnectionPoint;
  56974. protected _buildBlock(state: NodeMaterialBuildState): this;
  56975. }
  56976. }
  56977. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56978. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56979. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56980. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56981. /**
  56982. * Block used to add 2 vectors
  56983. */
  56984. export class AddBlock extends NodeMaterialBlock {
  56985. /**
  56986. * Creates a new AddBlock
  56987. * @param name defines the block name
  56988. */
  56989. constructor(name: string);
  56990. /**
  56991. * Gets the current class name
  56992. * @returns the class name
  56993. */
  56994. getClassName(): string;
  56995. /**
  56996. * Gets the left operand input component
  56997. */
  56998. readonly left: NodeMaterialConnectionPoint;
  56999. /**
  57000. * Gets the right operand input component
  57001. */
  57002. readonly right: NodeMaterialConnectionPoint;
  57003. /**
  57004. * Gets the output component
  57005. */
  57006. readonly output: NodeMaterialConnectionPoint;
  57007. protected _buildBlock(state: NodeMaterialBuildState): this;
  57008. }
  57009. }
  57010. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57011. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57012. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57013. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57014. /**
  57015. * Block used to scale a vector by a float
  57016. */
  57017. export class ScaleBlock extends NodeMaterialBlock {
  57018. /**
  57019. * Creates a new ScaleBlock
  57020. * @param name defines the block name
  57021. */
  57022. constructor(name: string);
  57023. /**
  57024. * Gets the current class name
  57025. * @returns the class name
  57026. */
  57027. getClassName(): string;
  57028. /**
  57029. * Gets the input component
  57030. */
  57031. readonly input: NodeMaterialConnectionPoint;
  57032. /**
  57033. * Gets the factor input component
  57034. */
  57035. readonly factor: NodeMaterialConnectionPoint;
  57036. /**
  57037. * Gets the output component
  57038. */
  57039. readonly output: NodeMaterialConnectionPoint;
  57040. protected _buildBlock(state: NodeMaterialBuildState): this;
  57041. }
  57042. }
  57043. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57044. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57045. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57046. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57047. import { Scene } from "babylonjs/scene";
  57048. /**
  57049. * Block used to clamp a float
  57050. */
  57051. export class ClampBlock extends NodeMaterialBlock {
  57052. /** Gets or sets the minimum range */
  57053. minimum: number;
  57054. /** Gets or sets the maximum range */
  57055. maximum: number;
  57056. /**
  57057. * Creates a new ClampBlock
  57058. * @param name defines the block name
  57059. */
  57060. constructor(name: string);
  57061. /**
  57062. * Gets the current class name
  57063. * @returns the class name
  57064. */
  57065. getClassName(): string;
  57066. /**
  57067. * Gets the value input component
  57068. */
  57069. readonly value: NodeMaterialConnectionPoint;
  57070. /**
  57071. * Gets the output component
  57072. */
  57073. readonly output: NodeMaterialConnectionPoint;
  57074. protected _buildBlock(state: NodeMaterialBuildState): this;
  57075. protected _dumpPropertiesCode(): string;
  57076. serialize(): any;
  57077. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57078. }
  57079. }
  57080. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57081. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57082. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57083. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57084. /**
  57085. * Block used to apply a cross product between 2 vectors
  57086. */
  57087. export class CrossBlock extends NodeMaterialBlock {
  57088. /**
  57089. * Creates a new CrossBlock
  57090. * @param name defines the block name
  57091. */
  57092. constructor(name: string);
  57093. /**
  57094. * Gets the current class name
  57095. * @returns the class name
  57096. */
  57097. getClassName(): string;
  57098. /**
  57099. * Gets the left operand input component
  57100. */
  57101. readonly left: NodeMaterialConnectionPoint;
  57102. /**
  57103. * Gets the right operand input component
  57104. */
  57105. readonly right: NodeMaterialConnectionPoint;
  57106. /**
  57107. * Gets the output component
  57108. */
  57109. readonly output: NodeMaterialConnectionPoint;
  57110. protected _buildBlock(state: NodeMaterialBuildState): this;
  57111. }
  57112. }
  57113. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57114. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57115. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57116. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57117. /**
  57118. * Block used to apply a dot product between 2 vectors
  57119. */
  57120. export class DotBlock extends NodeMaterialBlock {
  57121. /**
  57122. * Creates a new DotBlock
  57123. * @param name defines the block name
  57124. */
  57125. constructor(name: string);
  57126. /**
  57127. * Gets the current class name
  57128. * @returns the class name
  57129. */
  57130. getClassName(): string;
  57131. /**
  57132. * Gets the left operand input component
  57133. */
  57134. readonly left: NodeMaterialConnectionPoint;
  57135. /**
  57136. * Gets the right operand input component
  57137. */
  57138. readonly right: NodeMaterialConnectionPoint;
  57139. /**
  57140. * Gets the output component
  57141. */
  57142. readonly output: NodeMaterialConnectionPoint;
  57143. protected _buildBlock(state: NodeMaterialBuildState): this;
  57144. }
  57145. }
  57146. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57147. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57148. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57149. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57150. import { Vector2 } from "babylonjs/Maths/math.vector";
  57151. import { Scene } from "babylonjs/scene";
  57152. /**
  57153. * Block used to remap a float from a range to a new one
  57154. */
  57155. export class RemapBlock extends NodeMaterialBlock {
  57156. /**
  57157. * Gets or sets the source range
  57158. */
  57159. sourceRange: Vector2;
  57160. /**
  57161. * Gets or sets the target range
  57162. */
  57163. targetRange: Vector2;
  57164. /**
  57165. * Creates a new RemapBlock
  57166. * @param name defines the block name
  57167. */
  57168. constructor(name: string);
  57169. /**
  57170. * Gets the current class name
  57171. * @returns the class name
  57172. */
  57173. getClassName(): string;
  57174. /**
  57175. * Gets the input component
  57176. */
  57177. readonly input: NodeMaterialConnectionPoint;
  57178. /**
  57179. * Gets the source min input component
  57180. */
  57181. readonly sourceMin: NodeMaterialConnectionPoint;
  57182. /**
  57183. * Gets the source max input component
  57184. */
  57185. readonly sourceMax: NodeMaterialConnectionPoint;
  57186. /**
  57187. * Gets the target min input component
  57188. */
  57189. readonly targetMin: NodeMaterialConnectionPoint;
  57190. /**
  57191. * Gets the target max input component
  57192. */
  57193. readonly targetMax: NodeMaterialConnectionPoint;
  57194. /**
  57195. * Gets the output component
  57196. */
  57197. readonly output: NodeMaterialConnectionPoint;
  57198. protected _buildBlock(state: NodeMaterialBuildState): this;
  57199. protected _dumpPropertiesCode(): string;
  57200. serialize(): any;
  57201. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57202. }
  57203. }
  57204. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57205. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57206. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57207. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57208. /**
  57209. * Block used to normalize a vector
  57210. */
  57211. export class NormalizeBlock extends NodeMaterialBlock {
  57212. /**
  57213. * Creates a new NormalizeBlock
  57214. * @param name defines the block name
  57215. */
  57216. constructor(name: string);
  57217. /**
  57218. * Gets the current class name
  57219. * @returns the class name
  57220. */
  57221. getClassName(): string;
  57222. /**
  57223. * Gets the input component
  57224. */
  57225. readonly input: NodeMaterialConnectionPoint;
  57226. /**
  57227. * Gets the output component
  57228. */
  57229. readonly output: NodeMaterialConnectionPoint;
  57230. protected _buildBlock(state: NodeMaterialBuildState): this;
  57231. }
  57232. }
  57233. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57234. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57235. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57236. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57237. import { Scene } from "babylonjs/scene";
  57238. /**
  57239. * Operations supported by the Trigonometry block
  57240. */
  57241. export enum TrigonometryBlockOperations {
  57242. /** Cos */
  57243. Cos = 0,
  57244. /** Sin */
  57245. Sin = 1,
  57246. /** Abs */
  57247. Abs = 2,
  57248. /** Exp */
  57249. Exp = 3,
  57250. /** Exp2 */
  57251. Exp2 = 4,
  57252. /** Round */
  57253. Round = 5,
  57254. /** Floor */
  57255. Floor = 6,
  57256. /** Ceiling */
  57257. Ceiling = 7,
  57258. /** Square root */
  57259. Sqrt = 8,
  57260. /** Log */
  57261. Log = 9,
  57262. /** Tangent */
  57263. Tan = 10,
  57264. /** Arc tangent */
  57265. ArcTan = 11,
  57266. /** Arc cosinus */
  57267. ArcCos = 12,
  57268. /** Arc sinus */
  57269. ArcSin = 13,
  57270. /** Fraction */
  57271. Fract = 14,
  57272. /** Sign */
  57273. Sign = 15,
  57274. /** To radians (from degrees) */
  57275. Radians = 16,
  57276. /** To degrees (from radians) */
  57277. Degrees = 17
  57278. }
  57279. /**
  57280. * Block used to apply trigonometry operation to floats
  57281. */
  57282. export class TrigonometryBlock extends NodeMaterialBlock {
  57283. /**
  57284. * Gets or sets the operation applied by the block
  57285. */
  57286. operation: TrigonometryBlockOperations;
  57287. /**
  57288. * Creates a new TrigonometryBlock
  57289. * @param name defines the block name
  57290. */
  57291. constructor(name: string);
  57292. /**
  57293. * Gets the current class name
  57294. * @returns the class name
  57295. */
  57296. getClassName(): string;
  57297. /**
  57298. * Gets the input component
  57299. */
  57300. readonly input: NodeMaterialConnectionPoint;
  57301. /**
  57302. * Gets the output component
  57303. */
  57304. readonly output: NodeMaterialConnectionPoint;
  57305. protected _buildBlock(state: NodeMaterialBuildState): this;
  57306. serialize(): any;
  57307. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57308. }
  57309. }
  57310. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57311. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57312. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57313. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57314. /**
  57315. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57316. */
  57317. export class ColorMergerBlock extends NodeMaterialBlock {
  57318. /**
  57319. * Create a new ColorMergerBlock
  57320. * @param name defines the block name
  57321. */
  57322. constructor(name: string);
  57323. /**
  57324. * Gets the current class name
  57325. * @returns the class name
  57326. */
  57327. getClassName(): string;
  57328. /**
  57329. * Gets the r component (input)
  57330. */
  57331. readonly r: NodeMaterialConnectionPoint;
  57332. /**
  57333. * Gets the g component (input)
  57334. */
  57335. readonly g: NodeMaterialConnectionPoint;
  57336. /**
  57337. * Gets the b component (input)
  57338. */
  57339. readonly b: NodeMaterialConnectionPoint;
  57340. /**
  57341. * Gets the a component (input)
  57342. */
  57343. readonly a: NodeMaterialConnectionPoint;
  57344. /**
  57345. * Gets the rgba component (output)
  57346. */
  57347. readonly rgba: NodeMaterialConnectionPoint;
  57348. /**
  57349. * Gets the rgb component (output)
  57350. */
  57351. readonly rgb: NodeMaterialConnectionPoint;
  57352. protected _buildBlock(state: NodeMaterialBuildState): this;
  57353. }
  57354. }
  57355. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57356. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57357. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57358. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57359. /**
  57360. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57361. */
  57362. export class VectorMergerBlock extends NodeMaterialBlock {
  57363. /**
  57364. * Create a new VectorMergerBlock
  57365. * @param name defines the block name
  57366. */
  57367. constructor(name: string);
  57368. /**
  57369. * Gets the current class name
  57370. * @returns the class name
  57371. */
  57372. getClassName(): string;
  57373. /**
  57374. * Gets the x component (input)
  57375. */
  57376. readonly x: NodeMaterialConnectionPoint;
  57377. /**
  57378. * Gets the y component (input)
  57379. */
  57380. readonly y: NodeMaterialConnectionPoint;
  57381. /**
  57382. * Gets the z component (input)
  57383. */
  57384. readonly z: NodeMaterialConnectionPoint;
  57385. /**
  57386. * Gets the w component (input)
  57387. */
  57388. readonly w: NodeMaterialConnectionPoint;
  57389. /**
  57390. * Gets the xyzw component (output)
  57391. */
  57392. readonly xyzw: NodeMaterialConnectionPoint;
  57393. /**
  57394. * Gets the xyz component (output)
  57395. */
  57396. readonly xyz: NodeMaterialConnectionPoint;
  57397. /**
  57398. * Gets the xy component (output)
  57399. */
  57400. readonly xy: NodeMaterialConnectionPoint;
  57401. protected _buildBlock(state: NodeMaterialBuildState): this;
  57402. }
  57403. }
  57404. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57405. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57406. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57407. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57408. /**
  57409. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57410. */
  57411. export class ColorSplitterBlock extends NodeMaterialBlock {
  57412. /**
  57413. * Create a new ColorSplitterBlock
  57414. * @param name defines the block name
  57415. */
  57416. constructor(name: string);
  57417. /**
  57418. * Gets the current class name
  57419. * @returns the class name
  57420. */
  57421. getClassName(): string;
  57422. /**
  57423. * Gets the rgba component (input)
  57424. */
  57425. readonly rgba: NodeMaterialConnectionPoint;
  57426. /**
  57427. * Gets the rgb component (input)
  57428. */
  57429. readonly rgbIn: NodeMaterialConnectionPoint;
  57430. /**
  57431. * Gets the rgb component (output)
  57432. */
  57433. readonly rgbOut: NodeMaterialConnectionPoint;
  57434. /**
  57435. * Gets the r component (output)
  57436. */
  57437. readonly r: NodeMaterialConnectionPoint;
  57438. /**
  57439. * Gets the g component (output)
  57440. */
  57441. readonly g: NodeMaterialConnectionPoint;
  57442. /**
  57443. * Gets the b component (output)
  57444. */
  57445. readonly b: NodeMaterialConnectionPoint;
  57446. /**
  57447. * Gets the a component (output)
  57448. */
  57449. readonly a: NodeMaterialConnectionPoint;
  57450. protected _inputRename(name: string): string;
  57451. protected _outputRename(name: string): string;
  57452. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57453. }
  57454. }
  57455. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57456. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57457. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57458. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57459. /**
  57460. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57461. */
  57462. export class VectorSplitterBlock extends NodeMaterialBlock {
  57463. /**
  57464. * Create a new VectorSplitterBlock
  57465. * @param name defines the block name
  57466. */
  57467. constructor(name: string);
  57468. /**
  57469. * Gets the current class name
  57470. * @returns the class name
  57471. */
  57472. getClassName(): string;
  57473. /**
  57474. * Gets the xyzw component (input)
  57475. */
  57476. readonly xyzw: NodeMaterialConnectionPoint;
  57477. /**
  57478. * Gets the xyz component (input)
  57479. */
  57480. readonly xyzIn: NodeMaterialConnectionPoint;
  57481. /**
  57482. * Gets the xy component (input)
  57483. */
  57484. readonly xyIn: NodeMaterialConnectionPoint;
  57485. /**
  57486. * Gets the xyz component (output)
  57487. */
  57488. readonly xyzOut: NodeMaterialConnectionPoint;
  57489. /**
  57490. * Gets the xy component (output)
  57491. */
  57492. readonly xyOut: NodeMaterialConnectionPoint;
  57493. /**
  57494. * Gets the x component (output)
  57495. */
  57496. readonly x: NodeMaterialConnectionPoint;
  57497. /**
  57498. * Gets the y component (output)
  57499. */
  57500. readonly y: NodeMaterialConnectionPoint;
  57501. /**
  57502. * Gets the z component (output)
  57503. */
  57504. readonly z: NodeMaterialConnectionPoint;
  57505. /**
  57506. * Gets the w component (output)
  57507. */
  57508. readonly w: NodeMaterialConnectionPoint;
  57509. protected _inputRename(name: string): string;
  57510. protected _outputRename(name: string): string;
  57511. protected _buildBlock(state: NodeMaterialBuildState): this;
  57512. }
  57513. }
  57514. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57515. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57516. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57517. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57518. /**
  57519. * Block used to lerp between 2 values
  57520. */
  57521. export class LerpBlock extends NodeMaterialBlock {
  57522. /**
  57523. * Creates a new LerpBlock
  57524. * @param name defines the block name
  57525. */
  57526. constructor(name: string);
  57527. /**
  57528. * Gets the current class name
  57529. * @returns the class name
  57530. */
  57531. getClassName(): string;
  57532. /**
  57533. * Gets the left operand input component
  57534. */
  57535. readonly left: NodeMaterialConnectionPoint;
  57536. /**
  57537. * Gets the right operand input component
  57538. */
  57539. readonly right: NodeMaterialConnectionPoint;
  57540. /**
  57541. * Gets the gradient operand input component
  57542. */
  57543. readonly gradient: NodeMaterialConnectionPoint;
  57544. /**
  57545. * Gets the output component
  57546. */
  57547. readonly output: NodeMaterialConnectionPoint;
  57548. protected _buildBlock(state: NodeMaterialBuildState): this;
  57549. }
  57550. }
  57551. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57552. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57553. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57554. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57555. /**
  57556. * Block used to divide 2 vectors
  57557. */
  57558. export class DivideBlock extends NodeMaterialBlock {
  57559. /**
  57560. * Creates a new DivideBlock
  57561. * @param name defines the block name
  57562. */
  57563. constructor(name: string);
  57564. /**
  57565. * Gets the current class name
  57566. * @returns the class name
  57567. */
  57568. getClassName(): string;
  57569. /**
  57570. * Gets the left operand input component
  57571. */
  57572. readonly left: NodeMaterialConnectionPoint;
  57573. /**
  57574. * Gets the right operand input component
  57575. */
  57576. readonly right: NodeMaterialConnectionPoint;
  57577. /**
  57578. * Gets the output component
  57579. */
  57580. readonly output: NodeMaterialConnectionPoint;
  57581. protected _buildBlock(state: NodeMaterialBuildState): this;
  57582. }
  57583. }
  57584. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57585. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57586. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57587. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57588. /**
  57589. * Block used to subtract 2 vectors
  57590. */
  57591. export class SubtractBlock extends NodeMaterialBlock {
  57592. /**
  57593. * Creates a new SubtractBlock
  57594. * @param name defines the block name
  57595. */
  57596. constructor(name: string);
  57597. /**
  57598. * Gets the current class name
  57599. * @returns the class name
  57600. */
  57601. getClassName(): string;
  57602. /**
  57603. * Gets the left operand input component
  57604. */
  57605. readonly left: NodeMaterialConnectionPoint;
  57606. /**
  57607. * Gets the right operand input component
  57608. */
  57609. readonly right: NodeMaterialConnectionPoint;
  57610. /**
  57611. * Gets the output component
  57612. */
  57613. readonly output: NodeMaterialConnectionPoint;
  57614. protected _buildBlock(state: NodeMaterialBuildState): this;
  57615. }
  57616. }
  57617. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57618. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57619. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57620. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57621. /**
  57622. * Block used to step a value
  57623. */
  57624. export class StepBlock extends NodeMaterialBlock {
  57625. /**
  57626. * Creates a new StepBlock
  57627. * @param name defines the block name
  57628. */
  57629. constructor(name: string);
  57630. /**
  57631. * Gets the current class name
  57632. * @returns the class name
  57633. */
  57634. getClassName(): string;
  57635. /**
  57636. * Gets the value operand input component
  57637. */
  57638. readonly value: NodeMaterialConnectionPoint;
  57639. /**
  57640. * Gets the edge operand input component
  57641. */
  57642. readonly edge: NodeMaterialConnectionPoint;
  57643. /**
  57644. * Gets the output component
  57645. */
  57646. readonly output: NodeMaterialConnectionPoint;
  57647. protected _buildBlock(state: NodeMaterialBuildState): this;
  57648. }
  57649. }
  57650. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57651. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57652. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57653. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57654. /**
  57655. * Block used to get the opposite (1 - x) of a value
  57656. */
  57657. export class OneMinusBlock extends NodeMaterialBlock {
  57658. /**
  57659. * Creates a new OneMinusBlock
  57660. * @param name defines the block name
  57661. */
  57662. constructor(name: string);
  57663. /**
  57664. * Gets the current class name
  57665. * @returns the class name
  57666. */
  57667. getClassName(): string;
  57668. /**
  57669. * Gets the input component
  57670. */
  57671. readonly input: NodeMaterialConnectionPoint;
  57672. /**
  57673. * Gets the output component
  57674. */
  57675. readonly output: NodeMaterialConnectionPoint;
  57676. protected _buildBlock(state: NodeMaterialBuildState): this;
  57677. }
  57678. }
  57679. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57680. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57681. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57682. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57683. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57684. /**
  57685. * Block used to get the view direction
  57686. */
  57687. export class ViewDirectionBlock extends NodeMaterialBlock {
  57688. /**
  57689. * Creates a new ViewDirectionBlock
  57690. * @param name defines the block name
  57691. */
  57692. constructor(name: string);
  57693. /**
  57694. * Gets the current class name
  57695. * @returns the class name
  57696. */
  57697. getClassName(): string;
  57698. /**
  57699. * Gets the world position component
  57700. */
  57701. readonly worldPosition: NodeMaterialConnectionPoint;
  57702. /**
  57703. * Gets the camera position component
  57704. */
  57705. readonly cameraPosition: NodeMaterialConnectionPoint;
  57706. /**
  57707. * Gets the output component
  57708. */
  57709. readonly output: NodeMaterialConnectionPoint;
  57710. autoConfigure(material: NodeMaterial): void;
  57711. protected _buildBlock(state: NodeMaterialBuildState): this;
  57712. }
  57713. }
  57714. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57715. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57716. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57717. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57718. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57719. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57720. /**
  57721. * Block used to compute fresnel value
  57722. */
  57723. export class FresnelBlock extends NodeMaterialBlock {
  57724. /**
  57725. * Create a new FresnelBlock
  57726. * @param name defines the block name
  57727. */
  57728. constructor(name: string);
  57729. /**
  57730. * Gets the current class name
  57731. * @returns the class name
  57732. */
  57733. getClassName(): string;
  57734. /**
  57735. * Gets the world normal input component
  57736. */
  57737. readonly worldNormal: NodeMaterialConnectionPoint;
  57738. /**
  57739. * Gets the view direction input component
  57740. */
  57741. readonly viewDirection: NodeMaterialConnectionPoint;
  57742. /**
  57743. * Gets the bias input component
  57744. */
  57745. readonly bias: NodeMaterialConnectionPoint;
  57746. /**
  57747. * Gets the camera (or eye) position component
  57748. */
  57749. readonly power: NodeMaterialConnectionPoint;
  57750. /**
  57751. * Gets the fresnel output component
  57752. */
  57753. readonly fresnel: NodeMaterialConnectionPoint;
  57754. autoConfigure(material: NodeMaterial): void;
  57755. protected _buildBlock(state: NodeMaterialBuildState): this;
  57756. }
  57757. }
  57758. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57759. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57760. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57761. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57762. /**
  57763. * Block used to get the max of 2 values
  57764. */
  57765. export class MaxBlock extends NodeMaterialBlock {
  57766. /**
  57767. * Creates a new MaxBlock
  57768. * @param name defines the block name
  57769. */
  57770. constructor(name: string);
  57771. /**
  57772. * Gets the current class name
  57773. * @returns the class name
  57774. */
  57775. getClassName(): string;
  57776. /**
  57777. * Gets the left operand input component
  57778. */
  57779. readonly left: NodeMaterialConnectionPoint;
  57780. /**
  57781. * Gets the right operand input component
  57782. */
  57783. readonly right: NodeMaterialConnectionPoint;
  57784. /**
  57785. * Gets the output component
  57786. */
  57787. readonly output: NodeMaterialConnectionPoint;
  57788. protected _buildBlock(state: NodeMaterialBuildState): this;
  57789. }
  57790. }
  57791. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57792. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57793. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57794. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57795. /**
  57796. * Block used to get the min of 2 values
  57797. */
  57798. export class MinBlock extends NodeMaterialBlock {
  57799. /**
  57800. * Creates a new MinBlock
  57801. * @param name defines the block name
  57802. */
  57803. constructor(name: string);
  57804. /**
  57805. * Gets the current class name
  57806. * @returns the class name
  57807. */
  57808. getClassName(): string;
  57809. /**
  57810. * Gets the left operand input component
  57811. */
  57812. readonly left: NodeMaterialConnectionPoint;
  57813. /**
  57814. * Gets the right operand input component
  57815. */
  57816. readonly right: NodeMaterialConnectionPoint;
  57817. /**
  57818. * Gets the output component
  57819. */
  57820. readonly output: NodeMaterialConnectionPoint;
  57821. protected _buildBlock(state: NodeMaterialBuildState): this;
  57822. }
  57823. }
  57824. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57825. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57826. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57827. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57828. /**
  57829. * Block used to get the distance between 2 values
  57830. */
  57831. export class DistanceBlock extends NodeMaterialBlock {
  57832. /**
  57833. * Creates a new DistanceBlock
  57834. * @param name defines the block name
  57835. */
  57836. constructor(name: string);
  57837. /**
  57838. * Gets the current class name
  57839. * @returns the class name
  57840. */
  57841. getClassName(): string;
  57842. /**
  57843. * Gets the left operand input component
  57844. */
  57845. readonly left: NodeMaterialConnectionPoint;
  57846. /**
  57847. * Gets the right operand input component
  57848. */
  57849. readonly right: NodeMaterialConnectionPoint;
  57850. /**
  57851. * Gets the output component
  57852. */
  57853. readonly output: NodeMaterialConnectionPoint;
  57854. protected _buildBlock(state: NodeMaterialBuildState): this;
  57855. }
  57856. }
  57857. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57858. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57859. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57860. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57861. /**
  57862. * Block used to get the length of a vector
  57863. */
  57864. export class LengthBlock extends NodeMaterialBlock {
  57865. /**
  57866. * Creates a new LengthBlock
  57867. * @param name defines the block name
  57868. */
  57869. constructor(name: string);
  57870. /**
  57871. * Gets the current class name
  57872. * @returns the class name
  57873. */
  57874. getClassName(): string;
  57875. /**
  57876. * Gets the value input component
  57877. */
  57878. readonly value: NodeMaterialConnectionPoint;
  57879. /**
  57880. * Gets the output component
  57881. */
  57882. readonly output: NodeMaterialConnectionPoint;
  57883. protected _buildBlock(state: NodeMaterialBuildState): this;
  57884. }
  57885. }
  57886. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57887. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57888. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57889. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57890. /**
  57891. * Block used to get negative version of a value (i.e. x * -1)
  57892. */
  57893. export class NegateBlock extends NodeMaterialBlock {
  57894. /**
  57895. * Creates a new NegateBlock
  57896. * @param name defines the block name
  57897. */
  57898. constructor(name: string);
  57899. /**
  57900. * Gets the current class name
  57901. * @returns the class name
  57902. */
  57903. getClassName(): string;
  57904. /**
  57905. * Gets the value input component
  57906. */
  57907. readonly value: NodeMaterialConnectionPoint;
  57908. /**
  57909. * Gets the output component
  57910. */
  57911. readonly output: NodeMaterialConnectionPoint;
  57912. protected _buildBlock(state: NodeMaterialBuildState): this;
  57913. }
  57914. }
  57915. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57916. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57917. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57918. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57919. /**
  57920. * Block used to get the value of the first parameter raised to the power of the second
  57921. */
  57922. export class PowBlock extends NodeMaterialBlock {
  57923. /**
  57924. * Creates a new PowBlock
  57925. * @param name defines the block name
  57926. */
  57927. constructor(name: string);
  57928. /**
  57929. * Gets the current class name
  57930. * @returns the class name
  57931. */
  57932. getClassName(): string;
  57933. /**
  57934. * Gets the value operand input component
  57935. */
  57936. readonly value: NodeMaterialConnectionPoint;
  57937. /**
  57938. * Gets the power operand input component
  57939. */
  57940. readonly power: NodeMaterialConnectionPoint;
  57941. /**
  57942. * Gets the output component
  57943. */
  57944. readonly output: NodeMaterialConnectionPoint;
  57945. protected _buildBlock(state: NodeMaterialBuildState): this;
  57946. }
  57947. }
  57948. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  57949. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57950. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57951. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57952. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57953. /**
  57954. * Block used to get a random number
  57955. */
  57956. export class RandomNumberBlock extends NodeMaterialBlock {
  57957. /**
  57958. * Creates a new RandomNumberBlock
  57959. * @param name defines the block name
  57960. */
  57961. constructor(name: string);
  57962. /**
  57963. * Gets the current class name
  57964. * @returns the class name
  57965. */
  57966. getClassName(): string;
  57967. /**
  57968. * Gets the seed input component
  57969. */
  57970. readonly seed: NodeMaterialConnectionPoint;
  57971. /**
  57972. * Gets the output component
  57973. */
  57974. readonly output: NodeMaterialConnectionPoint;
  57975. protected _buildBlock(state: NodeMaterialBuildState): this;
  57976. }
  57977. }
  57978. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  57979. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57980. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57981. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57982. /**
  57983. * Block used to compute arc tangent of 2 values
  57984. */
  57985. export class ArcTan2Block extends NodeMaterialBlock {
  57986. /**
  57987. * Creates a new ArcTan2Block
  57988. * @param name defines the block name
  57989. */
  57990. constructor(name: string);
  57991. /**
  57992. * Gets the current class name
  57993. * @returns the class name
  57994. */
  57995. getClassName(): string;
  57996. /**
  57997. * Gets the x operand input component
  57998. */
  57999. readonly x: NodeMaterialConnectionPoint;
  58000. /**
  58001. * Gets the y operand input component
  58002. */
  58003. readonly y: NodeMaterialConnectionPoint;
  58004. /**
  58005. * Gets the output component
  58006. */
  58007. readonly output: NodeMaterialConnectionPoint;
  58008. protected _buildBlock(state: NodeMaterialBuildState): this;
  58009. }
  58010. }
  58011. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58012. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58013. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58014. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58015. /**
  58016. * Block used to smooth step a value
  58017. */
  58018. export class SmoothStepBlock extends NodeMaterialBlock {
  58019. /**
  58020. * Creates a new SmoothStepBlock
  58021. * @param name defines the block name
  58022. */
  58023. constructor(name: string);
  58024. /**
  58025. * Gets the current class name
  58026. * @returns the class name
  58027. */
  58028. getClassName(): string;
  58029. /**
  58030. * Gets the value operand input component
  58031. */
  58032. readonly value: NodeMaterialConnectionPoint;
  58033. /**
  58034. * Gets the first edge operand input component
  58035. */
  58036. readonly edge0: NodeMaterialConnectionPoint;
  58037. /**
  58038. * Gets the second edge operand input component
  58039. */
  58040. readonly edge1: NodeMaterialConnectionPoint;
  58041. /**
  58042. * Gets the output component
  58043. */
  58044. readonly output: NodeMaterialConnectionPoint;
  58045. protected _buildBlock(state: NodeMaterialBuildState): this;
  58046. }
  58047. }
  58048. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58049. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58050. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58051. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58052. /**
  58053. * Block used to get the reciprocal (1 / x) of a value
  58054. */
  58055. export class ReciprocalBlock extends NodeMaterialBlock {
  58056. /**
  58057. * Creates a new ReciprocalBlock
  58058. * @param name defines the block name
  58059. */
  58060. constructor(name: string);
  58061. /**
  58062. * Gets the current class name
  58063. * @returns the class name
  58064. */
  58065. getClassName(): string;
  58066. /**
  58067. * Gets the input component
  58068. */
  58069. readonly input: NodeMaterialConnectionPoint;
  58070. /**
  58071. * Gets the output component
  58072. */
  58073. readonly output: NodeMaterialConnectionPoint;
  58074. protected _buildBlock(state: NodeMaterialBuildState): this;
  58075. }
  58076. }
  58077. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58078. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58079. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58080. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58081. /**
  58082. * Block used to replace a color by another one
  58083. */
  58084. export class ReplaceColorBlock extends NodeMaterialBlock {
  58085. /**
  58086. * Creates a new ReplaceColorBlock
  58087. * @param name defines the block name
  58088. */
  58089. constructor(name: string);
  58090. /**
  58091. * Gets the current class name
  58092. * @returns the class name
  58093. */
  58094. getClassName(): string;
  58095. /**
  58096. * Gets the value input component
  58097. */
  58098. readonly value: NodeMaterialConnectionPoint;
  58099. /**
  58100. * Gets the reference input component
  58101. */
  58102. readonly reference: NodeMaterialConnectionPoint;
  58103. /**
  58104. * Gets the distance input component
  58105. */
  58106. readonly distance: NodeMaterialConnectionPoint;
  58107. /**
  58108. * Gets the replacement input component
  58109. */
  58110. readonly replacement: NodeMaterialConnectionPoint;
  58111. /**
  58112. * Gets the output component
  58113. */
  58114. readonly output: NodeMaterialConnectionPoint;
  58115. protected _buildBlock(state: NodeMaterialBuildState): this;
  58116. }
  58117. }
  58118. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58119. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58120. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58121. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58122. /**
  58123. * Block used to posterize a value
  58124. * @see https://en.wikipedia.org/wiki/Posterization
  58125. */
  58126. export class PosterizeBlock extends NodeMaterialBlock {
  58127. /**
  58128. * Creates a new PosterizeBlock
  58129. * @param name defines the block name
  58130. */
  58131. constructor(name: string);
  58132. /**
  58133. * Gets the current class name
  58134. * @returns the class name
  58135. */
  58136. getClassName(): string;
  58137. /**
  58138. * Gets the value input component
  58139. */
  58140. readonly value: NodeMaterialConnectionPoint;
  58141. /**
  58142. * Gets the steps input component
  58143. */
  58144. readonly steps: NodeMaterialConnectionPoint;
  58145. /**
  58146. * Gets the output component
  58147. */
  58148. readonly output: NodeMaterialConnectionPoint;
  58149. protected _buildBlock(state: NodeMaterialBuildState): this;
  58150. }
  58151. }
  58152. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58153. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58154. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58155. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58156. import { Scene } from "babylonjs/scene";
  58157. /**
  58158. * Operations supported by the Wave block
  58159. */
  58160. export enum WaveBlockKind {
  58161. /** SawTooth */
  58162. SawTooth = 0,
  58163. /** Square */
  58164. Square = 1,
  58165. /** Triangle */
  58166. Triangle = 2
  58167. }
  58168. /**
  58169. * Block used to apply wave operation to floats
  58170. */
  58171. export class WaveBlock extends NodeMaterialBlock {
  58172. /**
  58173. * Gets or sets the kibnd of wave to be applied by the block
  58174. */
  58175. kind: WaveBlockKind;
  58176. /**
  58177. * Creates a new WaveBlock
  58178. * @param name defines the block name
  58179. */
  58180. constructor(name: string);
  58181. /**
  58182. * Gets the current class name
  58183. * @returns the class name
  58184. */
  58185. getClassName(): string;
  58186. /**
  58187. * Gets the input component
  58188. */
  58189. readonly input: NodeMaterialConnectionPoint;
  58190. /**
  58191. * Gets the output component
  58192. */
  58193. readonly output: NodeMaterialConnectionPoint;
  58194. protected _buildBlock(state: NodeMaterialBuildState): this;
  58195. serialize(): any;
  58196. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58197. }
  58198. }
  58199. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58200. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58201. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58202. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58203. import { Color3 } from "babylonjs/Maths/math.color";
  58204. import { Scene } from "babylonjs/scene";
  58205. /**
  58206. * Class used to store a color step for the GradientBlock
  58207. */
  58208. export class GradientBlockColorStep {
  58209. /**
  58210. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58211. */
  58212. step: number;
  58213. /**
  58214. * Gets or sets the color associated with this step
  58215. */
  58216. color: Color3;
  58217. /**
  58218. * Creates a new GradientBlockColorStep
  58219. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58220. * @param color defines the color associated with this step
  58221. */
  58222. constructor(
  58223. /**
  58224. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58225. */
  58226. step: number,
  58227. /**
  58228. * Gets or sets the color associated with this step
  58229. */
  58230. color: Color3);
  58231. }
  58232. /**
  58233. * Block used to return a color from a gradient based on an input value between 0 and 1
  58234. */
  58235. export class GradientBlock extends NodeMaterialBlock {
  58236. /**
  58237. * Gets or sets the list of color steps
  58238. */
  58239. colorSteps: GradientBlockColorStep[];
  58240. /**
  58241. * Creates a new GradientBlock
  58242. * @param name defines the block name
  58243. */
  58244. constructor(name: string);
  58245. /**
  58246. * Gets the current class name
  58247. * @returns the class name
  58248. */
  58249. getClassName(): string;
  58250. /**
  58251. * Gets the gradient input component
  58252. */
  58253. readonly gradient: NodeMaterialConnectionPoint;
  58254. /**
  58255. * Gets the output component
  58256. */
  58257. readonly output: NodeMaterialConnectionPoint;
  58258. private _writeColorConstant;
  58259. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58260. serialize(): any;
  58261. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58262. protected _dumpPropertiesCode(): string;
  58263. }
  58264. }
  58265. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58266. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58267. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58268. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58269. /**
  58270. * Block used to normalize lerp between 2 values
  58271. */
  58272. export class NLerpBlock extends NodeMaterialBlock {
  58273. /**
  58274. * Creates a new NLerpBlock
  58275. * @param name defines the block name
  58276. */
  58277. constructor(name: string);
  58278. /**
  58279. * Gets the current class name
  58280. * @returns the class name
  58281. */
  58282. getClassName(): string;
  58283. /**
  58284. * Gets the left operand input component
  58285. */
  58286. readonly left: NodeMaterialConnectionPoint;
  58287. /**
  58288. * Gets the right operand input component
  58289. */
  58290. readonly right: NodeMaterialConnectionPoint;
  58291. /**
  58292. * Gets the gradient operand input component
  58293. */
  58294. readonly gradient: NodeMaterialConnectionPoint;
  58295. /**
  58296. * Gets the output component
  58297. */
  58298. readonly output: NodeMaterialConnectionPoint;
  58299. protected _buildBlock(state: NodeMaterialBuildState): this;
  58300. }
  58301. }
  58302. declare module "babylonjs/Materials/Node/Blocks/index" {
  58303. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58304. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58305. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58306. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58307. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58308. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58309. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58310. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58311. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58312. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58313. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58314. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58315. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58316. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58317. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58318. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58319. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58320. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58321. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58322. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58323. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58324. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58325. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58326. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58327. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58328. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58329. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58330. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58331. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58332. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58333. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58334. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58335. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58336. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58337. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58338. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58339. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  58340. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  58341. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  58342. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  58343. }
  58344. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58345. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58346. }
  58347. declare module "babylonjs/Materials/Node/index" {
  58348. export * from "babylonjs/Materials/Node/Enums/index";
  58349. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58350. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58351. export * from "babylonjs/Materials/Node/nodeMaterial";
  58352. export * from "babylonjs/Materials/Node/Blocks/index";
  58353. export * from "babylonjs/Materials/Node/Optimizers/index";
  58354. }
  58355. declare module "babylonjs/Materials/effectRenderer" {
  58356. import { Nullable } from "babylonjs/types";
  58357. import { Texture } from "babylonjs/Materials/Textures/texture";
  58358. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58359. import { Viewport } from "babylonjs/Maths/math.viewport";
  58360. import { Observable } from "babylonjs/Misc/observable";
  58361. import { Effect } from "babylonjs/Materials/effect";
  58362. import "babylonjs/Engines/Extensions/engine.renderTarget";
  58363. import "babylonjs/Shaders/postprocess.vertex";
  58364. /**
  58365. * Effect Render Options
  58366. */
  58367. export interface IEffectRendererOptions {
  58368. /**
  58369. * Defines the vertices positions.
  58370. */
  58371. positions?: number[];
  58372. /**
  58373. * Defines the indices.
  58374. */
  58375. indices?: number[];
  58376. }
  58377. /**
  58378. * Helper class to render one or more effects
  58379. */
  58380. export class EffectRenderer {
  58381. private engine;
  58382. private static _DefaultOptions;
  58383. private _vertexBuffers;
  58384. private _indexBuffer;
  58385. private _ringBufferIndex;
  58386. private _ringScreenBuffer;
  58387. private _fullscreenViewport;
  58388. private _getNextFrameBuffer;
  58389. /**
  58390. * Creates an effect renderer
  58391. * @param engine the engine to use for rendering
  58392. * @param options defines the options of the effect renderer
  58393. */
  58394. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58395. /**
  58396. * Sets the current viewport in normalized coordinates 0-1
  58397. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58398. */
  58399. setViewport(viewport?: Viewport): void;
  58400. /**
  58401. * Binds the embedded attributes buffer to the effect.
  58402. * @param effect Defines the effect to bind the attributes for
  58403. */
  58404. bindBuffers(effect: Effect): void;
  58405. /**
  58406. * Sets the current effect wrapper to use during draw.
  58407. * The effect needs to be ready before calling this api.
  58408. * This also sets the default full screen position attribute.
  58409. * @param effectWrapper Defines the effect to draw with
  58410. */
  58411. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58412. /**
  58413. * Draws a full screen quad.
  58414. */
  58415. draw(): void;
  58416. /**
  58417. * renders one or more effects to a specified texture
  58418. * @param effectWrappers list of effects to renderer
  58419. * @param outputTexture texture to draw to, if null it will render to the screen
  58420. */
  58421. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58422. /**
  58423. * Disposes of the effect renderer
  58424. */
  58425. dispose(): void;
  58426. }
  58427. /**
  58428. * Options to create an EffectWrapper
  58429. */
  58430. interface EffectWrapperCreationOptions {
  58431. /**
  58432. * Engine to use to create the effect
  58433. */
  58434. engine: ThinEngine;
  58435. /**
  58436. * Fragment shader for the effect
  58437. */
  58438. fragmentShader: string;
  58439. /**
  58440. * Vertex shader for the effect
  58441. */
  58442. vertexShader?: string;
  58443. /**
  58444. * Attributes to use in the shader
  58445. */
  58446. attributeNames?: Array<string>;
  58447. /**
  58448. * Uniforms to use in the shader
  58449. */
  58450. uniformNames?: Array<string>;
  58451. /**
  58452. * Texture sampler names to use in the shader
  58453. */
  58454. samplerNames?: Array<string>;
  58455. /**
  58456. * The friendly name of the effect displayed in Spector.
  58457. */
  58458. name?: string;
  58459. }
  58460. /**
  58461. * Wraps an effect to be used for rendering
  58462. */
  58463. export class EffectWrapper {
  58464. /**
  58465. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58466. */
  58467. onApplyObservable: Observable<{}>;
  58468. /**
  58469. * The underlying effect
  58470. */
  58471. effect: Effect;
  58472. /**
  58473. * Creates an effect to be renderer
  58474. * @param creationOptions options to create the effect
  58475. */
  58476. constructor(creationOptions: EffectWrapperCreationOptions);
  58477. /**
  58478. * Disposes of the effect wrapper
  58479. */
  58480. dispose(): void;
  58481. }
  58482. }
  58483. declare module "babylonjs/Materials/index" {
  58484. export * from "babylonjs/Materials/Background/index";
  58485. export * from "babylonjs/Materials/colorCurves";
  58486. export * from "babylonjs/Materials/iEffectFallbacks";
  58487. export * from "babylonjs/Materials/effectFallbacks";
  58488. export * from "babylonjs/Materials/effect";
  58489. export * from "babylonjs/Materials/fresnelParameters";
  58490. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58491. export * from "babylonjs/Materials/material";
  58492. export * from "babylonjs/Materials/materialDefines";
  58493. export * from "babylonjs/Materials/materialHelper";
  58494. export * from "babylonjs/Materials/multiMaterial";
  58495. export * from "babylonjs/Materials/PBR/index";
  58496. export * from "babylonjs/Materials/pushMaterial";
  58497. export * from "babylonjs/Materials/shaderMaterial";
  58498. export * from "babylonjs/Materials/standardMaterial";
  58499. export * from "babylonjs/Materials/Textures/index";
  58500. export * from "babylonjs/Materials/uniformBuffer";
  58501. export * from "babylonjs/Materials/materialFlags";
  58502. export * from "babylonjs/Materials/Node/index";
  58503. export * from "babylonjs/Materials/effectRenderer";
  58504. }
  58505. declare module "babylonjs/Maths/index" {
  58506. export * from "babylonjs/Maths/math.scalar";
  58507. export * from "babylonjs/Maths/math";
  58508. export * from "babylonjs/Maths/sphericalPolynomial";
  58509. }
  58510. declare module "babylonjs/Misc/workerPool" {
  58511. import { IDisposable } from "babylonjs/scene";
  58512. /**
  58513. * Helper class to push actions to a pool of workers.
  58514. */
  58515. export class WorkerPool implements IDisposable {
  58516. private _workerInfos;
  58517. private _pendingActions;
  58518. /**
  58519. * Constructor
  58520. * @param workers Array of workers to use for actions
  58521. */
  58522. constructor(workers: Array<Worker>);
  58523. /**
  58524. * Terminates all workers and clears any pending actions.
  58525. */
  58526. dispose(): void;
  58527. /**
  58528. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58529. * pended until a worker has completed its action.
  58530. * @param action The action to perform. Call onComplete when the action is complete.
  58531. */
  58532. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58533. private _execute;
  58534. }
  58535. }
  58536. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58537. import { IDisposable } from "babylonjs/scene";
  58538. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58539. /**
  58540. * Configuration for Draco compression
  58541. */
  58542. export interface IDracoCompressionConfiguration {
  58543. /**
  58544. * Configuration for the decoder.
  58545. */
  58546. decoder: {
  58547. /**
  58548. * The url to the WebAssembly module.
  58549. */
  58550. wasmUrl?: string;
  58551. /**
  58552. * The url to the WebAssembly binary.
  58553. */
  58554. wasmBinaryUrl?: string;
  58555. /**
  58556. * The url to the fallback JavaScript module.
  58557. */
  58558. fallbackUrl?: string;
  58559. };
  58560. }
  58561. /**
  58562. * Draco compression (https://google.github.io/draco/)
  58563. *
  58564. * This class wraps the Draco module.
  58565. *
  58566. * **Encoder**
  58567. *
  58568. * The encoder is not currently implemented.
  58569. *
  58570. * **Decoder**
  58571. *
  58572. * 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.
  58573. *
  58574. * To update the configuration, use the following code:
  58575. * ```javascript
  58576. * DracoCompression.Configuration = {
  58577. * decoder: {
  58578. * wasmUrl: "<url to the WebAssembly library>",
  58579. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58580. * fallbackUrl: "<url to the fallback JavaScript library>",
  58581. * }
  58582. * };
  58583. * ```
  58584. *
  58585. * 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.
  58586. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58587. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58588. *
  58589. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58590. * ```javascript
  58591. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58592. * ```
  58593. *
  58594. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58595. */
  58596. export class DracoCompression implements IDisposable {
  58597. private _workerPoolPromise?;
  58598. private _decoderModulePromise?;
  58599. /**
  58600. * The configuration. Defaults to the following urls:
  58601. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58602. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58603. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58604. */
  58605. static Configuration: IDracoCompressionConfiguration;
  58606. /**
  58607. * Returns true if the decoder configuration is available.
  58608. */
  58609. static readonly DecoderAvailable: boolean;
  58610. /**
  58611. * Default number of workers to create when creating the draco compression object.
  58612. */
  58613. static DefaultNumWorkers: number;
  58614. private static GetDefaultNumWorkers;
  58615. private static _Default;
  58616. /**
  58617. * Default instance for the draco compression object.
  58618. */
  58619. static readonly Default: DracoCompression;
  58620. /**
  58621. * Constructor
  58622. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58623. */
  58624. constructor(numWorkers?: number);
  58625. /**
  58626. * Stop all async operations and release resources.
  58627. */
  58628. dispose(): void;
  58629. /**
  58630. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58631. * @returns a promise that resolves when ready
  58632. */
  58633. whenReadyAsync(): Promise<void>;
  58634. /**
  58635. * Decode Draco compressed mesh data to vertex data.
  58636. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58637. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58638. * @returns A promise that resolves with the decoded vertex data
  58639. */
  58640. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58641. [kind: string]: number;
  58642. }): Promise<VertexData>;
  58643. }
  58644. }
  58645. declare module "babylonjs/Meshes/Compression/index" {
  58646. export * from "babylonjs/Meshes/Compression/dracoCompression";
  58647. }
  58648. declare module "babylonjs/Meshes/csg" {
  58649. import { Nullable } from "babylonjs/types";
  58650. import { Scene } from "babylonjs/scene";
  58651. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58652. import { Mesh } from "babylonjs/Meshes/mesh";
  58653. import { Material } from "babylonjs/Materials/material";
  58654. /**
  58655. * Class for building Constructive Solid Geometry
  58656. */
  58657. export class CSG {
  58658. private polygons;
  58659. /**
  58660. * The world matrix
  58661. */
  58662. matrix: Matrix;
  58663. /**
  58664. * Stores the position
  58665. */
  58666. position: Vector3;
  58667. /**
  58668. * Stores the rotation
  58669. */
  58670. rotation: Vector3;
  58671. /**
  58672. * Stores the rotation quaternion
  58673. */
  58674. rotationQuaternion: Nullable<Quaternion>;
  58675. /**
  58676. * Stores the scaling vector
  58677. */
  58678. scaling: Vector3;
  58679. /**
  58680. * Convert the Mesh to CSG
  58681. * @param mesh The Mesh to convert to CSG
  58682. * @returns A new CSG from the Mesh
  58683. */
  58684. static FromMesh(mesh: Mesh): CSG;
  58685. /**
  58686. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58687. * @param polygons Polygons used to construct a CSG solid
  58688. */
  58689. private static FromPolygons;
  58690. /**
  58691. * Clones, or makes a deep copy, of the CSG
  58692. * @returns A new CSG
  58693. */
  58694. clone(): CSG;
  58695. /**
  58696. * Unions this CSG with another CSG
  58697. * @param csg The CSG to union against this CSG
  58698. * @returns The unioned CSG
  58699. */
  58700. union(csg: CSG): CSG;
  58701. /**
  58702. * Unions this CSG with another CSG in place
  58703. * @param csg The CSG to union against this CSG
  58704. */
  58705. unionInPlace(csg: CSG): void;
  58706. /**
  58707. * Subtracts this CSG with another CSG
  58708. * @param csg The CSG to subtract against this CSG
  58709. * @returns A new CSG
  58710. */
  58711. subtract(csg: CSG): CSG;
  58712. /**
  58713. * Subtracts this CSG with another CSG in place
  58714. * @param csg The CSG to subtact against this CSG
  58715. */
  58716. subtractInPlace(csg: CSG): void;
  58717. /**
  58718. * Intersect this CSG with another CSG
  58719. * @param csg The CSG to intersect against this CSG
  58720. * @returns A new CSG
  58721. */
  58722. intersect(csg: CSG): CSG;
  58723. /**
  58724. * Intersects this CSG with another CSG in place
  58725. * @param csg The CSG to intersect against this CSG
  58726. */
  58727. intersectInPlace(csg: CSG): void;
  58728. /**
  58729. * Return a new CSG solid with solid and empty space switched. This solid is
  58730. * not modified.
  58731. * @returns A new CSG solid with solid and empty space switched
  58732. */
  58733. inverse(): CSG;
  58734. /**
  58735. * Inverses the CSG in place
  58736. */
  58737. inverseInPlace(): void;
  58738. /**
  58739. * This is used to keep meshes transformations so they can be restored
  58740. * when we build back a Babylon Mesh
  58741. * NB : All CSG operations are performed in world coordinates
  58742. * @param csg The CSG to copy the transform attributes from
  58743. * @returns This CSG
  58744. */
  58745. copyTransformAttributes(csg: CSG): CSG;
  58746. /**
  58747. * Build Raw mesh from CSG
  58748. * Coordinates here are in world space
  58749. * @param name The name of the mesh geometry
  58750. * @param scene The Scene
  58751. * @param keepSubMeshes Specifies if the submeshes should be kept
  58752. * @returns A new Mesh
  58753. */
  58754. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58755. /**
  58756. * Build Mesh from CSG taking material and transforms into account
  58757. * @param name The name of the Mesh
  58758. * @param material The material of the Mesh
  58759. * @param scene The Scene
  58760. * @param keepSubMeshes Specifies if submeshes should be kept
  58761. * @returns The new Mesh
  58762. */
  58763. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58764. }
  58765. }
  58766. declare module "babylonjs/Meshes/trailMesh" {
  58767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58768. import { Mesh } from "babylonjs/Meshes/mesh";
  58769. import { Scene } from "babylonjs/scene";
  58770. /**
  58771. * Class used to create a trail following a mesh
  58772. */
  58773. export class TrailMesh extends Mesh {
  58774. private _generator;
  58775. private _autoStart;
  58776. private _running;
  58777. private _diameter;
  58778. private _length;
  58779. private _sectionPolygonPointsCount;
  58780. private _sectionVectors;
  58781. private _sectionNormalVectors;
  58782. private _beforeRenderObserver;
  58783. /**
  58784. * @constructor
  58785. * @param name The value used by scene.getMeshByName() to do a lookup.
  58786. * @param generator The mesh to generate a trail.
  58787. * @param scene The scene to add this mesh to.
  58788. * @param diameter Diameter of trailing mesh. Default is 1.
  58789. * @param length Length of trailing mesh. Default is 60.
  58790. * @param autoStart Automatically start trailing mesh. Default true.
  58791. */
  58792. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58793. /**
  58794. * "TrailMesh"
  58795. * @returns "TrailMesh"
  58796. */
  58797. getClassName(): string;
  58798. private _createMesh;
  58799. /**
  58800. * Start trailing mesh.
  58801. */
  58802. start(): void;
  58803. /**
  58804. * Stop trailing mesh.
  58805. */
  58806. stop(): void;
  58807. /**
  58808. * Update trailing mesh geometry.
  58809. */
  58810. update(): void;
  58811. /**
  58812. * Returns a new TrailMesh object.
  58813. * @param name is a string, the name given to the new mesh
  58814. * @param newGenerator use new generator object for cloned trail mesh
  58815. * @returns a new mesh
  58816. */
  58817. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58818. /**
  58819. * Serializes this trail mesh
  58820. * @param serializationObject object to write serialization to
  58821. */
  58822. serialize(serializationObject: any): void;
  58823. /**
  58824. * Parses a serialized trail mesh
  58825. * @param parsedMesh the serialized mesh
  58826. * @param scene the scene to create the trail mesh in
  58827. * @returns the created trail mesh
  58828. */
  58829. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58830. }
  58831. }
  58832. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  58833. import { Nullable } from "babylonjs/types";
  58834. import { Scene } from "babylonjs/scene";
  58835. import { Vector4 } from "babylonjs/Maths/math.vector";
  58836. import { Color4 } from "babylonjs/Maths/math.color";
  58837. import { Mesh } from "babylonjs/Meshes/mesh";
  58838. /**
  58839. * Class containing static functions to help procedurally build meshes
  58840. */
  58841. export class TiledBoxBuilder {
  58842. /**
  58843. * Creates a box mesh
  58844. * 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)
  58845. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58847. * * 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
  58848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58849. * @param name defines the name of the mesh
  58850. * @param options defines the options used to create the mesh
  58851. * @param scene defines the hosting scene
  58852. * @returns the box mesh
  58853. */
  58854. static CreateTiledBox(name: string, options: {
  58855. pattern?: number;
  58856. width?: number;
  58857. height?: number;
  58858. depth?: number;
  58859. tileSize?: number;
  58860. tileWidth?: number;
  58861. tileHeight?: number;
  58862. alignHorizontal?: number;
  58863. alignVertical?: number;
  58864. faceUV?: Vector4[];
  58865. faceColors?: Color4[];
  58866. sideOrientation?: number;
  58867. updatable?: boolean;
  58868. }, scene?: Nullable<Scene>): Mesh;
  58869. }
  58870. }
  58871. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  58872. import { Vector4 } from "babylonjs/Maths/math.vector";
  58873. import { Mesh } from "babylonjs/Meshes/mesh";
  58874. /**
  58875. * Class containing static functions to help procedurally build meshes
  58876. */
  58877. export class TorusKnotBuilder {
  58878. /**
  58879. * Creates a torus knot mesh
  58880. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58881. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58882. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58883. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58884. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58885. * * 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
  58886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58887. * @param name defines the name of the mesh
  58888. * @param options defines the options used to create the mesh
  58889. * @param scene defines the hosting scene
  58890. * @returns the torus knot mesh
  58891. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58892. */
  58893. static CreateTorusKnot(name: string, options: {
  58894. radius?: number;
  58895. tube?: number;
  58896. radialSegments?: number;
  58897. tubularSegments?: number;
  58898. p?: number;
  58899. q?: number;
  58900. updatable?: boolean;
  58901. sideOrientation?: number;
  58902. frontUVs?: Vector4;
  58903. backUVs?: Vector4;
  58904. }, scene: any): Mesh;
  58905. }
  58906. }
  58907. declare module "babylonjs/Meshes/polygonMesh" {
  58908. import { Scene } from "babylonjs/scene";
  58909. import { Vector2 } from "babylonjs/Maths/math.vector";
  58910. import { Mesh } from "babylonjs/Meshes/mesh";
  58911. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58912. import { Path2 } from "babylonjs/Maths/math.path";
  58913. /**
  58914. * Polygon
  58915. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58916. */
  58917. export class Polygon {
  58918. /**
  58919. * Creates a rectangle
  58920. * @param xmin bottom X coord
  58921. * @param ymin bottom Y coord
  58922. * @param xmax top X coord
  58923. * @param ymax top Y coord
  58924. * @returns points that make the resulting rectation
  58925. */
  58926. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58927. /**
  58928. * Creates a circle
  58929. * @param radius radius of circle
  58930. * @param cx scale in x
  58931. * @param cy scale in y
  58932. * @param numberOfSides number of sides that make up the circle
  58933. * @returns points that make the resulting circle
  58934. */
  58935. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58936. /**
  58937. * Creates a polygon from input string
  58938. * @param input Input polygon data
  58939. * @returns the parsed points
  58940. */
  58941. static Parse(input: string): Vector2[];
  58942. /**
  58943. * Starts building a polygon from x and y coordinates
  58944. * @param x x coordinate
  58945. * @param y y coordinate
  58946. * @returns the started path2
  58947. */
  58948. static StartingAt(x: number, y: number): Path2;
  58949. }
  58950. /**
  58951. * Builds a polygon
  58952. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58953. */
  58954. export class PolygonMeshBuilder {
  58955. private _points;
  58956. private _outlinepoints;
  58957. private _holes;
  58958. private _name;
  58959. private _scene;
  58960. private _epoints;
  58961. private _eholes;
  58962. private _addToepoint;
  58963. /**
  58964. * Babylon reference to the earcut plugin.
  58965. */
  58966. bjsEarcut: any;
  58967. /**
  58968. * Creates a PolygonMeshBuilder
  58969. * @param name name of the builder
  58970. * @param contours Path of the polygon
  58971. * @param scene scene to add to when creating the mesh
  58972. * @param earcutInjection can be used to inject your own earcut reference
  58973. */
  58974. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58975. /**
  58976. * Adds a whole within the polygon
  58977. * @param hole Array of points defining the hole
  58978. * @returns this
  58979. */
  58980. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58981. /**
  58982. * Creates the polygon
  58983. * @param updatable If the mesh should be updatable
  58984. * @param depth The depth of the mesh created
  58985. * @returns the created mesh
  58986. */
  58987. build(updatable?: boolean, depth?: number): Mesh;
  58988. /**
  58989. * Creates the polygon
  58990. * @param depth The depth of the mesh created
  58991. * @returns the created VertexData
  58992. */
  58993. buildVertexData(depth?: number): VertexData;
  58994. /**
  58995. * Adds a side to the polygon
  58996. * @param positions points that make the polygon
  58997. * @param normals normals of the polygon
  58998. * @param uvs uvs of the polygon
  58999. * @param indices indices of the polygon
  59000. * @param bounds bounds of the polygon
  59001. * @param points points of the polygon
  59002. * @param depth depth of the polygon
  59003. * @param flip flip of the polygon
  59004. */
  59005. private addSide;
  59006. }
  59007. }
  59008. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59009. import { Scene } from "babylonjs/scene";
  59010. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59011. import { Color4 } from "babylonjs/Maths/math.color";
  59012. import { Mesh } from "babylonjs/Meshes/mesh";
  59013. import { Nullable } from "babylonjs/types";
  59014. /**
  59015. * Class containing static functions to help procedurally build meshes
  59016. */
  59017. export class PolygonBuilder {
  59018. /**
  59019. * Creates a polygon mesh
  59020. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59021. * * 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
  59022. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59024. * * 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)
  59025. * * Remember you can only change the shape positions, not their number when updating a polygon
  59026. * @param name defines the name of the mesh
  59027. * @param options defines the options used to create the mesh
  59028. * @param scene defines the hosting scene
  59029. * @param earcutInjection can be used to inject your own earcut reference
  59030. * @returns the polygon mesh
  59031. */
  59032. static CreatePolygon(name: string, options: {
  59033. shape: Vector3[];
  59034. holes?: Vector3[][];
  59035. depth?: number;
  59036. faceUV?: Vector4[];
  59037. faceColors?: Color4[];
  59038. updatable?: boolean;
  59039. sideOrientation?: number;
  59040. frontUVs?: Vector4;
  59041. backUVs?: Vector4;
  59042. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59043. /**
  59044. * Creates an extruded polygon mesh, with depth in the Y direction.
  59045. * * 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)
  59046. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59047. * @param name defines the name of the mesh
  59048. * @param options defines the options used to create the mesh
  59049. * @param scene defines the hosting scene
  59050. * @param earcutInjection can be used to inject your own earcut reference
  59051. * @returns the polygon mesh
  59052. */
  59053. static ExtrudePolygon(name: string, options: {
  59054. shape: Vector3[];
  59055. holes?: Vector3[][];
  59056. depth?: number;
  59057. faceUV?: Vector4[];
  59058. faceColors?: Color4[];
  59059. updatable?: boolean;
  59060. sideOrientation?: number;
  59061. frontUVs?: Vector4;
  59062. backUVs?: Vector4;
  59063. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59064. }
  59065. }
  59066. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59067. import { Scene } from "babylonjs/scene";
  59068. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59069. import { Mesh } from "babylonjs/Meshes/mesh";
  59070. import { Nullable } from "babylonjs/types";
  59071. /**
  59072. * Class containing static functions to help procedurally build meshes
  59073. */
  59074. export class LatheBuilder {
  59075. /**
  59076. * Creates lathe mesh.
  59077. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59078. * * 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
  59079. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59080. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59081. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59082. * * 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
  59083. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59084. * * 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
  59085. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59086. * * 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
  59087. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59089. * @param name defines the name of the mesh
  59090. * @param options defines the options used to create the mesh
  59091. * @param scene defines the hosting scene
  59092. * @returns the lathe mesh
  59093. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59094. */
  59095. static CreateLathe(name: string, options: {
  59096. shape: Vector3[];
  59097. radius?: number;
  59098. tessellation?: number;
  59099. clip?: number;
  59100. arc?: number;
  59101. closed?: boolean;
  59102. updatable?: boolean;
  59103. sideOrientation?: number;
  59104. frontUVs?: Vector4;
  59105. backUVs?: Vector4;
  59106. cap?: number;
  59107. invertUV?: boolean;
  59108. }, scene?: Nullable<Scene>): Mesh;
  59109. }
  59110. }
  59111. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59112. import { Nullable } from "babylonjs/types";
  59113. import { Scene } from "babylonjs/scene";
  59114. import { Vector4 } from "babylonjs/Maths/math.vector";
  59115. import { Mesh } from "babylonjs/Meshes/mesh";
  59116. /**
  59117. * Class containing static functions to help procedurally build meshes
  59118. */
  59119. export class TiledPlaneBuilder {
  59120. /**
  59121. * Creates a tiled plane mesh
  59122. * * The parameter `pattern` will, depending on value, do nothing or
  59123. * * * flip (reflect about central vertical) alternate tiles across and up
  59124. * * * flip every tile on alternate rows
  59125. * * * rotate (180 degs) alternate tiles across and up
  59126. * * * rotate every tile on alternate rows
  59127. * * * flip and rotate alternate tiles across and up
  59128. * * * flip and rotate every tile on alternate rows
  59129. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59130. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59131. * * 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
  59132. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59133. * * 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)
  59134. * * 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)
  59135. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59136. * @param name defines the name of the mesh
  59137. * @param options defines the options used to create the mesh
  59138. * @param scene defines the hosting scene
  59139. * @returns the box mesh
  59140. */
  59141. static CreateTiledPlane(name: string, options: {
  59142. pattern?: number;
  59143. tileSize?: number;
  59144. tileWidth?: number;
  59145. tileHeight?: number;
  59146. size?: number;
  59147. width?: number;
  59148. height?: number;
  59149. alignHorizontal?: number;
  59150. alignVertical?: number;
  59151. sideOrientation?: number;
  59152. frontUVs?: Vector4;
  59153. backUVs?: Vector4;
  59154. updatable?: boolean;
  59155. }, scene?: Nullable<Scene>): Mesh;
  59156. }
  59157. }
  59158. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59159. import { Nullable } from "babylonjs/types";
  59160. import { Scene } from "babylonjs/scene";
  59161. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59162. import { Mesh } from "babylonjs/Meshes/mesh";
  59163. /**
  59164. * Class containing static functions to help procedurally build meshes
  59165. */
  59166. export class TubeBuilder {
  59167. /**
  59168. * Creates a tube mesh.
  59169. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59170. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59171. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59172. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59173. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59174. * * 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)
  59175. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59176. * * 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
  59177. * * 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
  59178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59179. * * 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
  59180. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59182. * @param name defines the name of the mesh
  59183. * @param options defines the options used to create the mesh
  59184. * @param scene defines the hosting scene
  59185. * @returns the tube mesh
  59186. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59187. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59188. */
  59189. static CreateTube(name: string, options: {
  59190. path: Vector3[];
  59191. radius?: number;
  59192. tessellation?: number;
  59193. radiusFunction?: {
  59194. (i: number, distance: number): number;
  59195. };
  59196. cap?: number;
  59197. arc?: number;
  59198. updatable?: boolean;
  59199. sideOrientation?: number;
  59200. frontUVs?: Vector4;
  59201. backUVs?: Vector4;
  59202. instance?: Mesh;
  59203. invertUV?: boolean;
  59204. }, scene?: Nullable<Scene>): Mesh;
  59205. }
  59206. }
  59207. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59208. import { Scene } from "babylonjs/scene";
  59209. import { Vector4 } from "babylonjs/Maths/math.vector";
  59210. import { Mesh } from "babylonjs/Meshes/mesh";
  59211. import { Nullable } from "babylonjs/types";
  59212. /**
  59213. * Class containing static functions to help procedurally build meshes
  59214. */
  59215. export class IcoSphereBuilder {
  59216. /**
  59217. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59218. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59219. * * 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`)
  59220. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59221. * * 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
  59222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59223. * * 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
  59224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59225. * @param name defines the name of the mesh
  59226. * @param options defines the options used to create the mesh
  59227. * @param scene defines the hosting scene
  59228. * @returns the icosahedron mesh
  59229. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59230. */
  59231. static CreateIcoSphere(name: string, options: {
  59232. radius?: number;
  59233. radiusX?: number;
  59234. radiusY?: number;
  59235. radiusZ?: number;
  59236. flat?: boolean;
  59237. subdivisions?: number;
  59238. sideOrientation?: number;
  59239. frontUVs?: Vector4;
  59240. backUVs?: Vector4;
  59241. updatable?: boolean;
  59242. }, scene?: Nullable<Scene>): Mesh;
  59243. }
  59244. }
  59245. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59246. import { Vector3 } from "babylonjs/Maths/math.vector";
  59247. import { Mesh } from "babylonjs/Meshes/mesh";
  59248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59249. /**
  59250. * Class containing static functions to help procedurally build meshes
  59251. */
  59252. export class DecalBuilder {
  59253. /**
  59254. * Creates a decal mesh.
  59255. * 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
  59256. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59257. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59258. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59259. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59260. * @param name defines the name of the mesh
  59261. * @param sourceMesh defines the mesh where the decal must be applied
  59262. * @param options defines the options used to create the mesh
  59263. * @param scene defines the hosting scene
  59264. * @returns the decal mesh
  59265. * @see https://doc.babylonjs.com/how_to/decals
  59266. */
  59267. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59268. position?: Vector3;
  59269. normal?: Vector3;
  59270. size?: Vector3;
  59271. angle?: number;
  59272. }): Mesh;
  59273. }
  59274. }
  59275. declare module "babylonjs/Meshes/meshBuilder" {
  59276. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59277. import { Nullable } from "babylonjs/types";
  59278. import { Scene } from "babylonjs/scene";
  59279. import { Mesh } from "babylonjs/Meshes/mesh";
  59280. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59281. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59283. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59284. import { Plane } from "babylonjs/Maths/math.plane";
  59285. /**
  59286. * Class containing static functions to help procedurally build meshes
  59287. */
  59288. export class MeshBuilder {
  59289. /**
  59290. * Creates a box mesh
  59291. * * The parameter `size` sets the size (float) of each box side (default 1)
  59292. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59293. * * 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)
  59294. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59296. * * 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
  59297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59298. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59299. * @param name defines the name of the mesh
  59300. * @param options defines the options used to create the mesh
  59301. * @param scene defines the hosting scene
  59302. * @returns the box mesh
  59303. */
  59304. static CreateBox(name: string, options: {
  59305. size?: number;
  59306. width?: number;
  59307. height?: number;
  59308. depth?: number;
  59309. faceUV?: Vector4[];
  59310. faceColors?: Color4[];
  59311. sideOrientation?: number;
  59312. frontUVs?: Vector4;
  59313. backUVs?: Vector4;
  59314. updatable?: boolean;
  59315. }, scene?: Nullable<Scene>): Mesh;
  59316. /**
  59317. * Creates a tiled box mesh
  59318. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59320. * @param name defines the name of the mesh
  59321. * @param options defines the options used to create the mesh
  59322. * @param scene defines the hosting scene
  59323. * @returns the tiled box mesh
  59324. */
  59325. static CreateTiledBox(name: string, options: {
  59326. pattern?: number;
  59327. size?: number;
  59328. width?: number;
  59329. height?: number;
  59330. depth: number;
  59331. tileSize?: number;
  59332. tileWidth?: number;
  59333. tileHeight?: number;
  59334. faceUV?: Vector4[];
  59335. faceColors?: Color4[];
  59336. alignHorizontal?: number;
  59337. alignVertical?: number;
  59338. sideOrientation?: number;
  59339. updatable?: boolean;
  59340. }, scene?: Nullable<Scene>): Mesh;
  59341. /**
  59342. * Creates a sphere mesh
  59343. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59344. * * 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`)
  59345. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59346. * * 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
  59347. * * 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)
  59348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59349. * * 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
  59350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59351. * @param name defines the name of the mesh
  59352. * @param options defines the options used to create the mesh
  59353. * @param scene defines the hosting scene
  59354. * @returns the sphere mesh
  59355. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59356. */
  59357. static CreateSphere(name: string, options: {
  59358. segments?: number;
  59359. diameter?: number;
  59360. diameterX?: number;
  59361. diameterY?: number;
  59362. diameterZ?: number;
  59363. arc?: number;
  59364. slice?: number;
  59365. sideOrientation?: number;
  59366. frontUVs?: Vector4;
  59367. backUVs?: Vector4;
  59368. updatable?: boolean;
  59369. }, scene?: Nullable<Scene>): Mesh;
  59370. /**
  59371. * Creates a plane polygonal mesh. By default, this is a disc
  59372. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59373. * * 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
  59374. * * 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
  59375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59376. * * 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
  59377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59378. * @param name defines the name of the mesh
  59379. * @param options defines the options used to create the mesh
  59380. * @param scene defines the hosting scene
  59381. * @returns the plane polygonal mesh
  59382. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59383. */
  59384. static CreateDisc(name: string, options: {
  59385. radius?: number;
  59386. tessellation?: number;
  59387. arc?: number;
  59388. updatable?: boolean;
  59389. sideOrientation?: number;
  59390. frontUVs?: Vector4;
  59391. backUVs?: Vector4;
  59392. }, scene?: Nullable<Scene>): Mesh;
  59393. /**
  59394. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59395. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59396. * * 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`)
  59397. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59398. * * 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
  59399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59400. * * 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
  59401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59402. * @param name defines the name of the mesh
  59403. * @param options defines the options used to create the mesh
  59404. * @param scene defines the hosting scene
  59405. * @returns the icosahedron mesh
  59406. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59407. */
  59408. static CreateIcoSphere(name: string, options: {
  59409. radius?: number;
  59410. radiusX?: number;
  59411. radiusY?: number;
  59412. radiusZ?: number;
  59413. flat?: boolean;
  59414. subdivisions?: number;
  59415. sideOrientation?: number;
  59416. frontUVs?: Vector4;
  59417. backUVs?: Vector4;
  59418. updatable?: boolean;
  59419. }, scene?: Nullable<Scene>): Mesh;
  59420. /**
  59421. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59422. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59423. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59424. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59425. * * 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
  59426. * * 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
  59427. * * 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
  59428. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59429. * * 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
  59430. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59431. * * 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
  59432. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59433. * * 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
  59434. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59436. * @param name defines the name of the mesh
  59437. * @param options defines the options used to create the mesh
  59438. * @param scene defines the hosting scene
  59439. * @returns the ribbon mesh
  59440. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59441. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59442. */
  59443. static CreateRibbon(name: string, options: {
  59444. pathArray: Vector3[][];
  59445. closeArray?: boolean;
  59446. closePath?: boolean;
  59447. offset?: number;
  59448. updatable?: boolean;
  59449. sideOrientation?: number;
  59450. frontUVs?: Vector4;
  59451. backUVs?: Vector4;
  59452. instance?: Mesh;
  59453. invertUV?: boolean;
  59454. uvs?: Vector2[];
  59455. colors?: Color4[];
  59456. }, scene?: Nullable<Scene>): Mesh;
  59457. /**
  59458. * Creates a cylinder or a cone mesh
  59459. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59460. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59461. * * 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.
  59462. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59463. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59464. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59465. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59466. * * 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).
  59467. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59468. * * 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).
  59469. * * 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
  59470. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59471. * * 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
  59472. * * 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.
  59473. * * If `enclose` is false, a ring surface is one element.
  59474. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59475. * * 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
  59476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59477. * * 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
  59478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59479. * @param name defines the name of the mesh
  59480. * @param options defines the options used to create the mesh
  59481. * @param scene defines the hosting scene
  59482. * @returns the cylinder mesh
  59483. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59484. */
  59485. static CreateCylinder(name: string, options: {
  59486. height?: number;
  59487. diameterTop?: number;
  59488. diameterBottom?: number;
  59489. diameter?: number;
  59490. tessellation?: number;
  59491. subdivisions?: number;
  59492. arc?: number;
  59493. faceColors?: Color4[];
  59494. faceUV?: Vector4[];
  59495. updatable?: boolean;
  59496. hasRings?: boolean;
  59497. enclose?: boolean;
  59498. cap?: number;
  59499. sideOrientation?: number;
  59500. frontUVs?: Vector4;
  59501. backUVs?: Vector4;
  59502. }, scene?: Nullable<Scene>): Mesh;
  59503. /**
  59504. * Creates a torus mesh
  59505. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59506. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59507. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59508. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59509. * * 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
  59510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59511. * @param name defines the name of the mesh
  59512. * @param options defines the options used to create the mesh
  59513. * @param scene defines the hosting scene
  59514. * @returns the torus mesh
  59515. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59516. */
  59517. static CreateTorus(name: string, options: {
  59518. diameter?: number;
  59519. thickness?: number;
  59520. tessellation?: number;
  59521. updatable?: boolean;
  59522. sideOrientation?: number;
  59523. frontUVs?: Vector4;
  59524. backUVs?: Vector4;
  59525. }, scene?: Nullable<Scene>): Mesh;
  59526. /**
  59527. * Creates a torus knot mesh
  59528. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59529. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59530. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59531. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59532. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59533. * * 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
  59534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59535. * @param name defines the name of the mesh
  59536. * @param options defines the options used to create the mesh
  59537. * @param scene defines the hosting scene
  59538. * @returns the torus knot mesh
  59539. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59540. */
  59541. static CreateTorusKnot(name: string, options: {
  59542. radius?: number;
  59543. tube?: number;
  59544. radialSegments?: number;
  59545. tubularSegments?: number;
  59546. p?: number;
  59547. q?: number;
  59548. updatable?: boolean;
  59549. sideOrientation?: number;
  59550. frontUVs?: Vector4;
  59551. backUVs?: Vector4;
  59552. }, scene?: Nullable<Scene>): Mesh;
  59553. /**
  59554. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59555. * * 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
  59556. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59557. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59558. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59559. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59560. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59561. * * 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
  59562. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59564. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59565. * @param name defines the name of the new line system
  59566. * @param options defines the options used to create the line system
  59567. * @param scene defines the hosting scene
  59568. * @returns a new line system mesh
  59569. */
  59570. static CreateLineSystem(name: string, options: {
  59571. lines: Vector3[][];
  59572. updatable?: boolean;
  59573. instance?: Nullable<LinesMesh>;
  59574. colors?: Nullable<Color4[][]>;
  59575. useVertexAlpha?: boolean;
  59576. }, scene: Nullable<Scene>): LinesMesh;
  59577. /**
  59578. * Creates a line mesh
  59579. * 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
  59580. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59581. * * The parameter `points` is an array successive Vector3
  59582. * * 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
  59583. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59584. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59585. * * When updating an instance, remember that only point positions can change, not the number of points
  59586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59587. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59588. * @param name defines the name of the new line system
  59589. * @param options defines the options used to create the line system
  59590. * @param scene defines the hosting scene
  59591. * @returns a new line mesh
  59592. */
  59593. static CreateLines(name: string, options: {
  59594. points: Vector3[];
  59595. updatable?: boolean;
  59596. instance?: Nullable<LinesMesh>;
  59597. colors?: Color4[];
  59598. useVertexAlpha?: boolean;
  59599. }, scene?: Nullable<Scene>): LinesMesh;
  59600. /**
  59601. * Creates a dashed line mesh
  59602. * * 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
  59603. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59604. * * The parameter `points` is an array successive Vector3
  59605. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59606. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59607. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59608. * * 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
  59609. * * When updating an instance, remember that only point positions can change, not the number of points
  59610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59611. * @param name defines the name of the mesh
  59612. * @param options defines the options used to create the mesh
  59613. * @param scene defines the hosting scene
  59614. * @returns the dashed line mesh
  59615. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59616. */
  59617. static CreateDashedLines(name: string, options: {
  59618. points: Vector3[];
  59619. dashSize?: number;
  59620. gapSize?: number;
  59621. dashNb?: number;
  59622. updatable?: boolean;
  59623. instance?: LinesMesh;
  59624. }, scene?: Nullable<Scene>): LinesMesh;
  59625. /**
  59626. * 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.
  59627. * * 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.
  59628. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59629. * * 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.
  59630. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59631. * * 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
  59632. * * 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
  59633. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59634. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59635. * * 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
  59636. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59638. * @param name defines the name of the mesh
  59639. * @param options defines the options used to create the mesh
  59640. * @param scene defines the hosting scene
  59641. * @returns the extruded shape mesh
  59642. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59643. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59644. */
  59645. static ExtrudeShape(name: string, options: {
  59646. shape: Vector3[];
  59647. path: Vector3[];
  59648. scale?: number;
  59649. rotation?: number;
  59650. cap?: number;
  59651. updatable?: boolean;
  59652. sideOrientation?: number;
  59653. frontUVs?: Vector4;
  59654. backUVs?: Vector4;
  59655. instance?: Mesh;
  59656. invertUV?: boolean;
  59657. }, scene?: Nullable<Scene>): Mesh;
  59658. /**
  59659. * Creates an custom extruded shape mesh.
  59660. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59661. * * 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.
  59662. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59663. * * 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
  59664. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59665. * * 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
  59666. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59667. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59668. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59669. * * 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
  59670. * * 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
  59671. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59672. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59673. * * 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
  59674. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59676. * @param name defines the name of the mesh
  59677. * @param options defines the options used to create the mesh
  59678. * @param scene defines the hosting scene
  59679. * @returns the custom extruded shape mesh
  59680. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59681. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59682. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59683. */
  59684. static ExtrudeShapeCustom(name: string, options: {
  59685. shape: Vector3[];
  59686. path: Vector3[];
  59687. scaleFunction?: any;
  59688. rotationFunction?: any;
  59689. ribbonCloseArray?: boolean;
  59690. ribbonClosePath?: boolean;
  59691. cap?: number;
  59692. updatable?: boolean;
  59693. sideOrientation?: number;
  59694. frontUVs?: Vector4;
  59695. backUVs?: Vector4;
  59696. instance?: Mesh;
  59697. invertUV?: boolean;
  59698. }, scene?: Nullable<Scene>): Mesh;
  59699. /**
  59700. * Creates lathe mesh.
  59701. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59702. * * 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
  59703. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59704. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59705. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59706. * * 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
  59707. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59708. * * 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
  59709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59710. * * 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
  59711. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59713. * @param name defines the name of the mesh
  59714. * @param options defines the options used to create the mesh
  59715. * @param scene defines the hosting scene
  59716. * @returns the lathe mesh
  59717. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59718. */
  59719. static CreateLathe(name: string, options: {
  59720. shape: Vector3[];
  59721. radius?: number;
  59722. tessellation?: number;
  59723. clip?: number;
  59724. arc?: number;
  59725. closed?: boolean;
  59726. updatable?: boolean;
  59727. sideOrientation?: number;
  59728. frontUVs?: Vector4;
  59729. backUVs?: Vector4;
  59730. cap?: number;
  59731. invertUV?: boolean;
  59732. }, scene?: Nullable<Scene>): Mesh;
  59733. /**
  59734. * Creates a tiled plane mesh
  59735. * * You can set a limited pattern arrangement with the tiles
  59736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59737. * * 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
  59738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59739. * @param name defines the name of the mesh
  59740. * @param options defines the options used to create the mesh
  59741. * @param scene defines the hosting scene
  59742. * @returns the plane mesh
  59743. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59744. */
  59745. static CreateTiledPlane(name: string, options: {
  59746. pattern?: number;
  59747. tileSize?: number;
  59748. tileWidth?: number;
  59749. tileHeight?: number;
  59750. size?: number;
  59751. width?: number;
  59752. height?: number;
  59753. alignHorizontal?: number;
  59754. alignVertical?: number;
  59755. sideOrientation?: number;
  59756. frontUVs?: Vector4;
  59757. backUVs?: Vector4;
  59758. updatable?: boolean;
  59759. }, scene?: Nullable<Scene>): Mesh;
  59760. /**
  59761. * Creates a plane mesh
  59762. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59763. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59764. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59765. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59766. * * 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
  59767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59768. * @param name defines the name of the mesh
  59769. * @param options defines the options used to create the mesh
  59770. * @param scene defines the hosting scene
  59771. * @returns the plane mesh
  59772. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59773. */
  59774. static CreatePlane(name: string, options: {
  59775. size?: number;
  59776. width?: number;
  59777. height?: number;
  59778. sideOrientation?: number;
  59779. frontUVs?: Vector4;
  59780. backUVs?: Vector4;
  59781. updatable?: boolean;
  59782. sourcePlane?: Plane;
  59783. }, scene?: Nullable<Scene>): Mesh;
  59784. /**
  59785. * Creates a ground mesh
  59786. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59787. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59789. * @param name defines the name of the mesh
  59790. * @param options defines the options used to create the mesh
  59791. * @param scene defines the hosting scene
  59792. * @returns the ground mesh
  59793. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59794. */
  59795. static CreateGround(name: string, options: {
  59796. width?: number;
  59797. height?: number;
  59798. subdivisions?: number;
  59799. subdivisionsX?: number;
  59800. subdivisionsY?: number;
  59801. updatable?: boolean;
  59802. }, scene?: Nullable<Scene>): Mesh;
  59803. /**
  59804. * Creates a tiled ground mesh
  59805. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59806. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59807. * * 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
  59808. * * 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
  59809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59810. * @param name defines the name of the mesh
  59811. * @param options defines the options used to create the mesh
  59812. * @param scene defines the hosting scene
  59813. * @returns the tiled ground mesh
  59814. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59815. */
  59816. static CreateTiledGround(name: string, options: {
  59817. xmin: number;
  59818. zmin: number;
  59819. xmax: number;
  59820. zmax: number;
  59821. subdivisions?: {
  59822. w: number;
  59823. h: number;
  59824. };
  59825. precision?: {
  59826. w: number;
  59827. h: number;
  59828. };
  59829. updatable?: boolean;
  59830. }, scene?: Nullable<Scene>): Mesh;
  59831. /**
  59832. * Creates a ground mesh from a height map
  59833. * * The parameter `url` sets the URL of the height map image resource.
  59834. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59835. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59836. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59837. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59838. * * 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.
  59839. * * 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).
  59840. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59842. * @param name defines the name of the mesh
  59843. * @param url defines the url to the height map
  59844. * @param options defines the options used to create the mesh
  59845. * @param scene defines the hosting scene
  59846. * @returns the ground mesh
  59847. * @see https://doc.babylonjs.com/babylon101/height_map
  59848. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59849. */
  59850. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59851. width?: number;
  59852. height?: number;
  59853. subdivisions?: number;
  59854. minHeight?: number;
  59855. maxHeight?: number;
  59856. colorFilter?: Color3;
  59857. alphaFilter?: number;
  59858. updatable?: boolean;
  59859. onReady?: (mesh: GroundMesh) => void;
  59860. }, scene?: Nullable<Scene>): GroundMesh;
  59861. /**
  59862. * Creates a polygon mesh
  59863. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59864. * * 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
  59865. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59867. * * 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)
  59868. * * Remember you can only change the shape positions, not their number when updating a polygon
  59869. * @param name defines the name of the mesh
  59870. * @param options defines the options used to create the mesh
  59871. * @param scene defines the hosting scene
  59872. * @param earcutInjection can be used to inject your own earcut reference
  59873. * @returns the polygon mesh
  59874. */
  59875. static CreatePolygon(name: string, options: {
  59876. shape: Vector3[];
  59877. holes?: Vector3[][];
  59878. depth?: number;
  59879. faceUV?: Vector4[];
  59880. faceColors?: Color4[];
  59881. updatable?: boolean;
  59882. sideOrientation?: number;
  59883. frontUVs?: Vector4;
  59884. backUVs?: Vector4;
  59885. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59886. /**
  59887. * Creates an extruded polygon mesh, with depth in the Y direction.
  59888. * * 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)
  59889. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59890. * @param name defines the name of the mesh
  59891. * @param options defines the options used to create the mesh
  59892. * @param scene defines the hosting scene
  59893. * @param earcutInjection can be used to inject your own earcut reference
  59894. * @returns the polygon mesh
  59895. */
  59896. static ExtrudePolygon(name: string, options: {
  59897. shape: Vector3[];
  59898. holes?: Vector3[][];
  59899. depth?: number;
  59900. faceUV?: Vector4[];
  59901. faceColors?: Color4[];
  59902. updatable?: boolean;
  59903. sideOrientation?: number;
  59904. frontUVs?: Vector4;
  59905. backUVs?: Vector4;
  59906. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59907. /**
  59908. * Creates a tube mesh.
  59909. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59910. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59911. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59912. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59913. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59914. * * 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)
  59915. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59916. * * 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
  59917. * * 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
  59918. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59919. * * 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
  59920. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59922. * @param name defines the name of the mesh
  59923. * @param options defines the options used to create the mesh
  59924. * @param scene defines the hosting scene
  59925. * @returns the tube mesh
  59926. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59927. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59928. */
  59929. static CreateTube(name: string, options: {
  59930. path: Vector3[];
  59931. radius?: number;
  59932. tessellation?: number;
  59933. radiusFunction?: {
  59934. (i: number, distance: number): number;
  59935. };
  59936. cap?: number;
  59937. arc?: number;
  59938. updatable?: boolean;
  59939. sideOrientation?: number;
  59940. frontUVs?: Vector4;
  59941. backUVs?: Vector4;
  59942. instance?: Mesh;
  59943. invertUV?: boolean;
  59944. }, scene?: Nullable<Scene>): Mesh;
  59945. /**
  59946. * Creates a polyhedron mesh
  59947. * * 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
  59948. * * The parameter `size` (positive float, default 1) sets the polygon size
  59949. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59950. * * 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`
  59951. * * 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
  59952. * * 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)`)
  59953. * * 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
  59954. * * 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
  59955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59956. * * 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
  59957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59958. * @param name defines the name of the mesh
  59959. * @param options defines the options used to create the mesh
  59960. * @param scene defines the hosting scene
  59961. * @returns the polyhedron mesh
  59962. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59963. */
  59964. static CreatePolyhedron(name: string, options: {
  59965. type?: number;
  59966. size?: number;
  59967. sizeX?: number;
  59968. sizeY?: number;
  59969. sizeZ?: number;
  59970. custom?: any;
  59971. faceUV?: Vector4[];
  59972. faceColors?: Color4[];
  59973. flat?: boolean;
  59974. updatable?: boolean;
  59975. sideOrientation?: number;
  59976. frontUVs?: Vector4;
  59977. backUVs?: Vector4;
  59978. }, scene?: Nullable<Scene>): Mesh;
  59979. /**
  59980. * Creates a decal mesh.
  59981. * 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
  59982. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59983. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59984. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59985. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59986. * @param name defines the name of the mesh
  59987. * @param sourceMesh defines the mesh where the decal must be applied
  59988. * @param options defines the options used to create the mesh
  59989. * @param scene defines the hosting scene
  59990. * @returns the decal mesh
  59991. * @see https://doc.babylonjs.com/how_to/decals
  59992. */
  59993. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59994. position?: Vector3;
  59995. normal?: Vector3;
  59996. size?: Vector3;
  59997. angle?: number;
  59998. }): Mesh;
  59999. }
  60000. }
  60001. declare module "babylonjs/Meshes/meshSimplification" {
  60002. import { Mesh } from "babylonjs/Meshes/mesh";
  60003. /**
  60004. * A simplifier interface for future simplification implementations
  60005. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60006. */
  60007. export interface ISimplifier {
  60008. /**
  60009. * Simplification of a given mesh according to the given settings.
  60010. * Since this requires computation, it is assumed that the function runs async.
  60011. * @param settings The settings of the simplification, including quality and distance
  60012. * @param successCallback A callback that will be called after the mesh was simplified.
  60013. * @param errorCallback in case of an error, this callback will be called. optional.
  60014. */
  60015. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60016. }
  60017. /**
  60018. * Expected simplification settings.
  60019. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60020. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60021. */
  60022. export interface ISimplificationSettings {
  60023. /**
  60024. * Gets or sets the expected quality
  60025. */
  60026. quality: number;
  60027. /**
  60028. * Gets or sets the distance when this optimized version should be used
  60029. */
  60030. distance: number;
  60031. /**
  60032. * Gets an already optimized mesh
  60033. */
  60034. optimizeMesh?: boolean;
  60035. }
  60036. /**
  60037. * Class used to specify simplification options
  60038. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60039. */
  60040. export class SimplificationSettings implements ISimplificationSettings {
  60041. /** expected quality */
  60042. quality: number;
  60043. /** distance when this optimized version should be used */
  60044. distance: number;
  60045. /** already optimized mesh */
  60046. optimizeMesh?: boolean | undefined;
  60047. /**
  60048. * Creates a SimplificationSettings
  60049. * @param quality expected quality
  60050. * @param distance distance when this optimized version should be used
  60051. * @param optimizeMesh already optimized mesh
  60052. */
  60053. constructor(
  60054. /** expected quality */
  60055. quality: number,
  60056. /** distance when this optimized version should be used */
  60057. distance: number,
  60058. /** already optimized mesh */
  60059. optimizeMesh?: boolean | undefined);
  60060. }
  60061. /**
  60062. * Interface used to define a simplification task
  60063. */
  60064. export interface ISimplificationTask {
  60065. /**
  60066. * Array of settings
  60067. */
  60068. settings: Array<ISimplificationSettings>;
  60069. /**
  60070. * Simplification type
  60071. */
  60072. simplificationType: SimplificationType;
  60073. /**
  60074. * Mesh to simplify
  60075. */
  60076. mesh: Mesh;
  60077. /**
  60078. * Callback called on success
  60079. */
  60080. successCallback?: () => void;
  60081. /**
  60082. * Defines if parallel processing can be used
  60083. */
  60084. parallelProcessing: boolean;
  60085. }
  60086. /**
  60087. * Queue used to order the simplification tasks
  60088. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60089. */
  60090. export class SimplificationQueue {
  60091. private _simplificationArray;
  60092. /**
  60093. * Gets a boolean indicating that the process is still running
  60094. */
  60095. running: boolean;
  60096. /**
  60097. * Creates a new queue
  60098. */
  60099. constructor();
  60100. /**
  60101. * Adds a new simplification task
  60102. * @param task defines a task to add
  60103. */
  60104. addTask(task: ISimplificationTask): void;
  60105. /**
  60106. * Execute next task
  60107. */
  60108. executeNext(): void;
  60109. /**
  60110. * Execute a simplification task
  60111. * @param task defines the task to run
  60112. */
  60113. runSimplification(task: ISimplificationTask): void;
  60114. private getSimplifier;
  60115. }
  60116. /**
  60117. * The implemented types of simplification
  60118. * At the moment only Quadratic Error Decimation is implemented
  60119. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60120. */
  60121. export enum SimplificationType {
  60122. /** Quadratic error decimation */
  60123. QUADRATIC = 0
  60124. }
  60125. }
  60126. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60127. import { Scene } from "babylonjs/scene";
  60128. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60129. import { ISceneComponent } from "babylonjs/sceneComponent";
  60130. module "babylonjs/scene" {
  60131. interface Scene {
  60132. /** @hidden (Backing field) */
  60133. _simplificationQueue: SimplificationQueue;
  60134. /**
  60135. * Gets or sets the simplification queue attached to the scene
  60136. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60137. */
  60138. simplificationQueue: SimplificationQueue;
  60139. }
  60140. }
  60141. module "babylonjs/Meshes/mesh" {
  60142. interface Mesh {
  60143. /**
  60144. * Simplify the mesh according to the given array of settings.
  60145. * Function will return immediately and will simplify async
  60146. * @param settings a collection of simplification settings
  60147. * @param parallelProcessing should all levels calculate parallel or one after the other
  60148. * @param simplificationType the type of simplification to run
  60149. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60150. * @returns the current mesh
  60151. */
  60152. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60153. }
  60154. }
  60155. /**
  60156. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60157. * created in a scene
  60158. */
  60159. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60160. /**
  60161. * The component name helpfull to identify the component in the list of scene components.
  60162. */
  60163. readonly name: string;
  60164. /**
  60165. * The scene the component belongs to.
  60166. */
  60167. scene: Scene;
  60168. /**
  60169. * Creates a new instance of the component for the given scene
  60170. * @param scene Defines the scene to register the component in
  60171. */
  60172. constructor(scene: Scene);
  60173. /**
  60174. * Registers the component in a given scene
  60175. */
  60176. register(): void;
  60177. /**
  60178. * Rebuilds the elements related to this component in case of
  60179. * context lost for instance.
  60180. */
  60181. rebuild(): void;
  60182. /**
  60183. * Disposes the component and the associated ressources
  60184. */
  60185. dispose(): void;
  60186. private _beforeCameraUpdate;
  60187. }
  60188. }
  60189. declare module "babylonjs/Meshes/Builders/index" {
  60190. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60191. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60192. export * from "babylonjs/Meshes/Builders/discBuilder";
  60193. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60194. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60195. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60196. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60197. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60198. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60199. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60200. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60201. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60202. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60203. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60204. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60205. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60206. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60207. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60208. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60209. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60210. }
  60211. declare module "babylonjs/Meshes/index" {
  60212. export * from "babylonjs/Meshes/abstractMesh";
  60213. export * from "babylonjs/Meshes/buffer";
  60214. export * from "babylonjs/Meshes/Compression/index";
  60215. export * from "babylonjs/Meshes/csg";
  60216. export * from "babylonjs/Meshes/geometry";
  60217. export * from "babylonjs/Meshes/groundMesh";
  60218. export * from "babylonjs/Meshes/trailMesh";
  60219. export * from "babylonjs/Meshes/instancedMesh";
  60220. export * from "babylonjs/Meshes/linesMesh";
  60221. export * from "babylonjs/Meshes/mesh";
  60222. export * from "babylonjs/Meshes/mesh.vertexData";
  60223. export * from "babylonjs/Meshes/meshBuilder";
  60224. export * from "babylonjs/Meshes/meshSimplification";
  60225. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60226. export * from "babylonjs/Meshes/polygonMesh";
  60227. export * from "babylonjs/Meshes/subMesh";
  60228. export * from "babylonjs/Meshes/meshLODLevel";
  60229. export * from "babylonjs/Meshes/transformNode";
  60230. export * from "babylonjs/Meshes/Builders/index";
  60231. export * from "babylonjs/Meshes/dataBuffer";
  60232. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60233. }
  60234. declare module "babylonjs/Morph/index" {
  60235. export * from "babylonjs/Morph/morphTarget";
  60236. export * from "babylonjs/Morph/morphTargetManager";
  60237. }
  60238. declare module "babylonjs/Navigation/INavigationEngine" {
  60239. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60240. import { Vector3 } from "babylonjs/Maths/math";
  60241. import { Mesh } from "babylonjs/Meshes/mesh";
  60242. import { Scene } from "babylonjs/scene";
  60243. /**
  60244. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60245. */
  60246. export interface INavigationEnginePlugin {
  60247. /**
  60248. * plugin name
  60249. */
  60250. name: string;
  60251. /**
  60252. * Creates a navigation mesh
  60253. * @param meshes array of all the geometry used to compute the navigatio mesh
  60254. * @param parameters bunch of parameters used to filter geometry
  60255. */
  60256. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60257. /**
  60258. * Create a navigation mesh debug mesh
  60259. * @param scene is where the mesh will be added
  60260. * @returns debug display mesh
  60261. */
  60262. createDebugNavMesh(scene: Scene): Mesh;
  60263. /**
  60264. * Get a navigation mesh constrained position, closest to the parameter position
  60265. * @param position world position
  60266. * @returns the closest point to position constrained by the navigation mesh
  60267. */
  60268. getClosestPoint(position: Vector3): Vector3;
  60269. /**
  60270. * Get a navigation mesh constrained position, within a particular radius
  60271. * @param position world position
  60272. * @param maxRadius the maximum distance to the constrained world position
  60273. * @returns the closest point to position constrained by the navigation mesh
  60274. */
  60275. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60276. /**
  60277. * Compute the final position from a segment made of destination-position
  60278. * @param position world position
  60279. * @param destination world position
  60280. * @returns the resulting point along the navmesh
  60281. */
  60282. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60283. /**
  60284. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60285. * @param start world position
  60286. * @param end world position
  60287. * @returns array containing world position composing the path
  60288. */
  60289. computePath(start: Vector3, end: Vector3): Vector3[];
  60290. /**
  60291. * If this plugin is supported
  60292. * @returns true if plugin is supported
  60293. */
  60294. isSupported(): boolean;
  60295. /**
  60296. * Create a new Crowd so you can add agents
  60297. * @param maxAgents the maximum agent count in the crowd
  60298. * @param maxAgentRadius the maximum radius an agent can have
  60299. * @param scene to attach the crowd to
  60300. * @returns the crowd you can add agents to
  60301. */
  60302. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60303. /**
  60304. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60305. * The queries will try to find a solution within those bounds
  60306. * default is (1,1,1)
  60307. * @param extent x,y,z value that define the extent around the queries point of reference
  60308. */
  60309. setDefaultQueryExtent(extent: Vector3): void;
  60310. /**
  60311. * Get the Bounding box extent specified by setDefaultQueryExtent
  60312. * @returns the box extent values
  60313. */
  60314. getDefaultQueryExtent(): Vector3;
  60315. /**
  60316. * Release all resources
  60317. */
  60318. dispose(): void;
  60319. }
  60320. /**
  60321. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60322. */
  60323. export interface ICrowd {
  60324. /**
  60325. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60326. * You can attach anything to that node. The node position is updated in the scene update tick.
  60327. * @param pos world position that will be constrained by the navigation mesh
  60328. * @param parameters agent parameters
  60329. * @param transform hooked to the agent that will be update by the scene
  60330. * @returns agent index
  60331. */
  60332. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60333. /**
  60334. * Returns the agent position in world space
  60335. * @param index agent index returned by addAgent
  60336. * @returns world space position
  60337. */
  60338. getAgentPosition(index: number): Vector3;
  60339. /**
  60340. * Gets the agent velocity in world space
  60341. * @param index agent index returned by addAgent
  60342. * @returns world space velocity
  60343. */
  60344. getAgentVelocity(index: number): Vector3;
  60345. /**
  60346. * remove a particular agent previously created
  60347. * @param index agent index returned by addAgent
  60348. */
  60349. removeAgent(index: number): void;
  60350. /**
  60351. * get the list of all agents attached to this crowd
  60352. * @returns list of agent indices
  60353. */
  60354. getAgents(): number[];
  60355. /**
  60356. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60357. * @param deltaTime in seconds
  60358. */
  60359. update(deltaTime: number): void;
  60360. /**
  60361. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60362. * @param index agent index returned by addAgent
  60363. * @param destination targeted world position
  60364. */
  60365. agentGoto(index: number, destination: Vector3): void;
  60366. /**
  60367. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60368. * The queries will try to find a solution within those bounds
  60369. * default is (1,1,1)
  60370. * @param extent x,y,z value that define the extent around the queries point of reference
  60371. */
  60372. setDefaultQueryExtent(extent: Vector3): void;
  60373. /**
  60374. * Get the Bounding box extent specified by setDefaultQueryExtent
  60375. * @returns the box extent values
  60376. */
  60377. getDefaultQueryExtent(): Vector3;
  60378. /**
  60379. * Release all resources
  60380. */
  60381. dispose(): void;
  60382. }
  60383. /**
  60384. * Configures an agent
  60385. */
  60386. export interface IAgentParameters {
  60387. /**
  60388. * Agent radius. [Limit: >= 0]
  60389. */
  60390. radius: number;
  60391. /**
  60392. * Agent height. [Limit: > 0]
  60393. */
  60394. height: number;
  60395. /**
  60396. * Maximum allowed acceleration. [Limit: >= 0]
  60397. */
  60398. maxAcceleration: number;
  60399. /**
  60400. * Maximum allowed speed. [Limit: >= 0]
  60401. */
  60402. maxSpeed: number;
  60403. /**
  60404. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60405. */
  60406. collisionQueryRange: number;
  60407. /**
  60408. * The path visibility optimization range. [Limit: > 0]
  60409. */
  60410. pathOptimizationRange: number;
  60411. /**
  60412. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60413. */
  60414. separationWeight: number;
  60415. }
  60416. /**
  60417. * Configures the navigation mesh creation
  60418. */
  60419. export interface INavMeshParameters {
  60420. /**
  60421. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60422. */
  60423. cs: number;
  60424. /**
  60425. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60426. */
  60427. ch: number;
  60428. /**
  60429. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60430. */
  60431. walkableSlopeAngle: number;
  60432. /**
  60433. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60434. * be considered walkable. [Limit: >= 3] [Units: vx]
  60435. */
  60436. walkableHeight: number;
  60437. /**
  60438. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60439. */
  60440. walkableClimb: number;
  60441. /**
  60442. * The distance to erode/shrink the walkable area of the heightfield away from
  60443. * obstructions. [Limit: >=0] [Units: vx]
  60444. */
  60445. walkableRadius: number;
  60446. /**
  60447. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60448. */
  60449. maxEdgeLen: number;
  60450. /**
  60451. * The maximum distance a simplfied contour's border edges should deviate
  60452. * the original raw contour. [Limit: >=0] [Units: vx]
  60453. */
  60454. maxSimplificationError: number;
  60455. /**
  60456. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60457. */
  60458. minRegionArea: number;
  60459. /**
  60460. * Any regions with a span count smaller than this value will, if possible,
  60461. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60462. */
  60463. mergeRegionArea: number;
  60464. /**
  60465. * The maximum number of vertices allowed for polygons generated during the
  60466. * contour to polygon conversion process. [Limit: >= 3]
  60467. */
  60468. maxVertsPerPoly: number;
  60469. /**
  60470. * Sets the sampling distance to use when generating the detail mesh.
  60471. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60472. */
  60473. detailSampleDist: number;
  60474. /**
  60475. * The maximum distance the detail mesh surface should deviate from heightfield
  60476. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60477. */
  60478. detailSampleMaxError: number;
  60479. }
  60480. }
  60481. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60482. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60483. import { Mesh } from "babylonjs/Meshes/mesh";
  60484. import { Scene } from "babylonjs/scene";
  60485. import { Vector3 } from "babylonjs/Maths/math";
  60486. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60487. /**
  60488. * RecastJS navigation plugin
  60489. */
  60490. export class RecastJSPlugin implements INavigationEnginePlugin {
  60491. /**
  60492. * Reference to the Recast library
  60493. */
  60494. bjsRECAST: any;
  60495. /**
  60496. * plugin name
  60497. */
  60498. name: string;
  60499. /**
  60500. * the first navmesh created. We might extend this to support multiple navmeshes
  60501. */
  60502. navMesh: any;
  60503. /**
  60504. * Initializes the recastJS plugin
  60505. * @param recastInjection can be used to inject your own recast reference
  60506. */
  60507. constructor(recastInjection?: any);
  60508. /**
  60509. * Creates a navigation mesh
  60510. * @param meshes array of all the geometry used to compute the navigatio mesh
  60511. * @param parameters bunch of parameters used to filter geometry
  60512. */
  60513. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60514. /**
  60515. * Create a navigation mesh debug mesh
  60516. * @param scene is where the mesh will be added
  60517. * @returns debug display mesh
  60518. */
  60519. createDebugNavMesh(scene: Scene): Mesh;
  60520. /**
  60521. * Get a navigation mesh constrained position, closest to the parameter position
  60522. * @param position world position
  60523. * @returns the closest point to position constrained by the navigation mesh
  60524. */
  60525. getClosestPoint(position: Vector3): Vector3;
  60526. /**
  60527. * Get a navigation mesh constrained position, within a particular radius
  60528. * @param position world position
  60529. * @param maxRadius the maximum distance to the constrained world position
  60530. * @returns the closest point to position constrained by the navigation mesh
  60531. */
  60532. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60533. /**
  60534. * Compute the final position from a segment made of destination-position
  60535. * @param position world position
  60536. * @param destination world position
  60537. * @returns the resulting point along the navmesh
  60538. */
  60539. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60540. /**
  60541. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60542. * @param start world position
  60543. * @param end world position
  60544. * @returns array containing world position composing the path
  60545. */
  60546. computePath(start: Vector3, end: Vector3): Vector3[];
  60547. /**
  60548. * Create a new Crowd so you can add agents
  60549. * @param maxAgents the maximum agent count in the crowd
  60550. * @param maxAgentRadius the maximum radius an agent can have
  60551. * @param scene to attach the crowd to
  60552. * @returns the crowd you can add agents to
  60553. */
  60554. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60555. /**
  60556. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60557. * The queries will try to find a solution within those bounds
  60558. * default is (1,1,1)
  60559. * @param extent x,y,z value that define the extent around the queries point of reference
  60560. */
  60561. setDefaultQueryExtent(extent: Vector3): void;
  60562. /**
  60563. * Get the Bounding box extent specified by setDefaultQueryExtent
  60564. * @returns the box extent values
  60565. */
  60566. getDefaultQueryExtent(): Vector3;
  60567. /**
  60568. * Disposes
  60569. */
  60570. dispose(): void;
  60571. /**
  60572. * If this plugin is supported
  60573. * @returns true if plugin is supported
  60574. */
  60575. isSupported(): boolean;
  60576. }
  60577. /**
  60578. * Recast detour crowd implementation
  60579. */
  60580. export class RecastJSCrowd implements ICrowd {
  60581. /**
  60582. * Recast/detour plugin
  60583. */
  60584. bjsRECASTPlugin: RecastJSPlugin;
  60585. /**
  60586. * Link to the detour crowd
  60587. */
  60588. recastCrowd: any;
  60589. /**
  60590. * One transform per agent
  60591. */
  60592. transforms: TransformNode[];
  60593. /**
  60594. * All agents created
  60595. */
  60596. agents: number[];
  60597. /**
  60598. * Link to the scene is kept to unregister the crowd from the scene
  60599. */
  60600. private _scene;
  60601. /**
  60602. * Observer for crowd updates
  60603. */
  60604. private _onBeforeAnimationsObserver;
  60605. /**
  60606. * Constructor
  60607. * @param plugin recastJS plugin
  60608. * @param maxAgents the maximum agent count in the crowd
  60609. * @param maxAgentRadius the maximum radius an agent can have
  60610. * @param scene to attach the crowd to
  60611. * @returns the crowd you can add agents to
  60612. */
  60613. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60614. /**
  60615. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60616. * You can attach anything to that node. The node position is updated in the scene update tick.
  60617. * @param pos world position that will be constrained by the navigation mesh
  60618. * @param parameters agent parameters
  60619. * @param transform hooked to the agent that will be update by the scene
  60620. * @returns agent index
  60621. */
  60622. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60623. /**
  60624. * Returns the agent position in world space
  60625. * @param index agent index returned by addAgent
  60626. * @returns world space position
  60627. */
  60628. getAgentPosition(index: number): Vector3;
  60629. /**
  60630. * Returns the agent velocity in world space
  60631. * @param index agent index returned by addAgent
  60632. * @returns world space velocity
  60633. */
  60634. getAgentVelocity(index: number): Vector3;
  60635. /**
  60636. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60637. * @param index agent index returned by addAgent
  60638. * @param destination targeted world position
  60639. */
  60640. agentGoto(index: number, destination: Vector3): void;
  60641. /**
  60642. * remove a particular agent previously created
  60643. * @param index agent index returned by addAgent
  60644. */
  60645. removeAgent(index: number): void;
  60646. /**
  60647. * get the list of all agents attached to this crowd
  60648. * @returns list of agent indices
  60649. */
  60650. getAgents(): number[];
  60651. /**
  60652. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60653. * @param deltaTime in seconds
  60654. */
  60655. update(deltaTime: number): void;
  60656. /**
  60657. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60658. * The queries will try to find a solution within those bounds
  60659. * default is (1,1,1)
  60660. * @param extent x,y,z value that define the extent around the queries point of reference
  60661. */
  60662. setDefaultQueryExtent(extent: Vector3): void;
  60663. /**
  60664. * Get the Bounding box extent specified by setDefaultQueryExtent
  60665. * @returns the box extent values
  60666. */
  60667. getDefaultQueryExtent(): Vector3;
  60668. /**
  60669. * Release all resources
  60670. */
  60671. dispose(): void;
  60672. }
  60673. }
  60674. declare module "babylonjs/Navigation/Plugins/index" {
  60675. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  60676. }
  60677. declare module "babylonjs/Navigation/index" {
  60678. export * from "babylonjs/Navigation/INavigationEngine";
  60679. export * from "babylonjs/Navigation/Plugins/index";
  60680. }
  60681. declare module "babylonjs/Offline/database" {
  60682. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  60683. /**
  60684. * Class used to enable access to IndexedDB
  60685. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60686. */
  60687. export class Database implements IOfflineProvider {
  60688. private _callbackManifestChecked;
  60689. private _currentSceneUrl;
  60690. private _db;
  60691. private _enableSceneOffline;
  60692. private _enableTexturesOffline;
  60693. private _manifestVersionFound;
  60694. private _mustUpdateRessources;
  60695. private _hasReachedQuota;
  60696. private _isSupported;
  60697. private _idbFactory;
  60698. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60699. private static IsUASupportingBlobStorage;
  60700. /**
  60701. * Gets a boolean indicating if Database storate is enabled (off by default)
  60702. */
  60703. static IDBStorageEnabled: boolean;
  60704. /**
  60705. * Gets a boolean indicating if scene must be saved in the database
  60706. */
  60707. readonly enableSceneOffline: boolean;
  60708. /**
  60709. * Gets a boolean indicating if textures must be saved in the database
  60710. */
  60711. readonly enableTexturesOffline: boolean;
  60712. /**
  60713. * Creates a new Database
  60714. * @param urlToScene defines the url to load the scene
  60715. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60716. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60717. */
  60718. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60719. private static _ParseURL;
  60720. private static _ReturnFullUrlLocation;
  60721. private _checkManifestFile;
  60722. /**
  60723. * Open the database and make it available
  60724. * @param successCallback defines the callback to call on success
  60725. * @param errorCallback defines the callback to call on error
  60726. */
  60727. open(successCallback: () => void, errorCallback: () => void): void;
  60728. /**
  60729. * Loads an image from the database
  60730. * @param url defines the url to load from
  60731. * @param image defines the target DOM image
  60732. */
  60733. loadImage(url: string, image: HTMLImageElement): void;
  60734. private _loadImageFromDBAsync;
  60735. private _saveImageIntoDBAsync;
  60736. private _checkVersionFromDB;
  60737. private _loadVersionFromDBAsync;
  60738. private _saveVersionIntoDBAsync;
  60739. /**
  60740. * Loads a file from database
  60741. * @param url defines the URL to load from
  60742. * @param sceneLoaded defines a callback to call on success
  60743. * @param progressCallBack defines a callback to call when progress changed
  60744. * @param errorCallback defines a callback to call on error
  60745. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60746. */
  60747. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60748. private _loadFileAsync;
  60749. private _saveFileAsync;
  60750. /**
  60751. * Validates if xhr data is correct
  60752. * @param xhr defines the request to validate
  60753. * @param dataType defines the expected data type
  60754. * @returns true if data is correct
  60755. */
  60756. private static _ValidateXHRData;
  60757. }
  60758. }
  60759. declare module "babylonjs/Offline/index" {
  60760. export * from "babylonjs/Offline/database";
  60761. export * from "babylonjs/Offline/IOfflineProvider";
  60762. }
  60763. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  60764. /** @hidden */
  60765. export var gpuUpdateParticlesPixelShader: {
  60766. name: string;
  60767. shader: string;
  60768. };
  60769. }
  60770. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  60771. /** @hidden */
  60772. export var gpuUpdateParticlesVertexShader: {
  60773. name: string;
  60774. shader: string;
  60775. };
  60776. }
  60777. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  60778. /** @hidden */
  60779. export var clipPlaneFragmentDeclaration2: {
  60780. name: string;
  60781. shader: string;
  60782. };
  60783. }
  60784. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  60785. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  60786. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60787. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60788. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60789. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60790. /** @hidden */
  60791. export var gpuRenderParticlesPixelShader: {
  60792. name: string;
  60793. shader: string;
  60794. };
  60795. }
  60796. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  60797. /** @hidden */
  60798. export var clipPlaneVertexDeclaration2: {
  60799. name: string;
  60800. shader: string;
  60801. };
  60802. }
  60803. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  60804. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  60805. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60806. /** @hidden */
  60807. export var gpuRenderParticlesVertexShader: {
  60808. name: string;
  60809. shader: string;
  60810. };
  60811. }
  60812. declare module "babylonjs/Particles/gpuParticleSystem" {
  60813. import { Nullable } from "babylonjs/types";
  60814. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  60815. import { Observable } from "babylonjs/Misc/observable";
  60816. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60817. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60818. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  60819. import { Scene, IDisposable } from "babylonjs/scene";
  60820. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  60821. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60822. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  60823. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  60824. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  60825. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  60826. /**
  60827. * This represents a GPU particle system in Babylon
  60828. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60829. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60830. */
  60831. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60832. /**
  60833. * The layer mask we are rendering the particles through.
  60834. */
  60835. layerMask: number;
  60836. private _capacity;
  60837. private _activeCount;
  60838. private _currentActiveCount;
  60839. private _accumulatedCount;
  60840. private _renderEffect;
  60841. private _updateEffect;
  60842. private _buffer0;
  60843. private _buffer1;
  60844. private _spriteBuffer;
  60845. private _updateVAO;
  60846. private _renderVAO;
  60847. private _targetIndex;
  60848. private _sourceBuffer;
  60849. private _targetBuffer;
  60850. private _engine;
  60851. private _currentRenderId;
  60852. private _started;
  60853. private _stopped;
  60854. private _timeDelta;
  60855. private _randomTexture;
  60856. private _randomTexture2;
  60857. private _attributesStrideSize;
  60858. private _updateEffectOptions;
  60859. private _randomTextureSize;
  60860. private _actualFrame;
  60861. private readonly _rawTextureWidth;
  60862. /**
  60863. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60864. */
  60865. static readonly IsSupported: boolean;
  60866. /**
  60867. * An event triggered when the system is disposed.
  60868. */
  60869. onDisposeObservable: Observable<GPUParticleSystem>;
  60870. /**
  60871. * Gets the maximum number of particles active at the same time.
  60872. * @returns The max number of active particles.
  60873. */
  60874. getCapacity(): number;
  60875. /**
  60876. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60877. * to override the particles.
  60878. */
  60879. forceDepthWrite: boolean;
  60880. /**
  60881. * Gets or set the number of active particles
  60882. */
  60883. activeParticleCount: number;
  60884. private _preWarmDone;
  60885. /**
  60886. * Is this system ready to be used/rendered
  60887. * @return true if the system is ready
  60888. */
  60889. isReady(): boolean;
  60890. /**
  60891. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60892. * @returns True if it has been started, otherwise false.
  60893. */
  60894. isStarted(): boolean;
  60895. /**
  60896. * Starts the particle system and begins to emit
  60897. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60898. */
  60899. start(delay?: number): void;
  60900. /**
  60901. * Stops the particle system.
  60902. */
  60903. stop(): void;
  60904. /**
  60905. * Remove all active particles
  60906. */
  60907. reset(): void;
  60908. /**
  60909. * Returns the string "GPUParticleSystem"
  60910. * @returns a string containing the class name
  60911. */
  60912. getClassName(): string;
  60913. private _colorGradientsTexture;
  60914. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60915. /**
  60916. * Adds a new color gradient
  60917. * @param gradient defines the gradient to use (between 0 and 1)
  60918. * @param color1 defines the color to affect to the specified gradient
  60919. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60920. * @returns the current particle system
  60921. */
  60922. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60923. /**
  60924. * Remove a specific color gradient
  60925. * @param gradient defines the gradient to remove
  60926. * @returns the current particle system
  60927. */
  60928. removeColorGradient(gradient: number): GPUParticleSystem;
  60929. private _angularSpeedGradientsTexture;
  60930. private _sizeGradientsTexture;
  60931. private _velocityGradientsTexture;
  60932. private _limitVelocityGradientsTexture;
  60933. private _dragGradientsTexture;
  60934. private _addFactorGradient;
  60935. /**
  60936. * Adds a new size gradient
  60937. * @param gradient defines the gradient to use (between 0 and 1)
  60938. * @param factor defines the size factor to affect to the specified gradient
  60939. * @returns the current particle system
  60940. */
  60941. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60942. /**
  60943. * Remove a specific size gradient
  60944. * @param gradient defines the gradient to remove
  60945. * @returns the current particle system
  60946. */
  60947. removeSizeGradient(gradient: number): GPUParticleSystem;
  60948. /**
  60949. * Adds a new angular speed gradient
  60950. * @param gradient defines the gradient to use (between 0 and 1)
  60951. * @param factor defines the angular speed to affect to the specified gradient
  60952. * @returns the current particle system
  60953. */
  60954. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60955. /**
  60956. * Remove a specific angular speed gradient
  60957. * @param gradient defines the gradient to remove
  60958. * @returns the current particle system
  60959. */
  60960. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60961. /**
  60962. * Adds a new velocity gradient
  60963. * @param gradient defines the gradient to use (between 0 and 1)
  60964. * @param factor defines the velocity to affect to the specified gradient
  60965. * @returns the current particle system
  60966. */
  60967. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60968. /**
  60969. * Remove a specific velocity gradient
  60970. * @param gradient defines the gradient to remove
  60971. * @returns the current particle system
  60972. */
  60973. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60974. /**
  60975. * Adds a new limit velocity gradient
  60976. * @param gradient defines the gradient to use (between 0 and 1)
  60977. * @param factor defines the limit velocity value to affect to the specified gradient
  60978. * @returns the current particle system
  60979. */
  60980. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60981. /**
  60982. * Remove a specific limit velocity gradient
  60983. * @param gradient defines the gradient to remove
  60984. * @returns the current particle system
  60985. */
  60986. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60987. /**
  60988. * Adds a new drag gradient
  60989. * @param gradient defines the gradient to use (between 0 and 1)
  60990. * @param factor defines the drag value to affect to the specified gradient
  60991. * @returns the current particle system
  60992. */
  60993. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60994. /**
  60995. * Remove a specific drag gradient
  60996. * @param gradient defines the gradient to remove
  60997. * @returns the current particle system
  60998. */
  60999. removeDragGradient(gradient: number): GPUParticleSystem;
  61000. /**
  61001. * Not supported by GPUParticleSystem
  61002. * @param gradient defines the gradient to use (between 0 and 1)
  61003. * @param factor defines the emit rate value to affect to the specified gradient
  61004. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61005. * @returns the current particle system
  61006. */
  61007. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61008. /**
  61009. * Not supported by GPUParticleSystem
  61010. * @param gradient defines the gradient to remove
  61011. * @returns the current particle system
  61012. */
  61013. removeEmitRateGradient(gradient: number): IParticleSystem;
  61014. /**
  61015. * Not supported by GPUParticleSystem
  61016. * @param gradient defines the gradient to use (between 0 and 1)
  61017. * @param factor defines the start size value to affect to the specified gradient
  61018. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61019. * @returns the current particle system
  61020. */
  61021. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61022. /**
  61023. * Not supported by GPUParticleSystem
  61024. * @param gradient defines the gradient to remove
  61025. * @returns the current particle system
  61026. */
  61027. removeStartSizeGradient(gradient: number): IParticleSystem;
  61028. /**
  61029. * Not supported by GPUParticleSystem
  61030. * @param gradient defines the gradient to use (between 0 and 1)
  61031. * @param min defines the color remap minimal range
  61032. * @param max defines the color remap maximal range
  61033. * @returns the current particle system
  61034. */
  61035. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61036. /**
  61037. * Not supported by GPUParticleSystem
  61038. * @param gradient defines the gradient to remove
  61039. * @returns the current particle system
  61040. */
  61041. removeColorRemapGradient(): IParticleSystem;
  61042. /**
  61043. * Not supported by GPUParticleSystem
  61044. * @param gradient defines the gradient to use (between 0 and 1)
  61045. * @param min defines the alpha remap minimal range
  61046. * @param max defines the alpha remap maximal range
  61047. * @returns the current particle system
  61048. */
  61049. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61050. /**
  61051. * Not supported by GPUParticleSystem
  61052. * @param gradient defines the gradient to remove
  61053. * @returns the current particle system
  61054. */
  61055. removeAlphaRemapGradient(): IParticleSystem;
  61056. /**
  61057. * Not supported by GPUParticleSystem
  61058. * @param gradient defines the gradient to use (between 0 and 1)
  61059. * @param color defines the color to affect to the specified gradient
  61060. * @returns the current particle system
  61061. */
  61062. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61063. /**
  61064. * Not supported by GPUParticleSystem
  61065. * @param gradient defines the gradient to remove
  61066. * @returns the current particle system
  61067. */
  61068. removeRampGradient(): IParticleSystem;
  61069. /**
  61070. * Not supported by GPUParticleSystem
  61071. * @returns the list of ramp gradients
  61072. */
  61073. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61074. /**
  61075. * Not supported by GPUParticleSystem
  61076. * Gets or sets a boolean indicating that ramp gradients must be used
  61077. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61078. */
  61079. useRampGradients: boolean;
  61080. /**
  61081. * Not supported by GPUParticleSystem
  61082. * @param gradient defines the gradient to use (between 0 and 1)
  61083. * @param factor defines the life time factor to affect to the specified gradient
  61084. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61085. * @returns the current particle system
  61086. */
  61087. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61088. /**
  61089. * Not supported by GPUParticleSystem
  61090. * @param gradient defines the gradient to remove
  61091. * @returns the current particle system
  61092. */
  61093. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61094. /**
  61095. * Instantiates a GPU particle system.
  61096. * 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.
  61097. * @param name The name of the particle system
  61098. * @param options The options used to create the system
  61099. * @param scene The scene the particle system belongs to
  61100. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61101. */
  61102. constructor(name: string, options: Partial<{
  61103. capacity: number;
  61104. randomTextureSize: number;
  61105. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61106. protected _reset(): void;
  61107. private _createUpdateVAO;
  61108. private _createRenderVAO;
  61109. private _initialize;
  61110. /** @hidden */
  61111. _recreateUpdateEffect(): void;
  61112. /** @hidden */
  61113. _recreateRenderEffect(): void;
  61114. /**
  61115. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61116. * @param preWarm defines if we are in the pre-warmimg phase
  61117. */
  61118. animate(preWarm?: boolean): void;
  61119. private _createFactorGradientTexture;
  61120. private _createSizeGradientTexture;
  61121. private _createAngularSpeedGradientTexture;
  61122. private _createVelocityGradientTexture;
  61123. private _createLimitVelocityGradientTexture;
  61124. private _createDragGradientTexture;
  61125. private _createColorGradientTexture;
  61126. /**
  61127. * Renders the particle system in its current state
  61128. * @param preWarm defines if the system should only update the particles but not render them
  61129. * @returns the current number of particles
  61130. */
  61131. render(preWarm?: boolean): number;
  61132. /**
  61133. * Rebuilds the particle system
  61134. */
  61135. rebuild(): void;
  61136. private _releaseBuffers;
  61137. private _releaseVAOs;
  61138. /**
  61139. * Disposes the particle system and free the associated resources
  61140. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61141. */
  61142. dispose(disposeTexture?: boolean): void;
  61143. /**
  61144. * Clones the particle system.
  61145. * @param name The name of the cloned object
  61146. * @param newEmitter The new emitter to use
  61147. * @returns the cloned particle system
  61148. */
  61149. clone(name: string, newEmitter: any): GPUParticleSystem;
  61150. /**
  61151. * Serializes the particle system to a JSON object.
  61152. * @returns the JSON object
  61153. */
  61154. serialize(): any;
  61155. /**
  61156. * Parses a JSON object to create a GPU particle system.
  61157. * @param parsedParticleSystem The JSON object to parse
  61158. * @param scene The scene to create the particle system in
  61159. * @param rootUrl The root url to use to load external dependencies like texture
  61160. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61161. * @returns the parsed GPU particle system
  61162. */
  61163. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61164. }
  61165. }
  61166. declare module "babylonjs/Particles/particleSystemSet" {
  61167. import { Nullable } from "babylonjs/types";
  61168. import { Color3 } from "babylonjs/Maths/math.color";
  61169. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61171. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61172. import { Scene, IDisposable } from "babylonjs/scene";
  61173. /**
  61174. * Represents a set of particle systems working together to create a specific effect
  61175. */
  61176. export class ParticleSystemSet implements IDisposable {
  61177. private _emitterCreationOptions;
  61178. private _emitterNode;
  61179. /**
  61180. * Gets the particle system list
  61181. */
  61182. systems: IParticleSystem[];
  61183. /**
  61184. * Gets the emitter node used with this set
  61185. */
  61186. readonly emitterNode: Nullable<TransformNode>;
  61187. /**
  61188. * Creates a new emitter mesh as a sphere
  61189. * @param options defines the options used to create the sphere
  61190. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61191. * @param scene defines the hosting scene
  61192. */
  61193. setEmitterAsSphere(options: {
  61194. diameter: number;
  61195. segments: number;
  61196. color: Color3;
  61197. }, renderingGroupId: number, scene: Scene): void;
  61198. /**
  61199. * Starts all particle systems of the set
  61200. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61201. */
  61202. start(emitter?: AbstractMesh): void;
  61203. /**
  61204. * Release all associated resources
  61205. */
  61206. dispose(): void;
  61207. /**
  61208. * Serialize the set into a JSON compatible object
  61209. * @returns a JSON compatible representation of the set
  61210. */
  61211. serialize(): any;
  61212. /**
  61213. * Parse a new ParticleSystemSet from a serialized source
  61214. * @param data defines a JSON compatible representation of the set
  61215. * @param scene defines the hosting scene
  61216. * @param gpu defines if we want GPU particles or CPU particles
  61217. * @returns a new ParticleSystemSet
  61218. */
  61219. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61220. }
  61221. }
  61222. declare module "babylonjs/Particles/particleHelper" {
  61223. import { Nullable } from "babylonjs/types";
  61224. import { Scene } from "babylonjs/scene";
  61225. import { Vector3 } from "babylonjs/Maths/math.vector";
  61226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61227. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61228. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61229. /**
  61230. * This class is made for on one-liner static method to help creating particle system set.
  61231. */
  61232. export class ParticleHelper {
  61233. /**
  61234. * Gets or sets base Assets URL
  61235. */
  61236. static BaseAssetsUrl: string;
  61237. /**
  61238. * Create a default particle system that you can tweak
  61239. * @param emitter defines the emitter to use
  61240. * @param capacity defines the system capacity (default is 500 particles)
  61241. * @param scene defines the hosting scene
  61242. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61243. * @returns the new Particle system
  61244. */
  61245. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61246. /**
  61247. * This is the main static method (one-liner) of this helper to create different particle systems
  61248. * @param type This string represents the type to the particle system to create
  61249. * @param scene The scene where the particle system should live
  61250. * @param gpu If the system will use gpu
  61251. * @returns the ParticleSystemSet created
  61252. */
  61253. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61254. /**
  61255. * Static function used to export a particle system to a ParticleSystemSet variable.
  61256. * Please note that the emitter shape is not exported
  61257. * @param systems defines the particle systems to export
  61258. * @returns the created particle system set
  61259. */
  61260. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61261. }
  61262. }
  61263. declare module "babylonjs/Particles/particleSystemComponent" {
  61264. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61265. import { Effect } from "babylonjs/Materials/effect";
  61266. import "babylonjs/Shaders/particles.vertex";
  61267. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61268. module "babylonjs/Engines/engine" {
  61269. interface Engine {
  61270. /**
  61271. * Create an effect to use with particle systems.
  61272. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61273. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61274. * @param uniformsNames defines a list of attribute names
  61275. * @param samplers defines an array of string used to represent textures
  61276. * @param defines defines the string containing the defines to use to compile the shaders
  61277. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61278. * @param onCompiled defines a function to call when the effect creation is successful
  61279. * @param onError defines a function to call when the effect creation has failed
  61280. * @returns the new Effect
  61281. */
  61282. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61283. }
  61284. }
  61285. module "babylonjs/Meshes/mesh" {
  61286. interface Mesh {
  61287. /**
  61288. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61289. * @returns an array of IParticleSystem
  61290. */
  61291. getEmittedParticleSystems(): IParticleSystem[];
  61292. /**
  61293. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61294. * @returns an array of IParticleSystem
  61295. */
  61296. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61297. }
  61298. }
  61299. /**
  61300. * @hidden
  61301. */
  61302. export var _IDoNeedToBeInTheBuild: number;
  61303. }
  61304. declare module "babylonjs/Particles/index" {
  61305. export * from "babylonjs/Particles/baseParticleSystem";
  61306. export * from "babylonjs/Particles/EmitterTypes/index";
  61307. export * from "babylonjs/Particles/gpuParticleSystem";
  61308. export * from "babylonjs/Particles/IParticleSystem";
  61309. export * from "babylonjs/Particles/particle";
  61310. export * from "babylonjs/Particles/particleHelper";
  61311. export * from "babylonjs/Particles/particleSystem";
  61312. export * from "babylonjs/Particles/particleSystemComponent";
  61313. export * from "babylonjs/Particles/particleSystemSet";
  61314. export * from "babylonjs/Particles/solidParticle";
  61315. export * from "babylonjs/Particles/solidParticleSystem";
  61316. export * from "babylonjs/Particles/subEmitter";
  61317. }
  61318. declare module "babylonjs/Physics/physicsEngineComponent" {
  61319. import { Nullable } from "babylonjs/types";
  61320. import { Observable, Observer } from "babylonjs/Misc/observable";
  61321. import { Vector3 } from "babylonjs/Maths/math.vector";
  61322. import { Mesh } from "babylonjs/Meshes/mesh";
  61323. import { ISceneComponent } from "babylonjs/sceneComponent";
  61324. import { Scene } from "babylonjs/scene";
  61325. import { Node } from "babylonjs/node";
  61326. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61327. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61328. module "babylonjs/scene" {
  61329. interface Scene {
  61330. /** @hidden (Backing field) */
  61331. _physicsEngine: Nullable<IPhysicsEngine>;
  61332. /**
  61333. * Gets the current physics engine
  61334. * @returns a IPhysicsEngine or null if none attached
  61335. */
  61336. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61337. /**
  61338. * Enables physics to the current scene
  61339. * @param gravity defines the scene's gravity for the physics engine
  61340. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61341. * @return a boolean indicating if the physics engine was initialized
  61342. */
  61343. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61344. /**
  61345. * Disables and disposes the physics engine associated with the scene
  61346. */
  61347. disablePhysicsEngine(): void;
  61348. /**
  61349. * Gets a boolean indicating if there is an active physics engine
  61350. * @returns a boolean indicating if there is an active physics engine
  61351. */
  61352. isPhysicsEnabled(): boolean;
  61353. /**
  61354. * Deletes a physics compound impostor
  61355. * @param compound defines the compound to delete
  61356. */
  61357. deleteCompoundImpostor(compound: any): void;
  61358. /**
  61359. * An event triggered when physic simulation is about to be run
  61360. */
  61361. onBeforePhysicsObservable: Observable<Scene>;
  61362. /**
  61363. * An event triggered when physic simulation has been done
  61364. */
  61365. onAfterPhysicsObservable: Observable<Scene>;
  61366. }
  61367. }
  61368. module "babylonjs/Meshes/abstractMesh" {
  61369. interface AbstractMesh {
  61370. /** @hidden */
  61371. _physicsImpostor: Nullable<PhysicsImpostor>;
  61372. /**
  61373. * Gets or sets impostor used for physic simulation
  61374. * @see http://doc.babylonjs.com/features/physics_engine
  61375. */
  61376. physicsImpostor: Nullable<PhysicsImpostor>;
  61377. /**
  61378. * Gets the current physics impostor
  61379. * @see http://doc.babylonjs.com/features/physics_engine
  61380. * @returns a physics impostor or null
  61381. */
  61382. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61383. /** Apply a physic impulse to the mesh
  61384. * @param force defines the force to apply
  61385. * @param contactPoint defines where to apply the force
  61386. * @returns the current mesh
  61387. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61388. */
  61389. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61390. /**
  61391. * Creates a physic joint between two meshes
  61392. * @param otherMesh defines the other mesh to use
  61393. * @param pivot1 defines the pivot to use on this mesh
  61394. * @param pivot2 defines the pivot to use on the other mesh
  61395. * @param options defines additional options (can be plugin dependent)
  61396. * @returns the current mesh
  61397. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61398. */
  61399. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61400. /** @hidden */
  61401. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61402. }
  61403. }
  61404. /**
  61405. * Defines the physics engine scene component responsible to manage a physics engine
  61406. */
  61407. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61408. /**
  61409. * The component name helpful to identify the component in the list of scene components.
  61410. */
  61411. readonly name: string;
  61412. /**
  61413. * The scene the component belongs to.
  61414. */
  61415. scene: Scene;
  61416. /**
  61417. * Creates a new instance of the component for the given scene
  61418. * @param scene Defines the scene to register the component in
  61419. */
  61420. constructor(scene: Scene);
  61421. /**
  61422. * Registers the component in a given scene
  61423. */
  61424. register(): void;
  61425. /**
  61426. * Rebuilds the elements related to this component in case of
  61427. * context lost for instance.
  61428. */
  61429. rebuild(): void;
  61430. /**
  61431. * Disposes the component and the associated ressources
  61432. */
  61433. dispose(): void;
  61434. }
  61435. }
  61436. declare module "babylonjs/Physics/physicsHelper" {
  61437. import { Nullable } from "babylonjs/types";
  61438. import { Vector3 } from "babylonjs/Maths/math.vector";
  61439. import { Mesh } from "babylonjs/Meshes/mesh";
  61440. import { Scene } from "babylonjs/scene";
  61441. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61442. /**
  61443. * A helper for physics simulations
  61444. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61445. */
  61446. export class PhysicsHelper {
  61447. private _scene;
  61448. private _physicsEngine;
  61449. /**
  61450. * Initializes the Physics helper
  61451. * @param scene Babylon.js scene
  61452. */
  61453. constructor(scene: Scene);
  61454. /**
  61455. * Applies a radial explosion impulse
  61456. * @param origin the origin of the explosion
  61457. * @param radiusOrEventOptions the radius or the options of radial explosion
  61458. * @param strength the explosion strength
  61459. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61460. * @returns A physics radial explosion event, or null
  61461. */
  61462. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61463. /**
  61464. * Applies a radial explosion force
  61465. * @param origin the origin of the explosion
  61466. * @param radiusOrEventOptions the radius or the options of radial explosion
  61467. * @param strength the explosion strength
  61468. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61469. * @returns A physics radial explosion event, or null
  61470. */
  61471. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61472. /**
  61473. * Creates a gravitational field
  61474. * @param origin the origin of the explosion
  61475. * @param radiusOrEventOptions the radius or the options of radial explosion
  61476. * @param strength the explosion strength
  61477. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61478. * @returns A physics gravitational field event, or null
  61479. */
  61480. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61481. /**
  61482. * Creates a physics updraft event
  61483. * @param origin the origin of the updraft
  61484. * @param radiusOrEventOptions the radius or the options of the updraft
  61485. * @param strength the strength of the updraft
  61486. * @param height the height of the updraft
  61487. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61488. * @returns A physics updraft event, or null
  61489. */
  61490. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61491. /**
  61492. * Creates a physics vortex event
  61493. * @param origin the of the vortex
  61494. * @param radiusOrEventOptions the radius or the options of the vortex
  61495. * @param strength the strength of the vortex
  61496. * @param height the height of the vortex
  61497. * @returns a Physics vortex event, or null
  61498. * A physics vortex event or null
  61499. */
  61500. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61501. }
  61502. /**
  61503. * Represents a physics radial explosion event
  61504. */
  61505. class PhysicsRadialExplosionEvent {
  61506. private _scene;
  61507. private _options;
  61508. private _sphere;
  61509. private _dataFetched;
  61510. /**
  61511. * Initializes a radial explosioin event
  61512. * @param _scene BabylonJS scene
  61513. * @param _options The options for the vortex event
  61514. */
  61515. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61516. /**
  61517. * Returns the data related to the radial explosion event (sphere).
  61518. * @returns The radial explosion event data
  61519. */
  61520. getData(): PhysicsRadialExplosionEventData;
  61521. /**
  61522. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61523. * @param impostor A physics imposter
  61524. * @param origin the origin of the explosion
  61525. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61526. */
  61527. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61528. /**
  61529. * Triggers affecterd impostors callbacks
  61530. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61531. */
  61532. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61533. /**
  61534. * Disposes the sphere.
  61535. * @param force Specifies if the sphere should be disposed by force
  61536. */
  61537. dispose(force?: boolean): void;
  61538. /*** Helpers ***/
  61539. private _prepareSphere;
  61540. private _intersectsWithSphere;
  61541. }
  61542. /**
  61543. * Represents a gravitational field event
  61544. */
  61545. class PhysicsGravitationalFieldEvent {
  61546. private _physicsHelper;
  61547. private _scene;
  61548. private _origin;
  61549. private _options;
  61550. private _tickCallback;
  61551. private _sphere;
  61552. private _dataFetched;
  61553. /**
  61554. * Initializes the physics gravitational field event
  61555. * @param _physicsHelper A physics helper
  61556. * @param _scene BabylonJS scene
  61557. * @param _origin The origin position of the gravitational field event
  61558. * @param _options The options for the vortex event
  61559. */
  61560. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61561. /**
  61562. * Returns the data related to the gravitational field event (sphere).
  61563. * @returns A gravitational field event
  61564. */
  61565. getData(): PhysicsGravitationalFieldEventData;
  61566. /**
  61567. * Enables the gravitational field.
  61568. */
  61569. enable(): void;
  61570. /**
  61571. * Disables the gravitational field.
  61572. */
  61573. disable(): void;
  61574. /**
  61575. * Disposes the sphere.
  61576. * @param force The force to dispose from the gravitational field event
  61577. */
  61578. dispose(force?: boolean): void;
  61579. private _tick;
  61580. }
  61581. /**
  61582. * Represents a physics updraft event
  61583. */
  61584. class PhysicsUpdraftEvent {
  61585. private _scene;
  61586. private _origin;
  61587. private _options;
  61588. private _physicsEngine;
  61589. private _originTop;
  61590. private _originDirection;
  61591. private _tickCallback;
  61592. private _cylinder;
  61593. private _cylinderPosition;
  61594. private _dataFetched;
  61595. /**
  61596. * Initializes the physics updraft event
  61597. * @param _scene BabylonJS scene
  61598. * @param _origin The origin position of the updraft
  61599. * @param _options The options for the updraft event
  61600. */
  61601. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61602. /**
  61603. * Returns the data related to the updraft event (cylinder).
  61604. * @returns A physics updraft event
  61605. */
  61606. getData(): PhysicsUpdraftEventData;
  61607. /**
  61608. * Enables the updraft.
  61609. */
  61610. enable(): void;
  61611. /**
  61612. * Disables the updraft.
  61613. */
  61614. disable(): void;
  61615. /**
  61616. * Disposes the cylinder.
  61617. * @param force Specifies if the updraft should be disposed by force
  61618. */
  61619. dispose(force?: boolean): void;
  61620. private getImpostorHitData;
  61621. private _tick;
  61622. /*** Helpers ***/
  61623. private _prepareCylinder;
  61624. private _intersectsWithCylinder;
  61625. }
  61626. /**
  61627. * Represents a physics vortex event
  61628. */
  61629. class PhysicsVortexEvent {
  61630. private _scene;
  61631. private _origin;
  61632. private _options;
  61633. private _physicsEngine;
  61634. private _originTop;
  61635. private _tickCallback;
  61636. private _cylinder;
  61637. private _cylinderPosition;
  61638. private _dataFetched;
  61639. /**
  61640. * Initializes the physics vortex event
  61641. * @param _scene The BabylonJS scene
  61642. * @param _origin The origin position of the vortex
  61643. * @param _options The options for the vortex event
  61644. */
  61645. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61646. /**
  61647. * Returns the data related to the vortex event (cylinder).
  61648. * @returns The physics vortex event data
  61649. */
  61650. getData(): PhysicsVortexEventData;
  61651. /**
  61652. * Enables the vortex.
  61653. */
  61654. enable(): void;
  61655. /**
  61656. * Disables the cortex.
  61657. */
  61658. disable(): void;
  61659. /**
  61660. * Disposes the sphere.
  61661. * @param force
  61662. */
  61663. dispose(force?: boolean): void;
  61664. private getImpostorHitData;
  61665. private _tick;
  61666. /*** Helpers ***/
  61667. private _prepareCylinder;
  61668. private _intersectsWithCylinder;
  61669. }
  61670. /**
  61671. * Options fot the radial explosion event
  61672. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61673. */
  61674. export class PhysicsRadialExplosionEventOptions {
  61675. /**
  61676. * The radius of the sphere for the radial explosion.
  61677. */
  61678. radius: number;
  61679. /**
  61680. * The strenth of the explosion.
  61681. */
  61682. strength: number;
  61683. /**
  61684. * The strenght of the force in correspondence to the distance of the affected object
  61685. */
  61686. falloff: PhysicsRadialImpulseFalloff;
  61687. /**
  61688. * Sphere options for the radial explosion.
  61689. */
  61690. sphere: {
  61691. segments: number;
  61692. diameter: number;
  61693. };
  61694. /**
  61695. * Sphere options for the radial explosion.
  61696. */
  61697. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61698. }
  61699. /**
  61700. * Options fot the updraft event
  61701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61702. */
  61703. export class PhysicsUpdraftEventOptions {
  61704. /**
  61705. * The radius of the cylinder for the vortex
  61706. */
  61707. radius: number;
  61708. /**
  61709. * The strenth of the updraft.
  61710. */
  61711. strength: number;
  61712. /**
  61713. * The height of the cylinder for the updraft.
  61714. */
  61715. height: number;
  61716. /**
  61717. * The mode for the the updraft.
  61718. */
  61719. updraftMode: PhysicsUpdraftMode;
  61720. }
  61721. /**
  61722. * Options fot the vortex event
  61723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61724. */
  61725. export class PhysicsVortexEventOptions {
  61726. /**
  61727. * The radius of the cylinder for the vortex
  61728. */
  61729. radius: number;
  61730. /**
  61731. * The strenth of the vortex.
  61732. */
  61733. strength: number;
  61734. /**
  61735. * The height of the cylinder for the vortex.
  61736. */
  61737. height: number;
  61738. /**
  61739. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61740. */
  61741. centripetalForceThreshold: number;
  61742. /**
  61743. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61744. */
  61745. centripetalForceMultiplier: number;
  61746. /**
  61747. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61748. */
  61749. centrifugalForceMultiplier: number;
  61750. /**
  61751. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61752. */
  61753. updraftForceMultiplier: number;
  61754. }
  61755. /**
  61756. * The strenght of the force in correspondence to the distance of the affected object
  61757. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61758. */
  61759. export enum PhysicsRadialImpulseFalloff {
  61760. /** Defines that impulse is constant in strength across it's whole radius */
  61761. Constant = 0,
  61762. /** Defines that impulse gets weaker if it's further from the origin */
  61763. Linear = 1
  61764. }
  61765. /**
  61766. * The strength of the force in correspondence to the distance of the affected object
  61767. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61768. */
  61769. export enum PhysicsUpdraftMode {
  61770. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  61771. Center = 0,
  61772. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  61773. Perpendicular = 1
  61774. }
  61775. /**
  61776. * Interface for a physics hit data
  61777. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61778. */
  61779. export interface PhysicsHitData {
  61780. /**
  61781. * The force applied at the contact point
  61782. */
  61783. force: Vector3;
  61784. /**
  61785. * The contact point
  61786. */
  61787. contactPoint: Vector3;
  61788. /**
  61789. * The distance from the origin to the contact point
  61790. */
  61791. distanceFromOrigin: number;
  61792. }
  61793. /**
  61794. * Interface for radial explosion event data
  61795. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61796. */
  61797. export interface PhysicsRadialExplosionEventData {
  61798. /**
  61799. * A sphere used for the radial explosion event
  61800. */
  61801. sphere: Mesh;
  61802. }
  61803. /**
  61804. * Interface for gravitational field event data
  61805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61806. */
  61807. export interface PhysicsGravitationalFieldEventData {
  61808. /**
  61809. * A sphere mesh used for the gravitational field event
  61810. */
  61811. sphere: Mesh;
  61812. }
  61813. /**
  61814. * Interface for updraft event data
  61815. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61816. */
  61817. export interface PhysicsUpdraftEventData {
  61818. /**
  61819. * A cylinder used for the updraft event
  61820. */
  61821. cylinder: Mesh;
  61822. }
  61823. /**
  61824. * Interface for vortex event data
  61825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61826. */
  61827. export interface PhysicsVortexEventData {
  61828. /**
  61829. * A cylinder used for the vortex event
  61830. */
  61831. cylinder: Mesh;
  61832. }
  61833. /**
  61834. * Interface for an affected physics impostor
  61835. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61836. */
  61837. export interface PhysicsAffectedImpostorWithData {
  61838. /**
  61839. * The impostor affected by the effect
  61840. */
  61841. impostor: PhysicsImpostor;
  61842. /**
  61843. * The data about the hit/horce from the explosion
  61844. */
  61845. hitData: PhysicsHitData;
  61846. }
  61847. }
  61848. declare module "babylonjs/Physics/Plugins/index" {
  61849. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  61850. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  61851. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  61852. }
  61853. declare module "babylonjs/Physics/index" {
  61854. export * from "babylonjs/Physics/IPhysicsEngine";
  61855. export * from "babylonjs/Physics/physicsEngine";
  61856. export * from "babylonjs/Physics/physicsEngineComponent";
  61857. export * from "babylonjs/Physics/physicsHelper";
  61858. export * from "babylonjs/Physics/physicsImpostor";
  61859. export * from "babylonjs/Physics/physicsJoint";
  61860. export * from "babylonjs/Physics/Plugins/index";
  61861. }
  61862. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  61863. /** @hidden */
  61864. export var blackAndWhitePixelShader: {
  61865. name: string;
  61866. shader: string;
  61867. };
  61868. }
  61869. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  61870. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61871. import { Camera } from "babylonjs/Cameras/camera";
  61872. import { Engine } from "babylonjs/Engines/engine";
  61873. import "babylonjs/Shaders/blackAndWhite.fragment";
  61874. /**
  61875. * Post process used to render in black and white
  61876. */
  61877. export class BlackAndWhitePostProcess extends PostProcess {
  61878. /**
  61879. * Linear about to convert he result to black and white (default: 1)
  61880. */
  61881. degree: number;
  61882. /**
  61883. * Creates a black and white post process
  61884. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  61885. * @param name The name of the effect.
  61886. * @param options The required width/height ratio to downsize to before computing the render pass.
  61887. * @param camera The camera to apply the render pass to.
  61888. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61889. * @param engine The engine which the post process will be applied. (default: current engine)
  61890. * @param reusable If the post process can be reused on the same frame. (default: false)
  61891. */
  61892. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61893. }
  61894. }
  61895. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  61896. import { Nullable } from "babylonjs/types";
  61897. import { Camera } from "babylonjs/Cameras/camera";
  61898. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61899. import { Engine } from "babylonjs/Engines/engine";
  61900. /**
  61901. * This represents a set of one or more post processes in Babylon.
  61902. * A post process can be used to apply a shader to a texture after it is rendered.
  61903. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61904. */
  61905. export class PostProcessRenderEffect {
  61906. private _postProcesses;
  61907. private _getPostProcesses;
  61908. private _singleInstance;
  61909. private _cameras;
  61910. private _indicesForCamera;
  61911. /**
  61912. * Name of the effect
  61913. * @hidden
  61914. */
  61915. _name: string;
  61916. /**
  61917. * Instantiates a post process render effect.
  61918. * A post process can be used to apply a shader to a texture after it is rendered.
  61919. * @param engine The engine the effect is tied to
  61920. * @param name The name of the effect
  61921. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  61922. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  61923. */
  61924. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  61925. /**
  61926. * Checks if all the post processes in the effect are supported.
  61927. */
  61928. readonly isSupported: boolean;
  61929. /**
  61930. * Updates the current state of the effect
  61931. * @hidden
  61932. */
  61933. _update(): void;
  61934. /**
  61935. * Attaches the effect on cameras
  61936. * @param cameras The camera to attach to.
  61937. * @hidden
  61938. */
  61939. _attachCameras(cameras: Camera): void;
  61940. /**
  61941. * Attaches the effect on cameras
  61942. * @param cameras The camera to attach to.
  61943. * @hidden
  61944. */
  61945. _attachCameras(cameras: Camera[]): void;
  61946. /**
  61947. * Detaches the effect on cameras
  61948. * @param cameras The camera to detatch from.
  61949. * @hidden
  61950. */
  61951. _detachCameras(cameras: Camera): void;
  61952. /**
  61953. * Detatches the effect on cameras
  61954. * @param cameras The camera to detatch from.
  61955. * @hidden
  61956. */
  61957. _detachCameras(cameras: Camera[]): void;
  61958. /**
  61959. * Enables the effect on given cameras
  61960. * @param cameras The camera to enable.
  61961. * @hidden
  61962. */
  61963. _enable(cameras: Camera): void;
  61964. /**
  61965. * Enables the effect on given cameras
  61966. * @param cameras The camera to enable.
  61967. * @hidden
  61968. */
  61969. _enable(cameras: Nullable<Camera[]>): void;
  61970. /**
  61971. * Disables the effect on the given cameras
  61972. * @param cameras The camera to disable.
  61973. * @hidden
  61974. */
  61975. _disable(cameras: Camera): void;
  61976. /**
  61977. * Disables the effect on the given cameras
  61978. * @param cameras The camera to disable.
  61979. * @hidden
  61980. */
  61981. _disable(cameras: Nullable<Camera[]>): void;
  61982. /**
  61983. * Gets a list of the post processes contained in the effect.
  61984. * @param camera The camera to get the post processes on.
  61985. * @returns The list of the post processes in the effect.
  61986. */
  61987. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61988. }
  61989. }
  61990. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  61991. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61992. /** @hidden */
  61993. export var extractHighlightsPixelShader: {
  61994. name: string;
  61995. shader: string;
  61996. };
  61997. }
  61998. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  61999. import { Nullable } from "babylonjs/types";
  62000. import { Camera } from "babylonjs/Cameras/camera";
  62001. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62002. import { Engine } from "babylonjs/Engines/engine";
  62003. import "babylonjs/Shaders/extractHighlights.fragment";
  62004. /**
  62005. * 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.
  62006. */
  62007. export class ExtractHighlightsPostProcess extends PostProcess {
  62008. /**
  62009. * The luminance threshold, pixels below this value will be set to black.
  62010. */
  62011. threshold: number;
  62012. /** @hidden */
  62013. _exposure: number;
  62014. /**
  62015. * Post process which has the input texture to be used when performing highlight extraction
  62016. * @hidden
  62017. */
  62018. _inputPostProcess: Nullable<PostProcess>;
  62019. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62020. }
  62021. }
  62022. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  62023. /** @hidden */
  62024. export var bloomMergePixelShader: {
  62025. name: string;
  62026. shader: string;
  62027. };
  62028. }
  62029. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  62030. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62031. import { Nullable } from "babylonjs/types";
  62032. import { Engine } from "babylonjs/Engines/engine";
  62033. import { Camera } from "babylonjs/Cameras/camera";
  62034. import "babylonjs/Shaders/bloomMerge.fragment";
  62035. /**
  62036. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62037. */
  62038. export class BloomMergePostProcess extends PostProcess {
  62039. /** Weight of the bloom to be added to the original input. */
  62040. weight: number;
  62041. /**
  62042. * Creates a new instance of @see BloomMergePostProcess
  62043. * @param name The name of the effect.
  62044. * @param originalFromInput Post process which's input will be used for the merge.
  62045. * @param blurred Blurred highlights post process which's output will be used.
  62046. * @param weight Weight of the bloom to be added to the original input.
  62047. * @param options The required width/height ratio to downsize to before computing the render pass.
  62048. * @param camera The camera to apply the render pass to.
  62049. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62050. * @param engine The engine which the post process will be applied. (default: current engine)
  62051. * @param reusable If the post process can be reused on the same frame. (default: false)
  62052. * @param textureType Type of textures used when performing the post process. (default: 0)
  62053. * @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)
  62054. */
  62055. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62056. /** Weight of the bloom to be added to the original input. */
  62057. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62058. }
  62059. }
  62060. declare module "babylonjs/PostProcesses/bloomEffect" {
  62061. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62062. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62063. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62064. import { Camera } from "babylonjs/Cameras/camera";
  62065. import { Scene } from "babylonjs/scene";
  62066. /**
  62067. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62068. */
  62069. export class BloomEffect extends PostProcessRenderEffect {
  62070. private bloomScale;
  62071. /**
  62072. * @hidden Internal
  62073. */
  62074. _effects: Array<PostProcess>;
  62075. /**
  62076. * @hidden Internal
  62077. */
  62078. _downscale: ExtractHighlightsPostProcess;
  62079. private _blurX;
  62080. private _blurY;
  62081. private _merge;
  62082. /**
  62083. * The luminance threshold to find bright areas of the image to bloom.
  62084. */
  62085. threshold: number;
  62086. /**
  62087. * The strength of the bloom.
  62088. */
  62089. weight: number;
  62090. /**
  62091. * Specifies the size of the bloom blur kernel, relative to the final output size
  62092. */
  62093. kernel: number;
  62094. /**
  62095. * Creates a new instance of @see BloomEffect
  62096. * @param scene The scene the effect belongs to.
  62097. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62098. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62099. * @param bloomWeight The the strength of bloom.
  62100. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62101. * @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)
  62102. */
  62103. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62104. /**
  62105. * Disposes each of the internal effects for a given camera.
  62106. * @param camera The camera to dispose the effect on.
  62107. */
  62108. disposeEffects(camera: Camera): void;
  62109. /**
  62110. * @hidden Internal
  62111. */
  62112. _updateEffects(): void;
  62113. /**
  62114. * Internal
  62115. * @returns if all the contained post processes are ready.
  62116. * @hidden
  62117. */
  62118. _isReady(): boolean;
  62119. }
  62120. }
  62121. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  62122. /** @hidden */
  62123. export var chromaticAberrationPixelShader: {
  62124. name: string;
  62125. shader: string;
  62126. };
  62127. }
  62128. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  62129. import { Vector2 } from "babylonjs/Maths/math.vector";
  62130. import { Nullable } from "babylonjs/types";
  62131. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62132. import { Camera } from "babylonjs/Cameras/camera";
  62133. import { Engine } from "babylonjs/Engines/engine";
  62134. import "babylonjs/Shaders/chromaticAberration.fragment";
  62135. /**
  62136. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62137. */
  62138. export class ChromaticAberrationPostProcess extends PostProcess {
  62139. /**
  62140. * The amount of seperation of rgb channels (default: 30)
  62141. */
  62142. aberrationAmount: number;
  62143. /**
  62144. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62145. */
  62146. radialIntensity: number;
  62147. /**
  62148. * 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))
  62149. */
  62150. direction: Vector2;
  62151. /**
  62152. * 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))
  62153. */
  62154. centerPosition: Vector2;
  62155. /**
  62156. * Creates a new instance ChromaticAberrationPostProcess
  62157. * @param name The name of the effect.
  62158. * @param screenWidth The width of the screen to apply the effect on.
  62159. * @param screenHeight The height of the screen to apply the effect on.
  62160. * @param options The required width/height ratio to downsize to before computing the render pass.
  62161. * @param camera The camera to apply the render pass to.
  62162. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62163. * @param engine The engine which the post process will be applied. (default: current engine)
  62164. * @param reusable If the post process can be reused on the same frame. (default: false)
  62165. * @param textureType Type of textures used when performing the post process. (default: 0)
  62166. * @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)
  62167. */
  62168. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62169. }
  62170. }
  62171. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  62172. /** @hidden */
  62173. export var circleOfConfusionPixelShader: {
  62174. name: string;
  62175. shader: string;
  62176. };
  62177. }
  62178. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  62179. import { Nullable } from "babylonjs/types";
  62180. import { Engine } from "babylonjs/Engines/engine";
  62181. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62182. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62183. import { Camera } from "babylonjs/Cameras/camera";
  62184. import "babylonjs/Shaders/circleOfConfusion.fragment";
  62185. /**
  62186. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62187. */
  62188. export class CircleOfConfusionPostProcess extends PostProcess {
  62189. /**
  62190. * 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.
  62191. */
  62192. lensSize: number;
  62193. /**
  62194. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62195. */
  62196. fStop: number;
  62197. /**
  62198. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62199. */
  62200. focusDistance: number;
  62201. /**
  62202. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62203. */
  62204. focalLength: number;
  62205. private _depthTexture;
  62206. /**
  62207. * Creates a new instance CircleOfConfusionPostProcess
  62208. * @param name The name of the effect.
  62209. * @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.
  62210. * @param options The required width/height ratio to downsize to before computing the render pass.
  62211. * @param camera The camera to apply the render pass to.
  62212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62213. * @param engine The engine which the post process will be applied. (default: current engine)
  62214. * @param reusable If the post process can be reused on the same frame. (default: false)
  62215. * @param textureType Type of textures used when performing the post process. (default: 0)
  62216. * @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)
  62217. */
  62218. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62219. /**
  62220. * 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.
  62221. */
  62222. depthTexture: RenderTargetTexture;
  62223. }
  62224. }
  62225. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  62226. /** @hidden */
  62227. export var colorCorrectionPixelShader: {
  62228. name: string;
  62229. shader: string;
  62230. };
  62231. }
  62232. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  62233. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62234. import { Engine } from "babylonjs/Engines/engine";
  62235. import { Camera } from "babylonjs/Cameras/camera";
  62236. import "babylonjs/Shaders/colorCorrection.fragment";
  62237. /**
  62238. *
  62239. * This post-process allows the modification of rendered colors by using
  62240. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62241. *
  62242. * The object needs to be provided an url to a texture containing the color
  62243. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62244. * Use an image editing software to tweak the LUT to match your needs.
  62245. *
  62246. * For an example of a color LUT, see here:
  62247. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62248. * For explanations on color grading, see here:
  62249. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62250. *
  62251. */
  62252. export class ColorCorrectionPostProcess extends PostProcess {
  62253. private _colorTableTexture;
  62254. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62255. }
  62256. }
  62257. declare module "babylonjs/Shaders/convolution.fragment" {
  62258. /** @hidden */
  62259. export var convolutionPixelShader: {
  62260. name: string;
  62261. shader: string;
  62262. };
  62263. }
  62264. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  62265. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62266. import { Nullable } from "babylonjs/types";
  62267. import { Camera } from "babylonjs/Cameras/camera";
  62268. import { Engine } from "babylonjs/Engines/engine";
  62269. import "babylonjs/Shaders/convolution.fragment";
  62270. /**
  62271. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62272. * input texture to perform effects such as edge detection or sharpening
  62273. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62274. */
  62275. export class ConvolutionPostProcess extends PostProcess {
  62276. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62277. kernel: number[];
  62278. /**
  62279. * Creates a new instance ConvolutionPostProcess
  62280. * @param name The name of the effect.
  62281. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62282. * @param options The required width/height ratio to downsize to before computing the render pass.
  62283. * @param camera The camera to apply the render pass to.
  62284. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62285. * @param engine The engine which the post process will be applied. (default: current engine)
  62286. * @param reusable If the post process can be reused on the same frame. (default: false)
  62287. * @param textureType Type of textures used when performing the post process. (default: 0)
  62288. */
  62289. constructor(name: string,
  62290. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62291. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62292. /**
  62293. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62294. */
  62295. static EdgeDetect0Kernel: number[];
  62296. /**
  62297. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62298. */
  62299. static EdgeDetect1Kernel: number[];
  62300. /**
  62301. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62302. */
  62303. static EdgeDetect2Kernel: number[];
  62304. /**
  62305. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62306. */
  62307. static SharpenKernel: number[];
  62308. /**
  62309. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62310. */
  62311. static EmbossKernel: number[];
  62312. /**
  62313. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62314. */
  62315. static GaussianKernel: number[];
  62316. }
  62317. }
  62318. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  62319. import { Nullable } from "babylonjs/types";
  62320. import { Vector2 } from "babylonjs/Maths/math.vector";
  62321. import { Camera } from "babylonjs/Cameras/camera";
  62322. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62323. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62324. import { Engine } from "babylonjs/Engines/engine";
  62325. import { Scene } from "babylonjs/scene";
  62326. /**
  62327. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62328. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62329. * based on samples that have a large difference in distance than the center pixel.
  62330. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62331. */
  62332. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62333. direction: Vector2;
  62334. /**
  62335. * Creates a new instance CircleOfConfusionPostProcess
  62336. * @param name The name of the effect.
  62337. * @param scene The scene the effect belongs to.
  62338. * @param direction The direction the blur should be applied.
  62339. * @param kernel The size of the kernel used to blur.
  62340. * @param options The required width/height ratio to downsize to before computing the render pass.
  62341. * @param camera The camera to apply the render pass to.
  62342. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62343. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62344. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62345. * @param engine The engine which the post process will be applied. (default: current engine)
  62346. * @param reusable If the post process can be reused on the same frame. (default: false)
  62347. * @param textureType Type of textures used when performing the post process. (default: 0)
  62348. * @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)
  62349. */
  62350. 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);
  62351. }
  62352. }
  62353. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  62354. /** @hidden */
  62355. export var depthOfFieldMergePixelShader: {
  62356. name: string;
  62357. shader: string;
  62358. };
  62359. }
  62360. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  62361. import { Nullable } from "babylonjs/types";
  62362. import { Camera } from "babylonjs/Cameras/camera";
  62363. import { Effect } from "babylonjs/Materials/effect";
  62364. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62365. import { Engine } from "babylonjs/Engines/engine";
  62366. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  62367. /**
  62368. * Options to be set when merging outputs from the default pipeline.
  62369. */
  62370. export class DepthOfFieldMergePostProcessOptions {
  62371. /**
  62372. * The original image to merge on top of
  62373. */
  62374. originalFromInput: PostProcess;
  62375. /**
  62376. * Parameters to perform the merge of the depth of field effect
  62377. */
  62378. depthOfField?: {
  62379. circleOfConfusion: PostProcess;
  62380. blurSteps: Array<PostProcess>;
  62381. };
  62382. /**
  62383. * Parameters to perform the merge of bloom effect
  62384. */
  62385. bloom?: {
  62386. blurred: PostProcess;
  62387. weight: number;
  62388. };
  62389. }
  62390. /**
  62391. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62392. */
  62393. export class DepthOfFieldMergePostProcess extends PostProcess {
  62394. private blurSteps;
  62395. /**
  62396. * Creates a new instance of DepthOfFieldMergePostProcess
  62397. * @param name The name of the effect.
  62398. * @param originalFromInput Post process which's input will be used for the merge.
  62399. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62400. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62401. * @param options The required width/height ratio to downsize to before computing the render pass.
  62402. * @param camera The camera to apply the render pass to.
  62403. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62404. * @param engine The engine which the post process will be applied. (default: current engine)
  62405. * @param reusable If the post process can be reused on the same frame. (default: false)
  62406. * @param textureType Type of textures used when performing the post process. (default: 0)
  62407. * @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)
  62408. */
  62409. 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);
  62410. /**
  62411. * Updates the effect with the current post process compile time values and recompiles the shader.
  62412. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62413. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62414. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62415. * @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
  62416. * @param onCompiled Called when the shader has been compiled.
  62417. * @param onError Called if there is an error when compiling a shader.
  62418. */
  62419. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62420. }
  62421. }
  62422. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  62423. import { Nullable } from "babylonjs/types";
  62424. import { Camera } from "babylonjs/Cameras/camera";
  62425. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62426. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62427. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62428. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62429. import { Scene } from "babylonjs/scene";
  62430. /**
  62431. * Specifies the level of max blur that should be applied when using the depth of field effect
  62432. */
  62433. export enum DepthOfFieldEffectBlurLevel {
  62434. /**
  62435. * Subtle blur
  62436. */
  62437. Low = 0,
  62438. /**
  62439. * Medium blur
  62440. */
  62441. Medium = 1,
  62442. /**
  62443. * Large blur
  62444. */
  62445. High = 2
  62446. }
  62447. /**
  62448. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62449. */
  62450. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62451. private _circleOfConfusion;
  62452. /**
  62453. * @hidden Internal, blurs from high to low
  62454. */
  62455. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62456. private _depthOfFieldBlurY;
  62457. private _dofMerge;
  62458. /**
  62459. * @hidden Internal post processes in depth of field effect
  62460. */
  62461. _effects: Array<PostProcess>;
  62462. /**
  62463. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62464. */
  62465. focalLength: number;
  62466. /**
  62467. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62468. */
  62469. fStop: number;
  62470. /**
  62471. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62472. */
  62473. focusDistance: number;
  62474. /**
  62475. * 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.
  62476. */
  62477. lensSize: number;
  62478. /**
  62479. * Creates a new instance DepthOfFieldEffect
  62480. * @param scene The scene the effect belongs to.
  62481. * @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.
  62482. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62483. * @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)
  62484. */
  62485. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62486. /**
  62487. * Get the current class name of the current effet
  62488. * @returns "DepthOfFieldEffect"
  62489. */
  62490. getClassName(): string;
  62491. /**
  62492. * 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.
  62493. */
  62494. depthTexture: RenderTargetTexture;
  62495. /**
  62496. * Disposes each of the internal effects for a given camera.
  62497. * @param camera The camera to dispose the effect on.
  62498. */
  62499. disposeEffects(camera: Camera): void;
  62500. /**
  62501. * @hidden Internal
  62502. */
  62503. _updateEffects(): void;
  62504. /**
  62505. * Internal
  62506. * @returns if all the contained post processes are ready.
  62507. * @hidden
  62508. */
  62509. _isReady(): boolean;
  62510. }
  62511. }
  62512. declare module "babylonjs/Shaders/displayPass.fragment" {
  62513. /** @hidden */
  62514. export var displayPassPixelShader: {
  62515. name: string;
  62516. shader: string;
  62517. };
  62518. }
  62519. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  62520. import { Nullable } from "babylonjs/types";
  62521. import { Camera } from "babylonjs/Cameras/camera";
  62522. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62523. import { Engine } from "babylonjs/Engines/engine";
  62524. import "babylonjs/Shaders/displayPass.fragment";
  62525. /**
  62526. * DisplayPassPostProcess which produces an output the same as it's input
  62527. */
  62528. export class DisplayPassPostProcess extends PostProcess {
  62529. /**
  62530. * Creates the DisplayPassPostProcess
  62531. * @param name The name of the effect.
  62532. * @param options The required width/height ratio to downsize to before computing the render pass.
  62533. * @param camera The camera to apply the render pass to.
  62534. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62535. * @param engine The engine which the post process will be applied. (default: current engine)
  62536. * @param reusable If the post process can be reused on the same frame. (default: false)
  62537. */
  62538. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62539. }
  62540. }
  62541. declare module "babylonjs/Shaders/filter.fragment" {
  62542. /** @hidden */
  62543. export var filterPixelShader: {
  62544. name: string;
  62545. shader: string;
  62546. };
  62547. }
  62548. declare module "babylonjs/PostProcesses/filterPostProcess" {
  62549. import { Nullable } from "babylonjs/types";
  62550. import { Matrix } from "babylonjs/Maths/math.vector";
  62551. import { Camera } from "babylonjs/Cameras/camera";
  62552. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62553. import { Engine } from "babylonjs/Engines/engine";
  62554. import "babylonjs/Shaders/filter.fragment";
  62555. /**
  62556. * Applies a kernel filter to the image
  62557. */
  62558. export class FilterPostProcess extends PostProcess {
  62559. /** The matrix to be applied to the image */
  62560. kernelMatrix: Matrix;
  62561. /**
  62562. *
  62563. * @param name The name of the effect.
  62564. * @param kernelMatrix The matrix to be applied to the image
  62565. * @param options The required width/height ratio to downsize to before computing the render pass.
  62566. * @param camera The camera to apply the render pass to.
  62567. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62568. * @param engine The engine which the post process will be applied. (default: current engine)
  62569. * @param reusable If the post process can be reused on the same frame. (default: false)
  62570. */
  62571. constructor(name: string,
  62572. /** The matrix to be applied to the image */
  62573. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62574. }
  62575. }
  62576. declare module "babylonjs/Shaders/fxaa.fragment" {
  62577. /** @hidden */
  62578. export var fxaaPixelShader: {
  62579. name: string;
  62580. shader: string;
  62581. };
  62582. }
  62583. declare module "babylonjs/Shaders/fxaa.vertex" {
  62584. /** @hidden */
  62585. export var fxaaVertexShader: {
  62586. name: string;
  62587. shader: string;
  62588. };
  62589. }
  62590. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  62591. import { Nullable } from "babylonjs/types";
  62592. import { Camera } from "babylonjs/Cameras/camera";
  62593. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62594. import { Engine } from "babylonjs/Engines/engine";
  62595. import "babylonjs/Shaders/fxaa.fragment";
  62596. import "babylonjs/Shaders/fxaa.vertex";
  62597. /**
  62598. * Fxaa post process
  62599. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62600. */
  62601. export class FxaaPostProcess extends PostProcess {
  62602. /** @hidden */
  62603. texelWidth: number;
  62604. /** @hidden */
  62605. texelHeight: number;
  62606. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62607. private _getDefines;
  62608. }
  62609. }
  62610. declare module "babylonjs/Shaders/grain.fragment" {
  62611. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62612. /** @hidden */
  62613. export var grainPixelShader: {
  62614. name: string;
  62615. shader: string;
  62616. };
  62617. }
  62618. declare module "babylonjs/PostProcesses/grainPostProcess" {
  62619. import { Nullable } from "babylonjs/types";
  62620. import { Camera } from "babylonjs/Cameras/camera";
  62621. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62622. import { Engine } from "babylonjs/Engines/engine";
  62623. import "babylonjs/Shaders/grain.fragment";
  62624. /**
  62625. * The GrainPostProcess adds noise to the image at mid luminance levels
  62626. */
  62627. export class GrainPostProcess extends PostProcess {
  62628. /**
  62629. * The intensity of the grain added (default: 30)
  62630. */
  62631. intensity: number;
  62632. /**
  62633. * If the grain should be randomized on every frame
  62634. */
  62635. animated: boolean;
  62636. /**
  62637. * Creates a new instance of @see GrainPostProcess
  62638. * @param name The name of the effect.
  62639. * @param options The required width/height ratio to downsize to before computing the render pass.
  62640. * @param camera The camera to apply the render pass to.
  62641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62642. * @param engine The engine which the post process will be applied. (default: current engine)
  62643. * @param reusable If the post process can be reused on the same frame. (default: false)
  62644. * @param textureType Type of textures used when performing the post process. (default: 0)
  62645. * @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)
  62646. */
  62647. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62648. }
  62649. }
  62650. declare module "babylonjs/Shaders/highlights.fragment" {
  62651. /** @hidden */
  62652. export var highlightsPixelShader: {
  62653. name: string;
  62654. shader: string;
  62655. };
  62656. }
  62657. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  62658. import { Nullable } from "babylonjs/types";
  62659. import { Camera } from "babylonjs/Cameras/camera";
  62660. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62661. import { Engine } from "babylonjs/Engines/engine";
  62662. import "babylonjs/Shaders/highlights.fragment";
  62663. /**
  62664. * Extracts highlights from the image
  62665. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62666. */
  62667. export class HighlightsPostProcess extends PostProcess {
  62668. /**
  62669. * Extracts highlights from the image
  62670. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62671. * @param name The name of the effect.
  62672. * @param options The required width/height ratio to downsize to before computing the render pass.
  62673. * @param camera The camera to apply the render pass to.
  62674. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62675. * @param engine The engine which the post process will be applied. (default: current engine)
  62676. * @param reusable If the post process can be reused on the same frame. (default: false)
  62677. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62678. */
  62679. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62680. }
  62681. }
  62682. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  62683. /** @hidden */
  62684. export var mrtFragmentDeclaration: {
  62685. name: string;
  62686. shader: string;
  62687. };
  62688. }
  62689. declare module "babylonjs/Shaders/geometry.fragment" {
  62690. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  62691. /** @hidden */
  62692. export var geometryPixelShader: {
  62693. name: string;
  62694. shader: string;
  62695. };
  62696. }
  62697. declare module "babylonjs/Shaders/geometry.vertex" {
  62698. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62699. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62700. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62701. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62702. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62703. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62704. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62705. /** @hidden */
  62706. export var geometryVertexShader: {
  62707. name: string;
  62708. shader: string;
  62709. };
  62710. }
  62711. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  62712. import { Matrix } from "babylonjs/Maths/math.vector";
  62713. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62714. import { Mesh } from "babylonjs/Meshes/mesh";
  62715. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  62716. import { Effect } from "babylonjs/Materials/effect";
  62717. import { Scene } from "babylonjs/scene";
  62718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62719. import "babylonjs/Shaders/geometry.fragment";
  62720. import "babylonjs/Shaders/geometry.vertex";
  62721. /** @hidden */
  62722. interface ISavedTransformationMatrix {
  62723. world: Matrix;
  62724. viewProjection: Matrix;
  62725. }
  62726. /**
  62727. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62728. */
  62729. export class GeometryBufferRenderer {
  62730. /**
  62731. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62732. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62733. */
  62734. static readonly POSITION_TEXTURE_TYPE: number;
  62735. /**
  62736. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62737. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62738. */
  62739. static readonly VELOCITY_TEXTURE_TYPE: number;
  62740. /**
  62741. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62742. * in order to compute objects velocities when enableVelocity is set to "true"
  62743. * @hidden
  62744. */
  62745. _previousTransformationMatrices: {
  62746. [index: number]: ISavedTransformationMatrix;
  62747. };
  62748. /**
  62749. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62750. * in order to compute objects velocities when enableVelocity is set to "true"
  62751. * @hidden
  62752. */
  62753. _previousBonesTransformationMatrices: {
  62754. [index: number]: Float32Array;
  62755. };
  62756. /**
  62757. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62758. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62759. */
  62760. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62761. private _scene;
  62762. private _multiRenderTarget;
  62763. private _ratio;
  62764. private _enablePosition;
  62765. private _enableVelocity;
  62766. private _positionIndex;
  62767. private _velocityIndex;
  62768. protected _effect: Effect;
  62769. protected _cachedDefines: string;
  62770. /**
  62771. * Set the render list (meshes to be rendered) used in the G buffer.
  62772. */
  62773. renderList: Mesh[];
  62774. /**
  62775. * Gets wether or not G buffer are supported by the running hardware.
  62776. * This requires draw buffer supports
  62777. */
  62778. readonly isSupported: boolean;
  62779. /**
  62780. * Returns the index of the given texture type in the G-Buffer textures array
  62781. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62782. * @returns the index of the given texture type in the G-Buffer textures array
  62783. */
  62784. getTextureIndex(textureType: number): number;
  62785. /**
  62786. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62787. */
  62788. /**
  62789. * Sets whether or not objects positions are enabled for the G buffer.
  62790. */
  62791. enablePosition: boolean;
  62792. /**
  62793. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62794. */
  62795. /**
  62796. * Sets wether or not objects velocities are enabled for the G buffer.
  62797. */
  62798. enableVelocity: boolean;
  62799. /**
  62800. * Gets the scene associated with the buffer.
  62801. */
  62802. readonly scene: Scene;
  62803. /**
  62804. * Gets the ratio used by the buffer during its creation.
  62805. * How big is the buffer related to the main canvas.
  62806. */
  62807. readonly ratio: number;
  62808. /** @hidden */
  62809. static _SceneComponentInitialization: (scene: Scene) => void;
  62810. /**
  62811. * Creates a new G Buffer for the scene
  62812. * @param scene The scene the buffer belongs to
  62813. * @param ratio How big is the buffer related to the main canvas.
  62814. */
  62815. constructor(scene: Scene, ratio?: number);
  62816. /**
  62817. * Checks wether everything is ready to render a submesh to the G buffer.
  62818. * @param subMesh the submesh to check readiness for
  62819. * @param useInstances is the mesh drawn using instance or not
  62820. * @returns true if ready otherwise false
  62821. */
  62822. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62823. /**
  62824. * Gets the current underlying G Buffer.
  62825. * @returns the buffer
  62826. */
  62827. getGBuffer(): MultiRenderTarget;
  62828. /**
  62829. * Gets the number of samples used to render the buffer (anti aliasing).
  62830. */
  62831. /**
  62832. * Sets the number of samples used to render the buffer (anti aliasing).
  62833. */
  62834. samples: number;
  62835. /**
  62836. * Disposes the renderer and frees up associated resources.
  62837. */
  62838. dispose(): void;
  62839. protected _createRenderTargets(): void;
  62840. private _copyBonesTransformationMatrices;
  62841. }
  62842. }
  62843. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  62844. import { Nullable } from "babylonjs/types";
  62845. import { Scene } from "babylonjs/scene";
  62846. import { ISceneComponent } from "babylonjs/sceneComponent";
  62847. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  62848. module "babylonjs/scene" {
  62849. interface Scene {
  62850. /** @hidden (Backing field) */
  62851. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62852. /**
  62853. * Gets or Sets the current geometry buffer associated to the scene.
  62854. */
  62855. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62856. /**
  62857. * Enables a GeometryBufferRender and associates it with the scene
  62858. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62859. * @returns the GeometryBufferRenderer
  62860. */
  62861. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62862. /**
  62863. * Disables the GeometryBufferRender associated with the scene
  62864. */
  62865. disableGeometryBufferRenderer(): void;
  62866. }
  62867. }
  62868. /**
  62869. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62870. * in several rendering techniques.
  62871. */
  62872. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62873. /**
  62874. * The component name helpful to identify the component in the list of scene components.
  62875. */
  62876. readonly name: string;
  62877. /**
  62878. * The scene the component belongs to.
  62879. */
  62880. scene: Scene;
  62881. /**
  62882. * Creates a new instance of the component for the given scene
  62883. * @param scene Defines the scene to register the component in
  62884. */
  62885. constructor(scene: Scene);
  62886. /**
  62887. * Registers the component in a given scene
  62888. */
  62889. register(): void;
  62890. /**
  62891. * Rebuilds the elements related to this component in case of
  62892. * context lost for instance.
  62893. */
  62894. rebuild(): void;
  62895. /**
  62896. * Disposes the component and the associated ressources
  62897. */
  62898. dispose(): void;
  62899. private _gatherRenderTargets;
  62900. }
  62901. }
  62902. declare module "babylonjs/Shaders/motionBlur.fragment" {
  62903. /** @hidden */
  62904. export var motionBlurPixelShader: {
  62905. name: string;
  62906. shader: string;
  62907. };
  62908. }
  62909. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  62910. import { Nullable } from "babylonjs/types";
  62911. import { Camera } from "babylonjs/Cameras/camera";
  62912. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62913. import { Scene } from "babylonjs/scene";
  62914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62915. import "babylonjs/Animations/animatable";
  62916. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62917. import "babylonjs/Shaders/motionBlur.fragment";
  62918. import { Engine } from "babylonjs/Engines/engine";
  62919. /**
  62920. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62921. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  62922. * As an example, all you have to do is to create the post-process:
  62923. * var mb = new BABYLON.MotionBlurPostProcess(
  62924. * 'mb', // The name of the effect.
  62925. * scene, // The scene containing the objects to blur according to their velocity.
  62926. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  62927. * camera // The camera to apply the render pass to.
  62928. * );
  62929. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62930. */
  62931. export class MotionBlurPostProcess extends PostProcess {
  62932. /**
  62933. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62934. */
  62935. motionStrength: number;
  62936. /**
  62937. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62938. */
  62939. /**
  62940. * Sets the number of iterations to be used for motion blur quality
  62941. */
  62942. motionBlurSamples: number;
  62943. private _motionBlurSamples;
  62944. private _geometryBufferRenderer;
  62945. /**
  62946. * Creates a new instance MotionBlurPostProcess
  62947. * @param name The name of the effect.
  62948. * @param scene The scene containing the objects to blur according to their velocity.
  62949. * @param options The required width/height ratio to downsize to before computing the render pass.
  62950. * @param camera The camera to apply the render pass to.
  62951. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62952. * @param engine The engine which the post process will be applied. (default: current engine)
  62953. * @param reusable If the post process can be reused on the same frame. (default: false)
  62954. * @param textureType Type of textures used when performing the post process. (default: 0)
  62955. * @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)
  62956. */
  62957. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62958. /**
  62959. * Excludes the given skinned mesh from computing bones velocities.
  62960. * 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.
  62961. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62962. */
  62963. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62964. /**
  62965. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62966. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62967. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62968. */
  62969. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62970. /**
  62971. * Disposes the post process.
  62972. * @param camera The camera to dispose the post process on.
  62973. */
  62974. dispose(camera?: Camera): void;
  62975. }
  62976. }
  62977. declare module "babylonjs/Shaders/refraction.fragment" {
  62978. /** @hidden */
  62979. export var refractionPixelShader: {
  62980. name: string;
  62981. shader: string;
  62982. };
  62983. }
  62984. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  62985. import { Color3 } from "babylonjs/Maths/math.color";
  62986. import { Camera } from "babylonjs/Cameras/camera";
  62987. import { Texture } from "babylonjs/Materials/Textures/texture";
  62988. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62989. import { Engine } from "babylonjs/Engines/engine";
  62990. import "babylonjs/Shaders/refraction.fragment";
  62991. /**
  62992. * Post process which applies a refractin texture
  62993. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62994. */
  62995. export class RefractionPostProcess extends PostProcess {
  62996. /** the base color of the refraction (used to taint the rendering) */
  62997. color: Color3;
  62998. /** simulated refraction depth */
  62999. depth: number;
  63000. /** the coefficient of the base color (0 to remove base color tainting) */
  63001. colorLevel: number;
  63002. private _refTexture;
  63003. private _ownRefractionTexture;
  63004. /**
  63005. * Gets or sets the refraction texture
  63006. * Please note that you are responsible for disposing the texture if you set it manually
  63007. */
  63008. refractionTexture: Texture;
  63009. /**
  63010. * Initializes the RefractionPostProcess
  63011. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63012. * @param name The name of the effect.
  63013. * @param refractionTextureUrl Url of the refraction texture to use
  63014. * @param color the base color of the refraction (used to taint the rendering)
  63015. * @param depth simulated refraction depth
  63016. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  63017. * @param camera The camera to apply the render pass to.
  63018. * @param options The required width/height ratio to downsize to before computing the render pass.
  63019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63020. * @param engine The engine which the post process will be applied. (default: current engine)
  63021. * @param reusable If the post process can be reused on the same frame. (default: false)
  63022. */
  63023. constructor(name: string, refractionTextureUrl: string,
  63024. /** the base color of the refraction (used to taint the rendering) */
  63025. color: Color3,
  63026. /** simulated refraction depth */
  63027. depth: number,
  63028. /** the coefficient of the base color (0 to remove base color tainting) */
  63029. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63030. /**
  63031. * Disposes of the post process
  63032. * @param camera Camera to dispose post process on
  63033. */
  63034. dispose(camera: Camera): void;
  63035. }
  63036. }
  63037. declare module "babylonjs/Shaders/sharpen.fragment" {
  63038. /** @hidden */
  63039. export var sharpenPixelShader: {
  63040. name: string;
  63041. shader: string;
  63042. };
  63043. }
  63044. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  63045. import { Nullable } from "babylonjs/types";
  63046. import { Camera } from "babylonjs/Cameras/camera";
  63047. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63048. import "babylonjs/Shaders/sharpen.fragment";
  63049. import { Engine } from "babylonjs/Engines/engine";
  63050. /**
  63051. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63052. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63053. */
  63054. export class SharpenPostProcess extends PostProcess {
  63055. /**
  63056. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63057. */
  63058. colorAmount: number;
  63059. /**
  63060. * How much sharpness should be applied (default: 0.3)
  63061. */
  63062. edgeAmount: number;
  63063. /**
  63064. * Creates a new instance ConvolutionPostProcess
  63065. * @param name The name of the effect.
  63066. * @param options The required width/height ratio to downsize to before computing the render pass.
  63067. * @param camera The camera to apply the render pass to.
  63068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63069. * @param engine The engine which the post process will be applied. (default: current engine)
  63070. * @param reusable If the post process can be reused on the same frame. (default: false)
  63071. * @param textureType Type of textures used when performing the post process. (default: 0)
  63072. * @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)
  63073. */
  63074. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63075. }
  63076. }
  63077. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  63078. import { Nullable } from "babylonjs/types";
  63079. import { Camera } from "babylonjs/Cameras/camera";
  63080. import { Engine } from "babylonjs/Engines/engine";
  63081. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63082. import { IInspectable } from "babylonjs/Misc/iInspectable";
  63083. /**
  63084. * PostProcessRenderPipeline
  63085. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63086. */
  63087. export class PostProcessRenderPipeline {
  63088. private engine;
  63089. private _renderEffects;
  63090. private _renderEffectsForIsolatedPass;
  63091. /**
  63092. * List of inspectable custom properties (used by the Inspector)
  63093. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63094. */
  63095. inspectableCustomProperties: IInspectable[];
  63096. /**
  63097. * @hidden
  63098. */
  63099. protected _cameras: Camera[];
  63100. /** @hidden */
  63101. _name: string;
  63102. /**
  63103. * Gets pipeline name
  63104. */
  63105. readonly name: string;
  63106. /**
  63107. * Initializes a PostProcessRenderPipeline
  63108. * @param engine engine to add the pipeline to
  63109. * @param name name of the pipeline
  63110. */
  63111. constructor(engine: Engine, name: string);
  63112. /**
  63113. * Gets the class name
  63114. * @returns "PostProcessRenderPipeline"
  63115. */
  63116. getClassName(): string;
  63117. /**
  63118. * If all the render effects in the pipeline are supported
  63119. */
  63120. readonly isSupported: boolean;
  63121. /**
  63122. * Adds an effect to the pipeline
  63123. * @param renderEffect the effect to add
  63124. */
  63125. addEffect(renderEffect: PostProcessRenderEffect): void;
  63126. /** @hidden */
  63127. _rebuild(): void;
  63128. /** @hidden */
  63129. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63130. /** @hidden */
  63131. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63132. /** @hidden */
  63133. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63134. /** @hidden */
  63135. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63136. /** @hidden */
  63137. _attachCameras(cameras: Camera, unique: boolean): void;
  63138. /** @hidden */
  63139. _attachCameras(cameras: Camera[], unique: boolean): void;
  63140. /** @hidden */
  63141. _detachCameras(cameras: Camera): void;
  63142. /** @hidden */
  63143. _detachCameras(cameras: Nullable<Camera[]>): void;
  63144. /** @hidden */
  63145. _update(): void;
  63146. /** @hidden */
  63147. _reset(): void;
  63148. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63149. /**
  63150. * Disposes of the pipeline
  63151. */
  63152. dispose(): void;
  63153. }
  63154. }
  63155. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  63156. import { Camera } from "babylonjs/Cameras/camera";
  63157. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63158. /**
  63159. * PostProcessRenderPipelineManager class
  63160. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63161. */
  63162. export class PostProcessRenderPipelineManager {
  63163. private _renderPipelines;
  63164. /**
  63165. * Initializes a PostProcessRenderPipelineManager
  63166. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63167. */
  63168. constructor();
  63169. /**
  63170. * Gets the list of supported render pipelines
  63171. */
  63172. readonly supportedPipelines: PostProcessRenderPipeline[];
  63173. /**
  63174. * Adds a pipeline to the manager
  63175. * @param renderPipeline The pipeline to add
  63176. */
  63177. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63178. /**
  63179. * Attaches a camera to the pipeline
  63180. * @param renderPipelineName The name of the pipeline to attach to
  63181. * @param cameras the camera to attach
  63182. * @param unique if the camera can be attached multiple times to the pipeline
  63183. */
  63184. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63185. /**
  63186. * Detaches a camera from the pipeline
  63187. * @param renderPipelineName The name of the pipeline to detach from
  63188. * @param cameras the camera to detach
  63189. */
  63190. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63191. /**
  63192. * Enables an effect by name on a pipeline
  63193. * @param renderPipelineName the name of the pipeline to enable the effect in
  63194. * @param renderEffectName the name of the effect to enable
  63195. * @param cameras the cameras that the effect should be enabled on
  63196. */
  63197. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63198. /**
  63199. * Disables an effect by name on a pipeline
  63200. * @param renderPipelineName the name of the pipeline to disable the effect in
  63201. * @param renderEffectName the name of the effect to disable
  63202. * @param cameras the cameras that the effect should be disabled on
  63203. */
  63204. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63205. /**
  63206. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63207. */
  63208. update(): void;
  63209. /** @hidden */
  63210. _rebuild(): void;
  63211. /**
  63212. * Disposes of the manager and pipelines
  63213. */
  63214. dispose(): void;
  63215. }
  63216. }
  63217. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  63218. import { ISceneComponent } from "babylonjs/sceneComponent";
  63219. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63220. import { Scene } from "babylonjs/scene";
  63221. module "babylonjs/scene" {
  63222. interface Scene {
  63223. /** @hidden (Backing field) */
  63224. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63225. /**
  63226. * Gets the postprocess render pipeline manager
  63227. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63228. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63229. */
  63230. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63231. }
  63232. }
  63233. /**
  63234. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63235. */
  63236. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63237. /**
  63238. * The component name helpfull to identify the component in the list of scene components.
  63239. */
  63240. readonly name: string;
  63241. /**
  63242. * The scene the component belongs to.
  63243. */
  63244. scene: Scene;
  63245. /**
  63246. * Creates a new instance of the component for the given scene
  63247. * @param scene Defines the scene to register the component in
  63248. */
  63249. constructor(scene: Scene);
  63250. /**
  63251. * Registers the component in a given scene
  63252. */
  63253. register(): void;
  63254. /**
  63255. * Rebuilds the elements related to this component in case of
  63256. * context lost for instance.
  63257. */
  63258. rebuild(): void;
  63259. /**
  63260. * Disposes the component and the associated ressources
  63261. */
  63262. dispose(): void;
  63263. private _gatherRenderTargets;
  63264. }
  63265. }
  63266. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  63267. import { Nullable } from "babylonjs/types";
  63268. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63269. import { Camera } from "babylonjs/Cameras/camera";
  63270. import { IDisposable } from "babylonjs/scene";
  63271. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  63272. import { Scene } from "babylonjs/scene";
  63273. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  63274. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63275. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63276. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  63277. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63278. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63279. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  63280. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63281. import { Animation } from "babylonjs/Animations/animation";
  63282. /**
  63283. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63284. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63285. */
  63286. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63287. private _scene;
  63288. private _camerasToBeAttached;
  63289. /**
  63290. * ID of the sharpen post process,
  63291. */
  63292. private readonly SharpenPostProcessId;
  63293. /**
  63294. * @ignore
  63295. * ID of the image processing post process;
  63296. */
  63297. readonly ImageProcessingPostProcessId: string;
  63298. /**
  63299. * @ignore
  63300. * ID of the Fast Approximate Anti-Aliasing post process;
  63301. */
  63302. readonly FxaaPostProcessId: string;
  63303. /**
  63304. * ID of the chromatic aberration post process,
  63305. */
  63306. private readonly ChromaticAberrationPostProcessId;
  63307. /**
  63308. * ID of the grain post process
  63309. */
  63310. private readonly GrainPostProcessId;
  63311. /**
  63312. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63313. */
  63314. sharpen: SharpenPostProcess;
  63315. private _sharpenEffect;
  63316. private bloom;
  63317. /**
  63318. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63319. */
  63320. depthOfField: DepthOfFieldEffect;
  63321. /**
  63322. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63323. */
  63324. fxaa: FxaaPostProcess;
  63325. /**
  63326. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63327. */
  63328. imageProcessing: ImageProcessingPostProcess;
  63329. /**
  63330. * Chromatic aberration post process which will shift rgb colors in the image
  63331. */
  63332. chromaticAberration: ChromaticAberrationPostProcess;
  63333. private _chromaticAberrationEffect;
  63334. /**
  63335. * Grain post process which add noise to the image
  63336. */
  63337. grain: GrainPostProcess;
  63338. private _grainEffect;
  63339. /**
  63340. * Glow post process which adds a glow to emissive areas of the image
  63341. */
  63342. private _glowLayer;
  63343. /**
  63344. * Animations which can be used to tweak settings over a period of time
  63345. */
  63346. animations: Animation[];
  63347. private _imageProcessingConfigurationObserver;
  63348. private _sharpenEnabled;
  63349. private _bloomEnabled;
  63350. private _depthOfFieldEnabled;
  63351. private _depthOfFieldBlurLevel;
  63352. private _fxaaEnabled;
  63353. private _imageProcessingEnabled;
  63354. private _defaultPipelineTextureType;
  63355. private _bloomScale;
  63356. private _chromaticAberrationEnabled;
  63357. private _grainEnabled;
  63358. private _buildAllowed;
  63359. /**
  63360. * Gets active scene
  63361. */
  63362. readonly scene: Scene;
  63363. /**
  63364. * Enable or disable the sharpen process from the pipeline
  63365. */
  63366. sharpenEnabled: boolean;
  63367. private _resizeObserver;
  63368. private _hardwareScaleLevel;
  63369. private _bloomKernel;
  63370. /**
  63371. * Specifies the size of the bloom blur kernel, relative to the final output size
  63372. */
  63373. bloomKernel: number;
  63374. /**
  63375. * Specifies the weight of the bloom in the final rendering
  63376. */
  63377. private _bloomWeight;
  63378. /**
  63379. * Specifies the luma threshold for the area that will be blurred by the bloom
  63380. */
  63381. private _bloomThreshold;
  63382. private _hdr;
  63383. /**
  63384. * The strength of the bloom.
  63385. */
  63386. bloomWeight: number;
  63387. /**
  63388. * The strength of the bloom.
  63389. */
  63390. bloomThreshold: number;
  63391. /**
  63392. * The scale of the bloom, lower value will provide better performance.
  63393. */
  63394. bloomScale: number;
  63395. /**
  63396. * Enable or disable the bloom from the pipeline
  63397. */
  63398. bloomEnabled: boolean;
  63399. private _rebuildBloom;
  63400. /**
  63401. * If the depth of field is enabled.
  63402. */
  63403. depthOfFieldEnabled: boolean;
  63404. /**
  63405. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63406. */
  63407. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  63408. /**
  63409. * If the anti aliasing is enabled.
  63410. */
  63411. fxaaEnabled: boolean;
  63412. private _samples;
  63413. /**
  63414. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63415. */
  63416. samples: number;
  63417. /**
  63418. * If image processing is enabled.
  63419. */
  63420. imageProcessingEnabled: boolean;
  63421. /**
  63422. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63423. */
  63424. glowLayerEnabled: boolean;
  63425. /**
  63426. * Gets the glow layer (or null if not defined)
  63427. */
  63428. readonly glowLayer: Nullable<GlowLayer>;
  63429. /**
  63430. * Enable or disable the chromaticAberration process from the pipeline
  63431. */
  63432. chromaticAberrationEnabled: boolean;
  63433. /**
  63434. * Enable or disable the grain process from the pipeline
  63435. */
  63436. grainEnabled: boolean;
  63437. /**
  63438. * @constructor
  63439. * @param name - The rendering pipeline name (default: "")
  63440. * @param hdr - If high dynamic range textures should be used (default: true)
  63441. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63442. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63443. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63444. */
  63445. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63446. /**
  63447. * Get the class name
  63448. * @returns "DefaultRenderingPipeline"
  63449. */
  63450. getClassName(): string;
  63451. /**
  63452. * Force the compilation of the entire pipeline.
  63453. */
  63454. prepare(): void;
  63455. private _hasCleared;
  63456. private _prevPostProcess;
  63457. private _prevPrevPostProcess;
  63458. private _setAutoClearAndTextureSharing;
  63459. private _depthOfFieldSceneObserver;
  63460. private _buildPipeline;
  63461. private _disposePostProcesses;
  63462. /**
  63463. * Adds a camera to the pipeline
  63464. * @param camera the camera to be added
  63465. */
  63466. addCamera(camera: Camera): void;
  63467. /**
  63468. * Removes a camera from the pipeline
  63469. * @param camera the camera to remove
  63470. */
  63471. removeCamera(camera: Camera): void;
  63472. /**
  63473. * Dispose of the pipeline and stop all post processes
  63474. */
  63475. dispose(): void;
  63476. /**
  63477. * Serialize the rendering pipeline (Used when exporting)
  63478. * @returns the serialized object
  63479. */
  63480. serialize(): any;
  63481. /**
  63482. * Parse the serialized pipeline
  63483. * @param source Source pipeline.
  63484. * @param scene The scene to load the pipeline to.
  63485. * @param rootUrl The URL of the serialized pipeline.
  63486. * @returns An instantiated pipeline from the serialized object.
  63487. */
  63488. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63489. }
  63490. }
  63491. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  63492. /** @hidden */
  63493. export var lensHighlightsPixelShader: {
  63494. name: string;
  63495. shader: string;
  63496. };
  63497. }
  63498. declare module "babylonjs/Shaders/depthOfField.fragment" {
  63499. /** @hidden */
  63500. export var depthOfFieldPixelShader: {
  63501. name: string;
  63502. shader: string;
  63503. };
  63504. }
  63505. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  63506. import { Camera } from "babylonjs/Cameras/camera";
  63507. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63508. import { Scene } from "babylonjs/scene";
  63509. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63510. import "babylonjs/Shaders/chromaticAberration.fragment";
  63511. import "babylonjs/Shaders/lensHighlights.fragment";
  63512. import "babylonjs/Shaders/depthOfField.fragment";
  63513. /**
  63514. * BABYLON.JS Chromatic Aberration GLSL Shader
  63515. * Author: Olivier Guyot
  63516. * Separates very slightly R, G and B colors on the edges of the screen
  63517. * Inspired by Francois Tarlier & Martins Upitis
  63518. */
  63519. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63520. /**
  63521. * @ignore
  63522. * The chromatic aberration PostProcess id in the pipeline
  63523. */
  63524. LensChromaticAberrationEffect: string;
  63525. /**
  63526. * @ignore
  63527. * The highlights enhancing PostProcess id in the pipeline
  63528. */
  63529. HighlightsEnhancingEffect: string;
  63530. /**
  63531. * @ignore
  63532. * The depth-of-field PostProcess id in the pipeline
  63533. */
  63534. LensDepthOfFieldEffect: string;
  63535. private _scene;
  63536. private _depthTexture;
  63537. private _grainTexture;
  63538. private _chromaticAberrationPostProcess;
  63539. private _highlightsPostProcess;
  63540. private _depthOfFieldPostProcess;
  63541. private _edgeBlur;
  63542. private _grainAmount;
  63543. private _chromaticAberration;
  63544. private _distortion;
  63545. private _highlightsGain;
  63546. private _highlightsThreshold;
  63547. private _dofDistance;
  63548. private _dofAperture;
  63549. private _dofDarken;
  63550. private _dofPentagon;
  63551. private _blurNoise;
  63552. /**
  63553. * @constructor
  63554. *
  63555. * Effect parameters are as follow:
  63556. * {
  63557. * chromatic_aberration: number; // from 0 to x (1 for realism)
  63558. * edge_blur: number; // from 0 to x (1 for realism)
  63559. * distortion: number; // from 0 to x (1 for realism)
  63560. * grain_amount: number; // from 0 to 1
  63561. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  63562. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  63563. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  63564. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  63565. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  63566. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  63567. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  63568. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  63569. * }
  63570. * Note: if an effect parameter is unset, effect is disabled
  63571. *
  63572. * @param name The rendering pipeline name
  63573. * @param parameters - An object containing all parameters (see above)
  63574. * @param scene The scene linked to this pipeline
  63575. * @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)
  63576. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63577. */
  63578. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63579. /**
  63580. * Get the class name
  63581. * @returns "LensRenderingPipeline"
  63582. */
  63583. getClassName(): string;
  63584. /**
  63585. * Gets associated scene
  63586. */
  63587. readonly scene: Scene;
  63588. /**
  63589. * Gets or sets the edge blur
  63590. */
  63591. edgeBlur: number;
  63592. /**
  63593. * Gets or sets the grain amount
  63594. */
  63595. grainAmount: number;
  63596. /**
  63597. * Gets or sets the chromatic aberration amount
  63598. */
  63599. chromaticAberration: number;
  63600. /**
  63601. * Gets or sets the depth of field aperture
  63602. */
  63603. dofAperture: number;
  63604. /**
  63605. * Gets or sets the edge distortion
  63606. */
  63607. edgeDistortion: number;
  63608. /**
  63609. * Gets or sets the depth of field distortion
  63610. */
  63611. dofDistortion: number;
  63612. /**
  63613. * Gets or sets the darken out of focus amount
  63614. */
  63615. darkenOutOfFocus: number;
  63616. /**
  63617. * Gets or sets a boolean indicating if blur noise is enabled
  63618. */
  63619. blurNoise: boolean;
  63620. /**
  63621. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63622. */
  63623. pentagonBokeh: boolean;
  63624. /**
  63625. * Gets or sets the highlight grain amount
  63626. */
  63627. highlightsGain: number;
  63628. /**
  63629. * Gets or sets the highlight threshold
  63630. */
  63631. highlightsThreshold: number;
  63632. /**
  63633. * Sets the amount of blur at the edges
  63634. * @param amount blur amount
  63635. */
  63636. setEdgeBlur(amount: number): void;
  63637. /**
  63638. * Sets edge blur to 0
  63639. */
  63640. disableEdgeBlur(): void;
  63641. /**
  63642. * Sets the amout of grain
  63643. * @param amount Amount of grain
  63644. */
  63645. setGrainAmount(amount: number): void;
  63646. /**
  63647. * Set grain amount to 0
  63648. */
  63649. disableGrain(): void;
  63650. /**
  63651. * Sets the chromatic aberration amount
  63652. * @param amount amount of chromatic aberration
  63653. */
  63654. setChromaticAberration(amount: number): void;
  63655. /**
  63656. * Sets chromatic aberration amount to 0
  63657. */
  63658. disableChromaticAberration(): void;
  63659. /**
  63660. * Sets the EdgeDistortion amount
  63661. * @param amount amount of EdgeDistortion
  63662. */
  63663. setEdgeDistortion(amount: number): void;
  63664. /**
  63665. * Sets edge distortion to 0
  63666. */
  63667. disableEdgeDistortion(): void;
  63668. /**
  63669. * Sets the FocusDistance amount
  63670. * @param amount amount of FocusDistance
  63671. */
  63672. setFocusDistance(amount: number): void;
  63673. /**
  63674. * Disables depth of field
  63675. */
  63676. disableDepthOfField(): void;
  63677. /**
  63678. * Sets the Aperture amount
  63679. * @param amount amount of Aperture
  63680. */
  63681. setAperture(amount: number): void;
  63682. /**
  63683. * Sets the DarkenOutOfFocus amount
  63684. * @param amount amount of DarkenOutOfFocus
  63685. */
  63686. setDarkenOutOfFocus(amount: number): void;
  63687. private _pentagonBokehIsEnabled;
  63688. /**
  63689. * Creates a pentagon bokeh effect
  63690. */
  63691. enablePentagonBokeh(): void;
  63692. /**
  63693. * Disables the pentagon bokeh effect
  63694. */
  63695. disablePentagonBokeh(): void;
  63696. /**
  63697. * Enables noise blur
  63698. */
  63699. enableNoiseBlur(): void;
  63700. /**
  63701. * Disables noise blur
  63702. */
  63703. disableNoiseBlur(): void;
  63704. /**
  63705. * Sets the HighlightsGain amount
  63706. * @param amount amount of HighlightsGain
  63707. */
  63708. setHighlightsGain(amount: number): void;
  63709. /**
  63710. * Sets the HighlightsThreshold amount
  63711. * @param amount amount of HighlightsThreshold
  63712. */
  63713. setHighlightsThreshold(amount: number): void;
  63714. /**
  63715. * Disables highlights
  63716. */
  63717. disableHighlights(): void;
  63718. /**
  63719. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63720. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63721. */
  63722. dispose(disableDepthRender?: boolean): void;
  63723. private _createChromaticAberrationPostProcess;
  63724. private _createHighlightsPostProcess;
  63725. private _createDepthOfFieldPostProcess;
  63726. private _createGrainTexture;
  63727. }
  63728. }
  63729. declare module "babylonjs/Shaders/ssao2.fragment" {
  63730. /** @hidden */
  63731. export var ssao2PixelShader: {
  63732. name: string;
  63733. shader: string;
  63734. };
  63735. }
  63736. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  63737. /** @hidden */
  63738. export var ssaoCombinePixelShader: {
  63739. name: string;
  63740. shader: string;
  63741. };
  63742. }
  63743. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  63744. import { Camera } from "babylonjs/Cameras/camera";
  63745. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63746. import { Scene } from "babylonjs/scene";
  63747. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63748. import "babylonjs/Shaders/ssao2.fragment";
  63749. import "babylonjs/Shaders/ssaoCombine.fragment";
  63750. /**
  63751. * Render pipeline to produce ssao effect
  63752. */
  63753. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63754. /**
  63755. * @ignore
  63756. * The PassPostProcess id in the pipeline that contains the original scene color
  63757. */
  63758. SSAOOriginalSceneColorEffect: string;
  63759. /**
  63760. * @ignore
  63761. * The SSAO PostProcess id in the pipeline
  63762. */
  63763. SSAORenderEffect: string;
  63764. /**
  63765. * @ignore
  63766. * The horizontal blur PostProcess id in the pipeline
  63767. */
  63768. SSAOBlurHRenderEffect: string;
  63769. /**
  63770. * @ignore
  63771. * The vertical blur PostProcess id in the pipeline
  63772. */
  63773. SSAOBlurVRenderEffect: string;
  63774. /**
  63775. * @ignore
  63776. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63777. */
  63778. SSAOCombineRenderEffect: string;
  63779. /**
  63780. * The output strength of the SSAO post-process. Default value is 1.0.
  63781. */
  63782. totalStrength: number;
  63783. /**
  63784. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63785. */
  63786. maxZ: number;
  63787. /**
  63788. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63789. */
  63790. minZAspect: number;
  63791. private _samples;
  63792. /**
  63793. * Number of samples used for the SSAO calculations. Default value is 8
  63794. */
  63795. samples: number;
  63796. private _textureSamples;
  63797. /**
  63798. * Number of samples to use for antialiasing
  63799. */
  63800. textureSamples: number;
  63801. /**
  63802. * Ratio object used for SSAO ratio and blur ratio
  63803. */
  63804. private _ratio;
  63805. /**
  63806. * Dynamically generated sphere sampler.
  63807. */
  63808. private _sampleSphere;
  63809. /**
  63810. * Blur filter offsets
  63811. */
  63812. private _samplerOffsets;
  63813. private _expensiveBlur;
  63814. /**
  63815. * If bilateral blur should be used
  63816. */
  63817. expensiveBlur: boolean;
  63818. /**
  63819. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63820. */
  63821. radius: number;
  63822. /**
  63823. * The base color of the SSAO post-process
  63824. * The final result is "base + ssao" between [0, 1]
  63825. */
  63826. base: number;
  63827. /**
  63828. * Support test.
  63829. */
  63830. static readonly IsSupported: boolean;
  63831. private _scene;
  63832. private _depthTexture;
  63833. private _normalTexture;
  63834. private _randomTexture;
  63835. private _originalColorPostProcess;
  63836. private _ssaoPostProcess;
  63837. private _blurHPostProcess;
  63838. private _blurVPostProcess;
  63839. private _ssaoCombinePostProcess;
  63840. private _firstUpdate;
  63841. /**
  63842. * Gets active scene
  63843. */
  63844. readonly scene: Scene;
  63845. /**
  63846. * @constructor
  63847. * @param name The rendering pipeline name
  63848. * @param scene The scene linked to this pipeline
  63849. * @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 }
  63850. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63851. */
  63852. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63853. /**
  63854. * Get the class name
  63855. * @returns "SSAO2RenderingPipeline"
  63856. */
  63857. getClassName(): string;
  63858. /**
  63859. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63860. */
  63861. dispose(disableGeometryBufferRenderer?: boolean): void;
  63862. private _createBlurPostProcess;
  63863. /** @hidden */
  63864. _rebuild(): void;
  63865. private _bits;
  63866. private _radicalInverse_VdC;
  63867. private _hammersley;
  63868. private _hemisphereSample_uniform;
  63869. private _generateHemisphere;
  63870. private _createSSAOPostProcess;
  63871. private _createSSAOCombinePostProcess;
  63872. private _createRandomTexture;
  63873. /**
  63874. * Serialize the rendering pipeline (Used when exporting)
  63875. * @returns the serialized object
  63876. */
  63877. serialize(): any;
  63878. /**
  63879. * Parse the serialized pipeline
  63880. * @param source Source pipeline.
  63881. * @param scene The scene to load the pipeline to.
  63882. * @param rootUrl The URL of the serialized pipeline.
  63883. * @returns An instantiated pipeline from the serialized object.
  63884. */
  63885. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63886. }
  63887. }
  63888. declare module "babylonjs/Shaders/ssao.fragment" {
  63889. /** @hidden */
  63890. export var ssaoPixelShader: {
  63891. name: string;
  63892. shader: string;
  63893. };
  63894. }
  63895. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  63896. import { Camera } from "babylonjs/Cameras/camera";
  63897. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63898. import { Scene } from "babylonjs/scene";
  63899. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63900. import "babylonjs/Shaders/ssao.fragment";
  63901. import "babylonjs/Shaders/ssaoCombine.fragment";
  63902. /**
  63903. * Render pipeline to produce ssao effect
  63904. */
  63905. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63906. /**
  63907. * @ignore
  63908. * The PassPostProcess id in the pipeline that contains the original scene color
  63909. */
  63910. SSAOOriginalSceneColorEffect: string;
  63911. /**
  63912. * @ignore
  63913. * The SSAO PostProcess id in the pipeline
  63914. */
  63915. SSAORenderEffect: string;
  63916. /**
  63917. * @ignore
  63918. * The horizontal blur PostProcess id in the pipeline
  63919. */
  63920. SSAOBlurHRenderEffect: string;
  63921. /**
  63922. * @ignore
  63923. * The vertical blur PostProcess id in the pipeline
  63924. */
  63925. SSAOBlurVRenderEffect: string;
  63926. /**
  63927. * @ignore
  63928. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63929. */
  63930. SSAOCombineRenderEffect: string;
  63931. /**
  63932. * The output strength of the SSAO post-process. Default value is 1.0.
  63933. */
  63934. totalStrength: number;
  63935. /**
  63936. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63937. */
  63938. radius: number;
  63939. /**
  63940. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63941. * Must not be equal to fallOff and superior to fallOff.
  63942. * Default value is 0.0075
  63943. */
  63944. area: number;
  63945. /**
  63946. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63947. * Must not be equal to area and inferior to area.
  63948. * Default value is 0.000001
  63949. */
  63950. fallOff: number;
  63951. /**
  63952. * The base color of the SSAO post-process
  63953. * The final result is "base + ssao" between [0, 1]
  63954. */
  63955. base: number;
  63956. private _scene;
  63957. private _depthTexture;
  63958. private _randomTexture;
  63959. private _originalColorPostProcess;
  63960. private _ssaoPostProcess;
  63961. private _blurHPostProcess;
  63962. private _blurVPostProcess;
  63963. private _ssaoCombinePostProcess;
  63964. private _firstUpdate;
  63965. /**
  63966. * Gets active scene
  63967. */
  63968. readonly scene: Scene;
  63969. /**
  63970. * @constructor
  63971. * @param name - The rendering pipeline name
  63972. * @param scene - The scene linked to this pipeline
  63973. * @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 }
  63974. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63975. */
  63976. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63977. /**
  63978. * Get the class name
  63979. * @returns "SSAORenderingPipeline"
  63980. */
  63981. getClassName(): string;
  63982. /**
  63983. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63984. */
  63985. dispose(disableDepthRender?: boolean): void;
  63986. private _createBlurPostProcess;
  63987. /** @hidden */
  63988. _rebuild(): void;
  63989. private _createSSAOPostProcess;
  63990. private _createSSAOCombinePostProcess;
  63991. private _createRandomTexture;
  63992. }
  63993. }
  63994. declare module "babylonjs/Shaders/standard.fragment" {
  63995. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63996. /** @hidden */
  63997. export var standardPixelShader: {
  63998. name: string;
  63999. shader: string;
  64000. };
  64001. }
  64002. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  64003. import { Nullable } from "babylonjs/types";
  64004. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64005. import { Camera } from "babylonjs/Cameras/camera";
  64006. import { Texture } from "babylonjs/Materials/Textures/texture";
  64007. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64008. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64009. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64010. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64011. import { IDisposable } from "babylonjs/scene";
  64012. import { SpotLight } from "babylonjs/Lights/spotLight";
  64013. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  64014. import { Scene } from "babylonjs/scene";
  64015. import { Animation } from "babylonjs/Animations/animation";
  64016. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64017. import "babylonjs/Shaders/standard.fragment";
  64018. /**
  64019. * Standard rendering pipeline
  64020. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64021. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  64022. */
  64023. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64024. /**
  64025. * Public members
  64026. */
  64027. /**
  64028. * Post-process which contains the original scene color before the pipeline applies all the effects
  64029. */
  64030. originalPostProcess: Nullable<PostProcess>;
  64031. /**
  64032. * Post-process used to down scale an image x4
  64033. */
  64034. downSampleX4PostProcess: Nullable<PostProcess>;
  64035. /**
  64036. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  64037. */
  64038. brightPassPostProcess: Nullable<PostProcess>;
  64039. /**
  64040. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64041. */
  64042. blurHPostProcesses: PostProcess[];
  64043. /**
  64044. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64045. */
  64046. blurVPostProcesses: PostProcess[];
  64047. /**
  64048. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64049. */
  64050. textureAdderPostProcess: Nullable<PostProcess>;
  64051. /**
  64052. * Post-process used to create volumetric lighting effect
  64053. */
  64054. volumetricLightPostProcess: Nullable<PostProcess>;
  64055. /**
  64056. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64057. */
  64058. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64059. /**
  64060. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64061. */
  64062. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64063. /**
  64064. * Post-process used to merge the volumetric light effect and the real scene color
  64065. */
  64066. volumetricLightMergePostProces: Nullable<PostProcess>;
  64067. /**
  64068. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64069. */
  64070. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64071. /**
  64072. * Base post-process used to calculate the average luminance of the final image for HDR
  64073. */
  64074. luminancePostProcess: Nullable<PostProcess>;
  64075. /**
  64076. * Post-processes used to create down sample post-processes in order to get
  64077. * the average luminance of the final image for HDR
  64078. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64079. */
  64080. luminanceDownSamplePostProcesses: PostProcess[];
  64081. /**
  64082. * Post-process used to create a HDR effect (light adaptation)
  64083. */
  64084. hdrPostProcess: Nullable<PostProcess>;
  64085. /**
  64086. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64087. */
  64088. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64089. /**
  64090. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64091. */
  64092. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64093. /**
  64094. * Post-process used to merge the final HDR post-process and the real scene color
  64095. */
  64096. hdrFinalPostProcess: Nullable<PostProcess>;
  64097. /**
  64098. * Post-process used to create a lens flare effect
  64099. */
  64100. lensFlarePostProcess: Nullable<PostProcess>;
  64101. /**
  64102. * Post-process that merges the result of the lens flare post-process and the real scene color
  64103. */
  64104. lensFlareComposePostProcess: Nullable<PostProcess>;
  64105. /**
  64106. * Post-process used to create a motion blur effect
  64107. */
  64108. motionBlurPostProcess: Nullable<PostProcess>;
  64109. /**
  64110. * Post-process used to create a depth of field effect
  64111. */
  64112. depthOfFieldPostProcess: Nullable<PostProcess>;
  64113. /**
  64114. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64115. */
  64116. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64117. /**
  64118. * Represents the brightness threshold in order to configure the illuminated surfaces
  64119. */
  64120. brightThreshold: number;
  64121. /**
  64122. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64123. */
  64124. blurWidth: number;
  64125. /**
  64126. * Sets if the blur for highlighted surfaces must be only horizontal
  64127. */
  64128. horizontalBlur: boolean;
  64129. /**
  64130. * Gets the overall exposure used by the pipeline
  64131. */
  64132. /**
  64133. * Sets the overall exposure used by the pipeline
  64134. */
  64135. exposure: number;
  64136. /**
  64137. * Texture used typically to simulate "dirty" on camera lens
  64138. */
  64139. lensTexture: Nullable<Texture>;
  64140. /**
  64141. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64142. */
  64143. volumetricLightCoefficient: number;
  64144. /**
  64145. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64146. */
  64147. volumetricLightPower: number;
  64148. /**
  64149. * Used the set the blur intensity to smooth the volumetric lights
  64150. */
  64151. volumetricLightBlurScale: number;
  64152. /**
  64153. * Light (spot or directional) used to generate the volumetric lights rays
  64154. * The source light must have a shadow generate so the pipeline can get its
  64155. * depth map
  64156. */
  64157. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64158. /**
  64159. * For eye adaptation, represents the minimum luminance the eye can see
  64160. */
  64161. hdrMinimumLuminance: number;
  64162. /**
  64163. * For eye adaptation, represents the decrease luminance speed
  64164. */
  64165. hdrDecreaseRate: number;
  64166. /**
  64167. * For eye adaptation, represents the increase luminance speed
  64168. */
  64169. hdrIncreaseRate: number;
  64170. /**
  64171. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64172. */
  64173. /**
  64174. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64175. */
  64176. hdrAutoExposure: boolean;
  64177. /**
  64178. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64179. */
  64180. lensColorTexture: Nullable<Texture>;
  64181. /**
  64182. * The overall strengh for the lens flare effect
  64183. */
  64184. lensFlareStrength: number;
  64185. /**
  64186. * Dispersion coefficient for lens flare ghosts
  64187. */
  64188. lensFlareGhostDispersal: number;
  64189. /**
  64190. * Main lens flare halo width
  64191. */
  64192. lensFlareHaloWidth: number;
  64193. /**
  64194. * Based on the lens distortion effect, defines how much the lens flare result
  64195. * is distorted
  64196. */
  64197. lensFlareDistortionStrength: number;
  64198. /**
  64199. * Configures the blur intensity used for for lens flare (halo)
  64200. */
  64201. lensFlareBlurWidth: number;
  64202. /**
  64203. * Lens star texture must be used to simulate rays on the flares and is available
  64204. * in the documentation
  64205. */
  64206. lensStarTexture: Nullable<Texture>;
  64207. /**
  64208. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64209. * flare effect by taking account of the dirt texture
  64210. */
  64211. lensFlareDirtTexture: Nullable<Texture>;
  64212. /**
  64213. * Represents the focal length for the depth of field effect
  64214. */
  64215. depthOfFieldDistance: number;
  64216. /**
  64217. * Represents the blur intensity for the blurred part of the depth of field effect
  64218. */
  64219. depthOfFieldBlurWidth: number;
  64220. /**
  64221. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64222. */
  64223. /**
  64224. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64225. */
  64226. motionStrength: number;
  64227. /**
  64228. * Gets wether or not the motion blur post-process is object based or screen based.
  64229. */
  64230. /**
  64231. * Sets wether or not the motion blur post-process should be object based or screen based
  64232. */
  64233. objectBasedMotionBlur: boolean;
  64234. /**
  64235. * List of animations for the pipeline (IAnimatable implementation)
  64236. */
  64237. animations: Animation[];
  64238. /**
  64239. * Private members
  64240. */
  64241. private _scene;
  64242. private _currentDepthOfFieldSource;
  64243. private _basePostProcess;
  64244. private _fixedExposure;
  64245. private _currentExposure;
  64246. private _hdrAutoExposure;
  64247. private _hdrCurrentLuminance;
  64248. private _motionStrength;
  64249. private _isObjectBasedMotionBlur;
  64250. private _floatTextureType;
  64251. private _camerasToBeAttached;
  64252. private _ratio;
  64253. private _bloomEnabled;
  64254. private _depthOfFieldEnabled;
  64255. private _vlsEnabled;
  64256. private _lensFlareEnabled;
  64257. private _hdrEnabled;
  64258. private _motionBlurEnabled;
  64259. private _fxaaEnabled;
  64260. private _motionBlurSamples;
  64261. private _volumetricLightStepsCount;
  64262. private _samples;
  64263. /**
  64264. * @ignore
  64265. * Specifies if the bloom pipeline is enabled
  64266. */
  64267. BloomEnabled: boolean;
  64268. /**
  64269. * @ignore
  64270. * Specifies if the depth of field pipeline is enabed
  64271. */
  64272. DepthOfFieldEnabled: boolean;
  64273. /**
  64274. * @ignore
  64275. * Specifies if the lens flare pipeline is enabed
  64276. */
  64277. LensFlareEnabled: boolean;
  64278. /**
  64279. * @ignore
  64280. * Specifies if the HDR pipeline is enabled
  64281. */
  64282. HDREnabled: boolean;
  64283. /**
  64284. * @ignore
  64285. * Specifies if the volumetric lights scattering effect is enabled
  64286. */
  64287. VLSEnabled: boolean;
  64288. /**
  64289. * @ignore
  64290. * Specifies if the motion blur effect is enabled
  64291. */
  64292. MotionBlurEnabled: boolean;
  64293. /**
  64294. * Specifies if anti-aliasing is enabled
  64295. */
  64296. fxaaEnabled: boolean;
  64297. /**
  64298. * Specifies the number of steps used to calculate the volumetric lights
  64299. * Typically in interval [50, 200]
  64300. */
  64301. volumetricLightStepsCount: number;
  64302. /**
  64303. * Specifies the number of samples used for the motion blur effect
  64304. * Typically in interval [16, 64]
  64305. */
  64306. motionBlurSamples: number;
  64307. /**
  64308. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64309. */
  64310. samples: number;
  64311. /**
  64312. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64313. * @constructor
  64314. * @param name The rendering pipeline name
  64315. * @param scene The scene linked to this pipeline
  64316. * @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)
  64317. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64318. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64319. */
  64320. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64321. private _buildPipeline;
  64322. private _createDownSampleX4PostProcess;
  64323. private _createBrightPassPostProcess;
  64324. private _createBlurPostProcesses;
  64325. private _createTextureAdderPostProcess;
  64326. private _createVolumetricLightPostProcess;
  64327. private _createLuminancePostProcesses;
  64328. private _createHdrPostProcess;
  64329. private _createLensFlarePostProcess;
  64330. private _createDepthOfFieldPostProcess;
  64331. private _createMotionBlurPostProcess;
  64332. private _getDepthTexture;
  64333. private _disposePostProcesses;
  64334. /**
  64335. * Dispose of the pipeline and stop all post processes
  64336. */
  64337. dispose(): void;
  64338. /**
  64339. * Serialize the rendering pipeline (Used when exporting)
  64340. * @returns the serialized object
  64341. */
  64342. serialize(): any;
  64343. /**
  64344. * Parse the serialized pipeline
  64345. * @param source Source pipeline.
  64346. * @param scene The scene to load the pipeline to.
  64347. * @param rootUrl The URL of the serialized pipeline.
  64348. * @returns An instantiated pipeline from the serialized object.
  64349. */
  64350. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64351. /**
  64352. * Luminance steps
  64353. */
  64354. static LuminanceSteps: number;
  64355. }
  64356. }
  64357. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  64358. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  64359. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  64360. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  64361. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  64362. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  64363. }
  64364. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  64365. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  64366. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64367. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64368. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64369. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64370. }
  64371. declare module "babylonjs/Shaders/tonemap.fragment" {
  64372. /** @hidden */
  64373. export var tonemapPixelShader: {
  64374. name: string;
  64375. shader: string;
  64376. };
  64377. }
  64378. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  64379. import { Camera } from "babylonjs/Cameras/camera";
  64380. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64381. import "babylonjs/Shaders/tonemap.fragment";
  64382. import { Engine } from "babylonjs/Engines/engine";
  64383. /** Defines operator used for tonemapping */
  64384. export enum TonemappingOperator {
  64385. /** Hable */
  64386. Hable = 0,
  64387. /** Reinhard */
  64388. Reinhard = 1,
  64389. /** HejiDawson */
  64390. HejiDawson = 2,
  64391. /** Photographic */
  64392. Photographic = 3
  64393. }
  64394. /**
  64395. * Defines a post process to apply tone mapping
  64396. */
  64397. export class TonemapPostProcess extends PostProcess {
  64398. private _operator;
  64399. /** Defines the required exposure adjustement */
  64400. exposureAdjustment: number;
  64401. /**
  64402. * Creates a new TonemapPostProcess
  64403. * @param name defines the name of the postprocess
  64404. * @param _operator defines the operator to use
  64405. * @param exposureAdjustment defines the required exposure adjustement
  64406. * @param camera defines the camera to use (can be null)
  64407. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64408. * @param engine defines the hosting engine (can be ignore if camera is set)
  64409. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64410. */
  64411. constructor(name: string, _operator: TonemappingOperator,
  64412. /** Defines the required exposure adjustement */
  64413. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64414. }
  64415. }
  64416. declare module "babylonjs/Shaders/depth.vertex" {
  64417. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64418. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64419. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64420. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64421. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64422. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64423. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64424. /** @hidden */
  64425. export var depthVertexShader: {
  64426. name: string;
  64427. shader: string;
  64428. };
  64429. }
  64430. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  64431. /** @hidden */
  64432. export var volumetricLightScatteringPixelShader: {
  64433. name: string;
  64434. shader: string;
  64435. };
  64436. }
  64437. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  64438. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64439. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64440. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64441. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64442. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64443. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64444. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64445. /** @hidden */
  64446. export var volumetricLightScatteringPassVertexShader: {
  64447. name: string;
  64448. shader: string;
  64449. };
  64450. }
  64451. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  64452. /** @hidden */
  64453. export var volumetricLightScatteringPassPixelShader: {
  64454. name: string;
  64455. shader: string;
  64456. };
  64457. }
  64458. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  64459. import { Vector3 } from "babylonjs/Maths/math.vector";
  64460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64461. import { Mesh } from "babylonjs/Meshes/mesh";
  64462. import { Camera } from "babylonjs/Cameras/camera";
  64463. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64464. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64465. import { Scene } from "babylonjs/scene";
  64466. import "babylonjs/Meshes/Builders/planeBuilder";
  64467. import "babylonjs/Shaders/depth.vertex";
  64468. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  64469. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  64470. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  64471. import { Engine } from "babylonjs/Engines/engine";
  64472. /**
  64473. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64474. */
  64475. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64476. private _volumetricLightScatteringPass;
  64477. private _volumetricLightScatteringRTT;
  64478. private _viewPort;
  64479. private _screenCoordinates;
  64480. private _cachedDefines;
  64481. /**
  64482. * If not undefined, the mesh position is computed from the attached node position
  64483. */
  64484. attachedNode: {
  64485. position: Vector3;
  64486. };
  64487. /**
  64488. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64489. */
  64490. customMeshPosition: Vector3;
  64491. /**
  64492. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64493. */
  64494. useCustomMeshPosition: boolean;
  64495. /**
  64496. * If the post-process should inverse the light scattering direction
  64497. */
  64498. invert: boolean;
  64499. /**
  64500. * The internal mesh used by the post-process
  64501. */
  64502. mesh: Mesh;
  64503. /**
  64504. * @hidden
  64505. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64506. */
  64507. useDiffuseColor: boolean;
  64508. /**
  64509. * Array containing the excluded meshes not rendered in the internal pass
  64510. */
  64511. excludedMeshes: AbstractMesh[];
  64512. /**
  64513. * Controls the overall intensity of the post-process
  64514. */
  64515. exposure: number;
  64516. /**
  64517. * Dissipates each sample's contribution in range [0, 1]
  64518. */
  64519. decay: number;
  64520. /**
  64521. * Controls the overall intensity of each sample
  64522. */
  64523. weight: number;
  64524. /**
  64525. * Controls the density of each sample
  64526. */
  64527. density: number;
  64528. /**
  64529. * @constructor
  64530. * @param name The post-process name
  64531. * @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)
  64532. * @param camera The camera that the post-process will be attached to
  64533. * @param mesh The mesh used to create the light scattering
  64534. * @param samples The post-process quality, default 100
  64535. * @param samplingModeThe post-process filtering mode
  64536. * @param engine The babylon engine
  64537. * @param reusable If the post-process is reusable
  64538. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64539. */
  64540. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64541. /**
  64542. * Returns the string "VolumetricLightScatteringPostProcess"
  64543. * @returns "VolumetricLightScatteringPostProcess"
  64544. */
  64545. getClassName(): string;
  64546. private _isReady;
  64547. /**
  64548. * Sets the new light position for light scattering effect
  64549. * @param position The new custom light position
  64550. */
  64551. setCustomMeshPosition(position: Vector3): void;
  64552. /**
  64553. * Returns the light position for light scattering effect
  64554. * @return Vector3 The custom light position
  64555. */
  64556. getCustomMeshPosition(): Vector3;
  64557. /**
  64558. * Disposes the internal assets and detaches the post-process from the camera
  64559. */
  64560. dispose(camera: Camera): void;
  64561. /**
  64562. * Returns the render target texture used by the post-process
  64563. * @return the render target texture used by the post-process
  64564. */
  64565. getPass(): RenderTargetTexture;
  64566. private _meshExcluded;
  64567. private _createPass;
  64568. private _updateMeshScreenCoordinates;
  64569. /**
  64570. * Creates a default mesh for the Volumeric Light Scattering post-process
  64571. * @param name The mesh name
  64572. * @param scene The scene where to create the mesh
  64573. * @return the default mesh
  64574. */
  64575. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  64576. }
  64577. }
  64578. declare module "babylonjs/PostProcesses/index" {
  64579. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  64580. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  64581. export * from "babylonjs/PostProcesses/bloomEffect";
  64582. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  64583. export * from "babylonjs/PostProcesses/blurPostProcess";
  64584. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64585. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  64586. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  64587. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  64588. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64589. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  64590. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  64591. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  64592. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64593. export * from "babylonjs/PostProcesses/filterPostProcess";
  64594. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  64595. export * from "babylonjs/PostProcesses/grainPostProcess";
  64596. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  64597. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64598. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  64599. export * from "babylonjs/PostProcesses/passPostProcess";
  64600. export * from "babylonjs/PostProcesses/postProcess";
  64601. export * from "babylonjs/PostProcesses/postProcessManager";
  64602. export * from "babylonjs/PostProcesses/refractionPostProcess";
  64603. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  64604. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  64605. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  64606. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  64607. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  64608. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  64609. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  64610. }
  64611. declare module "babylonjs/Probes/index" {
  64612. export * from "babylonjs/Probes/reflectionProbe";
  64613. }
  64614. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  64615. import { Scene } from "babylonjs/scene";
  64616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64617. import { SmartArray } from "babylonjs/Misc/smartArray";
  64618. import { ISceneComponent } from "babylonjs/sceneComponent";
  64619. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  64620. import "babylonjs/Meshes/Builders/boxBuilder";
  64621. import "babylonjs/Shaders/color.fragment";
  64622. import "babylonjs/Shaders/color.vertex";
  64623. import { Color3 } from "babylonjs/Maths/math.color";
  64624. module "babylonjs/scene" {
  64625. interface Scene {
  64626. /** @hidden (Backing field) */
  64627. _boundingBoxRenderer: BoundingBoxRenderer;
  64628. /** @hidden (Backing field) */
  64629. _forceShowBoundingBoxes: boolean;
  64630. /**
  64631. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  64632. */
  64633. forceShowBoundingBoxes: boolean;
  64634. /**
  64635. * Gets the bounding box renderer associated with the scene
  64636. * @returns a BoundingBoxRenderer
  64637. */
  64638. getBoundingBoxRenderer(): BoundingBoxRenderer;
  64639. }
  64640. }
  64641. module "babylonjs/Meshes/abstractMesh" {
  64642. interface AbstractMesh {
  64643. /** @hidden (Backing field) */
  64644. _showBoundingBox: boolean;
  64645. /**
  64646. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  64647. */
  64648. showBoundingBox: boolean;
  64649. }
  64650. }
  64651. /**
  64652. * Component responsible of rendering the bounding box of the meshes in a scene.
  64653. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  64654. */
  64655. export class BoundingBoxRenderer implements ISceneComponent {
  64656. /**
  64657. * The component name helpfull to identify the component in the list of scene components.
  64658. */
  64659. readonly name: string;
  64660. /**
  64661. * The scene the component belongs to.
  64662. */
  64663. scene: Scene;
  64664. /**
  64665. * Color of the bounding box lines placed in front of an object
  64666. */
  64667. frontColor: Color3;
  64668. /**
  64669. * Color of the bounding box lines placed behind an object
  64670. */
  64671. backColor: Color3;
  64672. /**
  64673. * Defines if the renderer should show the back lines or not
  64674. */
  64675. showBackLines: boolean;
  64676. /**
  64677. * @hidden
  64678. */
  64679. renderList: SmartArray<BoundingBox>;
  64680. private _colorShader;
  64681. private _vertexBuffers;
  64682. private _indexBuffer;
  64683. private _fillIndexBuffer;
  64684. private _fillIndexData;
  64685. /**
  64686. * Instantiates a new bounding box renderer in a scene.
  64687. * @param scene the scene the renderer renders in
  64688. */
  64689. constructor(scene: Scene);
  64690. /**
  64691. * Registers the component in a given scene
  64692. */
  64693. register(): void;
  64694. private _evaluateSubMesh;
  64695. private _activeMesh;
  64696. private _prepareRessources;
  64697. private _createIndexBuffer;
  64698. /**
  64699. * Rebuilds the elements related to this component in case of
  64700. * context lost for instance.
  64701. */
  64702. rebuild(): void;
  64703. /**
  64704. * @hidden
  64705. */
  64706. reset(): void;
  64707. /**
  64708. * Render the bounding boxes of a specific rendering group
  64709. * @param renderingGroupId defines the rendering group to render
  64710. */
  64711. render(renderingGroupId: number): void;
  64712. /**
  64713. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64714. * @param mesh Define the mesh to render the occlusion bounding box for
  64715. */
  64716. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64717. /**
  64718. * Dispose and release the resources attached to this renderer.
  64719. */
  64720. dispose(): void;
  64721. }
  64722. }
  64723. declare module "babylonjs/Shaders/depth.fragment" {
  64724. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64725. /** @hidden */
  64726. export var depthPixelShader: {
  64727. name: string;
  64728. shader: string;
  64729. };
  64730. }
  64731. declare module "babylonjs/Rendering/depthRenderer" {
  64732. import { Nullable } from "babylonjs/types";
  64733. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64734. import { Scene } from "babylonjs/scene";
  64735. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64736. import { Camera } from "babylonjs/Cameras/camera";
  64737. import "babylonjs/Shaders/depth.fragment";
  64738. import "babylonjs/Shaders/depth.vertex";
  64739. /**
  64740. * This represents a depth renderer in Babylon.
  64741. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64742. */
  64743. export class DepthRenderer {
  64744. private _scene;
  64745. private _depthMap;
  64746. private _effect;
  64747. private readonly _storeNonLinearDepth;
  64748. private readonly _clearColor;
  64749. /** Get if the depth renderer is using packed depth or not */
  64750. readonly isPacked: boolean;
  64751. private _cachedDefines;
  64752. private _camera;
  64753. /**
  64754. * Specifiess that the depth renderer will only be used within
  64755. * the camera it is created for.
  64756. * This can help forcing its rendering during the camera processing.
  64757. */
  64758. useOnlyInActiveCamera: boolean;
  64759. /** @hidden */
  64760. static _SceneComponentInitialization: (scene: Scene) => void;
  64761. /**
  64762. * Instantiates a depth renderer
  64763. * @param scene The scene the renderer belongs to
  64764. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64765. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64766. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64767. */
  64768. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64769. /**
  64770. * Creates the depth rendering effect and checks if the effect is ready.
  64771. * @param subMesh The submesh to be used to render the depth map of
  64772. * @param useInstances If multiple world instances should be used
  64773. * @returns if the depth renderer is ready to render the depth map
  64774. */
  64775. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64776. /**
  64777. * Gets the texture which the depth map will be written to.
  64778. * @returns The depth map texture
  64779. */
  64780. getDepthMap(): RenderTargetTexture;
  64781. /**
  64782. * Disposes of the depth renderer.
  64783. */
  64784. dispose(): void;
  64785. }
  64786. }
  64787. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  64788. import { Nullable } from "babylonjs/types";
  64789. import { Scene } from "babylonjs/scene";
  64790. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64791. import { Camera } from "babylonjs/Cameras/camera";
  64792. import { ISceneComponent } from "babylonjs/sceneComponent";
  64793. module "babylonjs/scene" {
  64794. interface Scene {
  64795. /** @hidden (Backing field) */
  64796. _depthRenderer: {
  64797. [id: string]: DepthRenderer;
  64798. };
  64799. /**
  64800. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64801. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64802. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64803. * @returns the created depth renderer
  64804. */
  64805. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64806. /**
  64807. * Disables a depth renderer for a given camera
  64808. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64809. */
  64810. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64811. }
  64812. }
  64813. /**
  64814. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64815. * in several rendering techniques.
  64816. */
  64817. export class DepthRendererSceneComponent implements ISceneComponent {
  64818. /**
  64819. * The component name helpfull to identify the component in the list of scene components.
  64820. */
  64821. readonly name: string;
  64822. /**
  64823. * The scene the component belongs to.
  64824. */
  64825. scene: Scene;
  64826. /**
  64827. * Creates a new instance of the component for the given scene
  64828. * @param scene Defines the scene to register the component in
  64829. */
  64830. constructor(scene: Scene);
  64831. /**
  64832. * Registers the component in a given scene
  64833. */
  64834. register(): void;
  64835. /**
  64836. * Rebuilds the elements related to this component in case of
  64837. * context lost for instance.
  64838. */
  64839. rebuild(): void;
  64840. /**
  64841. * Disposes the component and the associated ressources
  64842. */
  64843. dispose(): void;
  64844. private _gatherRenderTargets;
  64845. private _gatherActiveCameraRenderTargets;
  64846. }
  64847. }
  64848. declare module "babylonjs/Shaders/outline.fragment" {
  64849. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64850. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  64851. /** @hidden */
  64852. export var outlinePixelShader: {
  64853. name: string;
  64854. shader: string;
  64855. };
  64856. }
  64857. declare module "babylonjs/Shaders/outline.vertex" {
  64858. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64859. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64860. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64861. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64862. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64863. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64864. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64865. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64866. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  64867. /** @hidden */
  64868. export var outlineVertexShader: {
  64869. name: string;
  64870. shader: string;
  64871. };
  64872. }
  64873. declare module "babylonjs/Rendering/outlineRenderer" {
  64874. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64875. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  64876. import { Scene } from "babylonjs/scene";
  64877. import { ISceneComponent } from "babylonjs/sceneComponent";
  64878. import "babylonjs/Shaders/outline.fragment";
  64879. import "babylonjs/Shaders/outline.vertex";
  64880. module "babylonjs/scene" {
  64881. interface Scene {
  64882. /** @hidden */
  64883. _outlineRenderer: OutlineRenderer;
  64884. /**
  64885. * Gets the outline renderer associated with the scene
  64886. * @returns a OutlineRenderer
  64887. */
  64888. getOutlineRenderer(): OutlineRenderer;
  64889. }
  64890. }
  64891. module "babylonjs/Meshes/abstractMesh" {
  64892. interface AbstractMesh {
  64893. /** @hidden (Backing field) */
  64894. _renderOutline: boolean;
  64895. /**
  64896. * Gets or sets a boolean indicating if the outline must be rendered as well
  64897. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64898. */
  64899. renderOutline: boolean;
  64900. /** @hidden (Backing field) */
  64901. _renderOverlay: boolean;
  64902. /**
  64903. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64904. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64905. */
  64906. renderOverlay: boolean;
  64907. }
  64908. }
  64909. /**
  64910. * This class is responsible to draw bothe outline/overlay of meshes.
  64911. * It should not be used directly but through the available method on mesh.
  64912. */
  64913. export class OutlineRenderer implements ISceneComponent {
  64914. /**
  64915. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64916. */
  64917. private static _StencilReference;
  64918. /**
  64919. * The name of the component. Each component must have a unique name.
  64920. */
  64921. name: string;
  64922. /**
  64923. * The scene the component belongs to.
  64924. */
  64925. scene: Scene;
  64926. /**
  64927. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64928. */
  64929. zOffset: number;
  64930. private _engine;
  64931. private _effect;
  64932. private _cachedDefines;
  64933. private _savedDepthWrite;
  64934. /**
  64935. * Instantiates a new outline renderer. (There could be only one per scene).
  64936. * @param scene Defines the scene it belongs to
  64937. */
  64938. constructor(scene: Scene);
  64939. /**
  64940. * Register the component to one instance of a scene.
  64941. */
  64942. register(): void;
  64943. /**
  64944. * Rebuilds the elements related to this component in case of
  64945. * context lost for instance.
  64946. */
  64947. rebuild(): void;
  64948. /**
  64949. * Disposes the component and the associated ressources.
  64950. */
  64951. dispose(): void;
  64952. /**
  64953. * Renders the outline in the canvas.
  64954. * @param subMesh Defines the sumesh to render
  64955. * @param batch Defines the batch of meshes in case of instances
  64956. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64957. */
  64958. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64959. /**
  64960. * Returns whether or not the outline renderer is ready for a given submesh.
  64961. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64962. * @param subMesh Defines the submesh to check readyness for
  64963. * @param useInstances Defines wheter wee are trying to render instances or not
  64964. * @returns true if ready otherwise false
  64965. */
  64966. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64967. private _beforeRenderingMesh;
  64968. private _afterRenderingMesh;
  64969. }
  64970. }
  64971. declare module "babylonjs/Rendering/index" {
  64972. export * from "babylonjs/Rendering/boundingBoxRenderer";
  64973. export * from "babylonjs/Rendering/depthRenderer";
  64974. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  64975. export * from "babylonjs/Rendering/edgesRenderer";
  64976. export * from "babylonjs/Rendering/geometryBufferRenderer";
  64977. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64978. export * from "babylonjs/Rendering/outlineRenderer";
  64979. export * from "babylonjs/Rendering/renderingGroup";
  64980. export * from "babylonjs/Rendering/renderingManager";
  64981. export * from "babylonjs/Rendering/utilityLayerRenderer";
  64982. }
  64983. declare module "babylonjs/Sprites/spritePackedManager" {
  64984. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  64985. import { Scene } from "babylonjs/scene";
  64986. /**
  64987. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64988. * @see http://doc.babylonjs.com/babylon101/sprites
  64989. */
  64990. export class SpritePackedManager extends SpriteManager {
  64991. /** defines the packed manager's name */
  64992. name: string;
  64993. /**
  64994. * Creates a new sprite manager from a packed sprite sheet
  64995. * @param name defines the manager's name
  64996. * @param imgUrl defines the sprite sheet url
  64997. * @param capacity defines the maximum allowed number of sprites
  64998. * @param scene defines the hosting scene
  64999. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  65000. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  65001. * @param samplingMode defines the smapling mode to use with spritesheet
  65002. * @param fromPacked set to true; do not alter
  65003. */
  65004. constructor(
  65005. /** defines the packed manager's name */
  65006. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  65007. }
  65008. }
  65009. declare module "babylonjs/Sprites/index" {
  65010. export * from "babylonjs/Sprites/sprite";
  65011. export * from "babylonjs/Sprites/spriteManager";
  65012. export * from "babylonjs/Sprites/spritePackedManager";
  65013. export * from "babylonjs/Sprites/spriteSceneComponent";
  65014. }
  65015. declare module "babylonjs/States/index" {
  65016. export * from "babylonjs/States/alphaCullingState";
  65017. export * from "babylonjs/States/depthCullingState";
  65018. export * from "babylonjs/States/stencilState";
  65019. }
  65020. declare module "babylonjs/Misc/assetsManager" {
  65021. import { Scene } from "babylonjs/scene";
  65022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65023. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65024. import { Skeleton } from "babylonjs/Bones/skeleton";
  65025. import { Observable } from "babylonjs/Misc/observable";
  65026. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65027. import { Texture } from "babylonjs/Materials/Textures/texture";
  65028. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65029. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  65030. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65031. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  65032. /**
  65033. * Defines the list of states available for a task inside a AssetsManager
  65034. */
  65035. export enum AssetTaskState {
  65036. /**
  65037. * Initialization
  65038. */
  65039. INIT = 0,
  65040. /**
  65041. * Running
  65042. */
  65043. RUNNING = 1,
  65044. /**
  65045. * Done
  65046. */
  65047. DONE = 2,
  65048. /**
  65049. * Error
  65050. */
  65051. ERROR = 3
  65052. }
  65053. /**
  65054. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65055. */
  65056. export abstract class AbstractAssetTask {
  65057. /**
  65058. * Task name
  65059. */ name: string;
  65060. /**
  65061. * Callback called when the task is successful
  65062. */
  65063. onSuccess: (task: any) => void;
  65064. /**
  65065. * Callback called when the task is not successful
  65066. */
  65067. onError: (task: any, message?: string, exception?: any) => void;
  65068. /**
  65069. * Creates a new AssetsManager
  65070. * @param name defines the name of the task
  65071. */
  65072. constructor(
  65073. /**
  65074. * Task name
  65075. */ name: string);
  65076. private _isCompleted;
  65077. private _taskState;
  65078. private _errorObject;
  65079. /**
  65080. * Get if the task is completed
  65081. */
  65082. readonly isCompleted: boolean;
  65083. /**
  65084. * Gets the current state of the task
  65085. */
  65086. readonly taskState: AssetTaskState;
  65087. /**
  65088. * Gets the current error object (if task is in error)
  65089. */
  65090. readonly errorObject: {
  65091. message?: string;
  65092. exception?: any;
  65093. };
  65094. /**
  65095. * Internal only
  65096. * @hidden
  65097. */
  65098. _setErrorObject(message?: string, exception?: any): void;
  65099. /**
  65100. * Execute the current task
  65101. * @param scene defines the scene where you want your assets to be loaded
  65102. * @param onSuccess is a callback called when the task is successfully executed
  65103. * @param onError is a callback called if an error occurs
  65104. */
  65105. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65106. /**
  65107. * Execute the current task
  65108. * @param scene defines the scene where you want your assets to be loaded
  65109. * @param onSuccess is a callback called when the task is successfully executed
  65110. * @param onError is a callback called if an error occurs
  65111. */
  65112. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65113. /**
  65114. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65115. * This can be used with failed tasks that have the reason for failure fixed.
  65116. */
  65117. reset(): void;
  65118. private onErrorCallback;
  65119. private onDoneCallback;
  65120. }
  65121. /**
  65122. * Define the interface used by progress events raised during assets loading
  65123. */
  65124. export interface IAssetsProgressEvent {
  65125. /**
  65126. * Defines the number of remaining tasks to process
  65127. */
  65128. remainingCount: number;
  65129. /**
  65130. * Defines the total number of tasks
  65131. */
  65132. totalCount: number;
  65133. /**
  65134. * Defines the task that was just processed
  65135. */
  65136. task: AbstractAssetTask;
  65137. }
  65138. /**
  65139. * Class used to share progress information about assets loading
  65140. */
  65141. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65142. /**
  65143. * Defines the number of remaining tasks to process
  65144. */
  65145. remainingCount: number;
  65146. /**
  65147. * Defines the total number of tasks
  65148. */
  65149. totalCount: number;
  65150. /**
  65151. * Defines the task that was just processed
  65152. */
  65153. task: AbstractAssetTask;
  65154. /**
  65155. * Creates a AssetsProgressEvent
  65156. * @param remainingCount defines the number of remaining tasks to process
  65157. * @param totalCount defines the total number of tasks
  65158. * @param task defines the task that was just processed
  65159. */
  65160. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65161. }
  65162. /**
  65163. * Define a task used by AssetsManager to load meshes
  65164. */
  65165. export class MeshAssetTask extends AbstractAssetTask {
  65166. /**
  65167. * Defines the name of the task
  65168. */
  65169. name: string;
  65170. /**
  65171. * Defines the list of mesh's names you want to load
  65172. */
  65173. meshesNames: any;
  65174. /**
  65175. * Defines the root url to use as a base to load your meshes and associated resources
  65176. */
  65177. rootUrl: string;
  65178. /**
  65179. * Defines the filename of the scene to load from
  65180. */
  65181. sceneFilename: string;
  65182. /**
  65183. * Gets the list of loaded meshes
  65184. */
  65185. loadedMeshes: Array<AbstractMesh>;
  65186. /**
  65187. * Gets the list of loaded particle systems
  65188. */
  65189. loadedParticleSystems: Array<IParticleSystem>;
  65190. /**
  65191. * Gets the list of loaded skeletons
  65192. */
  65193. loadedSkeletons: Array<Skeleton>;
  65194. /**
  65195. * Gets the list of loaded animation groups
  65196. */
  65197. loadedAnimationGroups: Array<AnimationGroup>;
  65198. /**
  65199. * Callback called when the task is successful
  65200. */
  65201. onSuccess: (task: MeshAssetTask) => void;
  65202. /**
  65203. * Callback called when the task is successful
  65204. */
  65205. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65206. /**
  65207. * Creates a new MeshAssetTask
  65208. * @param name defines the name of the task
  65209. * @param meshesNames defines the list of mesh's names you want to load
  65210. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65211. * @param sceneFilename defines the filename of the scene to load from
  65212. */
  65213. constructor(
  65214. /**
  65215. * Defines the name of the task
  65216. */
  65217. name: string,
  65218. /**
  65219. * Defines the list of mesh's names you want to load
  65220. */
  65221. meshesNames: any,
  65222. /**
  65223. * Defines the root url to use as a base to load your meshes and associated resources
  65224. */
  65225. rootUrl: string,
  65226. /**
  65227. * Defines the filename of the scene to load from
  65228. */
  65229. sceneFilename: string);
  65230. /**
  65231. * Execute the current task
  65232. * @param scene defines the scene where you want your assets to be loaded
  65233. * @param onSuccess is a callback called when the task is successfully executed
  65234. * @param onError is a callback called if an error occurs
  65235. */
  65236. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65237. }
  65238. /**
  65239. * Define a task used by AssetsManager to load text content
  65240. */
  65241. export class TextFileAssetTask extends AbstractAssetTask {
  65242. /**
  65243. * Defines the name of the task
  65244. */
  65245. name: string;
  65246. /**
  65247. * Defines the location of the file to load
  65248. */
  65249. url: string;
  65250. /**
  65251. * Gets the loaded text string
  65252. */
  65253. text: string;
  65254. /**
  65255. * Callback called when the task is successful
  65256. */
  65257. onSuccess: (task: TextFileAssetTask) => void;
  65258. /**
  65259. * Callback called when the task is successful
  65260. */
  65261. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65262. /**
  65263. * Creates a new TextFileAssetTask object
  65264. * @param name defines the name of the task
  65265. * @param url defines the location of the file to load
  65266. */
  65267. constructor(
  65268. /**
  65269. * Defines the name of the task
  65270. */
  65271. name: string,
  65272. /**
  65273. * Defines the location of the file to load
  65274. */
  65275. url: string);
  65276. /**
  65277. * Execute the current task
  65278. * @param scene defines the scene where you want your assets to be loaded
  65279. * @param onSuccess is a callback called when the task is successfully executed
  65280. * @param onError is a callback called if an error occurs
  65281. */
  65282. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65283. }
  65284. /**
  65285. * Define a task used by AssetsManager to load binary data
  65286. */
  65287. export class BinaryFileAssetTask extends AbstractAssetTask {
  65288. /**
  65289. * Defines the name of the task
  65290. */
  65291. name: string;
  65292. /**
  65293. * Defines the location of the file to load
  65294. */
  65295. url: string;
  65296. /**
  65297. * Gets the lodaded data (as an array buffer)
  65298. */
  65299. data: ArrayBuffer;
  65300. /**
  65301. * Callback called when the task is successful
  65302. */
  65303. onSuccess: (task: BinaryFileAssetTask) => void;
  65304. /**
  65305. * Callback called when the task is successful
  65306. */
  65307. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65308. /**
  65309. * Creates a new BinaryFileAssetTask object
  65310. * @param name defines the name of the new task
  65311. * @param url defines the location of the file to load
  65312. */
  65313. constructor(
  65314. /**
  65315. * Defines the name of the task
  65316. */
  65317. name: string,
  65318. /**
  65319. * Defines the location of the file to load
  65320. */
  65321. url: string);
  65322. /**
  65323. * Execute the current task
  65324. * @param scene defines the scene where you want your assets to be loaded
  65325. * @param onSuccess is a callback called when the task is successfully executed
  65326. * @param onError is a callback called if an error occurs
  65327. */
  65328. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65329. }
  65330. /**
  65331. * Define a task used by AssetsManager to load images
  65332. */
  65333. export class ImageAssetTask extends AbstractAssetTask {
  65334. /**
  65335. * Defines the name of the task
  65336. */
  65337. name: string;
  65338. /**
  65339. * Defines the location of the image to load
  65340. */
  65341. url: string;
  65342. /**
  65343. * Gets the loaded images
  65344. */
  65345. image: HTMLImageElement;
  65346. /**
  65347. * Callback called when the task is successful
  65348. */
  65349. onSuccess: (task: ImageAssetTask) => void;
  65350. /**
  65351. * Callback called when the task is successful
  65352. */
  65353. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65354. /**
  65355. * Creates a new ImageAssetTask
  65356. * @param name defines the name of the task
  65357. * @param url defines the location of the image to load
  65358. */
  65359. constructor(
  65360. /**
  65361. * Defines the name of the task
  65362. */
  65363. name: string,
  65364. /**
  65365. * Defines the location of the image to load
  65366. */
  65367. url: string);
  65368. /**
  65369. * Execute the current task
  65370. * @param scene defines the scene where you want your assets to be loaded
  65371. * @param onSuccess is a callback called when the task is successfully executed
  65372. * @param onError is a callback called if an error occurs
  65373. */
  65374. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65375. }
  65376. /**
  65377. * Defines the interface used by texture loading tasks
  65378. */
  65379. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65380. /**
  65381. * Gets the loaded texture
  65382. */
  65383. texture: TEX;
  65384. }
  65385. /**
  65386. * Define a task used by AssetsManager to load 2D textures
  65387. */
  65388. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65389. /**
  65390. * Defines the name of the task
  65391. */
  65392. name: string;
  65393. /**
  65394. * Defines the location of the file to load
  65395. */
  65396. url: string;
  65397. /**
  65398. * Defines if mipmap should not be generated (default is false)
  65399. */
  65400. noMipmap?: boolean | undefined;
  65401. /**
  65402. * Defines if texture must be inverted on Y axis (default is false)
  65403. */
  65404. invertY?: boolean | undefined;
  65405. /**
  65406. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65407. */
  65408. samplingMode: number;
  65409. /**
  65410. * Gets the loaded texture
  65411. */
  65412. texture: Texture;
  65413. /**
  65414. * Callback called when the task is successful
  65415. */
  65416. onSuccess: (task: TextureAssetTask) => void;
  65417. /**
  65418. * Callback called when the task is successful
  65419. */
  65420. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65421. /**
  65422. * Creates a new TextureAssetTask object
  65423. * @param name defines the name of the task
  65424. * @param url defines the location of the file to load
  65425. * @param noMipmap defines if mipmap should not be generated (default is false)
  65426. * @param invertY defines if texture must be inverted on Y axis (default is false)
  65427. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65428. */
  65429. constructor(
  65430. /**
  65431. * Defines the name of the task
  65432. */
  65433. name: string,
  65434. /**
  65435. * Defines the location of the file to load
  65436. */
  65437. url: string,
  65438. /**
  65439. * Defines if mipmap should not be generated (default is false)
  65440. */
  65441. noMipmap?: boolean | undefined,
  65442. /**
  65443. * Defines if texture must be inverted on Y axis (default is false)
  65444. */
  65445. invertY?: boolean | undefined,
  65446. /**
  65447. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65448. */
  65449. samplingMode?: number);
  65450. /**
  65451. * Execute the current task
  65452. * @param scene defines the scene where you want your assets to be loaded
  65453. * @param onSuccess is a callback called when the task is successfully executed
  65454. * @param onError is a callback called if an error occurs
  65455. */
  65456. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65457. }
  65458. /**
  65459. * Define a task used by AssetsManager to load cube textures
  65460. */
  65461. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65462. /**
  65463. * Defines the name of the task
  65464. */
  65465. name: string;
  65466. /**
  65467. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65468. */
  65469. url: string;
  65470. /**
  65471. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65472. */
  65473. extensions?: string[] | undefined;
  65474. /**
  65475. * Defines if mipmaps should not be generated (default is false)
  65476. */
  65477. noMipmap?: boolean | undefined;
  65478. /**
  65479. * Defines the explicit list of files (undefined by default)
  65480. */
  65481. files?: string[] | undefined;
  65482. /**
  65483. * Gets the loaded texture
  65484. */
  65485. texture: CubeTexture;
  65486. /**
  65487. * Callback called when the task is successful
  65488. */
  65489. onSuccess: (task: CubeTextureAssetTask) => void;
  65490. /**
  65491. * Callback called when the task is successful
  65492. */
  65493. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65494. /**
  65495. * Creates a new CubeTextureAssetTask
  65496. * @param name defines the name of the task
  65497. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65498. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65499. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65500. * @param files defines the explicit list of files (undefined by default)
  65501. */
  65502. constructor(
  65503. /**
  65504. * Defines the name of the task
  65505. */
  65506. name: string,
  65507. /**
  65508. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65509. */
  65510. url: string,
  65511. /**
  65512. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65513. */
  65514. extensions?: string[] | undefined,
  65515. /**
  65516. * Defines if mipmaps should not be generated (default is false)
  65517. */
  65518. noMipmap?: boolean | undefined,
  65519. /**
  65520. * Defines the explicit list of files (undefined by default)
  65521. */
  65522. files?: string[] | undefined);
  65523. /**
  65524. * Execute the current task
  65525. * @param scene defines the scene where you want your assets to be loaded
  65526. * @param onSuccess is a callback called when the task is successfully executed
  65527. * @param onError is a callback called if an error occurs
  65528. */
  65529. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65530. }
  65531. /**
  65532. * Define a task used by AssetsManager to load HDR cube textures
  65533. */
  65534. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65535. /**
  65536. * Defines the name of the task
  65537. */
  65538. name: string;
  65539. /**
  65540. * Defines the location of the file to load
  65541. */
  65542. url: string;
  65543. /**
  65544. * Defines the desired size (the more it increases the longer the generation will be)
  65545. */
  65546. size: number;
  65547. /**
  65548. * Defines if mipmaps should not be generated (default is false)
  65549. */
  65550. noMipmap: boolean;
  65551. /**
  65552. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65553. */
  65554. generateHarmonics: boolean;
  65555. /**
  65556. * 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)
  65557. */
  65558. gammaSpace: boolean;
  65559. /**
  65560. * Internal Use Only
  65561. */
  65562. reserved: boolean;
  65563. /**
  65564. * Gets the loaded texture
  65565. */
  65566. texture: HDRCubeTexture;
  65567. /**
  65568. * Callback called when the task is successful
  65569. */
  65570. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65571. /**
  65572. * Callback called when the task is successful
  65573. */
  65574. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65575. /**
  65576. * Creates a new HDRCubeTextureAssetTask object
  65577. * @param name defines the name of the task
  65578. * @param url defines the location of the file to load
  65579. * @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.
  65580. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65581. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65582. * @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)
  65583. * @param reserved Internal use only
  65584. */
  65585. constructor(
  65586. /**
  65587. * Defines the name of the task
  65588. */
  65589. name: string,
  65590. /**
  65591. * Defines the location of the file to load
  65592. */
  65593. url: string,
  65594. /**
  65595. * Defines the desired size (the more it increases the longer the generation will be)
  65596. */
  65597. size: number,
  65598. /**
  65599. * Defines if mipmaps should not be generated (default is false)
  65600. */
  65601. noMipmap?: boolean,
  65602. /**
  65603. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65604. */
  65605. generateHarmonics?: boolean,
  65606. /**
  65607. * 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)
  65608. */
  65609. gammaSpace?: boolean,
  65610. /**
  65611. * Internal Use Only
  65612. */
  65613. reserved?: boolean);
  65614. /**
  65615. * Execute the current task
  65616. * @param scene defines the scene where you want your assets to be loaded
  65617. * @param onSuccess is a callback called when the task is successfully executed
  65618. * @param onError is a callback called if an error occurs
  65619. */
  65620. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65621. }
  65622. /**
  65623. * Define a task used by AssetsManager to load Equirectangular cube textures
  65624. */
  65625. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65626. /**
  65627. * Defines the name of the task
  65628. */
  65629. name: string;
  65630. /**
  65631. * Defines the location of the file to load
  65632. */
  65633. url: string;
  65634. /**
  65635. * Defines the desired size (the more it increases the longer the generation will be)
  65636. */
  65637. size: number;
  65638. /**
  65639. * Defines if mipmaps should not be generated (default is false)
  65640. */
  65641. noMipmap: boolean;
  65642. /**
  65643. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65644. * but the standard material would require them in Gamma space) (default is true)
  65645. */
  65646. gammaSpace: boolean;
  65647. /**
  65648. * Gets the loaded texture
  65649. */
  65650. texture: EquiRectangularCubeTexture;
  65651. /**
  65652. * Callback called when the task is successful
  65653. */
  65654. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65655. /**
  65656. * Callback called when the task is successful
  65657. */
  65658. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65659. /**
  65660. * Creates a new EquiRectangularCubeTextureAssetTask object
  65661. * @param name defines the name of the task
  65662. * @param url defines the location of the file to load
  65663. * @param size defines the desired size (the more it increases the longer the generation will be)
  65664. * If the size is omitted this implies you are using a preprocessed cubemap.
  65665. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65666. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65667. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65668. * (default is true)
  65669. */
  65670. constructor(
  65671. /**
  65672. * Defines the name of the task
  65673. */
  65674. name: string,
  65675. /**
  65676. * Defines the location of the file to load
  65677. */
  65678. url: string,
  65679. /**
  65680. * Defines the desired size (the more it increases the longer the generation will be)
  65681. */
  65682. size: number,
  65683. /**
  65684. * Defines if mipmaps should not be generated (default is false)
  65685. */
  65686. noMipmap?: boolean,
  65687. /**
  65688. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65689. * but the standard material would require them in Gamma space) (default is true)
  65690. */
  65691. gammaSpace?: boolean);
  65692. /**
  65693. * Execute the current task
  65694. * @param scene defines the scene where you want your assets to be loaded
  65695. * @param onSuccess is a callback called when the task is successfully executed
  65696. * @param onError is a callback called if an error occurs
  65697. */
  65698. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65699. }
  65700. /**
  65701. * This class can be used to easily import assets into a scene
  65702. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65703. */
  65704. export class AssetsManager {
  65705. private _scene;
  65706. private _isLoading;
  65707. protected _tasks: AbstractAssetTask[];
  65708. protected _waitingTasksCount: number;
  65709. protected _totalTasksCount: number;
  65710. /**
  65711. * Callback called when all tasks are processed
  65712. */
  65713. onFinish: (tasks: AbstractAssetTask[]) => void;
  65714. /**
  65715. * Callback called when a task is successful
  65716. */
  65717. onTaskSuccess: (task: AbstractAssetTask) => void;
  65718. /**
  65719. * Callback called when a task had an error
  65720. */
  65721. onTaskError: (task: AbstractAssetTask) => void;
  65722. /**
  65723. * Callback called when a task is done (whatever the result is)
  65724. */
  65725. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65726. /**
  65727. * Observable called when all tasks are processed
  65728. */
  65729. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65730. /**
  65731. * Observable called when a task had an error
  65732. */
  65733. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65734. /**
  65735. * Observable called when all tasks were executed
  65736. */
  65737. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65738. /**
  65739. * Observable called when a task is done (whatever the result is)
  65740. */
  65741. onProgressObservable: Observable<IAssetsProgressEvent>;
  65742. /**
  65743. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65744. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65745. */
  65746. useDefaultLoadingScreen: boolean;
  65747. /**
  65748. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65749. * when all assets have been downloaded.
  65750. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65751. */
  65752. autoHideLoadingUI: boolean;
  65753. /**
  65754. * Creates a new AssetsManager
  65755. * @param scene defines the scene to work on
  65756. */
  65757. constructor(scene: Scene);
  65758. /**
  65759. * Add a MeshAssetTask to the list of active tasks
  65760. * @param taskName defines the name of the new task
  65761. * @param meshesNames defines the name of meshes to load
  65762. * @param rootUrl defines the root url to use to locate files
  65763. * @param sceneFilename defines the filename of the scene file
  65764. * @returns a new MeshAssetTask object
  65765. */
  65766. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65767. /**
  65768. * Add a TextFileAssetTask to the list of active tasks
  65769. * @param taskName defines the name of the new task
  65770. * @param url defines the url of the file to load
  65771. * @returns a new TextFileAssetTask object
  65772. */
  65773. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65774. /**
  65775. * Add a BinaryFileAssetTask to the list of active tasks
  65776. * @param taskName defines the name of the new task
  65777. * @param url defines the url of the file to load
  65778. * @returns a new BinaryFileAssetTask object
  65779. */
  65780. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65781. /**
  65782. * Add a ImageAssetTask to the list of active tasks
  65783. * @param taskName defines the name of the new task
  65784. * @param url defines the url of the file to load
  65785. * @returns a new ImageAssetTask object
  65786. */
  65787. addImageTask(taskName: string, url: string): ImageAssetTask;
  65788. /**
  65789. * Add a TextureAssetTask to the list of active tasks
  65790. * @param taskName defines the name of the new task
  65791. * @param url defines the url of the file to load
  65792. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65793. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65794. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65795. * @returns a new TextureAssetTask object
  65796. */
  65797. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65798. /**
  65799. * Add a CubeTextureAssetTask to the list of active tasks
  65800. * @param taskName defines the name of the new task
  65801. * @param url defines the url of the file to load
  65802. * @param extensions defines the extension to use to load the cube map (can be null)
  65803. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65804. * @param files defines the list of files to load (can be null)
  65805. * @returns a new CubeTextureAssetTask object
  65806. */
  65807. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  65808. /**
  65809. *
  65810. * Add a HDRCubeTextureAssetTask to the list of active tasks
  65811. * @param taskName defines the name of the new task
  65812. * @param url defines the url of the file to load
  65813. * @param size defines the size you want for the cubemap (can be null)
  65814. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65815. * @param generateHarmonics defines if you want to automatically generate (true by default)
  65816. * @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)
  65817. * @param reserved Internal use only
  65818. * @returns a new HDRCubeTextureAssetTask object
  65819. */
  65820. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  65821. /**
  65822. *
  65823. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  65824. * @param taskName defines the name of the new task
  65825. * @param url defines the url of the file to load
  65826. * @param size defines the size you want for the cubemap (can be null)
  65827. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65828. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65829. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65830. * @returns a new EquiRectangularCubeTextureAssetTask object
  65831. */
  65832. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  65833. /**
  65834. * Remove a task from the assets manager.
  65835. * @param task the task to remove
  65836. */
  65837. removeTask(task: AbstractAssetTask): void;
  65838. private _decreaseWaitingTasksCount;
  65839. private _runTask;
  65840. /**
  65841. * Reset the AssetsManager and remove all tasks
  65842. * @return the current instance of the AssetsManager
  65843. */
  65844. reset(): AssetsManager;
  65845. /**
  65846. * Start the loading process
  65847. * @return the current instance of the AssetsManager
  65848. */
  65849. load(): AssetsManager;
  65850. /**
  65851. * Start the loading process as an async operation
  65852. * @return a promise returning the list of failed tasks
  65853. */
  65854. loadAsync(): Promise<void>;
  65855. }
  65856. }
  65857. declare module "babylonjs/Misc/deferred" {
  65858. /**
  65859. * Wrapper class for promise with external resolve and reject.
  65860. */
  65861. export class Deferred<T> {
  65862. /**
  65863. * The promise associated with this deferred object.
  65864. */
  65865. readonly promise: Promise<T>;
  65866. private _resolve;
  65867. private _reject;
  65868. /**
  65869. * The resolve method of the promise associated with this deferred object.
  65870. */
  65871. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  65872. /**
  65873. * The reject method of the promise associated with this deferred object.
  65874. */
  65875. readonly reject: (reason?: any) => void;
  65876. /**
  65877. * Constructor for this deferred object.
  65878. */
  65879. constructor();
  65880. }
  65881. }
  65882. declare module "babylonjs/Misc/meshExploder" {
  65883. import { Mesh } from "babylonjs/Meshes/mesh";
  65884. /**
  65885. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  65886. */
  65887. export class MeshExploder {
  65888. private _centerMesh;
  65889. private _meshes;
  65890. private _meshesOrigins;
  65891. private _toCenterVectors;
  65892. private _scaledDirection;
  65893. private _newPosition;
  65894. private _centerPosition;
  65895. /**
  65896. * Explodes meshes from a center mesh.
  65897. * @param meshes The meshes to explode.
  65898. * @param centerMesh The mesh to be center of explosion.
  65899. */
  65900. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  65901. private _setCenterMesh;
  65902. /**
  65903. * Get class name
  65904. * @returns "MeshExploder"
  65905. */
  65906. getClassName(): string;
  65907. /**
  65908. * "Exploded meshes"
  65909. * @returns Array of meshes with the centerMesh at index 0.
  65910. */
  65911. getMeshes(): Array<Mesh>;
  65912. /**
  65913. * Explodes meshes giving a specific direction
  65914. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  65915. */
  65916. explode(direction?: number): void;
  65917. }
  65918. }
  65919. declare module "babylonjs/Misc/filesInput" {
  65920. import { Engine } from "babylonjs/Engines/engine";
  65921. import { Scene } from "babylonjs/scene";
  65922. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  65923. /**
  65924. * Class used to help managing file picking and drag'n'drop
  65925. */
  65926. export class FilesInput {
  65927. /**
  65928. * List of files ready to be loaded
  65929. */
  65930. static readonly FilesToLoad: {
  65931. [key: string]: File;
  65932. };
  65933. /**
  65934. * Callback called when a file is processed
  65935. */
  65936. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  65937. private _engine;
  65938. private _currentScene;
  65939. private _sceneLoadedCallback;
  65940. private _progressCallback;
  65941. private _additionalRenderLoopLogicCallback;
  65942. private _textureLoadingCallback;
  65943. private _startingProcessingFilesCallback;
  65944. private _onReloadCallback;
  65945. private _errorCallback;
  65946. private _elementToMonitor;
  65947. private _sceneFileToLoad;
  65948. private _filesToLoad;
  65949. /**
  65950. * Creates a new FilesInput
  65951. * @param engine defines the rendering engine
  65952. * @param scene defines the hosting scene
  65953. * @param sceneLoadedCallback callback called when scene is loaded
  65954. * @param progressCallback callback called to track progress
  65955. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  65956. * @param textureLoadingCallback callback called when a texture is loading
  65957. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  65958. * @param onReloadCallback callback called when a reload is requested
  65959. * @param errorCallback callback call if an error occurs
  65960. */
  65961. 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);
  65962. private _dragEnterHandler;
  65963. private _dragOverHandler;
  65964. private _dropHandler;
  65965. /**
  65966. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65967. * @param elementToMonitor defines the DOM element to track
  65968. */
  65969. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65970. /**
  65971. * Release all associated resources
  65972. */
  65973. dispose(): void;
  65974. private renderFunction;
  65975. private drag;
  65976. private drop;
  65977. private _traverseFolder;
  65978. private _processFiles;
  65979. /**
  65980. * Load files from a drop event
  65981. * @param event defines the drop event to use as source
  65982. */
  65983. loadFiles(event: any): void;
  65984. private _processReload;
  65985. /**
  65986. * Reload the current scene from the loaded files
  65987. */
  65988. reload(): void;
  65989. }
  65990. }
  65991. declare module "babylonjs/Misc/HighDynamicRange/index" {
  65992. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  65993. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  65994. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  65995. }
  65996. declare module "babylonjs/Misc/sceneOptimizer" {
  65997. import { Scene, IDisposable } from "babylonjs/scene";
  65998. import { Observable } from "babylonjs/Misc/observable";
  65999. /**
  66000. * Defines the root class used to create scene optimization to use with SceneOptimizer
  66001. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66002. */
  66003. export class SceneOptimization {
  66004. /**
  66005. * Defines the priority of this optimization (0 by default which means first in the list)
  66006. */
  66007. priority: number;
  66008. /**
  66009. * Gets a string describing the action executed by the current optimization
  66010. * @returns description string
  66011. */
  66012. getDescription(): string;
  66013. /**
  66014. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66015. * @param scene defines the current scene where to apply this optimization
  66016. * @param optimizer defines the current optimizer
  66017. * @returns true if everything that can be done was applied
  66018. */
  66019. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66020. /**
  66021. * Creates the SceneOptimization object
  66022. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66023. * @param desc defines the description associated with the optimization
  66024. */
  66025. constructor(
  66026. /**
  66027. * Defines the priority of this optimization (0 by default which means first in the list)
  66028. */
  66029. priority?: number);
  66030. }
  66031. /**
  66032. * Defines an optimization used to reduce the size of render target textures
  66033. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66034. */
  66035. export class TextureOptimization extends SceneOptimization {
  66036. /**
  66037. * Defines the priority of this optimization (0 by default which means first in the list)
  66038. */
  66039. priority: number;
  66040. /**
  66041. * 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
  66042. */
  66043. maximumSize: number;
  66044. /**
  66045. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66046. */
  66047. step: number;
  66048. /**
  66049. * Gets a string describing the action executed by the current optimization
  66050. * @returns description string
  66051. */
  66052. getDescription(): string;
  66053. /**
  66054. * Creates the TextureOptimization object
  66055. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66056. * @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
  66057. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66058. */
  66059. constructor(
  66060. /**
  66061. * Defines the priority of this optimization (0 by default which means first in the list)
  66062. */
  66063. priority?: number,
  66064. /**
  66065. * 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
  66066. */
  66067. maximumSize?: number,
  66068. /**
  66069. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66070. */
  66071. step?: number);
  66072. /**
  66073. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66074. * @param scene defines the current scene where to apply this optimization
  66075. * @param optimizer defines the current optimizer
  66076. * @returns true if everything that can be done was applied
  66077. */
  66078. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66079. }
  66080. /**
  66081. * Defines an optimization used to increase or decrease the rendering resolution
  66082. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66083. */
  66084. export class HardwareScalingOptimization extends SceneOptimization {
  66085. /**
  66086. * Defines the priority of this optimization (0 by default which means first in the list)
  66087. */
  66088. priority: number;
  66089. /**
  66090. * Defines the maximum scale to use (2 by default)
  66091. */
  66092. maximumScale: number;
  66093. /**
  66094. * Defines the step to use between two passes (0.5 by default)
  66095. */
  66096. step: number;
  66097. private _currentScale;
  66098. private _directionOffset;
  66099. /**
  66100. * Gets a string describing the action executed by the current optimization
  66101. * @return description string
  66102. */
  66103. getDescription(): string;
  66104. /**
  66105. * Creates the HardwareScalingOptimization object
  66106. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66107. * @param maximumScale defines the maximum scale to use (2 by default)
  66108. * @param step defines the step to use between two passes (0.5 by default)
  66109. */
  66110. constructor(
  66111. /**
  66112. * Defines the priority of this optimization (0 by default which means first in the list)
  66113. */
  66114. priority?: number,
  66115. /**
  66116. * Defines the maximum scale to use (2 by default)
  66117. */
  66118. maximumScale?: number,
  66119. /**
  66120. * Defines the step to use between two passes (0.5 by default)
  66121. */
  66122. step?: number);
  66123. /**
  66124. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66125. * @param scene defines the current scene where to apply this optimization
  66126. * @param optimizer defines the current optimizer
  66127. * @returns true if everything that can be done was applied
  66128. */
  66129. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66130. }
  66131. /**
  66132. * Defines an optimization used to remove shadows
  66133. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66134. */
  66135. export class ShadowsOptimization extends SceneOptimization {
  66136. /**
  66137. * Gets a string describing the action executed by the current optimization
  66138. * @return description string
  66139. */
  66140. getDescription(): string;
  66141. /**
  66142. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66143. * @param scene defines the current scene where to apply this optimization
  66144. * @param optimizer defines the current optimizer
  66145. * @returns true if everything that can be done was applied
  66146. */
  66147. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66148. }
  66149. /**
  66150. * Defines an optimization used to turn post-processes off
  66151. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66152. */
  66153. export class PostProcessesOptimization extends SceneOptimization {
  66154. /**
  66155. * Gets a string describing the action executed by the current optimization
  66156. * @return description string
  66157. */
  66158. getDescription(): string;
  66159. /**
  66160. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66161. * @param scene defines the current scene where to apply this optimization
  66162. * @param optimizer defines the current optimizer
  66163. * @returns true if everything that can be done was applied
  66164. */
  66165. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66166. }
  66167. /**
  66168. * Defines an optimization used to turn lens flares off
  66169. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66170. */
  66171. export class LensFlaresOptimization extends SceneOptimization {
  66172. /**
  66173. * Gets a string describing the action executed by the current optimization
  66174. * @return description string
  66175. */
  66176. getDescription(): string;
  66177. /**
  66178. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66179. * @param scene defines the current scene where to apply this optimization
  66180. * @param optimizer defines the current optimizer
  66181. * @returns true if everything that can be done was applied
  66182. */
  66183. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66184. }
  66185. /**
  66186. * Defines an optimization based on user defined callback.
  66187. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66188. */
  66189. export class CustomOptimization extends SceneOptimization {
  66190. /**
  66191. * Callback called to apply the custom optimization.
  66192. */
  66193. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66194. /**
  66195. * Callback called to get custom description
  66196. */
  66197. onGetDescription: () => string;
  66198. /**
  66199. * Gets a string describing the action executed by the current optimization
  66200. * @returns description string
  66201. */
  66202. getDescription(): string;
  66203. /**
  66204. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66205. * @param scene defines the current scene where to apply this optimization
  66206. * @param optimizer defines the current optimizer
  66207. * @returns true if everything that can be done was applied
  66208. */
  66209. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66210. }
  66211. /**
  66212. * Defines an optimization used to turn particles off
  66213. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66214. */
  66215. export class ParticlesOptimization extends SceneOptimization {
  66216. /**
  66217. * Gets a string describing the action executed by the current optimization
  66218. * @return description string
  66219. */
  66220. getDescription(): string;
  66221. /**
  66222. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66223. * @param scene defines the current scene where to apply this optimization
  66224. * @param optimizer defines the current optimizer
  66225. * @returns true if everything that can be done was applied
  66226. */
  66227. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66228. }
  66229. /**
  66230. * Defines an optimization used to turn render targets off
  66231. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66232. */
  66233. export class RenderTargetsOptimization extends SceneOptimization {
  66234. /**
  66235. * Gets a string describing the action executed by the current optimization
  66236. * @return description string
  66237. */
  66238. getDescription(): string;
  66239. /**
  66240. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66241. * @param scene defines the current scene where to apply this optimization
  66242. * @param optimizer defines the current optimizer
  66243. * @returns true if everything that can be done was applied
  66244. */
  66245. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66246. }
  66247. /**
  66248. * Defines an optimization used to merge meshes with compatible materials
  66249. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66250. */
  66251. export class MergeMeshesOptimization extends SceneOptimization {
  66252. private static _UpdateSelectionTree;
  66253. /**
  66254. * Gets or sets a boolean which defines if optimization octree has to be updated
  66255. */
  66256. /**
  66257. * Gets or sets a boolean which defines if optimization octree has to be updated
  66258. */
  66259. static UpdateSelectionTree: boolean;
  66260. /**
  66261. * Gets a string describing the action executed by the current optimization
  66262. * @return description string
  66263. */
  66264. getDescription(): string;
  66265. private _canBeMerged;
  66266. /**
  66267. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66268. * @param scene defines the current scene where to apply this optimization
  66269. * @param optimizer defines the current optimizer
  66270. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66271. * @returns true if everything that can be done was applied
  66272. */
  66273. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66274. }
  66275. /**
  66276. * Defines a list of options used by SceneOptimizer
  66277. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66278. */
  66279. export class SceneOptimizerOptions {
  66280. /**
  66281. * Defines the target frame rate to reach (60 by default)
  66282. */
  66283. targetFrameRate: number;
  66284. /**
  66285. * Defines the interval between two checkes (2000ms by default)
  66286. */
  66287. trackerDuration: number;
  66288. /**
  66289. * Gets the list of optimizations to apply
  66290. */
  66291. optimizations: SceneOptimization[];
  66292. /**
  66293. * Creates a new list of options used by SceneOptimizer
  66294. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66295. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66296. */
  66297. constructor(
  66298. /**
  66299. * Defines the target frame rate to reach (60 by default)
  66300. */
  66301. targetFrameRate?: number,
  66302. /**
  66303. * Defines the interval between two checkes (2000ms by default)
  66304. */
  66305. trackerDuration?: number);
  66306. /**
  66307. * Add a new optimization
  66308. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66309. * @returns the current SceneOptimizerOptions
  66310. */
  66311. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66312. /**
  66313. * Add a new custom optimization
  66314. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66315. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66316. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66317. * @returns the current SceneOptimizerOptions
  66318. */
  66319. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66320. /**
  66321. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66322. * @param targetFrameRate defines the target frame rate (60 by default)
  66323. * @returns a SceneOptimizerOptions object
  66324. */
  66325. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66326. /**
  66327. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66328. * @param targetFrameRate defines the target frame rate (60 by default)
  66329. * @returns a SceneOptimizerOptions object
  66330. */
  66331. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66332. /**
  66333. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66334. * @param targetFrameRate defines the target frame rate (60 by default)
  66335. * @returns a SceneOptimizerOptions object
  66336. */
  66337. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66338. }
  66339. /**
  66340. * Class used to run optimizations in order to reach a target frame rate
  66341. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66342. */
  66343. export class SceneOptimizer implements IDisposable {
  66344. private _isRunning;
  66345. private _options;
  66346. private _scene;
  66347. private _currentPriorityLevel;
  66348. private _targetFrameRate;
  66349. private _trackerDuration;
  66350. private _currentFrameRate;
  66351. private _sceneDisposeObserver;
  66352. private _improvementMode;
  66353. /**
  66354. * Defines an observable called when the optimizer reaches the target frame rate
  66355. */
  66356. onSuccessObservable: Observable<SceneOptimizer>;
  66357. /**
  66358. * Defines an observable called when the optimizer enables an optimization
  66359. */
  66360. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66361. /**
  66362. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66363. */
  66364. onFailureObservable: Observable<SceneOptimizer>;
  66365. /**
  66366. * Gets a boolean indicating if the optimizer is in improvement mode
  66367. */
  66368. readonly isInImprovementMode: boolean;
  66369. /**
  66370. * Gets the current priority level (0 at start)
  66371. */
  66372. readonly currentPriorityLevel: number;
  66373. /**
  66374. * Gets the current frame rate checked by the SceneOptimizer
  66375. */
  66376. readonly currentFrameRate: number;
  66377. /**
  66378. * Gets or sets the current target frame rate (60 by default)
  66379. */
  66380. /**
  66381. * Gets or sets the current target frame rate (60 by default)
  66382. */
  66383. targetFrameRate: number;
  66384. /**
  66385. * Gets or sets the current interval between two checks (every 2000ms by default)
  66386. */
  66387. /**
  66388. * Gets or sets the current interval between two checks (every 2000ms by default)
  66389. */
  66390. trackerDuration: number;
  66391. /**
  66392. * Gets the list of active optimizations
  66393. */
  66394. readonly optimizations: SceneOptimization[];
  66395. /**
  66396. * Creates a new SceneOptimizer
  66397. * @param scene defines the scene to work on
  66398. * @param options defines the options to use with the SceneOptimizer
  66399. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66400. * @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)
  66401. */
  66402. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66403. /**
  66404. * Stops the current optimizer
  66405. */
  66406. stop(): void;
  66407. /**
  66408. * Reset the optimizer to initial step (current priority level = 0)
  66409. */
  66410. reset(): void;
  66411. /**
  66412. * Start the optimizer. By default it will try to reach a specific framerate
  66413. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66414. */
  66415. start(): void;
  66416. private _checkCurrentState;
  66417. /**
  66418. * Release all resources
  66419. */
  66420. dispose(): void;
  66421. /**
  66422. * Helper function to create a SceneOptimizer with one single line of code
  66423. * @param scene defines the scene to work on
  66424. * @param options defines the options to use with the SceneOptimizer
  66425. * @param onSuccess defines a callback to call on success
  66426. * @param onFailure defines a callback to call on failure
  66427. * @returns the new SceneOptimizer object
  66428. */
  66429. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  66430. }
  66431. }
  66432. declare module "babylonjs/Misc/sceneSerializer" {
  66433. import { Scene } from "babylonjs/scene";
  66434. /**
  66435. * Class used to serialize a scene into a string
  66436. */
  66437. export class SceneSerializer {
  66438. /**
  66439. * Clear cache used by a previous serialization
  66440. */
  66441. static ClearCache(): void;
  66442. /**
  66443. * Serialize a scene into a JSON compatible object
  66444. * @param scene defines the scene to serialize
  66445. * @returns a JSON compatible object
  66446. */
  66447. static Serialize(scene: Scene): any;
  66448. /**
  66449. * Serialize a mesh into a JSON compatible object
  66450. * @param toSerialize defines the mesh to serialize
  66451. * @param withParents defines if parents must be serialized as well
  66452. * @param withChildren defines if children must be serialized as well
  66453. * @returns a JSON compatible object
  66454. */
  66455. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66456. }
  66457. }
  66458. declare module "babylonjs/Misc/textureTools" {
  66459. import { Texture } from "babylonjs/Materials/Textures/texture";
  66460. /**
  66461. * Class used to host texture specific utilities
  66462. */
  66463. export class TextureTools {
  66464. /**
  66465. * Uses the GPU to create a copy texture rescaled at a given size
  66466. * @param texture Texture to copy from
  66467. * @param width defines the desired width
  66468. * @param height defines the desired height
  66469. * @param useBilinearMode defines if bilinear mode has to be used
  66470. * @return the generated texture
  66471. */
  66472. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66473. }
  66474. }
  66475. declare module "babylonjs/Misc/videoRecorder" {
  66476. import { Nullable } from "babylonjs/types";
  66477. import { Engine } from "babylonjs/Engines/engine";
  66478. /**
  66479. * This represents the different options available for the video capture.
  66480. */
  66481. export interface VideoRecorderOptions {
  66482. /** Defines the mime type of the video. */
  66483. mimeType: string;
  66484. /** Defines the FPS the video should be recorded at. */
  66485. fps: number;
  66486. /** Defines the chunk size for the recording data. */
  66487. recordChunckSize: number;
  66488. /** The audio tracks to attach to the recording. */
  66489. audioTracks?: MediaStreamTrack[];
  66490. }
  66491. /**
  66492. * This can help with recording videos from BabylonJS.
  66493. * This is based on the available WebRTC functionalities of the browser.
  66494. *
  66495. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66496. */
  66497. export class VideoRecorder {
  66498. private static readonly _defaultOptions;
  66499. /**
  66500. * Returns whether or not the VideoRecorder is available in your browser.
  66501. * @param engine Defines the Babylon Engine.
  66502. * @returns true if supported otherwise false.
  66503. */
  66504. static IsSupported(engine: Engine): boolean;
  66505. private readonly _options;
  66506. private _canvas;
  66507. private _mediaRecorder;
  66508. private _recordedChunks;
  66509. private _fileName;
  66510. private _resolve;
  66511. private _reject;
  66512. /**
  66513. * True when a recording is already in progress.
  66514. */
  66515. readonly isRecording: boolean;
  66516. /**
  66517. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66518. * @param engine Defines the BabylonJS Engine you wish to record.
  66519. * @param options Defines options that can be used to customize the capture.
  66520. */
  66521. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66522. /**
  66523. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66524. */
  66525. stopRecording(): void;
  66526. /**
  66527. * Starts recording the canvas for a max duration specified in parameters.
  66528. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66529. * If null no automatic download will start and you can rely on the promise to get the data back.
  66530. * @param maxDuration Defines the maximum recording time in seconds.
  66531. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66532. * @return A promise callback at the end of the recording with the video data in Blob.
  66533. */
  66534. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66535. /**
  66536. * Releases internal resources used during the recording.
  66537. */
  66538. dispose(): void;
  66539. private _handleDataAvailable;
  66540. private _handleError;
  66541. private _handleStop;
  66542. }
  66543. }
  66544. declare module "babylonjs/Misc/screenshotTools" {
  66545. import { Camera } from "babylonjs/Cameras/camera";
  66546. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  66547. import { Engine } from "babylonjs/Engines/engine";
  66548. /**
  66549. * Class containing a set of static utilities functions for screenshots
  66550. */
  66551. export class ScreenshotTools {
  66552. /**
  66553. * Captures a screenshot of the current rendering
  66554. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66555. * @param engine defines the rendering engine
  66556. * @param camera defines the source camera
  66557. * @param size This parameter can be set to a single number or to an object with the
  66558. * following (optional) properties: precision, width, height. If a single number is passed,
  66559. * it will be used for both width and height. If an object is passed, the screenshot size
  66560. * will be derived from the parameters. The precision property is a multiplier allowing
  66561. * rendering at a higher or lower resolution
  66562. * @param successCallback defines the callback receives a single parameter which contains the
  66563. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66564. * src parameter of an <img> to display it
  66565. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66566. * Check your browser for supported MIME types
  66567. */
  66568. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66569. /**
  66570. * Captures a screenshot of the current rendering
  66571. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66572. * @param engine defines the rendering engine
  66573. * @param camera defines the source camera
  66574. * @param size This parameter can be set to a single number or to an object with the
  66575. * following (optional) properties: precision, width, height. If a single number is passed,
  66576. * it will be used for both width and height. If an object is passed, the screenshot size
  66577. * will be derived from the parameters. The precision property is a multiplier allowing
  66578. * rendering at a higher or lower resolution
  66579. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66580. * Check your browser for supported MIME types
  66581. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66582. * to the src parameter of an <img> to display it
  66583. */
  66584. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66585. /**
  66586. * Generates an image screenshot from the specified camera.
  66587. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66588. * @param engine The engine to use for rendering
  66589. * @param camera The camera to use for rendering
  66590. * @param size This parameter can be set to a single number or to an object with the
  66591. * following (optional) properties: precision, width, height. If a single number is passed,
  66592. * it will be used for both width and height. If an object is passed, the screenshot size
  66593. * will be derived from the parameters. The precision property is a multiplier allowing
  66594. * rendering at a higher or lower resolution
  66595. * @param successCallback The callback receives a single parameter which contains the
  66596. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66597. * src parameter of an <img> to display it
  66598. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66599. * Check your browser for supported MIME types
  66600. * @param samples Texture samples (default: 1)
  66601. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66602. * @param fileName A name for for the downloaded file.
  66603. */
  66604. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66605. /**
  66606. * Generates an image screenshot from the specified camera.
  66607. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66608. * @param engine The engine to use for rendering
  66609. * @param camera The camera to use for rendering
  66610. * @param size This parameter can be set to a single number or to an object with the
  66611. * following (optional) properties: precision, width, height. If a single number is passed,
  66612. * it will be used for both width and height. If an object is passed, the screenshot size
  66613. * will be derived from the parameters. The precision property is a multiplier allowing
  66614. * rendering at a higher or lower resolution
  66615. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66616. * Check your browser for supported MIME types
  66617. * @param samples Texture samples (default: 1)
  66618. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66619. * @param fileName A name for for the downloaded file.
  66620. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66621. * to the src parameter of an <img> to display it
  66622. */
  66623. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66624. /**
  66625. * Gets height and width for screenshot size
  66626. * @private
  66627. */
  66628. private static _getScreenshotSize;
  66629. }
  66630. }
  66631. declare module "babylonjs/Misc/index" {
  66632. export * from "babylonjs/Misc/andOrNotEvaluator";
  66633. export * from "babylonjs/Misc/assetsManager";
  66634. export * from "babylonjs/Misc/dds";
  66635. export * from "babylonjs/Misc/decorators";
  66636. export * from "babylonjs/Misc/deferred";
  66637. export * from "babylonjs/Misc/environmentTextureTools";
  66638. export * from "babylonjs/Misc/meshExploder";
  66639. export * from "babylonjs/Misc/filesInput";
  66640. export * from "babylonjs/Misc/HighDynamicRange/index";
  66641. export * from "babylonjs/Misc/khronosTextureContainer";
  66642. export * from "babylonjs/Misc/observable";
  66643. export * from "babylonjs/Misc/performanceMonitor";
  66644. export * from "babylonjs/Misc/promise";
  66645. export * from "babylonjs/Misc/sceneOptimizer";
  66646. export * from "babylonjs/Misc/sceneSerializer";
  66647. export * from "babylonjs/Misc/smartArray";
  66648. export * from "babylonjs/Misc/stringDictionary";
  66649. export * from "babylonjs/Misc/tags";
  66650. export * from "babylonjs/Misc/textureTools";
  66651. export * from "babylonjs/Misc/tga";
  66652. export * from "babylonjs/Misc/tools";
  66653. export * from "babylonjs/Misc/videoRecorder";
  66654. export * from "babylonjs/Misc/virtualJoystick";
  66655. export * from "babylonjs/Misc/workerPool";
  66656. export * from "babylonjs/Misc/logger";
  66657. export * from "babylonjs/Misc/typeStore";
  66658. export * from "babylonjs/Misc/filesInputStore";
  66659. export * from "babylonjs/Misc/deepCopier";
  66660. export * from "babylonjs/Misc/pivotTools";
  66661. export * from "babylonjs/Misc/precisionDate";
  66662. export * from "babylonjs/Misc/screenshotTools";
  66663. export * from "babylonjs/Misc/typeStore";
  66664. export * from "babylonjs/Misc/webRequest";
  66665. export * from "babylonjs/Misc/iInspectable";
  66666. export * from "babylonjs/Misc/brdfTextureTools";
  66667. export * from "babylonjs/Misc/rgbdTextureTools";
  66668. export * from "babylonjs/Misc/gradients";
  66669. export * from "babylonjs/Misc/perfCounter";
  66670. export * from "babylonjs/Misc/fileRequest";
  66671. export * from "babylonjs/Misc/customAnimationFrameRequester";
  66672. export * from "babylonjs/Misc/retryStrategy";
  66673. export * from "babylonjs/Misc/loadFileError";
  66674. export * from "babylonjs/Misc/interfaces/screenshotSize";
  66675. }
  66676. declare module "babylonjs/index" {
  66677. export * from "babylonjs/abstractScene";
  66678. export * from "babylonjs/Actions/index";
  66679. export * from "babylonjs/Animations/index";
  66680. export * from "babylonjs/assetContainer";
  66681. export * from "babylonjs/Audio/index";
  66682. export * from "babylonjs/Behaviors/index";
  66683. export * from "babylonjs/Bones/index";
  66684. export * from "babylonjs/Cameras/index";
  66685. export * from "babylonjs/Collisions/index";
  66686. export * from "babylonjs/Culling/index";
  66687. export * from "babylonjs/Debug/index";
  66688. export * from "babylonjs/Engines/index";
  66689. export * from "babylonjs/Events/index";
  66690. export * from "babylonjs/Gamepads/index";
  66691. export * from "babylonjs/Gizmos/index";
  66692. export * from "babylonjs/Helpers/index";
  66693. export * from "babylonjs/Instrumentation/index";
  66694. export * from "babylonjs/Layers/index";
  66695. export * from "babylonjs/LensFlares/index";
  66696. export * from "babylonjs/Lights/index";
  66697. export * from "babylonjs/Loading/index";
  66698. export * from "babylonjs/Materials/index";
  66699. export * from "babylonjs/Maths/index";
  66700. export * from "babylonjs/Meshes/index";
  66701. export * from "babylonjs/Morph/index";
  66702. export * from "babylonjs/Navigation/index";
  66703. export * from "babylonjs/node";
  66704. export * from "babylonjs/Offline/index";
  66705. export * from "babylonjs/Particles/index";
  66706. export * from "babylonjs/Physics/index";
  66707. export * from "babylonjs/PostProcesses/index";
  66708. export * from "babylonjs/Probes/index";
  66709. export * from "babylonjs/Rendering/index";
  66710. export * from "babylonjs/scene";
  66711. export * from "babylonjs/sceneComponent";
  66712. export * from "babylonjs/Sprites/index";
  66713. export * from "babylonjs/States/index";
  66714. export * from "babylonjs/Misc/index";
  66715. export * from "babylonjs/types";
  66716. }
  66717. declare module "babylonjs/Animations/pathCursor" {
  66718. import { Vector3 } from "babylonjs/Maths/math.vector";
  66719. import { Path2 } from "babylonjs/Maths/math.path";
  66720. /**
  66721. * A cursor which tracks a point on a path
  66722. */
  66723. export class PathCursor {
  66724. private path;
  66725. /**
  66726. * Stores path cursor callbacks for when an onchange event is triggered
  66727. */
  66728. private _onchange;
  66729. /**
  66730. * The value of the path cursor
  66731. */
  66732. value: number;
  66733. /**
  66734. * The animation array of the path cursor
  66735. */
  66736. animations: Animation[];
  66737. /**
  66738. * Initializes the path cursor
  66739. * @param path The path to track
  66740. */
  66741. constructor(path: Path2);
  66742. /**
  66743. * Gets the cursor point on the path
  66744. * @returns A point on the path cursor at the cursor location
  66745. */
  66746. getPoint(): Vector3;
  66747. /**
  66748. * Moves the cursor ahead by the step amount
  66749. * @param step The amount to move the cursor forward
  66750. * @returns This path cursor
  66751. */
  66752. moveAhead(step?: number): PathCursor;
  66753. /**
  66754. * Moves the cursor behind by the step amount
  66755. * @param step The amount to move the cursor back
  66756. * @returns This path cursor
  66757. */
  66758. moveBack(step?: number): PathCursor;
  66759. /**
  66760. * Moves the cursor by the step amount
  66761. * If the step amount is greater than one, an exception is thrown
  66762. * @param step The amount to move the cursor
  66763. * @returns This path cursor
  66764. */
  66765. move(step: number): PathCursor;
  66766. /**
  66767. * Ensures that the value is limited between zero and one
  66768. * @returns This path cursor
  66769. */
  66770. private ensureLimits;
  66771. /**
  66772. * Runs onchange callbacks on change (used by the animation engine)
  66773. * @returns This path cursor
  66774. */
  66775. private raiseOnChange;
  66776. /**
  66777. * Executes a function on change
  66778. * @param f A path cursor onchange callback
  66779. * @returns This path cursor
  66780. */
  66781. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66782. }
  66783. }
  66784. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  66785. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  66786. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  66787. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  66788. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  66789. }
  66790. declare module "babylonjs/Engines/Processors/Expressions/index" {
  66791. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  66792. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  66793. }
  66794. declare module "babylonjs/Engines/Processors/index" {
  66795. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  66796. export * from "babylonjs/Engines/Processors/Expressions/index";
  66797. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  66798. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  66799. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  66800. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  66801. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  66802. export * from "babylonjs/Engines/Processors/shaderProcessor";
  66803. }
  66804. declare module "babylonjs/Legacy/legacy" {
  66805. import * as Babylon from "babylonjs/index";
  66806. export * from "babylonjs/index";
  66807. }
  66808. declare module "babylonjs/Shaders/blur.fragment" {
  66809. /** @hidden */
  66810. export var blurPixelShader: {
  66811. name: string;
  66812. shader: string;
  66813. };
  66814. }
  66815. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  66816. /** @hidden */
  66817. export var pointCloudVertexDeclaration: {
  66818. name: string;
  66819. shader: string;
  66820. };
  66821. }
  66822. declare module "babylonjs" {
  66823. export * from "babylonjs/Legacy/legacy";
  66824. }
  66825. declare module BABYLON {
  66826. /** Alias type for value that can be null */
  66827. export type Nullable<T> = T | null;
  66828. /**
  66829. * Alias type for number that are floats
  66830. * @ignorenaming
  66831. */
  66832. export type float = number;
  66833. /**
  66834. * Alias type for number that are doubles.
  66835. * @ignorenaming
  66836. */
  66837. export type double = number;
  66838. /**
  66839. * Alias type for number that are integer
  66840. * @ignorenaming
  66841. */
  66842. export type int = number;
  66843. /** Alias type for number array or Float32Array */
  66844. export type FloatArray = number[] | Float32Array;
  66845. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  66846. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  66847. /**
  66848. * Alias for types that can be used by a Buffer or VertexBuffer.
  66849. */
  66850. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  66851. /**
  66852. * Alias type for primitive types
  66853. * @ignorenaming
  66854. */
  66855. type Primitive = undefined | null | boolean | string | number | Function;
  66856. /**
  66857. * Type modifier to make all the properties of an object Readonly
  66858. */
  66859. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  66860. /**
  66861. * Type modifier to make all the properties of an object Readonly recursively
  66862. */
  66863. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  66864. /**
  66865. * Type modifier to make object properties readonly.
  66866. */
  66867. export type DeepImmutableObject<T> = {
  66868. readonly [K in keyof T]: DeepImmutable<T[K]>;
  66869. };
  66870. /** @hidden */
  66871. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  66872. }
  66873. }
  66874. declare module BABYLON {
  66875. /**
  66876. * A class serves as a medium between the observable and its observers
  66877. */
  66878. export class EventState {
  66879. /**
  66880. * Create a new EventState
  66881. * @param mask defines the mask associated with this state
  66882. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66883. * @param target defines the original target of the state
  66884. * @param currentTarget defines the current target of the state
  66885. */
  66886. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66887. /**
  66888. * Initialize the current event state
  66889. * @param mask defines the mask associated with this state
  66890. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66891. * @param target defines the original target of the state
  66892. * @param currentTarget defines the current target of the state
  66893. * @returns the current event state
  66894. */
  66895. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66896. /**
  66897. * An Observer can set this property to true to prevent subsequent observers of being notified
  66898. */
  66899. skipNextObservers: boolean;
  66900. /**
  66901. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66902. */
  66903. mask: number;
  66904. /**
  66905. * The object that originally notified the event
  66906. */
  66907. target?: any;
  66908. /**
  66909. * The current object in the bubbling phase
  66910. */
  66911. currentTarget?: any;
  66912. /**
  66913. * This will be populated with the return value of the last function that was executed.
  66914. * If it is the first function in the callback chain it will be the event data.
  66915. */
  66916. lastReturnValue?: any;
  66917. }
  66918. /**
  66919. * Represent an Observer registered to a given Observable object.
  66920. */
  66921. export class Observer<T> {
  66922. /**
  66923. * Defines the callback to call when the observer is notified
  66924. */
  66925. callback: (eventData: T, eventState: EventState) => void;
  66926. /**
  66927. * Defines the mask of the observer (used to filter notifications)
  66928. */
  66929. mask: number;
  66930. /**
  66931. * Defines the current scope used to restore the JS context
  66932. */
  66933. scope: any;
  66934. /** @hidden */
  66935. _willBeUnregistered: boolean;
  66936. /**
  66937. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66938. */
  66939. unregisterOnNextCall: boolean;
  66940. /**
  66941. * Creates a new observer
  66942. * @param callback defines the callback to call when the observer is notified
  66943. * @param mask defines the mask of the observer (used to filter notifications)
  66944. * @param scope defines the current scope used to restore the JS context
  66945. */
  66946. constructor(
  66947. /**
  66948. * Defines the callback to call when the observer is notified
  66949. */
  66950. callback: (eventData: T, eventState: EventState) => void,
  66951. /**
  66952. * Defines the mask of the observer (used to filter notifications)
  66953. */
  66954. mask: number,
  66955. /**
  66956. * Defines the current scope used to restore the JS context
  66957. */
  66958. scope?: any);
  66959. }
  66960. /**
  66961. * Represent a list of observers registered to multiple Observables object.
  66962. */
  66963. export class MultiObserver<T> {
  66964. private _observers;
  66965. private _observables;
  66966. /**
  66967. * Release associated resources
  66968. */
  66969. dispose(): void;
  66970. /**
  66971. * Raise a callback when one of the observable will notify
  66972. * @param observables defines a list of observables to watch
  66973. * @param callback defines the callback to call on notification
  66974. * @param mask defines the mask used to filter notifications
  66975. * @param scope defines the current scope used to restore the JS context
  66976. * @returns the new MultiObserver
  66977. */
  66978. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66979. }
  66980. /**
  66981. * The Observable class is a simple implementation of the Observable pattern.
  66982. *
  66983. * 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.
  66984. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66985. * 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).
  66986. * 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.
  66987. */
  66988. export class Observable<T> {
  66989. private _observers;
  66990. private _eventState;
  66991. private _onObserverAdded;
  66992. /**
  66993. * Gets the list of observers
  66994. */
  66995. readonly observers: Array<Observer<T>>;
  66996. /**
  66997. * Creates a new observable
  66998. * @param onObserverAdded defines a callback to call when a new observer is added
  66999. */
  67000. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  67001. /**
  67002. * Create a new Observer with the specified callback
  67003. * @param callback the callback that will be executed for that Observer
  67004. * @param mask the mask used to filter observers
  67005. * @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.
  67006. * @param scope optional scope for the callback to be called from
  67007. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  67008. * @returns the new observer created for the callback
  67009. */
  67010. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  67011. /**
  67012. * Create a new Observer with the specified callback and unregisters after the next notification
  67013. * @param callback the callback that will be executed for that Observer
  67014. * @returns the new observer created for the callback
  67015. */
  67016. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  67017. /**
  67018. * Remove an Observer from the Observable object
  67019. * @param observer the instance of the Observer to remove
  67020. * @returns false if it doesn't belong to this Observable
  67021. */
  67022. remove(observer: Nullable<Observer<T>>): boolean;
  67023. /**
  67024. * Remove a callback from the Observable object
  67025. * @param callback the callback to remove
  67026. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67027. * @returns false if it doesn't belong to this Observable
  67028. */
  67029. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67030. private _deferUnregister;
  67031. private _remove;
  67032. /**
  67033. * Moves the observable to the top of the observer list making it get called first when notified
  67034. * @param observer the observer to move
  67035. */
  67036. makeObserverTopPriority(observer: Observer<T>): void;
  67037. /**
  67038. * Moves the observable to the bottom of the observer list making it get called last when notified
  67039. * @param observer the observer to move
  67040. */
  67041. makeObserverBottomPriority(observer: Observer<T>): void;
  67042. /**
  67043. * Notify all Observers by calling their respective callback with the given data
  67044. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67045. * @param eventData defines the data to send to all observers
  67046. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67047. * @param target defines the original target of the state
  67048. * @param currentTarget defines the current target of the state
  67049. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67050. */
  67051. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67052. /**
  67053. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67054. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67055. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67056. * and it is crucial that all callbacks will be executed.
  67057. * The order of the callbacks is kept, callbacks are not executed parallel.
  67058. *
  67059. * @param eventData The data to be sent to each callback
  67060. * @param mask is used to filter observers defaults to -1
  67061. * @param target defines the callback target (see EventState)
  67062. * @param currentTarget defines he current object in the bubbling phase
  67063. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67064. */
  67065. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67066. /**
  67067. * Notify a specific observer
  67068. * @param observer defines the observer to notify
  67069. * @param eventData defines the data to be sent to each callback
  67070. * @param mask is used to filter observers defaults to -1
  67071. */
  67072. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67073. /**
  67074. * Gets a boolean indicating if the observable has at least one observer
  67075. * @returns true is the Observable has at least one Observer registered
  67076. */
  67077. hasObservers(): boolean;
  67078. /**
  67079. * Clear the list of observers
  67080. */
  67081. clear(): void;
  67082. /**
  67083. * Clone the current observable
  67084. * @returns a new observable
  67085. */
  67086. clone(): Observable<T>;
  67087. /**
  67088. * Does this observable handles observer registered with a given mask
  67089. * @param mask defines the mask to be tested
  67090. * @return whether or not one observer registered with the given mask is handeled
  67091. **/
  67092. hasSpecificMask(mask?: number): boolean;
  67093. }
  67094. }
  67095. declare module BABYLON {
  67096. /**
  67097. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67098. * Babylon.js
  67099. */
  67100. export class DomManagement {
  67101. /**
  67102. * Checks if the window object exists
  67103. * @returns true if the window object exists
  67104. */
  67105. static IsWindowObjectExist(): boolean;
  67106. /**
  67107. * Checks if the navigator object exists
  67108. * @returns true if the navigator object exists
  67109. */
  67110. static IsNavigatorAvailable(): boolean;
  67111. /**
  67112. * Extracts text content from a DOM element hierarchy
  67113. * @param element defines the root element
  67114. * @returns a string
  67115. */
  67116. static GetDOMTextContent(element: HTMLElement): string;
  67117. }
  67118. }
  67119. declare module BABYLON {
  67120. /**
  67121. * Logger used througouht the application to allow configuration of
  67122. * the log level required for the messages.
  67123. */
  67124. export class Logger {
  67125. /**
  67126. * No log
  67127. */
  67128. static readonly NoneLogLevel: number;
  67129. /**
  67130. * Only message logs
  67131. */
  67132. static readonly MessageLogLevel: number;
  67133. /**
  67134. * Only warning logs
  67135. */
  67136. static readonly WarningLogLevel: number;
  67137. /**
  67138. * Only error logs
  67139. */
  67140. static readonly ErrorLogLevel: number;
  67141. /**
  67142. * All logs
  67143. */
  67144. static readonly AllLogLevel: number;
  67145. private static _LogCache;
  67146. /**
  67147. * Gets a value indicating the number of loading errors
  67148. * @ignorenaming
  67149. */
  67150. static errorsCount: number;
  67151. /**
  67152. * Callback called when a new log is added
  67153. */
  67154. static OnNewCacheEntry: (entry: string) => void;
  67155. private static _AddLogEntry;
  67156. private static _FormatMessage;
  67157. private static _LogDisabled;
  67158. private static _LogEnabled;
  67159. private static _WarnDisabled;
  67160. private static _WarnEnabled;
  67161. private static _ErrorDisabled;
  67162. private static _ErrorEnabled;
  67163. /**
  67164. * Log a message to the console
  67165. */
  67166. static Log: (message: string) => void;
  67167. /**
  67168. * Write a warning message to the console
  67169. */
  67170. static Warn: (message: string) => void;
  67171. /**
  67172. * Write an error message to the console
  67173. */
  67174. static Error: (message: string) => void;
  67175. /**
  67176. * Gets current log cache (list of logs)
  67177. */
  67178. static readonly LogCache: string;
  67179. /**
  67180. * Clears the log cache
  67181. */
  67182. static ClearLogCache(): void;
  67183. /**
  67184. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67185. */
  67186. static LogLevels: number;
  67187. }
  67188. }
  67189. declare module BABYLON {
  67190. /** @hidden */
  67191. export class _TypeStore {
  67192. /** @hidden */
  67193. static RegisteredTypes: {
  67194. [key: string]: Object;
  67195. };
  67196. /** @hidden */
  67197. static GetClass(fqdn: string): any;
  67198. }
  67199. }
  67200. declare module BABYLON {
  67201. /**
  67202. * Class containing a set of static utilities functions for deep copy.
  67203. */
  67204. export class DeepCopier {
  67205. /**
  67206. * Tries to copy an object by duplicating every property
  67207. * @param source defines the source object
  67208. * @param destination defines the target object
  67209. * @param doNotCopyList defines a list of properties to avoid
  67210. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67211. */
  67212. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67213. }
  67214. }
  67215. declare module BABYLON {
  67216. /**
  67217. * Class containing a set of static utilities functions for precision date
  67218. */
  67219. export class PrecisionDate {
  67220. /**
  67221. * Gets either window.performance.now() if supported or Date.now() else
  67222. */
  67223. static readonly Now: number;
  67224. }
  67225. }
  67226. declare module BABYLON {
  67227. /** @hidden */
  67228. export class _DevTools {
  67229. static WarnImport(name: string): string;
  67230. }
  67231. }
  67232. declare module BABYLON {
  67233. /**
  67234. * Interface used to define the mechanism to get data from the network
  67235. */
  67236. export interface IWebRequest {
  67237. /**
  67238. * Returns client's response url
  67239. */
  67240. responseURL: string;
  67241. /**
  67242. * Returns client's status
  67243. */
  67244. status: number;
  67245. /**
  67246. * Returns client's status as a text
  67247. */
  67248. statusText: string;
  67249. }
  67250. }
  67251. declare module BABYLON {
  67252. /**
  67253. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67254. */
  67255. export class WebRequest implements IWebRequest {
  67256. private _xhr;
  67257. /**
  67258. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67259. * i.e. when loading files, where the server/service expects an Authorization header
  67260. */
  67261. static CustomRequestHeaders: {
  67262. [key: string]: string;
  67263. };
  67264. /**
  67265. * Add callback functions in this array to update all the requests before they get sent to the network
  67266. */
  67267. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67268. private _injectCustomRequestHeaders;
  67269. /**
  67270. * Gets or sets a function to be called when loading progress changes
  67271. */
  67272. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67273. /**
  67274. * Returns client's state
  67275. */
  67276. readonly readyState: number;
  67277. /**
  67278. * Returns client's status
  67279. */
  67280. readonly status: number;
  67281. /**
  67282. * Returns client's status as a text
  67283. */
  67284. readonly statusText: string;
  67285. /**
  67286. * Returns client's response
  67287. */
  67288. readonly response: any;
  67289. /**
  67290. * Returns client's response url
  67291. */
  67292. readonly responseURL: string;
  67293. /**
  67294. * Returns client's response as text
  67295. */
  67296. readonly responseText: string;
  67297. /**
  67298. * Gets or sets the expected response type
  67299. */
  67300. responseType: XMLHttpRequestResponseType;
  67301. /** @hidden */
  67302. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67303. /** @hidden */
  67304. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67305. /**
  67306. * Cancels any network activity
  67307. */
  67308. abort(): void;
  67309. /**
  67310. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67311. * @param body defines an optional request body
  67312. */
  67313. send(body?: Document | BodyInit | null): void;
  67314. /**
  67315. * Sets the request method, request URL
  67316. * @param method defines the method to use (GET, POST, etc..)
  67317. * @param url defines the url to connect with
  67318. */
  67319. open(method: string, url: string): void;
  67320. }
  67321. }
  67322. declare module BABYLON {
  67323. /**
  67324. * File request interface
  67325. */
  67326. export interface IFileRequest {
  67327. /**
  67328. * Raised when the request is complete (success or error).
  67329. */
  67330. onCompleteObservable: Observable<IFileRequest>;
  67331. /**
  67332. * Aborts the request for a file.
  67333. */
  67334. abort: () => void;
  67335. }
  67336. }
  67337. declare module BABYLON {
  67338. /**
  67339. * Define options used to create a render target texture
  67340. */
  67341. export class RenderTargetCreationOptions {
  67342. /**
  67343. * Specifies is mipmaps must be generated
  67344. */
  67345. generateMipMaps?: boolean;
  67346. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  67347. generateDepthBuffer?: boolean;
  67348. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  67349. generateStencilBuffer?: boolean;
  67350. /** Defines texture type (int by default) */
  67351. type?: number;
  67352. /** Defines sampling mode (trilinear by default) */
  67353. samplingMode?: number;
  67354. /** Defines format (RGBA by default) */
  67355. format?: number;
  67356. }
  67357. }
  67358. declare module BABYLON {
  67359. /**
  67360. * @hidden
  67361. **/
  67362. export class _TimeToken {
  67363. _startTimeQuery: Nullable<WebGLQuery>;
  67364. _endTimeQuery: Nullable<WebGLQuery>;
  67365. _timeElapsedQuery: Nullable<WebGLQuery>;
  67366. _timeElapsedQueryEnded: boolean;
  67367. }
  67368. }
  67369. declare module BABYLON {
  67370. /** Defines the cross module used constants to avoid circular dependncies */
  67371. export class Constants {
  67372. /** Defines that alpha blending is disabled */
  67373. static readonly ALPHA_DISABLE: number;
  67374. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67375. static readonly ALPHA_ADD: number;
  67376. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67377. static readonly ALPHA_COMBINE: number;
  67378. /** Defines that alpha blending to DEST - SRC * DEST */
  67379. static readonly ALPHA_SUBTRACT: number;
  67380. /** Defines that alpha blending to SRC * DEST */
  67381. static readonly ALPHA_MULTIPLY: number;
  67382. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67383. static readonly ALPHA_MAXIMIZED: number;
  67384. /** Defines that alpha blending to SRC + DEST */
  67385. static readonly ALPHA_ONEONE: number;
  67386. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67387. static readonly ALPHA_PREMULTIPLIED: number;
  67388. /**
  67389. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67390. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67391. */
  67392. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67393. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67394. static readonly ALPHA_INTERPOLATE: number;
  67395. /**
  67396. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67397. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67398. */
  67399. static readonly ALPHA_SCREENMODE: number;
  67400. /**
  67401. * Defines that alpha blending to SRC + DST
  67402. * Alpha will be set to SRC ALPHA + DST ALPHA
  67403. */
  67404. static readonly ALPHA_ONEONE_ONEONE: number;
  67405. /**
  67406. * Defines that alpha blending to SRC * DST ALPHA + DST
  67407. * Alpha will be set to 0
  67408. */
  67409. static readonly ALPHA_ALPHATOCOLOR: number;
  67410. /**
  67411. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  67412. */
  67413. static readonly ALPHA_REVERSEONEMINUS: number;
  67414. /**
  67415. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  67416. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  67417. */
  67418. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  67419. /**
  67420. * Defines that alpha blending to SRC + DST
  67421. * Alpha will be set to SRC ALPHA
  67422. */
  67423. static readonly ALPHA_ONEONE_ONEZERO: number;
  67424. /** Defines that alpha blending equation a SUM */
  67425. static readonly ALPHA_EQUATION_ADD: number;
  67426. /** Defines that alpha blending equation a SUBSTRACTION */
  67427. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  67428. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  67429. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  67430. /** Defines that alpha blending equation a MAX operation */
  67431. static readonly ALPHA_EQUATION_MAX: number;
  67432. /** Defines that alpha blending equation a MIN operation */
  67433. static readonly ALPHA_EQUATION_MIN: number;
  67434. /**
  67435. * Defines that alpha blending equation a DARKEN operation:
  67436. * It takes the min of the src and sums the alpha channels.
  67437. */
  67438. static readonly ALPHA_EQUATION_DARKEN: number;
  67439. /** Defines that the ressource is not delayed*/
  67440. static readonly DELAYLOADSTATE_NONE: number;
  67441. /** Defines that the ressource was successfully delay loaded */
  67442. static readonly DELAYLOADSTATE_LOADED: number;
  67443. /** Defines that the ressource is currently delay loading */
  67444. static readonly DELAYLOADSTATE_LOADING: number;
  67445. /** Defines that the ressource is delayed and has not started loading */
  67446. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67447. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67448. static readonly NEVER: number;
  67449. /** 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 */
  67450. static readonly ALWAYS: number;
  67451. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67452. static readonly LESS: number;
  67453. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67454. static readonly EQUAL: number;
  67455. /** 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 */
  67456. static readonly LEQUAL: number;
  67457. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67458. static readonly GREATER: number;
  67459. /** 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 */
  67460. static readonly GEQUAL: number;
  67461. /** 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 */
  67462. static readonly NOTEQUAL: number;
  67463. /** Passed to stencilOperation to specify that stencil value must be kept */
  67464. static readonly KEEP: number;
  67465. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67466. static readonly REPLACE: number;
  67467. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67468. static readonly INCR: number;
  67469. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67470. static readonly DECR: number;
  67471. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67472. static readonly INVERT: number;
  67473. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67474. static readonly INCR_WRAP: number;
  67475. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67476. static readonly DECR_WRAP: number;
  67477. /** Texture is not repeating outside of 0..1 UVs */
  67478. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67479. /** Texture is repeating outside of 0..1 UVs */
  67480. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67481. /** Texture is repeating and mirrored */
  67482. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67483. /** ALPHA */
  67484. static readonly TEXTUREFORMAT_ALPHA: number;
  67485. /** LUMINANCE */
  67486. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67487. /** LUMINANCE_ALPHA */
  67488. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67489. /** RGB */
  67490. static readonly TEXTUREFORMAT_RGB: number;
  67491. /** RGBA */
  67492. static readonly TEXTUREFORMAT_RGBA: number;
  67493. /** RED */
  67494. static readonly TEXTUREFORMAT_RED: number;
  67495. /** RED (2nd reference) */
  67496. static readonly TEXTUREFORMAT_R: number;
  67497. /** RG */
  67498. static readonly TEXTUREFORMAT_RG: number;
  67499. /** RED_INTEGER */
  67500. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67501. /** RED_INTEGER (2nd reference) */
  67502. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67503. /** RG_INTEGER */
  67504. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67505. /** RGB_INTEGER */
  67506. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67507. /** RGBA_INTEGER */
  67508. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67509. /** UNSIGNED_BYTE */
  67510. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67511. /** UNSIGNED_BYTE (2nd reference) */
  67512. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67513. /** FLOAT */
  67514. static readonly TEXTURETYPE_FLOAT: number;
  67515. /** HALF_FLOAT */
  67516. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67517. /** BYTE */
  67518. static readonly TEXTURETYPE_BYTE: number;
  67519. /** SHORT */
  67520. static readonly TEXTURETYPE_SHORT: number;
  67521. /** UNSIGNED_SHORT */
  67522. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67523. /** INT */
  67524. static readonly TEXTURETYPE_INT: number;
  67525. /** UNSIGNED_INT */
  67526. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67527. /** UNSIGNED_SHORT_4_4_4_4 */
  67528. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67529. /** UNSIGNED_SHORT_5_5_5_1 */
  67530. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67531. /** UNSIGNED_SHORT_5_6_5 */
  67532. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67533. /** UNSIGNED_INT_2_10_10_10_REV */
  67534. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67535. /** UNSIGNED_INT_24_8 */
  67536. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67537. /** UNSIGNED_INT_10F_11F_11F_REV */
  67538. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67539. /** UNSIGNED_INT_5_9_9_9_REV */
  67540. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67541. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67542. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67543. /** nearest is mag = nearest and min = nearest and mip = linear */
  67544. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67545. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67546. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67547. /** Trilinear is mag = linear and min = linear and mip = linear */
  67548. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67549. /** nearest is mag = nearest and min = nearest and mip = linear */
  67550. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67551. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67552. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67553. /** Trilinear is mag = linear and min = linear and mip = linear */
  67554. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67555. /** mag = nearest and min = nearest and mip = nearest */
  67556. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67557. /** mag = nearest and min = linear and mip = nearest */
  67558. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67559. /** mag = nearest and min = linear and mip = linear */
  67560. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67561. /** mag = nearest and min = linear and mip = none */
  67562. static readonly TEXTURE_NEAREST_LINEAR: number;
  67563. /** mag = nearest and min = nearest and mip = none */
  67564. static readonly TEXTURE_NEAREST_NEAREST: number;
  67565. /** mag = linear and min = nearest and mip = nearest */
  67566. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67567. /** mag = linear and min = nearest and mip = linear */
  67568. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67569. /** mag = linear and min = linear and mip = none */
  67570. static readonly TEXTURE_LINEAR_LINEAR: number;
  67571. /** mag = linear and min = nearest and mip = none */
  67572. static readonly TEXTURE_LINEAR_NEAREST: number;
  67573. /** Explicit coordinates mode */
  67574. static readonly TEXTURE_EXPLICIT_MODE: number;
  67575. /** Spherical coordinates mode */
  67576. static readonly TEXTURE_SPHERICAL_MODE: number;
  67577. /** Planar coordinates mode */
  67578. static readonly TEXTURE_PLANAR_MODE: number;
  67579. /** Cubic coordinates mode */
  67580. static readonly TEXTURE_CUBIC_MODE: number;
  67581. /** Projection coordinates mode */
  67582. static readonly TEXTURE_PROJECTION_MODE: number;
  67583. /** Skybox coordinates mode */
  67584. static readonly TEXTURE_SKYBOX_MODE: number;
  67585. /** Inverse Cubic coordinates mode */
  67586. static readonly TEXTURE_INVCUBIC_MODE: number;
  67587. /** Equirectangular coordinates mode */
  67588. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67589. /** Equirectangular Fixed coordinates mode */
  67590. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67591. /** Equirectangular Fixed Mirrored coordinates mode */
  67592. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67593. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67594. static readonly SCALEMODE_FLOOR: number;
  67595. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67596. static readonly SCALEMODE_NEAREST: number;
  67597. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67598. static readonly SCALEMODE_CEILING: number;
  67599. /**
  67600. * The dirty texture flag value
  67601. */
  67602. static readonly MATERIAL_TextureDirtyFlag: number;
  67603. /**
  67604. * The dirty light flag value
  67605. */
  67606. static readonly MATERIAL_LightDirtyFlag: number;
  67607. /**
  67608. * The dirty fresnel flag value
  67609. */
  67610. static readonly MATERIAL_FresnelDirtyFlag: number;
  67611. /**
  67612. * The dirty attribute flag value
  67613. */
  67614. static readonly MATERIAL_AttributesDirtyFlag: number;
  67615. /**
  67616. * The dirty misc flag value
  67617. */
  67618. static readonly MATERIAL_MiscDirtyFlag: number;
  67619. /**
  67620. * The all dirty flag value
  67621. */
  67622. static readonly MATERIAL_AllDirtyFlag: number;
  67623. /**
  67624. * Returns the triangle fill mode
  67625. */
  67626. static readonly MATERIAL_TriangleFillMode: number;
  67627. /**
  67628. * Returns the wireframe mode
  67629. */
  67630. static readonly MATERIAL_WireFrameFillMode: number;
  67631. /**
  67632. * Returns the point fill mode
  67633. */
  67634. static readonly MATERIAL_PointFillMode: number;
  67635. /**
  67636. * Returns the point list draw mode
  67637. */
  67638. static readonly MATERIAL_PointListDrawMode: number;
  67639. /**
  67640. * Returns the line list draw mode
  67641. */
  67642. static readonly MATERIAL_LineListDrawMode: number;
  67643. /**
  67644. * Returns the line loop draw mode
  67645. */
  67646. static readonly MATERIAL_LineLoopDrawMode: number;
  67647. /**
  67648. * Returns the line strip draw mode
  67649. */
  67650. static readonly MATERIAL_LineStripDrawMode: number;
  67651. /**
  67652. * Returns the triangle strip draw mode
  67653. */
  67654. static readonly MATERIAL_TriangleStripDrawMode: number;
  67655. /**
  67656. * Returns the triangle fan draw mode
  67657. */
  67658. static readonly MATERIAL_TriangleFanDrawMode: number;
  67659. /**
  67660. * Stores the clock-wise side orientation
  67661. */
  67662. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67663. /**
  67664. * Stores the counter clock-wise side orientation
  67665. */
  67666. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67667. /**
  67668. * Nothing
  67669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67670. */
  67671. static readonly ACTION_NothingTrigger: number;
  67672. /**
  67673. * On pick
  67674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67675. */
  67676. static readonly ACTION_OnPickTrigger: number;
  67677. /**
  67678. * On left pick
  67679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67680. */
  67681. static readonly ACTION_OnLeftPickTrigger: number;
  67682. /**
  67683. * On right pick
  67684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67685. */
  67686. static readonly ACTION_OnRightPickTrigger: number;
  67687. /**
  67688. * On center pick
  67689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67690. */
  67691. static readonly ACTION_OnCenterPickTrigger: number;
  67692. /**
  67693. * On pick down
  67694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67695. */
  67696. static readonly ACTION_OnPickDownTrigger: number;
  67697. /**
  67698. * On double pick
  67699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67700. */
  67701. static readonly ACTION_OnDoublePickTrigger: number;
  67702. /**
  67703. * On pick up
  67704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67705. */
  67706. static readonly ACTION_OnPickUpTrigger: number;
  67707. /**
  67708. * On pick out.
  67709. * This trigger will only be raised if you also declared a OnPickDown
  67710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67711. */
  67712. static readonly ACTION_OnPickOutTrigger: number;
  67713. /**
  67714. * On long press
  67715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67716. */
  67717. static readonly ACTION_OnLongPressTrigger: number;
  67718. /**
  67719. * On pointer over
  67720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67721. */
  67722. static readonly ACTION_OnPointerOverTrigger: number;
  67723. /**
  67724. * On pointer out
  67725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67726. */
  67727. static readonly ACTION_OnPointerOutTrigger: number;
  67728. /**
  67729. * On every frame
  67730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67731. */
  67732. static readonly ACTION_OnEveryFrameTrigger: number;
  67733. /**
  67734. * On intersection enter
  67735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67736. */
  67737. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67738. /**
  67739. * On intersection exit
  67740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67741. */
  67742. static readonly ACTION_OnIntersectionExitTrigger: number;
  67743. /**
  67744. * On key down
  67745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67746. */
  67747. static readonly ACTION_OnKeyDownTrigger: number;
  67748. /**
  67749. * On key up
  67750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67751. */
  67752. static readonly ACTION_OnKeyUpTrigger: number;
  67753. /**
  67754. * Billboard mode will only apply to Y axis
  67755. */
  67756. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67757. /**
  67758. * Billboard mode will apply to all axes
  67759. */
  67760. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67761. /**
  67762. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67763. */
  67764. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67765. /**
  67766. * Gets or sets base Assets URL
  67767. */
  67768. static PARTICLES_BaseAssetsUrl: string;
  67769. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67770. * Test order :
  67771. * Is the bounding sphere outside the frustum ?
  67772. * If not, are the bounding box vertices outside the frustum ?
  67773. * It not, then the cullable object is in the frustum.
  67774. */
  67775. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67776. /** Culling strategy : Bounding Sphere Only.
  67777. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67778. * It's also less accurate than the standard because some not visible objects can still be selected.
  67779. * Test : is the bounding sphere outside the frustum ?
  67780. * If not, then the cullable object is in the frustum.
  67781. */
  67782. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67783. /** Culling strategy : Optimistic Inclusion.
  67784. * This in an inclusion test first, then the standard exclusion test.
  67785. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67786. * 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.
  67787. * Anyway, it's as accurate as the standard strategy.
  67788. * Test :
  67789. * Is the cullable object bounding sphere center in the frustum ?
  67790. * If not, apply the default culling strategy.
  67791. */
  67792. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67793. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67794. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67795. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67796. * 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.
  67797. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67798. * Test :
  67799. * Is the cullable object bounding sphere center in the frustum ?
  67800. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67801. */
  67802. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67803. /**
  67804. * No logging while loading
  67805. */
  67806. static readonly SCENELOADER_NO_LOGGING: number;
  67807. /**
  67808. * Minimal logging while loading
  67809. */
  67810. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67811. /**
  67812. * Summary logging while loading
  67813. */
  67814. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67815. /**
  67816. * Detailled logging while loading
  67817. */
  67818. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67819. }
  67820. }
  67821. declare module BABYLON {
  67822. /**
  67823. * This represents the required contract to create a new type of texture loader.
  67824. */
  67825. export interface IInternalTextureLoader {
  67826. /**
  67827. * Defines wether the loader supports cascade loading the different faces.
  67828. */
  67829. supportCascades: boolean;
  67830. /**
  67831. * This returns if the loader support the current file information.
  67832. * @param extension defines the file extension of the file being loaded
  67833. * @param textureFormatInUse defines the current compressed format in use iun the engine
  67834. * @param fallback defines the fallback internal texture if any
  67835. * @param isBase64 defines whether the texture is encoded as a base64
  67836. * @param isBuffer defines whether the texture data are stored as a buffer
  67837. * @returns true if the loader can load the specified file
  67838. */
  67839. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  67840. /**
  67841. * Transform the url before loading if required.
  67842. * @param rootUrl the url of the texture
  67843. * @param textureFormatInUse defines the current compressed format in use iun the engine
  67844. * @returns the transformed texture
  67845. */
  67846. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  67847. /**
  67848. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  67849. * @param rootUrl the url of the texture
  67850. * @param textureFormatInUse defines the current compressed format in use iun the engine
  67851. * @returns the fallback texture
  67852. */
  67853. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  67854. /**
  67855. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  67856. * @param data contains the texture data
  67857. * @param texture defines the BabylonJS internal texture
  67858. * @param createPolynomials will be true if polynomials have been requested
  67859. * @param onLoad defines the callback to trigger once the texture is ready
  67860. * @param onError defines the callback to trigger in case of error
  67861. */
  67862. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  67863. /**
  67864. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  67865. * @param data contains the texture data
  67866. * @param texture defines the BabylonJS internal texture
  67867. * @param callback defines the method to call once ready to upload
  67868. */
  67869. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  67870. }
  67871. }
  67872. declare module BABYLON {
  67873. /**
  67874. * Class used to store and describe the pipeline context associated with an effect
  67875. */
  67876. export interface IPipelineContext {
  67877. /**
  67878. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  67879. */
  67880. isAsync: boolean;
  67881. /**
  67882. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  67883. */
  67884. isReady: boolean;
  67885. /** @hidden */
  67886. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  67887. }
  67888. }
  67889. declare module BABYLON {
  67890. /**
  67891. * Class used to store gfx data (like WebGLBuffer)
  67892. */
  67893. export class DataBuffer {
  67894. /**
  67895. * Gets or sets the number of objects referencing this buffer
  67896. */
  67897. references: number;
  67898. /** Gets or sets the size of the underlying buffer */
  67899. capacity: number;
  67900. /**
  67901. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  67902. */
  67903. is32Bits: boolean;
  67904. /**
  67905. * Gets the underlying buffer
  67906. */
  67907. readonly underlyingResource: any;
  67908. }
  67909. }
  67910. declare module BABYLON {
  67911. /** @hidden */
  67912. export interface IShaderProcessor {
  67913. attributeProcessor?: (attribute: string) => string;
  67914. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  67915. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  67916. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  67917. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  67918. lineProcessor?: (line: string, isFragment: boolean) => string;
  67919. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67920. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67921. }
  67922. }
  67923. declare module BABYLON {
  67924. /** @hidden */
  67925. export interface ProcessingOptions {
  67926. defines: string[];
  67927. indexParameters: any;
  67928. isFragment: boolean;
  67929. shouldUseHighPrecisionShader: boolean;
  67930. supportsUniformBuffers: boolean;
  67931. shadersRepository: string;
  67932. includesShadersStore: {
  67933. [key: string]: string;
  67934. };
  67935. processor?: IShaderProcessor;
  67936. version: string;
  67937. platformName: string;
  67938. lookForClosingBracketForUniformBuffer?: boolean;
  67939. }
  67940. }
  67941. declare module BABYLON {
  67942. /**
  67943. * Helper to manipulate strings
  67944. */
  67945. export class StringTools {
  67946. /**
  67947. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  67948. * @param str Source string
  67949. * @param suffix Suffix to search for in the source string
  67950. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  67951. */
  67952. static EndsWith(str: string, suffix: string): boolean;
  67953. /**
  67954. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  67955. * @param str Source string
  67956. * @param suffix Suffix to search for in the source string
  67957. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  67958. */
  67959. static StartsWith(str: string, suffix: string): boolean;
  67960. }
  67961. }
  67962. declare module BABYLON {
  67963. /** @hidden */
  67964. export class ShaderCodeNode {
  67965. line: string;
  67966. children: ShaderCodeNode[];
  67967. additionalDefineKey?: string;
  67968. additionalDefineValue?: string;
  67969. isValid(preprocessors: {
  67970. [key: string]: string;
  67971. }): boolean;
  67972. process(preprocessors: {
  67973. [key: string]: string;
  67974. }, options: ProcessingOptions): string;
  67975. }
  67976. }
  67977. declare module BABYLON {
  67978. /** @hidden */
  67979. export class ShaderCodeCursor {
  67980. private _lines;
  67981. lineIndex: number;
  67982. readonly currentLine: string;
  67983. readonly canRead: boolean;
  67984. lines: string[];
  67985. }
  67986. }
  67987. declare module BABYLON {
  67988. /** @hidden */
  67989. export class ShaderCodeConditionNode extends ShaderCodeNode {
  67990. process(preprocessors: {
  67991. [key: string]: string;
  67992. }, options: ProcessingOptions): string;
  67993. }
  67994. }
  67995. declare module BABYLON {
  67996. /** @hidden */
  67997. export class ShaderDefineExpression {
  67998. isTrue(preprocessors: {
  67999. [key: string]: string;
  68000. }): boolean;
  68001. }
  68002. }
  68003. declare module BABYLON {
  68004. /** @hidden */
  68005. export class ShaderCodeTestNode extends ShaderCodeNode {
  68006. testExpression: ShaderDefineExpression;
  68007. isValid(preprocessors: {
  68008. [key: string]: string;
  68009. }): boolean;
  68010. }
  68011. }
  68012. declare module BABYLON {
  68013. /** @hidden */
  68014. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68015. define: string;
  68016. not: boolean;
  68017. constructor(define: string, not?: boolean);
  68018. isTrue(preprocessors: {
  68019. [key: string]: string;
  68020. }): boolean;
  68021. }
  68022. }
  68023. declare module BABYLON {
  68024. /** @hidden */
  68025. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68026. leftOperand: ShaderDefineExpression;
  68027. rightOperand: ShaderDefineExpression;
  68028. isTrue(preprocessors: {
  68029. [key: string]: string;
  68030. }): boolean;
  68031. }
  68032. }
  68033. declare module BABYLON {
  68034. /** @hidden */
  68035. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68036. leftOperand: ShaderDefineExpression;
  68037. rightOperand: ShaderDefineExpression;
  68038. isTrue(preprocessors: {
  68039. [key: string]: string;
  68040. }): boolean;
  68041. }
  68042. }
  68043. declare module BABYLON {
  68044. /** @hidden */
  68045. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68046. define: string;
  68047. operand: string;
  68048. testValue: string;
  68049. constructor(define: string, operand: string, testValue: string);
  68050. isTrue(preprocessors: {
  68051. [key: string]: string;
  68052. }): boolean;
  68053. }
  68054. }
  68055. declare module BABYLON {
  68056. /**
  68057. * @ignore
  68058. * Application error to support additional information when loading a file
  68059. */
  68060. export class LoadFileError extends Error {
  68061. /** defines the optional web request */
  68062. request?: WebRequest | undefined;
  68063. private static _setPrototypeOf;
  68064. /**
  68065. * Creates a new LoadFileError
  68066. * @param message defines the message of the error
  68067. * @param request defines the optional web request
  68068. */
  68069. constructor(message: string,
  68070. /** defines the optional web request */
  68071. request?: WebRequest | undefined);
  68072. }
  68073. }
  68074. declare module BABYLON {
  68075. /**
  68076. * Class used to enable access to offline support
  68077. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68078. */
  68079. export interface IOfflineProvider {
  68080. /**
  68081. * Gets a boolean indicating if scene must be saved in the database
  68082. */
  68083. enableSceneOffline: boolean;
  68084. /**
  68085. * Gets a boolean indicating if textures must be saved in the database
  68086. */
  68087. enableTexturesOffline: boolean;
  68088. /**
  68089. * Open the offline support and make it available
  68090. * @param successCallback defines the callback to call on success
  68091. * @param errorCallback defines the callback to call on error
  68092. */
  68093. open(successCallback: () => void, errorCallback: () => void): void;
  68094. /**
  68095. * Loads an image from the offline support
  68096. * @param url defines the url to load from
  68097. * @param image defines the target DOM image
  68098. */
  68099. loadImage(url: string, image: HTMLImageElement): void;
  68100. /**
  68101. * Loads a file from offline support
  68102. * @param url defines the URL to load from
  68103. * @param sceneLoaded defines a callback to call on success
  68104. * @param progressCallBack defines a callback to call when progress changed
  68105. * @param errorCallback defines a callback to call on error
  68106. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68107. */
  68108. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68109. }
  68110. }
  68111. declare module BABYLON {
  68112. /**
  68113. * Class used to help managing file picking and drag'n'drop
  68114. * File Storage
  68115. */
  68116. export class FilesInputStore {
  68117. /**
  68118. * List of files ready to be loaded
  68119. */
  68120. static FilesToLoad: {
  68121. [key: string]: File;
  68122. };
  68123. }
  68124. }
  68125. declare module BABYLON {
  68126. /**
  68127. * Class used to define a retry strategy when error happens while loading assets
  68128. */
  68129. export class RetryStrategy {
  68130. /**
  68131. * Function used to defines an exponential back off strategy
  68132. * @param maxRetries defines the maximum number of retries (3 by default)
  68133. * @param baseInterval defines the interval between retries
  68134. * @returns the strategy function to use
  68135. */
  68136. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  68137. }
  68138. }
  68139. declare module BABYLON {
  68140. /**
  68141. * @hidden
  68142. */
  68143. export class FileTools {
  68144. /**
  68145. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  68146. */
  68147. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  68148. /**
  68149. * Gets or sets the base URL to use to load assets
  68150. */
  68151. static BaseUrl: string;
  68152. /**
  68153. * Default behaviour for cors in the application.
  68154. * It can be a string if the expected behavior is identical in the entire app.
  68155. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  68156. */
  68157. static CorsBehavior: string | ((url: string | string[]) => string);
  68158. /**
  68159. * Gets or sets a function used to pre-process url before using them to load assets
  68160. */
  68161. static PreprocessUrl: (url: string) => string;
  68162. /**
  68163. * Removes unwanted characters from an url
  68164. * @param url defines the url to clean
  68165. * @returns the cleaned url
  68166. */
  68167. private static _CleanUrl;
  68168. /**
  68169. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  68170. * @param url define the url we are trying
  68171. * @param element define the dom element where to configure the cors policy
  68172. */
  68173. static SetCorsBehavior(url: string | string[], element: {
  68174. crossOrigin: string | null;
  68175. }): void;
  68176. /**
  68177. * Loads an image as an HTMLImageElement.
  68178. * @param input url string, ArrayBuffer, or Blob to load
  68179. * @param onLoad callback called when the image successfully loads
  68180. * @param onError callback called when the image fails to load
  68181. * @param offlineProvider offline provider for caching
  68182. * @returns the HTMLImageElement of the loaded image
  68183. */
  68184. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  68185. /**
  68186. * Loads a file
  68187. * @param fileToLoad defines the file to load
  68188. * @param callback defines the callback to call when data is loaded
  68189. * @param progressCallBack defines the callback to call during loading process
  68190. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68191. * @returns a file request object
  68192. */
  68193. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  68194. /**
  68195. * Loads a file
  68196. * @param url url string, ArrayBuffer, or Blob to load
  68197. * @param onSuccess callback called when the file successfully loads
  68198. * @param onProgress callback called while file is loading (if the server supports this mode)
  68199. * @param offlineProvider defines the offline provider for caching
  68200. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68201. * @param onError callback called when the file fails to load
  68202. * @returns a file request object
  68203. */
  68204. 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;
  68205. /**
  68206. * Checks if the loaded document was accessed via `file:`-Protocol.
  68207. * @returns boolean
  68208. */
  68209. static IsFileURL(): boolean;
  68210. }
  68211. }
  68212. declare module BABYLON {
  68213. /** @hidden */
  68214. export class ShaderProcessor {
  68215. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68216. private static _ProcessPrecision;
  68217. private static _ExtractOperation;
  68218. private static _BuildSubExpression;
  68219. private static _BuildExpression;
  68220. private static _MoveCursorWithinIf;
  68221. private static _MoveCursor;
  68222. private static _EvaluatePreProcessors;
  68223. private static _PreparePreProcessors;
  68224. private static _ProcessShaderConversion;
  68225. private static _ProcessIncludes;
  68226. }
  68227. }
  68228. declare module BABYLON {
  68229. /**
  68230. * @hidden
  68231. */
  68232. export interface IColor4Like {
  68233. r: float;
  68234. g: float;
  68235. b: float;
  68236. a: float;
  68237. }
  68238. /**
  68239. * @hidden
  68240. */
  68241. export interface IColor3Like {
  68242. r: float;
  68243. g: float;
  68244. b: float;
  68245. }
  68246. /**
  68247. * @hidden
  68248. */
  68249. export interface IVector4Like {
  68250. x: float;
  68251. y: float;
  68252. z: float;
  68253. w: float;
  68254. }
  68255. /**
  68256. * @hidden
  68257. */
  68258. export interface IVector3Like {
  68259. x: float;
  68260. y: float;
  68261. z: float;
  68262. }
  68263. /**
  68264. * @hidden
  68265. */
  68266. export interface IVector2Like {
  68267. x: float;
  68268. y: float;
  68269. }
  68270. /**
  68271. * @hidden
  68272. */
  68273. export interface IMatrixLike {
  68274. toArray(): DeepImmutable<Float32Array>;
  68275. updateFlag: int;
  68276. }
  68277. /**
  68278. * @hidden
  68279. */
  68280. export interface IViewportLike {
  68281. x: float;
  68282. y: float;
  68283. width: float;
  68284. height: float;
  68285. }
  68286. /**
  68287. * @hidden
  68288. */
  68289. export interface IPlaneLike {
  68290. normal: IVector3Like;
  68291. d: float;
  68292. normalize(): void;
  68293. }
  68294. }
  68295. declare module BABYLON {
  68296. /**
  68297. * Interface used to define common properties for effect fallbacks
  68298. */
  68299. export interface IEffectFallbacks {
  68300. /**
  68301. * Removes the defines that should be removed when falling back.
  68302. * @param currentDefines defines the current define statements for the shader.
  68303. * @param effect defines the current effect we try to compile
  68304. * @returns The resulting defines with defines of the current rank removed.
  68305. */
  68306. reduce(currentDefines: string, effect: Effect): string;
  68307. /**
  68308. * Removes the fallback from the bound mesh.
  68309. */
  68310. unBindMesh(): void;
  68311. /**
  68312. * Checks to see if more fallbacks are still availible.
  68313. */
  68314. hasMoreFallbacks: boolean;
  68315. }
  68316. }
  68317. declare module BABYLON {
  68318. /**
  68319. * Class used to evalaute queries containing `and` and `or` operators
  68320. */
  68321. export class AndOrNotEvaluator {
  68322. /**
  68323. * Evaluate a query
  68324. * @param query defines the query to evaluate
  68325. * @param evaluateCallback defines the callback used to filter result
  68326. * @returns true if the query matches
  68327. */
  68328. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  68329. private static _HandleParenthesisContent;
  68330. private static _SimplifyNegation;
  68331. }
  68332. }
  68333. declare module BABYLON {
  68334. /**
  68335. * Class used to store custom tags
  68336. */
  68337. export class Tags {
  68338. /**
  68339. * Adds support for tags on the given object
  68340. * @param obj defines the object to use
  68341. */
  68342. static EnableFor(obj: any): void;
  68343. /**
  68344. * Removes tags support
  68345. * @param obj defines the object to use
  68346. */
  68347. static DisableFor(obj: any): void;
  68348. /**
  68349. * Gets a boolean indicating if the given object has tags
  68350. * @param obj defines the object to use
  68351. * @returns a boolean
  68352. */
  68353. static HasTags(obj: any): boolean;
  68354. /**
  68355. * Gets the tags available on a given object
  68356. * @param obj defines the object to use
  68357. * @param asString defines if the tags must be returned as a string instead of an array of strings
  68358. * @returns the tags
  68359. */
  68360. static GetTags(obj: any, asString?: boolean): any;
  68361. /**
  68362. * Adds tags to an object
  68363. * @param obj defines the object to use
  68364. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  68365. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  68366. */
  68367. static AddTagsTo(obj: any, tagsString: string): void;
  68368. /**
  68369. * @hidden
  68370. */
  68371. static _AddTagTo(obj: any, tag: string): void;
  68372. /**
  68373. * Removes specific tags from a specific object
  68374. * @param obj defines the object to use
  68375. * @param tagsString defines the tags to remove
  68376. */
  68377. static RemoveTagsFrom(obj: any, tagsString: string): void;
  68378. /**
  68379. * @hidden
  68380. */
  68381. static _RemoveTagFrom(obj: any, tag: string): void;
  68382. /**
  68383. * Defines if tags hosted on an object match a given query
  68384. * @param obj defines the object to use
  68385. * @param tagsQuery defines the tag query
  68386. * @returns a boolean
  68387. */
  68388. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  68389. }
  68390. }
  68391. declare module BABYLON {
  68392. /**
  68393. * Scalar computation library
  68394. */
  68395. export class Scalar {
  68396. /**
  68397. * Two pi constants convenient for computation.
  68398. */
  68399. static TwoPi: number;
  68400. /**
  68401. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  68402. * @param a number
  68403. * @param b number
  68404. * @param epsilon (default = 1.401298E-45)
  68405. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  68406. */
  68407. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  68408. /**
  68409. * Returns a string : the upper case translation of the number i to hexadecimal.
  68410. * @param i number
  68411. * @returns the upper case translation of the number i to hexadecimal.
  68412. */
  68413. static ToHex(i: number): string;
  68414. /**
  68415. * Returns -1 if value is negative and +1 is value is positive.
  68416. * @param value the value
  68417. * @returns the value itself if it's equal to zero.
  68418. */
  68419. static Sign(value: number): number;
  68420. /**
  68421. * Returns the value itself if it's between min and max.
  68422. * Returns min if the value is lower than min.
  68423. * Returns max if the value is greater than max.
  68424. * @param value the value to clmap
  68425. * @param min the min value to clamp to (default: 0)
  68426. * @param max the max value to clamp to (default: 1)
  68427. * @returns the clamped value
  68428. */
  68429. static Clamp(value: number, min?: number, max?: number): number;
  68430. /**
  68431. * the log2 of value.
  68432. * @param value the value to compute log2 of
  68433. * @returns the log2 of value.
  68434. */
  68435. static Log2(value: number): number;
  68436. /**
  68437. * Loops the value, so that it is never larger than length and never smaller than 0.
  68438. *
  68439. * This is similar to the modulo operator but it works with floating point numbers.
  68440. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  68441. * With t = 5 and length = 2.5, the result would be 0.0.
  68442. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  68443. * @param value the value
  68444. * @param length the length
  68445. * @returns the looped value
  68446. */
  68447. static Repeat(value: number, length: number): number;
  68448. /**
  68449. * Normalize the value between 0.0 and 1.0 using min and max values
  68450. * @param value value to normalize
  68451. * @param min max to normalize between
  68452. * @param max min to normalize between
  68453. * @returns the normalized value
  68454. */
  68455. static Normalize(value: number, min: number, max: number): number;
  68456. /**
  68457. * Denormalize the value from 0.0 and 1.0 using min and max values
  68458. * @param normalized value to denormalize
  68459. * @param min max to denormalize between
  68460. * @param max min to denormalize between
  68461. * @returns the denormalized value
  68462. */
  68463. static Denormalize(normalized: number, min: number, max: number): number;
  68464. /**
  68465. * Calculates the shortest difference between two given angles given in degrees.
  68466. * @param current current angle in degrees
  68467. * @param target target angle in degrees
  68468. * @returns the delta
  68469. */
  68470. static DeltaAngle(current: number, target: number): number;
  68471. /**
  68472. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  68473. * @param tx value
  68474. * @param length length
  68475. * @returns The returned value will move back and forth between 0 and length
  68476. */
  68477. static PingPong(tx: number, length: number): number;
  68478. /**
  68479. * Interpolates between min and max with smoothing at the limits.
  68480. *
  68481. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  68482. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  68483. * @param from from
  68484. * @param to to
  68485. * @param tx value
  68486. * @returns the smooth stepped value
  68487. */
  68488. static SmoothStep(from: number, to: number, tx: number): number;
  68489. /**
  68490. * Moves a value current towards target.
  68491. *
  68492. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  68493. * Negative values of maxDelta pushes the value away from target.
  68494. * @param current current value
  68495. * @param target target value
  68496. * @param maxDelta max distance to move
  68497. * @returns resulting value
  68498. */
  68499. static MoveTowards(current: number, target: number, maxDelta: number): number;
  68500. /**
  68501. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  68502. *
  68503. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  68504. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  68505. * @param current current value
  68506. * @param target target value
  68507. * @param maxDelta max distance to move
  68508. * @returns resulting angle
  68509. */
  68510. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  68511. /**
  68512. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  68513. * @param start start value
  68514. * @param end target value
  68515. * @param amount amount to lerp between
  68516. * @returns the lerped value
  68517. */
  68518. static Lerp(start: number, end: number, amount: number): number;
  68519. /**
  68520. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  68521. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  68522. * @param start start value
  68523. * @param end target value
  68524. * @param amount amount to lerp between
  68525. * @returns the lerped value
  68526. */
  68527. static LerpAngle(start: number, end: number, amount: number): number;
  68528. /**
  68529. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  68530. * @param a start value
  68531. * @param b target value
  68532. * @param value value between a and b
  68533. * @returns the inverseLerp value
  68534. */
  68535. static InverseLerp(a: number, b: number, value: number): number;
  68536. /**
  68537. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  68538. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  68539. * @param value1 spline value
  68540. * @param tangent1 spline value
  68541. * @param value2 spline value
  68542. * @param tangent2 spline value
  68543. * @param amount input value
  68544. * @returns hermite result
  68545. */
  68546. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  68547. /**
  68548. * Returns a random float number between and min and max values
  68549. * @param min min value of random
  68550. * @param max max value of random
  68551. * @returns random value
  68552. */
  68553. static RandomRange(min: number, max: number): number;
  68554. /**
  68555. * This function returns percentage of a number in a given range.
  68556. *
  68557. * RangeToPercent(40,20,60) will return 0.5 (50%)
  68558. * RangeToPercent(34,0,100) will return 0.34 (34%)
  68559. * @param number to convert to percentage
  68560. * @param min min range
  68561. * @param max max range
  68562. * @returns the percentage
  68563. */
  68564. static RangeToPercent(number: number, min: number, max: number): number;
  68565. /**
  68566. * This function returns number that corresponds to the percentage in a given range.
  68567. *
  68568. * PercentToRange(0.34,0,100) will return 34.
  68569. * @param percent to convert to number
  68570. * @param min min range
  68571. * @param max max range
  68572. * @returns the number
  68573. */
  68574. static PercentToRange(percent: number, min: number, max: number): number;
  68575. /**
  68576. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  68577. * @param angle The angle to normalize in radian.
  68578. * @return The converted angle.
  68579. */
  68580. static NormalizeRadians(angle: number): number;
  68581. }
  68582. }
  68583. declare module BABYLON {
  68584. /**
  68585. * Constant used to convert a value to gamma space
  68586. * @ignorenaming
  68587. */
  68588. export const ToGammaSpace: number;
  68589. /**
  68590. * Constant used to convert a value to linear space
  68591. * @ignorenaming
  68592. */
  68593. export const ToLinearSpace = 2.2;
  68594. /**
  68595. * Constant used to define the minimal number value in Babylon.js
  68596. * @ignorenaming
  68597. */
  68598. let Epsilon: number;
  68599. }
  68600. declare module BABYLON {
  68601. /**
  68602. * Class used to represent a viewport on screen
  68603. */
  68604. export class Viewport {
  68605. /** viewport left coordinate */
  68606. x: number;
  68607. /** viewport top coordinate */
  68608. y: number;
  68609. /**viewport width */
  68610. width: number;
  68611. /** viewport height */
  68612. height: number;
  68613. /**
  68614. * Creates a Viewport object located at (x, y) and sized (width, height)
  68615. * @param x defines viewport left coordinate
  68616. * @param y defines viewport top coordinate
  68617. * @param width defines the viewport width
  68618. * @param height defines the viewport height
  68619. */
  68620. constructor(
  68621. /** viewport left coordinate */
  68622. x: number,
  68623. /** viewport top coordinate */
  68624. y: number,
  68625. /**viewport width */
  68626. width: number,
  68627. /** viewport height */
  68628. height: number);
  68629. /**
  68630. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  68631. * @param renderWidth defines the rendering width
  68632. * @param renderHeight defines the rendering height
  68633. * @returns a new Viewport
  68634. */
  68635. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  68636. /**
  68637. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  68638. * @param renderWidth defines the rendering width
  68639. * @param renderHeight defines the rendering height
  68640. * @param ref defines the target viewport
  68641. * @returns the current viewport
  68642. */
  68643. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  68644. /**
  68645. * Returns a new Viewport copied from the current one
  68646. * @returns a new Viewport
  68647. */
  68648. clone(): Viewport;
  68649. }
  68650. }
  68651. declare module BABYLON {
  68652. /**
  68653. * Class containing a set of static utilities functions for arrays.
  68654. */
  68655. export class ArrayTools {
  68656. /**
  68657. * Returns an array of the given size filled with element built from the given constructor and the paramters
  68658. * @param size the number of element to construct and put in the array
  68659. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  68660. * @returns a new array filled with new objects
  68661. */
  68662. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  68663. }
  68664. }
  68665. declare module BABYLON {
  68666. /**
  68667. * Class representing a vector containing 2 coordinates
  68668. */
  68669. export class Vector2 {
  68670. /** defines the first coordinate */
  68671. x: number;
  68672. /** defines the second coordinate */
  68673. y: number;
  68674. /**
  68675. * Creates a new Vector2 from the given x and y coordinates
  68676. * @param x defines the first coordinate
  68677. * @param y defines the second coordinate
  68678. */
  68679. constructor(
  68680. /** defines the first coordinate */
  68681. x?: number,
  68682. /** defines the second coordinate */
  68683. y?: number);
  68684. /**
  68685. * Gets a string with the Vector2 coordinates
  68686. * @returns a string with the Vector2 coordinates
  68687. */
  68688. toString(): string;
  68689. /**
  68690. * Gets class name
  68691. * @returns the string "Vector2"
  68692. */
  68693. getClassName(): string;
  68694. /**
  68695. * Gets current vector hash code
  68696. * @returns the Vector2 hash code as a number
  68697. */
  68698. getHashCode(): number;
  68699. /**
  68700. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  68701. * @param array defines the source array
  68702. * @param index defines the offset in source array
  68703. * @returns the current Vector2
  68704. */
  68705. toArray(array: FloatArray, index?: number): Vector2;
  68706. /**
  68707. * Copy the current vector to an array
  68708. * @returns a new array with 2 elements: the Vector2 coordinates.
  68709. */
  68710. asArray(): number[];
  68711. /**
  68712. * Sets the Vector2 coordinates with the given Vector2 coordinates
  68713. * @param source defines the source Vector2
  68714. * @returns the current updated Vector2
  68715. */
  68716. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  68717. /**
  68718. * Sets the Vector2 coordinates with the given floats
  68719. * @param x defines the first coordinate
  68720. * @param y defines the second coordinate
  68721. * @returns the current updated Vector2
  68722. */
  68723. copyFromFloats(x: number, y: number): Vector2;
  68724. /**
  68725. * Sets the Vector2 coordinates with the given floats
  68726. * @param x defines the first coordinate
  68727. * @param y defines the second coordinate
  68728. * @returns the current updated Vector2
  68729. */
  68730. set(x: number, y: number): Vector2;
  68731. /**
  68732. * Add another vector with the current one
  68733. * @param otherVector defines the other vector
  68734. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  68735. */
  68736. add(otherVector: DeepImmutable<Vector2>): Vector2;
  68737. /**
  68738. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  68739. * @param otherVector defines the other vector
  68740. * @param result defines the target vector
  68741. * @returns the unmodified current Vector2
  68742. */
  68743. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68744. /**
  68745. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  68746. * @param otherVector defines the other vector
  68747. * @returns the current updated Vector2
  68748. */
  68749. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68750. /**
  68751. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  68752. * @param otherVector defines the other vector
  68753. * @returns a new Vector2
  68754. */
  68755. addVector3(otherVector: Vector3): Vector2;
  68756. /**
  68757. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  68758. * @param otherVector defines the other vector
  68759. * @returns a new Vector2
  68760. */
  68761. subtract(otherVector: Vector2): Vector2;
  68762. /**
  68763. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  68764. * @param otherVector defines the other vector
  68765. * @param result defines the target vector
  68766. * @returns the unmodified current Vector2
  68767. */
  68768. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68769. /**
  68770. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  68771. * @param otherVector defines the other vector
  68772. * @returns the current updated Vector2
  68773. */
  68774. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68775. /**
  68776. * Multiplies in place the current Vector2 coordinates by the given ones
  68777. * @param otherVector defines the other vector
  68778. * @returns the current updated Vector2
  68779. */
  68780. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68781. /**
  68782. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  68783. * @param otherVector defines the other vector
  68784. * @returns a new Vector2
  68785. */
  68786. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  68787. /**
  68788. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  68789. * @param otherVector defines the other vector
  68790. * @param result defines the target vector
  68791. * @returns the unmodified current Vector2
  68792. */
  68793. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68794. /**
  68795. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  68796. * @param x defines the first coordinate
  68797. * @param y defines the second coordinate
  68798. * @returns a new Vector2
  68799. */
  68800. multiplyByFloats(x: number, y: number): Vector2;
  68801. /**
  68802. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  68803. * @param otherVector defines the other vector
  68804. * @returns a new Vector2
  68805. */
  68806. divide(otherVector: Vector2): Vector2;
  68807. /**
  68808. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  68809. * @param otherVector defines the other vector
  68810. * @param result defines the target vector
  68811. * @returns the unmodified current Vector2
  68812. */
  68813. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68814. /**
  68815. * Divides the current Vector2 coordinates by the given ones
  68816. * @param otherVector defines the other vector
  68817. * @returns the current updated Vector2
  68818. */
  68819. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68820. /**
  68821. * Gets a new Vector2 with current Vector2 negated coordinates
  68822. * @returns a new Vector2
  68823. */
  68824. negate(): Vector2;
  68825. /**
  68826. * Multiply the Vector2 coordinates by scale
  68827. * @param scale defines the scaling factor
  68828. * @returns the current updated Vector2
  68829. */
  68830. scaleInPlace(scale: number): Vector2;
  68831. /**
  68832. * Returns a new Vector2 scaled by "scale" from the current Vector2
  68833. * @param scale defines the scaling factor
  68834. * @returns a new Vector2
  68835. */
  68836. scale(scale: number): Vector2;
  68837. /**
  68838. * Scale the current Vector2 values by a factor to a given Vector2
  68839. * @param scale defines the scale factor
  68840. * @param result defines the Vector2 object where to store the result
  68841. * @returns the unmodified current Vector2
  68842. */
  68843. scaleToRef(scale: number, result: Vector2): Vector2;
  68844. /**
  68845. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  68846. * @param scale defines the scale factor
  68847. * @param result defines the Vector2 object where to store the result
  68848. * @returns the unmodified current Vector2
  68849. */
  68850. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  68851. /**
  68852. * Gets a boolean if two vectors are equals
  68853. * @param otherVector defines the other vector
  68854. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  68855. */
  68856. equals(otherVector: DeepImmutable<Vector2>): boolean;
  68857. /**
  68858. * Gets a boolean if two vectors are equals (using an epsilon value)
  68859. * @param otherVector defines the other vector
  68860. * @param epsilon defines the minimal distance to consider equality
  68861. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  68862. */
  68863. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  68864. /**
  68865. * Gets a new Vector2 from current Vector2 floored values
  68866. * @returns a new Vector2
  68867. */
  68868. floor(): Vector2;
  68869. /**
  68870. * Gets a new Vector2 from current Vector2 floored values
  68871. * @returns a new Vector2
  68872. */
  68873. fract(): Vector2;
  68874. /**
  68875. * Gets the length of the vector
  68876. * @returns the vector length (float)
  68877. */
  68878. length(): number;
  68879. /**
  68880. * Gets the vector squared length
  68881. * @returns the vector squared length (float)
  68882. */
  68883. lengthSquared(): number;
  68884. /**
  68885. * Normalize the vector
  68886. * @returns the current updated Vector2
  68887. */
  68888. normalize(): Vector2;
  68889. /**
  68890. * Gets a new Vector2 copied from the Vector2
  68891. * @returns a new Vector2
  68892. */
  68893. clone(): Vector2;
  68894. /**
  68895. * Gets a new Vector2(0, 0)
  68896. * @returns a new Vector2
  68897. */
  68898. static Zero(): Vector2;
  68899. /**
  68900. * Gets a new Vector2(1, 1)
  68901. * @returns a new Vector2
  68902. */
  68903. static One(): Vector2;
  68904. /**
  68905. * Gets a new Vector2 set from the given index element of the given array
  68906. * @param array defines the data source
  68907. * @param offset defines the offset in the data source
  68908. * @returns a new Vector2
  68909. */
  68910. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  68911. /**
  68912. * Sets "result" from the given index element of the given array
  68913. * @param array defines the data source
  68914. * @param offset defines the offset in the data source
  68915. * @param result defines the target vector
  68916. */
  68917. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  68918. /**
  68919. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  68920. * @param value1 defines 1st point of control
  68921. * @param value2 defines 2nd point of control
  68922. * @param value3 defines 3rd point of control
  68923. * @param value4 defines 4th point of control
  68924. * @param amount defines the interpolation factor
  68925. * @returns a new Vector2
  68926. */
  68927. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  68928. /**
  68929. * 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".
  68930. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  68931. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  68932. * @param value defines the value to clamp
  68933. * @param min defines the lower limit
  68934. * @param max defines the upper limit
  68935. * @returns a new Vector2
  68936. */
  68937. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  68938. /**
  68939. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  68940. * @param value1 defines the 1st control point
  68941. * @param tangent1 defines the outgoing tangent
  68942. * @param value2 defines the 2nd control point
  68943. * @param tangent2 defines the incoming tangent
  68944. * @param amount defines the interpolation factor
  68945. * @returns a new Vector2
  68946. */
  68947. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  68948. /**
  68949. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  68950. * @param start defines the start vector
  68951. * @param end defines the end vector
  68952. * @param amount defines the interpolation factor
  68953. * @returns a new Vector2
  68954. */
  68955. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  68956. /**
  68957. * Gets the dot product of the vector "left" and the vector "right"
  68958. * @param left defines first vector
  68959. * @param right defines second vector
  68960. * @returns the dot product (float)
  68961. */
  68962. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  68963. /**
  68964. * Returns a new Vector2 equal to the normalized given vector
  68965. * @param vector defines the vector to normalize
  68966. * @returns a new Vector2
  68967. */
  68968. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  68969. /**
  68970. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  68971. * @param left defines 1st vector
  68972. * @param right defines 2nd vector
  68973. * @returns a new Vector2
  68974. */
  68975. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  68976. /**
  68977. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  68978. * @param left defines 1st vector
  68979. * @param right defines 2nd vector
  68980. * @returns a new Vector2
  68981. */
  68982. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  68983. /**
  68984. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  68985. * @param vector defines the vector to transform
  68986. * @param transformation defines the matrix to apply
  68987. * @returns a new Vector2
  68988. */
  68989. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  68990. /**
  68991. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  68992. * @param vector defines the vector to transform
  68993. * @param transformation defines the matrix to apply
  68994. * @param result defines the target vector
  68995. */
  68996. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  68997. /**
  68998. * Determines if a given vector is included in a triangle
  68999. * @param p defines the vector to test
  69000. * @param p0 defines 1st triangle point
  69001. * @param p1 defines 2nd triangle point
  69002. * @param p2 defines 3rd triangle point
  69003. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  69004. */
  69005. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  69006. /**
  69007. * Gets the distance between the vectors "value1" and "value2"
  69008. * @param value1 defines first vector
  69009. * @param value2 defines second vector
  69010. * @returns the distance between vectors
  69011. */
  69012. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69013. /**
  69014. * Returns the squared distance between the vectors "value1" and "value2"
  69015. * @param value1 defines first vector
  69016. * @param value2 defines second vector
  69017. * @returns the squared distance between vectors
  69018. */
  69019. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69020. /**
  69021. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  69022. * @param value1 defines first vector
  69023. * @param value2 defines second vector
  69024. * @returns a new Vector2
  69025. */
  69026. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  69027. /**
  69028. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  69029. * @param p defines the middle point
  69030. * @param segA defines one point of the segment
  69031. * @param segB defines the other point of the segment
  69032. * @returns the shortest distance
  69033. */
  69034. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  69035. }
  69036. /**
  69037. * Classed used to store (x,y,z) vector representation
  69038. * A Vector3 is the main object used in 3D geometry
  69039. * It can represent etiher the coordinates of a point the space, either a direction
  69040. * Reminder: js uses a left handed forward facing system
  69041. */
  69042. export class Vector3 {
  69043. /**
  69044. * Defines the first coordinates (on X axis)
  69045. */
  69046. x: number;
  69047. /**
  69048. * Defines the second coordinates (on Y axis)
  69049. */
  69050. y: number;
  69051. /**
  69052. * Defines the third coordinates (on Z axis)
  69053. */
  69054. z: number;
  69055. private static _UpReadOnly;
  69056. private static _ZeroReadOnly;
  69057. /**
  69058. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  69059. * @param x defines the first coordinates (on X axis)
  69060. * @param y defines the second coordinates (on Y axis)
  69061. * @param z defines the third coordinates (on Z axis)
  69062. */
  69063. constructor(
  69064. /**
  69065. * Defines the first coordinates (on X axis)
  69066. */
  69067. x?: number,
  69068. /**
  69069. * Defines the second coordinates (on Y axis)
  69070. */
  69071. y?: number,
  69072. /**
  69073. * Defines the third coordinates (on Z axis)
  69074. */
  69075. z?: number);
  69076. /**
  69077. * Creates a string representation of the Vector3
  69078. * @returns a string with the Vector3 coordinates.
  69079. */
  69080. toString(): string;
  69081. /**
  69082. * Gets the class name
  69083. * @returns the string "Vector3"
  69084. */
  69085. getClassName(): string;
  69086. /**
  69087. * Creates the Vector3 hash code
  69088. * @returns a number which tends to be unique between Vector3 instances
  69089. */
  69090. getHashCode(): number;
  69091. /**
  69092. * Creates an array containing three elements : the coordinates of the Vector3
  69093. * @returns a new array of numbers
  69094. */
  69095. asArray(): number[];
  69096. /**
  69097. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  69098. * @param array defines the destination array
  69099. * @param index defines the offset in the destination array
  69100. * @returns the current Vector3
  69101. */
  69102. toArray(array: FloatArray, index?: number): Vector3;
  69103. /**
  69104. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  69105. * @returns a new Quaternion object, computed from the Vector3 coordinates
  69106. */
  69107. toQuaternion(): Quaternion;
  69108. /**
  69109. * Adds the given vector to the current Vector3
  69110. * @param otherVector defines the second operand
  69111. * @returns the current updated Vector3
  69112. */
  69113. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69114. /**
  69115. * Adds the given coordinates to the current Vector3
  69116. * @param x defines the x coordinate of the operand
  69117. * @param y defines the y coordinate of the operand
  69118. * @param z defines the z coordinate of the operand
  69119. * @returns the current updated Vector3
  69120. */
  69121. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69122. /**
  69123. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  69124. * @param otherVector defines the second operand
  69125. * @returns the resulting Vector3
  69126. */
  69127. add(otherVector: DeepImmutable<Vector3>): Vector3;
  69128. /**
  69129. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  69130. * @param otherVector defines the second operand
  69131. * @param result defines the Vector3 object where to store the result
  69132. * @returns the current Vector3
  69133. */
  69134. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69135. /**
  69136. * Subtract the given vector from the current Vector3
  69137. * @param otherVector defines the second operand
  69138. * @returns the current updated Vector3
  69139. */
  69140. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69141. /**
  69142. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  69143. * @param otherVector defines the second operand
  69144. * @returns the resulting Vector3
  69145. */
  69146. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  69147. /**
  69148. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  69149. * @param otherVector defines the second operand
  69150. * @param result defines the Vector3 object where to store the result
  69151. * @returns the current Vector3
  69152. */
  69153. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69154. /**
  69155. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  69156. * @param x defines the x coordinate of the operand
  69157. * @param y defines the y coordinate of the operand
  69158. * @param z defines the z coordinate of the operand
  69159. * @returns the resulting Vector3
  69160. */
  69161. subtractFromFloats(x: number, y: number, z: number): Vector3;
  69162. /**
  69163. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  69164. * @param x defines the x coordinate of the operand
  69165. * @param y defines the y coordinate of the operand
  69166. * @param z defines the z coordinate of the operand
  69167. * @param result defines the Vector3 object where to store the result
  69168. * @returns the current Vector3
  69169. */
  69170. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  69171. /**
  69172. * Gets a new Vector3 set with the current Vector3 negated coordinates
  69173. * @returns a new Vector3
  69174. */
  69175. negate(): Vector3;
  69176. /**
  69177. * Multiplies the Vector3 coordinates by the float "scale"
  69178. * @param scale defines the multiplier factor
  69179. * @returns the current updated Vector3
  69180. */
  69181. scaleInPlace(scale: number): Vector3;
  69182. /**
  69183. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  69184. * @param scale defines the multiplier factor
  69185. * @returns a new Vector3
  69186. */
  69187. scale(scale: number): Vector3;
  69188. /**
  69189. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  69190. * @param scale defines the multiplier factor
  69191. * @param result defines the Vector3 object where to store the result
  69192. * @returns the current Vector3
  69193. */
  69194. scaleToRef(scale: number, result: Vector3): Vector3;
  69195. /**
  69196. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  69197. * @param scale defines the scale factor
  69198. * @param result defines the Vector3 object where to store the result
  69199. * @returns the unmodified current Vector3
  69200. */
  69201. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  69202. /**
  69203. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  69204. * @param otherVector defines the second operand
  69205. * @returns true if both vectors are equals
  69206. */
  69207. equals(otherVector: DeepImmutable<Vector3>): boolean;
  69208. /**
  69209. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  69210. * @param otherVector defines the second operand
  69211. * @param epsilon defines the minimal distance to define values as equals
  69212. * @returns true if both vectors are distant less than epsilon
  69213. */
  69214. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  69215. /**
  69216. * Returns true if the current Vector3 coordinates equals the given floats
  69217. * @param x defines the x coordinate of the operand
  69218. * @param y defines the y coordinate of the operand
  69219. * @param z defines the z coordinate of the operand
  69220. * @returns true if both vectors are equals
  69221. */
  69222. equalsToFloats(x: number, y: number, z: number): boolean;
  69223. /**
  69224. * Multiplies the current Vector3 coordinates by the given ones
  69225. * @param otherVector defines the second operand
  69226. * @returns the current updated Vector3
  69227. */
  69228. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69229. /**
  69230. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  69231. * @param otherVector defines the second operand
  69232. * @returns the new Vector3
  69233. */
  69234. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  69235. /**
  69236. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  69237. * @param otherVector defines the second operand
  69238. * @param result defines the Vector3 object where to store the result
  69239. * @returns the current Vector3
  69240. */
  69241. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69242. /**
  69243. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  69244. * @param x defines the x coordinate of the operand
  69245. * @param y defines the y coordinate of the operand
  69246. * @param z defines the z coordinate of the operand
  69247. * @returns the new Vector3
  69248. */
  69249. multiplyByFloats(x: number, y: number, z: number): Vector3;
  69250. /**
  69251. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  69252. * @param otherVector defines the second operand
  69253. * @returns the new Vector3
  69254. */
  69255. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  69256. /**
  69257. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  69258. * @param otherVector defines the second operand
  69259. * @param result defines the Vector3 object where to store the result
  69260. * @returns the current Vector3
  69261. */
  69262. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69263. /**
  69264. * Divides the current Vector3 coordinates by the given ones.
  69265. * @param otherVector defines the second operand
  69266. * @returns the current updated Vector3
  69267. */
  69268. divideInPlace(otherVector: Vector3): Vector3;
  69269. /**
  69270. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  69271. * @param other defines the second operand
  69272. * @returns the current updated Vector3
  69273. */
  69274. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69275. /**
  69276. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  69277. * @param other defines the second operand
  69278. * @returns the current updated Vector3
  69279. */
  69280. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69281. /**
  69282. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  69283. * @param x defines the x coordinate of the operand
  69284. * @param y defines the y coordinate of the operand
  69285. * @param z defines the z coordinate of the operand
  69286. * @returns the current updated Vector3
  69287. */
  69288. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69289. /**
  69290. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  69291. * @param x defines the x coordinate of the operand
  69292. * @param y defines the y coordinate of the operand
  69293. * @param z defines the z coordinate of the operand
  69294. * @returns the current updated Vector3
  69295. */
  69296. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69297. /**
  69298. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  69299. * Check if is non uniform within a certain amount of decimal places to account for this
  69300. * @param epsilon the amount the values can differ
  69301. * @returns if the the vector is non uniform to a certain number of decimal places
  69302. */
  69303. isNonUniformWithinEpsilon(epsilon: number): boolean;
  69304. /**
  69305. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  69306. */
  69307. readonly isNonUniform: boolean;
  69308. /**
  69309. * Gets a new Vector3 from current Vector3 floored values
  69310. * @returns a new Vector3
  69311. */
  69312. floor(): Vector3;
  69313. /**
  69314. * Gets a new Vector3 from current Vector3 floored values
  69315. * @returns a new Vector3
  69316. */
  69317. fract(): Vector3;
  69318. /**
  69319. * Gets the length of the Vector3
  69320. * @returns the length of the Vector3
  69321. */
  69322. length(): number;
  69323. /**
  69324. * Gets the squared length of the Vector3
  69325. * @returns squared length of the Vector3
  69326. */
  69327. lengthSquared(): number;
  69328. /**
  69329. * Normalize the current Vector3.
  69330. * Please note that this is an in place operation.
  69331. * @returns the current updated Vector3
  69332. */
  69333. normalize(): Vector3;
  69334. /**
  69335. * Reorders the x y z properties of the vector in place
  69336. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  69337. * @returns the current updated vector
  69338. */
  69339. reorderInPlace(order: string): this;
  69340. /**
  69341. * Rotates the vector around 0,0,0 by a quaternion
  69342. * @param quaternion the rotation quaternion
  69343. * @param result vector to store the result
  69344. * @returns the resulting vector
  69345. */
  69346. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  69347. /**
  69348. * Rotates a vector around a given point
  69349. * @param quaternion the rotation quaternion
  69350. * @param point the point to rotate around
  69351. * @param result vector to store the result
  69352. * @returns the resulting vector
  69353. */
  69354. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  69355. /**
  69356. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  69357. * The cross product is then orthogonal to both current and "other"
  69358. * @param other defines the right operand
  69359. * @returns the cross product
  69360. */
  69361. cross(other: Vector3): Vector3;
  69362. /**
  69363. * Normalize the current Vector3 with the given input length.
  69364. * Please note that this is an in place operation.
  69365. * @param len the length of the vector
  69366. * @returns the current updated Vector3
  69367. */
  69368. normalizeFromLength(len: number): Vector3;
  69369. /**
  69370. * Normalize the current Vector3 to a new vector
  69371. * @returns the new Vector3
  69372. */
  69373. normalizeToNew(): Vector3;
  69374. /**
  69375. * Normalize the current Vector3 to the reference
  69376. * @param reference define the Vector3 to update
  69377. * @returns the updated Vector3
  69378. */
  69379. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  69380. /**
  69381. * Creates a new Vector3 copied from the current Vector3
  69382. * @returns the new Vector3
  69383. */
  69384. clone(): Vector3;
  69385. /**
  69386. * Copies the given vector coordinates to the current Vector3 ones
  69387. * @param source defines the source Vector3
  69388. * @returns the current updated Vector3
  69389. */
  69390. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  69391. /**
  69392. * Copies the given floats to the current Vector3 coordinates
  69393. * @param x defines the x coordinate of the operand
  69394. * @param y defines the y coordinate of the operand
  69395. * @param z defines the z coordinate of the operand
  69396. * @returns the current updated Vector3
  69397. */
  69398. copyFromFloats(x: number, y: number, z: number): Vector3;
  69399. /**
  69400. * Copies the given floats to the current Vector3 coordinates
  69401. * @param x defines the x coordinate of the operand
  69402. * @param y defines the y coordinate of the operand
  69403. * @param z defines the z coordinate of the operand
  69404. * @returns the current updated Vector3
  69405. */
  69406. set(x: number, y: number, z: number): Vector3;
  69407. /**
  69408. * Copies the given float to the current Vector3 coordinates
  69409. * @param v defines the x, y and z coordinates of the operand
  69410. * @returns the current updated Vector3
  69411. */
  69412. setAll(v: number): Vector3;
  69413. /**
  69414. * Get the clip factor between two vectors
  69415. * @param vector0 defines the first operand
  69416. * @param vector1 defines the second operand
  69417. * @param axis defines the axis to use
  69418. * @param size defines the size along the axis
  69419. * @returns the clip factor
  69420. */
  69421. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  69422. /**
  69423. * Get angle between two vectors
  69424. * @param vector0 angle between vector0 and vector1
  69425. * @param vector1 angle between vector0 and vector1
  69426. * @param normal direction of the normal
  69427. * @return the angle between vector0 and vector1
  69428. */
  69429. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  69430. /**
  69431. * Returns a new Vector3 set from the index "offset" of the given array
  69432. * @param array defines the source array
  69433. * @param offset defines the offset in the source array
  69434. * @returns the new Vector3
  69435. */
  69436. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  69437. /**
  69438. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  69439. * This function is deprecated. Use FromArray instead
  69440. * @param array defines the source array
  69441. * @param offset defines the offset in the source array
  69442. * @returns the new Vector3
  69443. */
  69444. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  69445. /**
  69446. * Sets the given vector "result" with the element values from the index "offset" of the given array
  69447. * @param array defines the source array
  69448. * @param offset defines the offset in the source array
  69449. * @param result defines the Vector3 where to store the result
  69450. */
  69451. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  69452. /**
  69453. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  69454. * This function is deprecated. Use FromArrayToRef instead.
  69455. * @param array defines the source array
  69456. * @param offset defines the offset in the source array
  69457. * @param result defines the Vector3 where to store the result
  69458. */
  69459. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  69460. /**
  69461. * Sets the given vector "result" with the given floats.
  69462. * @param x defines the x coordinate of the source
  69463. * @param y defines the y coordinate of the source
  69464. * @param z defines the z coordinate of the source
  69465. * @param result defines the Vector3 where to store the result
  69466. */
  69467. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  69468. /**
  69469. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  69470. * @returns a new empty Vector3
  69471. */
  69472. static Zero(): Vector3;
  69473. /**
  69474. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  69475. * @returns a new unit Vector3
  69476. */
  69477. static One(): Vector3;
  69478. /**
  69479. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  69480. * @returns a new up Vector3
  69481. */
  69482. static Up(): Vector3;
  69483. /**
  69484. * Gets a up Vector3 that must not be updated
  69485. */
  69486. static readonly UpReadOnly: DeepImmutable<Vector3>;
  69487. /**
  69488. * Gets a zero Vector3 that must not be updated
  69489. */
  69490. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  69491. /**
  69492. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  69493. * @returns a new down Vector3
  69494. */
  69495. static Down(): Vector3;
  69496. /**
  69497. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  69498. * @returns a new forward Vector3
  69499. */
  69500. static Forward(): Vector3;
  69501. /**
  69502. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  69503. * @returns a new forward Vector3
  69504. */
  69505. static Backward(): Vector3;
  69506. /**
  69507. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  69508. * @returns a new right Vector3
  69509. */
  69510. static Right(): Vector3;
  69511. /**
  69512. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  69513. * @returns a new left Vector3
  69514. */
  69515. static Left(): Vector3;
  69516. /**
  69517. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  69518. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69519. * @param vector defines the Vector3 to transform
  69520. * @param transformation defines the transformation matrix
  69521. * @returns the transformed Vector3
  69522. */
  69523. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  69524. /**
  69525. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  69526. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69527. * @param vector defines the Vector3 to transform
  69528. * @param transformation defines the transformation matrix
  69529. * @param result defines the Vector3 where to store the result
  69530. */
  69531. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69532. /**
  69533. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  69534. * This method computes tranformed coordinates only, not transformed direction vectors
  69535. * @param x define the x coordinate of the source vector
  69536. * @param y define the y coordinate of the source vector
  69537. * @param z define the z coordinate of the source vector
  69538. * @param transformation defines the transformation matrix
  69539. * @param result defines the Vector3 where to store the result
  69540. */
  69541. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69542. /**
  69543. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  69544. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69545. * @param vector defines the Vector3 to transform
  69546. * @param transformation defines the transformation matrix
  69547. * @returns the new Vector3
  69548. */
  69549. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  69550. /**
  69551. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  69552. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69553. * @param vector defines the Vector3 to transform
  69554. * @param transformation defines the transformation matrix
  69555. * @param result defines the Vector3 where to store the result
  69556. */
  69557. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69558. /**
  69559. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  69560. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69561. * @param x define the x coordinate of the source vector
  69562. * @param y define the y coordinate of the source vector
  69563. * @param z define the z coordinate of the source vector
  69564. * @param transformation defines the transformation matrix
  69565. * @param result defines the Vector3 where to store the result
  69566. */
  69567. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69568. /**
  69569. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  69570. * @param value1 defines the first control point
  69571. * @param value2 defines the second control point
  69572. * @param value3 defines the third control point
  69573. * @param value4 defines the fourth control point
  69574. * @param amount defines the amount on the spline to use
  69575. * @returns the new Vector3
  69576. */
  69577. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  69578. /**
  69579. * 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"
  69580. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  69581. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  69582. * @param value defines the current value
  69583. * @param min defines the lower range value
  69584. * @param max defines the upper range value
  69585. * @returns the new Vector3
  69586. */
  69587. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  69588. /**
  69589. * 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"
  69590. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  69591. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  69592. * @param value defines the current value
  69593. * @param min defines the lower range value
  69594. * @param max defines the upper range value
  69595. * @param result defines the Vector3 where to store the result
  69596. */
  69597. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  69598. /**
  69599. * Checks if a given vector is inside a specific range
  69600. * @param v defines the vector to test
  69601. * @param min defines the minimum range
  69602. * @param max defines the maximum range
  69603. */
  69604. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  69605. /**
  69606. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  69607. * @param value1 defines the first control point
  69608. * @param tangent1 defines the first tangent vector
  69609. * @param value2 defines the second control point
  69610. * @param tangent2 defines the second tangent vector
  69611. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  69612. * @returns the new Vector3
  69613. */
  69614. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  69615. /**
  69616. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  69617. * @param start defines the start value
  69618. * @param end defines the end value
  69619. * @param amount max defines amount between both (between 0 and 1)
  69620. * @returns the new Vector3
  69621. */
  69622. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  69623. /**
  69624. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  69625. * @param start defines the start value
  69626. * @param end defines the end value
  69627. * @param amount max defines amount between both (between 0 and 1)
  69628. * @param result defines the Vector3 where to store the result
  69629. */
  69630. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  69631. /**
  69632. * Returns the dot product (float) between the vectors "left" and "right"
  69633. * @param left defines the left operand
  69634. * @param right defines the right operand
  69635. * @returns the dot product
  69636. */
  69637. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  69638. /**
  69639. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  69640. * The cross product is then orthogonal to both "left" and "right"
  69641. * @param left defines the left operand
  69642. * @param right defines the right operand
  69643. * @returns the cross product
  69644. */
  69645. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  69646. /**
  69647. * Sets the given vector "result" with the cross product of "left" and "right"
  69648. * The cross product is then orthogonal to both "left" and "right"
  69649. * @param left defines the left operand
  69650. * @param right defines the right operand
  69651. * @param result defines the Vector3 where to store the result
  69652. */
  69653. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  69654. /**
  69655. * Returns a new Vector3 as the normalization of the given vector
  69656. * @param vector defines the Vector3 to normalize
  69657. * @returns the new Vector3
  69658. */
  69659. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  69660. /**
  69661. * Sets the given vector "result" with the normalization of the given first vector
  69662. * @param vector defines the Vector3 to normalize
  69663. * @param result defines the Vector3 where to store the result
  69664. */
  69665. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  69666. /**
  69667. * Project a Vector3 onto screen space
  69668. * @param vector defines the Vector3 to project
  69669. * @param world defines the world matrix to use
  69670. * @param transform defines the transform (view x projection) matrix to use
  69671. * @param viewport defines the screen viewport to use
  69672. * @returns the new Vector3
  69673. */
  69674. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  69675. /** @hidden */
  69676. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  69677. /**
  69678. * Unproject from screen space to object space
  69679. * @param source defines the screen space Vector3 to use
  69680. * @param viewportWidth defines the current width of the viewport
  69681. * @param viewportHeight defines the current height of the viewport
  69682. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69683. * @param transform defines the transform (view x projection) matrix to use
  69684. * @returns the new Vector3
  69685. */
  69686. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  69687. /**
  69688. * Unproject from screen space to object space
  69689. * @param source defines the screen space Vector3 to use
  69690. * @param viewportWidth defines the current width of the viewport
  69691. * @param viewportHeight defines the current height of the viewport
  69692. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69693. * @param view defines the view matrix to use
  69694. * @param projection defines the projection matrix to use
  69695. * @returns the new Vector3
  69696. */
  69697. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  69698. /**
  69699. * Unproject from screen space to object space
  69700. * @param source defines the screen space Vector3 to use
  69701. * @param viewportWidth defines the current width of the viewport
  69702. * @param viewportHeight defines the current height of the viewport
  69703. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69704. * @param view defines the view matrix to use
  69705. * @param projection defines the projection matrix to use
  69706. * @param result defines the Vector3 where to store the result
  69707. */
  69708. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  69709. /**
  69710. * Unproject from screen space to object space
  69711. * @param sourceX defines the screen space x coordinate to use
  69712. * @param sourceY defines the screen space y coordinate to use
  69713. * @param sourceZ defines the screen space z coordinate to use
  69714. * @param viewportWidth defines the current width of the viewport
  69715. * @param viewportHeight defines the current height of the viewport
  69716. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69717. * @param view defines the view matrix to use
  69718. * @param projection defines the projection matrix to use
  69719. * @param result defines the Vector3 where to store the result
  69720. */
  69721. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  69722. /**
  69723. * Gets the minimal coordinate values between two Vector3
  69724. * @param left defines the first operand
  69725. * @param right defines the second operand
  69726. * @returns the new Vector3
  69727. */
  69728. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  69729. /**
  69730. * Gets the maximal coordinate values between two Vector3
  69731. * @param left defines the first operand
  69732. * @param right defines the second operand
  69733. * @returns the new Vector3
  69734. */
  69735. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  69736. /**
  69737. * Returns the distance between the vectors "value1" and "value2"
  69738. * @param value1 defines the first operand
  69739. * @param value2 defines the second operand
  69740. * @returns the distance
  69741. */
  69742. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  69743. /**
  69744. * Returns the squared distance between the vectors "value1" and "value2"
  69745. * @param value1 defines the first operand
  69746. * @param value2 defines the second operand
  69747. * @returns the squared distance
  69748. */
  69749. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  69750. /**
  69751. * Returns a new Vector3 located at the center between "value1" and "value2"
  69752. * @param value1 defines the first operand
  69753. * @param value2 defines the second operand
  69754. * @returns the new Vector3
  69755. */
  69756. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  69757. /**
  69758. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  69759. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  69760. * to something in order to rotate it from its local system to the given target system
  69761. * Note: axis1, axis2 and axis3 are normalized during this operation
  69762. * @param axis1 defines the first axis
  69763. * @param axis2 defines the second axis
  69764. * @param axis3 defines the third axis
  69765. * @returns a new Vector3
  69766. */
  69767. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  69768. /**
  69769. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  69770. * @param axis1 defines the first axis
  69771. * @param axis2 defines the second axis
  69772. * @param axis3 defines the third axis
  69773. * @param ref defines the Vector3 where to store the result
  69774. */
  69775. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  69776. }
  69777. /**
  69778. * Vector4 class created for EulerAngle class conversion to Quaternion
  69779. */
  69780. export class Vector4 {
  69781. /** x value of the vector */
  69782. x: number;
  69783. /** y value of the vector */
  69784. y: number;
  69785. /** z value of the vector */
  69786. z: number;
  69787. /** w value of the vector */
  69788. w: number;
  69789. /**
  69790. * Creates a Vector4 object from the given floats.
  69791. * @param x x value of the vector
  69792. * @param y y value of the vector
  69793. * @param z z value of the vector
  69794. * @param w w value of the vector
  69795. */
  69796. constructor(
  69797. /** x value of the vector */
  69798. x: number,
  69799. /** y value of the vector */
  69800. y: number,
  69801. /** z value of the vector */
  69802. z: number,
  69803. /** w value of the vector */
  69804. w: number);
  69805. /**
  69806. * Returns the string with the Vector4 coordinates.
  69807. * @returns a string containing all the vector values
  69808. */
  69809. toString(): string;
  69810. /**
  69811. * Returns the string "Vector4".
  69812. * @returns "Vector4"
  69813. */
  69814. getClassName(): string;
  69815. /**
  69816. * Returns the Vector4 hash code.
  69817. * @returns a unique hash code
  69818. */
  69819. getHashCode(): number;
  69820. /**
  69821. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  69822. * @returns the resulting array
  69823. */
  69824. asArray(): number[];
  69825. /**
  69826. * Populates the given array from the given index with the Vector4 coordinates.
  69827. * @param array array to populate
  69828. * @param index index of the array to start at (default: 0)
  69829. * @returns the Vector4.
  69830. */
  69831. toArray(array: FloatArray, index?: number): Vector4;
  69832. /**
  69833. * Adds the given vector to the current Vector4.
  69834. * @param otherVector the vector to add
  69835. * @returns the updated Vector4.
  69836. */
  69837. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  69838. /**
  69839. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  69840. * @param otherVector the vector to add
  69841. * @returns the resulting vector
  69842. */
  69843. add(otherVector: DeepImmutable<Vector4>): Vector4;
  69844. /**
  69845. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  69846. * @param otherVector the vector to add
  69847. * @param result the vector to store the result
  69848. * @returns the current Vector4.
  69849. */
  69850. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69851. /**
  69852. * Subtract in place the given vector from the current Vector4.
  69853. * @param otherVector the vector to subtract
  69854. * @returns the updated Vector4.
  69855. */
  69856. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  69857. /**
  69858. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  69859. * @param otherVector the vector to add
  69860. * @returns the new vector with the result
  69861. */
  69862. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  69863. /**
  69864. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  69865. * @param otherVector the vector to subtract
  69866. * @param result the vector to store the result
  69867. * @returns the current Vector4.
  69868. */
  69869. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69870. /**
  69871. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69872. */
  69873. /**
  69874. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69875. * @param x value to subtract
  69876. * @param y value to subtract
  69877. * @param z value to subtract
  69878. * @param w value to subtract
  69879. * @returns new vector containing the result
  69880. */
  69881. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  69882. /**
  69883. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69884. * @param x value to subtract
  69885. * @param y value to subtract
  69886. * @param z value to subtract
  69887. * @param w value to subtract
  69888. * @param result the vector to store the result in
  69889. * @returns the current Vector4.
  69890. */
  69891. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  69892. /**
  69893. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  69894. * @returns a new vector with the negated values
  69895. */
  69896. negate(): Vector4;
  69897. /**
  69898. * Multiplies the current Vector4 coordinates by scale (float).
  69899. * @param scale the number to scale with
  69900. * @returns the updated Vector4.
  69901. */
  69902. scaleInPlace(scale: number): Vector4;
  69903. /**
  69904. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  69905. * @param scale the number to scale with
  69906. * @returns a new vector with the result
  69907. */
  69908. scale(scale: number): Vector4;
  69909. /**
  69910. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  69911. * @param scale the number to scale with
  69912. * @param result a vector to store the result in
  69913. * @returns the current Vector4.
  69914. */
  69915. scaleToRef(scale: number, result: Vector4): Vector4;
  69916. /**
  69917. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  69918. * @param scale defines the scale factor
  69919. * @param result defines the Vector4 object where to store the result
  69920. * @returns the unmodified current Vector4
  69921. */
  69922. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  69923. /**
  69924. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  69925. * @param otherVector the vector to compare against
  69926. * @returns true if they are equal
  69927. */
  69928. equals(otherVector: DeepImmutable<Vector4>): boolean;
  69929. /**
  69930. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  69931. * @param otherVector vector to compare against
  69932. * @param epsilon (Default: very small number)
  69933. * @returns true if they are equal
  69934. */
  69935. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  69936. /**
  69937. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  69938. * @param x x value to compare against
  69939. * @param y y value to compare against
  69940. * @param z z value to compare against
  69941. * @param w w value to compare against
  69942. * @returns true if equal
  69943. */
  69944. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  69945. /**
  69946. * Multiplies in place the current Vector4 by the given one.
  69947. * @param otherVector vector to multiple with
  69948. * @returns the updated Vector4.
  69949. */
  69950. multiplyInPlace(otherVector: Vector4): Vector4;
  69951. /**
  69952. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  69953. * @param otherVector vector to multiple with
  69954. * @returns resulting new vector
  69955. */
  69956. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  69957. /**
  69958. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  69959. * @param otherVector vector to multiple with
  69960. * @param result vector to store the result
  69961. * @returns the current Vector4.
  69962. */
  69963. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69964. /**
  69965. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  69966. * @param x x value multiply with
  69967. * @param y y value multiply with
  69968. * @param z z value multiply with
  69969. * @param w w value multiply with
  69970. * @returns resulting new vector
  69971. */
  69972. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  69973. /**
  69974. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  69975. * @param otherVector vector to devide with
  69976. * @returns resulting new vector
  69977. */
  69978. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  69979. /**
  69980. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  69981. * @param otherVector vector to devide with
  69982. * @param result vector to store the result
  69983. * @returns the current Vector4.
  69984. */
  69985. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69986. /**
  69987. * Divides the current Vector3 coordinates by the given ones.
  69988. * @param otherVector vector to devide with
  69989. * @returns the updated Vector3.
  69990. */
  69991. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  69992. /**
  69993. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  69994. * @param other defines the second operand
  69995. * @returns the current updated Vector4
  69996. */
  69997. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  69998. /**
  69999. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  70000. * @param other defines the second operand
  70001. * @returns the current updated Vector4
  70002. */
  70003. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70004. /**
  70005. * Gets a new Vector4 from current Vector4 floored values
  70006. * @returns a new Vector4
  70007. */
  70008. floor(): Vector4;
  70009. /**
  70010. * Gets a new Vector4 from current Vector3 floored values
  70011. * @returns a new Vector4
  70012. */
  70013. fract(): Vector4;
  70014. /**
  70015. * Returns the Vector4 length (float).
  70016. * @returns the length
  70017. */
  70018. length(): number;
  70019. /**
  70020. * Returns the Vector4 squared length (float).
  70021. * @returns the length squared
  70022. */
  70023. lengthSquared(): number;
  70024. /**
  70025. * Normalizes in place the Vector4.
  70026. * @returns the updated Vector4.
  70027. */
  70028. normalize(): Vector4;
  70029. /**
  70030. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  70031. * @returns this converted to a new vector3
  70032. */
  70033. toVector3(): Vector3;
  70034. /**
  70035. * Returns a new Vector4 copied from the current one.
  70036. * @returns the new cloned vector
  70037. */
  70038. clone(): Vector4;
  70039. /**
  70040. * Updates the current Vector4 with the given one coordinates.
  70041. * @param source the source vector to copy from
  70042. * @returns the updated Vector4.
  70043. */
  70044. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  70045. /**
  70046. * Updates the current Vector4 coordinates with the given floats.
  70047. * @param x float to copy from
  70048. * @param y float to copy from
  70049. * @param z float to copy from
  70050. * @param w float to copy from
  70051. * @returns the updated Vector4.
  70052. */
  70053. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70054. /**
  70055. * Updates the current Vector4 coordinates with the given floats.
  70056. * @param x float to set from
  70057. * @param y float to set from
  70058. * @param z float to set from
  70059. * @param w float to set from
  70060. * @returns the updated Vector4.
  70061. */
  70062. set(x: number, y: number, z: number, w: number): Vector4;
  70063. /**
  70064. * Copies the given float to the current Vector3 coordinates
  70065. * @param v defines the x, y, z and w coordinates of the operand
  70066. * @returns the current updated Vector3
  70067. */
  70068. setAll(v: number): Vector4;
  70069. /**
  70070. * Returns a new Vector4 set from the starting index of the given array.
  70071. * @param array the array to pull values from
  70072. * @param offset the offset into the array to start at
  70073. * @returns the new vector
  70074. */
  70075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  70076. /**
  70077. * Updates the given vector "result" from the starting index of the given array.
  70078. * @param array the array to pull values from
  70079. * @param offset the offset into the array to start at
  70080. * @param result the vector to store the result in
  70081. */
  70082. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  70083. /**
  70084. * Updates the given vector "result" from the starting index of the given Float32Array.
  70085. * @param array the array to pull values from
  70086. * @param offset the offset into the array to start at
  70087. * @param result the vector to store the result in
  70088. */
  70089. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  70090. /**
  70091. * Updates the given vector "result" coordinates from the given floats.
  70092. * @param x float to set from
  70093. * @param y float to set from
  70094. * @param z float to set from
  70095. * @param w float to set from
  70096. * @param result the vector to the floats in
  70097. */
  70098. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  70099. /**
  70100. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  70101. * @returns the new vector
  70102. */
  70103. static Zero(): Vector4;
  70104. /**
  70105. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  70106. * @returns the new vector
  70107. */
  70108. static One(): Vector4;
  70109. /**
  70110. * Returns a new normalized Vector4 from the given one.
  70111. * @param vector the vector to normalize
  70112. * @returns the vector
  70113. */
  70114. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  70115. /**
  70116. * Updates the given vector "result" from the normalization of the given one.
  70117. * @param vector the vector to normalize
  70118. * @param result the vector to store the result in
  70119. */
  70120. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  70121. /**
  70122. * Returns a vector with the minimum values from the left and right vectors
  70123. * @param left left vector to minimize
  70124. * @param right right vector to minimize
  70125. * @returns a new vector with the minimum of the left and right vector values
  70126. */
  70127. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70128. /**
  70129. * Returns a vector with the maximum values from the left and right vectors
  70130. * @param left left vector to maximize
  70131. * @param right right vector to maximize
  70132. * @returns a new vector with the maximum of the left and right vector values
  70133. */
  70134. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70135. /**
  70136. * Returns the distance (float) between the vectors "value1" and "value2".
  70137. * @param value1 value to calulate the distance between
  70138. * @param value2 value to calulate the distance between
  70139. * @return the distance between the two vectors
  70140. */
  70141. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70142. /**
  70143. * Returns the squared distance (float) between the vectors "value1" and "value2".
  70144. * @param value1 value to calulate the distance between
  70145. * @param value2 value to calulate the distance between
  70146. * @return the distance between the two vectors squared
  70147. */
  70148. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70149. /**
  70150. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  70151. * @param value1 value to calulate the center between
  70152. * @param value2 value to calulate the center between
  70153. * @return the center between the two vectors
  70154. */
  70155. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  70156. /**
  70157. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  70158. * This methods computes transformed normalized direction vectors only.
  70159. * @param vector the vector to transform
  70160. * @param transformation the transformation matrix to apply
  70161. * @returns the new vector
  70162. */
  70163. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  70164. /**
  70165. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  70166. * This methods computes transformed normalized direction vectors only.
  70167. * @param vector the vector to transform
  70168. * @param transformation the transformation matrix to apply
  70169. * @param result the vector to store the result in
  70170. */
  70171. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70172. /**
  70173. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  70174. * This methods computes transformed normalized direction vectors only.
  70175. * @param x value to transform
  70176. * @param y value to transform
  70177. * @param z value to transform
  70178. * @param w value to transform
  70179. * @param transformation the transformation matrix to apply
  70180. * @param result the vector to store the results in
  70181. */
  70182. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70183. /**
  70184. * Creates a new Vector4 from a Vector3
  70185. * @param source defines the source data
  70186. * @param w defines the 4th component (default is 0)
  70187. * @returns a new Vector4
  70188. */
  70189. static FromVector3(source: Vector3, w?: number): Vector4;
  70190. }
  70191. /**
  70192. * Class used to store quaternion data
  70193. * @see https://en.wikipedia.org/wiki/Quaternion
  70194. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  70195. */
  70196. export class Quaternion {
  70197. /** defines the first component (0 by default) */
  70198. x: number;
  70199. /** defines the second component (0 by default) */
  70200. y: number;
  70201. /** defines the third component (0 by default) */
  70202. z: number;
  70203. /** defines the fourth component (1.0 by default) */
  70204. w: number;
  70205. /**
  70206. * Creates a new Quaternion from the given floats
  70207. * @param x defines the first component (0 by default)
  70208. * @param y defines the second component (0 by default)
  70209. * @param z defines the third component (0 by default)
  70210. * @param w defines the fourth component (1.0 by default)
  70211. */
  70212. constructor(
  70213. /** defines the first component (0 by default) */
  70214. x?: number,
  70215. /** defines the second component (0 by default) */
  70216. y?: number,
  70217. /** defines the third component (0 by default) */
  70218. z?: number,
  70219. /** defines the fourth component (1.0 by default) */
  70220. w?: number);
  70221. /**
  70222. * Gets a string representation for the current quaternion
  70223. * @returns a string with the Quaternion coordinates
  70224. */
  70225. toString(): string;
  70226. /**
  70227. * Gets the class name of the quaternion
  70228. * @returns the string "Quaternion"
  70229. */
  70230. getClassName(): string;
  70231. /**
  70232. * Gets a hash code for this quaternion
  70233. * @returns the quaternion hash code
  70234. */
  70235. getHashCode(): number;
  70236. /**
  70237. * Copy the quaternion to an array
  70238. * @returns a new array populated with 4 elements from the quaternion coordinates
  70239. */
  70240. asArray(): number[];
  70241. /**
  70242. * Check if two quaternions are equals
  70243. * @param otherQuaternion defines the second operand
  70244. * @return true if the current quaternion and the given one coordinates are strictly equals
  70245. */
  70246. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  70247. /**
  70248. * Clone the current quaternion
  70249. * @returns a new quaternion copied from the current one
  70250. */
  70251. clone(): Quaternion;
  70252. /**
  70253. * Copy a quaternion to the current one
  70254. * @param other defines the other quaternion
  70255. * @returns the updated current quaternion
  70256. */
  70257. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  70258. /**
  70259. * Updates the current quaternion with the given float coordinates
  70260. * @param x defines the x coordinate
  70261. * @param y defines the y coordinate
  70262. * @param z defines the z coordinate
  70263. * @param w defines the w coordinate
  70264. * @returns the updated current quaternion
  70265. */
  70266. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  70267. /**
  70268. * Updates the current quaternion from the given float coordinates
  70269. * @param x defines the x coordinate
  70270. * @param y defines the y coordinate
  70271. * @param z defines the z coordinate
  70272. * @param w defines the w coordinate
  70273. * @returns the updated current quaternion
  70274. */
  70275. set(x: number, y: number, z: number, w: number): Quaternion;
  70276. /**
  70277. * Adds two quaternions
  70278. * @param other defines the second operand
  70279. * @returns a new quaternion as the addition result of the given one and the current quaternion
  70280. */
  70281. add(other: DeepImmutable<Quaternion>): Quaternion;
  70282. /**
  70283. * Add a quaternion to the current one
  70284. * @param other defines the quaternion to add
  70285. * @returns the current quaternion
  70286. */
  70287. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  70288. /**
  70289. * Subtract two quaternions
  70290. * @param other defines the second operand
  70291. * @returns a new quaternion as the subtraction result of the given one from the current one
  70292. */
  70293. subtract(other: Quaternion): Quaternion;
  70294. /**
  70295. * Multiplies the current quaternion by a scale factor
  70296. * @param value defines the scale factor
  70297. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  70298. */
  70299. scale(value: number): Quaternion;
  70300. /**
  70301. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  70302. * @param scale defines the scale factor
  70303. * @param result defines the Quaternion object where to store the result
  70304. * @returns the unmodified current quaternion
  70305. */
  70306. scaleToRef(scale: number, result: Quaternion): Quaternion;
  70307. /**
  70308. * Multiplies in place the current quaternion by a scale factor
  70309. * @param value defines the scale factor
  70310. * @returns the current modified quaternion
  70311. */
  70312. scaleInPlace(value: number): Quaternion;
  70313. /**
  70314. * Scale the current quaternion values by a factor and add the result to a given quaternion
  70315. * @param scale defines the scale factor
  70316. * @param result defines the Quaternion object where to store the result
  70317. * @returns the unmodified current quaternion
  70318. */
  70319. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  70320. /**
  70321. * Multiplies two quaternions
  70322. * @param q1 defines the second operand
  70323. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  70324. */
  70325. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  70326. /**
  70327. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  70328. * @param q1 defines the second operand
  70329. * @param result defines the target quaternion
  70330. * @returns the current quaternion
  70331. */
  70332. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  70333. /**
  70334. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  70335. * @param q1 defines the second operand
  70336. * @returns the currentupdated quaternion
  70337. */
  70338. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  70339. /**
  70340. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  70341. * @param ref defines the target quaternion
  70342. * @returns the current quaternion
  70343. */
  70344. conjugateToRef(ref: Quaternion): Quaternion;
  70345. /**
  70346. * Conjugates in place (1-q) the current quaternion
  70347. * @returns the current updated quaternion
  70348. */
  70349. conjugateInPlace(): Quaternion;
  70350. /**
  70351. * Conjugates in place (1-q) the current quaternion
  70352. * @returns a new quaternion
  70353. */
  70354. conjugate(): Quaternion;
  70355. /**
  70356. * Gets length of current quaternion
  70357. * @returns the quaternion length (float)
  70358. */
  70359. length(): number;
  70360. /**
  70361. * Normalize in place the current quaternion
  70362. * @returns the current updated quaternion
  70363. */
  70364. normalize(): Quaternion;
  70365. /**
  70366. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  70367. * @param order is a reserved parameter and is ignore for now
  70368. * @returns a new Vector3 containing the Euler angles
  70369. */
  70370. toEulerAngles(order?: string): Vector3;
  70371. /**
  70372. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  70373. * @param result defines the vector which will be filled with the Euler angles
  70374. * @param order is a reserved parameter and is ignore for now
  70375. * @returns the current unchanged quaternion
  70376. */
  70377. toEulerAnglesToRef(result: Vector3): Quaternion;
  70378. /**
  70379. * Updates the given rotation matrix with the current quaternion values
  70380. * @param result defines the target matrix
  70381. * @returns the current unchanged quaternion
  70382. */
  70383. toRotationMatrix(result: Matrix): Quaternion;
  70384. /**
  70385. * Updates the current quaternion from the given rotation matrix values
  70386. * @param matrix defines the source matrix
  70387. * @returns the current updated quaternion
  70388. */
  70389. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  70390. /**
  70391. * Creates a new quaternion from a rotation matrix
  70392. * @param matrix defines the source matrix
  70393. * @returns a new quaternion created from the given rotation matrix values
  70394. */
  70395. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  70396. /**
  70397. * Updates the given quaternion with the given rotation matrix values
  70398. * @param matrix defines the source matrix
  70399. * @param result defines the target quaternion
  70400. */
  70401. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  70402. /**
  70403. * Returns the dot product (float) between the quaternions "left" and "right"
  70404. * @param left defines the left operand
  70405. * @param right defines the right operand
  70406. * @returns the dot product
  70407. */
  70408. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  70409. /**
  70410. * Checks if the two quaternions are close to each other
  70411. * @param quat0 defines the first quaternion to check
  70412. * @param quat1 defines the second quaternion to check
  70413. * @returns true if the two quaternions are close to each other
  70414. */
  70415. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  70416. /**
  70417. * Creates an empty quaternion
  70418. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  70419. */
  70420. static Zero(): Quaternion;
  70421. /**
  70422. * Inverse a given quaternion
  70423. * @param q defines the source quaternion
  70424. * @returns a new quaternion as the inverted current quaternion
  70425. */
  70426. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  70427. /**
  70428. * Inverse a given quaternion
  70429. * @param q defines the source quaternion
  70430. * @param result the quaternion the result will be stored in
  70431. * @returns the result quaternion
  70432. */
  70433. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  70434. /**
  70435. * Creates an identity quaternion
  70436. * @returns the identity quaternion
  70437. */
  70438. static Identity(): Quaternion;
  70439. /**
  70440. * Gets a boolean indicating if the given quaternion is identity
  70441. * @param quaternion defines the quaternion to check
  70442. * @returns true if the quaternion is identity
  70443. */
  70444. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  70445. /**
  70446. * Creates a quaternion from a rotation around an axis
  70447. * @param axis defines the axis to use
  70448. * @param angle defines the angle to use
  70449. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  70450. */
  70451. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  70452. /**
  70453. * Creates a rotation around an axis and stores it into the given quaternion
  70454. * @param axis defines the axis to use
  70455. * @param angle defines the angle to use
  70456. * @param result defines the target quaternion
  70457. * @returns the target quaternion
  70458. */
  70459. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  70460. /**
  70461. * Creates a new quaternion from data stored into an array
  70462. * @param array defines the data source
  70463. * @param offset defines the offset in the source array where the data starts
  70464. * @returns a new quaternion
  70465. */
  70466. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  70467. /**
  70468. * Create a quaternion from Euler rotation angles
  70469. * @param x Pitch
  70470. * @param y Yaw
  70471. * @param z Roll
  70472. * @returns the new Quaternion
  70473. */
  70474. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  70475. /**
  70476. * Updates a quaternion from Euler rotation angles
  70477. * @param x Pitch
  70478. * @param y Yaw
  70479. * @param z Roll
  70480. * @param result the quaternion to store the result
  70481. * @returns the updated quaternion
  70482. */
  70483. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  70484. /**
  70485. * Create a quaternion from Euler rotation vector
  70486. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  70487. * @returns the new Quaternion
  70488. */
  70489. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  70490. /**
  70491. * Updates a quaternion from Euler rotation vector
  70492. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  70493. * @param result the quaternion to store the result
  70494. * @returns the updated quaternion
  70495. */
  70496. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  70497. /**
  70498. * Creates a new quaternion from the given Euler float angles (y, x, z)
  70499. * @param yaw defines the rotation around Y axis
  70500. * @param pitch defines the rotation around X axis
  70501. * @param roll defines the rotation around Z axis
  70502. * @returns the new quaternion
  70503. */
  70504. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  70505. /**
  70506. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  70507. * @param yaw defines the rotation around Y axis
  70508. * @param pitch defines the rotation around X axis
  70509. * @param roll defines the rotation around Z axis
  70510. * @param result defines the target quaternion
  70511. */
  70512. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  70513. /**
  70514. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  70515. * @param alpha defines the rotation around first axis
  70516. * @param beta defines the rotation around second axis
  70517. * @param gamma defines the rotation around third axis
  70518. * @returns the new quaternion
  70519. */
  70520. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  70521. /**
  70522. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  70523. * @param alpha defines the rotation around first axis
  70524. * @param beta defines the rotation around second axis
  70525. * @param gamma defines the rotation around third axis
  70526. * @param result defines the target quaternion
  70527. */
  70528. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  70529. /**
  70530. * 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)
  70531. * @param axis1 defines the first axis
  70532. * @param axis2 defines the second axis
  70533. * @param axis3 defines the third axis
  70534. * @returns the new quaternion
  70535. */
  70536. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  70537. /**
  70538. * 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
  70539. * @param axis1 defines the first axis
  70540. * @param axis2 defines the second axis
  70541. * @param axis3 defines the third axis
  70542. * @param ref defines the target quaternion
  70543. */
  70544. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  70545. /**
  70546. * Interpolates between two quaternions
  70547. * @param left defines first quaternion
  70548. * @param right defines second quaternion
  70549. * @param amount defines the gradient to use
  70550. * @returns the new interpolated quaternion
  70551. */
  70552. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  70553. /**
  70554. * Interpolates between two quaternions and stores it into a target quaternion
  70555. * @param left defines first quaternion
  70556. * @param right defines second quaternion
  70557. * @param amount defines the gradient to use
  70558. * @param result defines the target quaternion
  70559. */
  70560. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  70561. /**
  70562. * Interpolate between two quaternions using Hermite interpolation
  70563. * @param value1 defines first quaternion
  70564. * @param tangent1 defines the incoming tangent
  70565. * @param value2 defines second quaternion
  70566. * @param tangent2 defines the outgoing tangent
  70567. * @param amount defines the target quaternion
  70568. * @returns the new interpolated quaternion
  70569. */
  70570. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  70571. }
  70572. /**
  70573. * Class used to store matrix data (4x4)
  70574. */
  70575. export class Matrix {
  70576. private static _updateFlagSeed;
  70577. private static _identityReadOnly;
  70578. private _isIdentity;
  70579. private _isIdentityDirty;
  70580. private _isIdentity3x2;
  70581. private _isIdentity3x2Dirty;
  70582. /**
  70583. * Gets the update flag of the matrix which is an unique number for the matrix.
  70584. * It will be incremented every time the matrix data change.
  70585. * You can use it to speed the comparison between two versions of the same matrix.
  70586. */
  70587. updateFlag: number;
  70588. private readonly _m;
  70589. /**
  70590. * Gets the internal data of the matrix
  70591. */
  70592. readonly m: DeepImmutable<Float32Array>;
  70593. /** @hidden */
  70594. _markAsUpdated(): void;
  70595. /** @hidden */
  70596. private _updateIdentityStatus;
  70597. /**
  70598. * Creates an empty matrix (filled with zeros)
  70599. */
  70600. constructor();
  70601. /**
  70602. * Check if the current matrix is identity
  70603. * @returns true is the matrix is the identity matrix
  70604. */
  70605. isIdentity(): boolean;
  70606. /**
  70607. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  70608. * @returns true is the matrix is the identity matrix
  70609. */
  70610. isIdentityAs3x2(): boolean;
  70611. /**
  70612. * Gets the determinant of the matrix
  70613. * @returns the matrix determinant
  70614. */
  70615. determinant(): number;
  70616. /**
  70617. * Returns the matrix as a Float32Array
  70618. * @returns the matrix underlying array
  70619. */
  70620. toArray(): DeepImmutable<Float32Array>;
  70621. /**
  70622. * Returns the matrix as a Float32Array
  70623. * @returns the matrix underlying array.
  70624. */
  70625. asArray(): DeepImmutable<Float32Array>;
  70626. /**
  70627. * Inverts the current matrix in place
  70628. * @returns the current inverted matrix
  70629. */
  70630. invert(): Matrix;
  70631. /**
  70632. * Sets all the matrix elements to zero
  70633. * @returns the current matrix
  70634. */
  70635. reset(): Matrix;
  70636. /**
  70637. * Adds the current matrix with a second one
  70638. * @param other defines the matrix to add
  70639. * @returns a new matrix as the addition of the current matrix and the given one
  70640. */
  70641. add(other: DeepImmutable<Matrix>): Matrix;
  70642. /**
  70643. * Sets the given matrix "result" to the addition of the current matrix and the given one
  70644. * @param other defines the matrix to add
  70645. * @param result defines the target matrix
  70646. * @returns the current matrix
  70647. */
  70648. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  70649. /**
  70650. * Adds in place the given matrix to the current matrix
  70651. * @param other defines the second operand
  70652. * @returns the current updated matrix
  70653. */
  70654. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  70655. /**
  70656. * Sets the given matrix to the current inverted Matrix
  70657. * @param other defines the target matrix
  70658. * @returns the unmodified current matrix
  70659. */
  70660. invertToRef(other: Matrix): Matrix;
  70661. /**
  70662. * add a value at the specified position in the current Matrix
  70663. * @param index the index of the value within the matrix. between 0 and 15.
  70664. * @param value the value to be added
  70665. * @returns the current updated matrix
  70666. */
  70667. addAtIndex(index: number, value: number): Matrix;
  70668. /**
  70669. * mutiply the specified position in the current Matrix by a value
  70670. * @param index the index of the value within the matrix. between 0 and 15.
  70671. * @param value the value to be added
  70672. * @returns the current updated matrix
  70673. */
  70674. multiplyAtIndex(index: number, value: number): Matrix;
  70675. /**
  70676. * Inserts the translation vector (using 3 floats) in the current matrix
  70677. * @param x defines the 1st component of the translation
  70678. * @param y defines the 2nd component of the translation
  70679. * @param z defines the 3rd component of the translation
  70680. * @returns the current updated matrix
  70681. */
  70682. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  70683. /**
  70684. * Adds the translation vector (using 3 floats) in the current matrix
  70685. * @param x defines the 1st component of the translation
  70686. * @param y defines the 2nd component of the translation
  70687. * @param z defines the 3rd component of the translation
  70688. * @returns the current updated matrix
  70689. */
  70690. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  70691. /**
  70692. * Inserts the translation vector in the current matrix
  70693. * @param vector3 defines the translation to insert
  70694. * @returns the current updated matrix
  70695. */
  70696. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  70697. /**
  70698. * Gets the translation value of the current matrix
  70699. * @returns a new Vector3 as the extracted translation from the matrix
  70700. */
  70701. getTranslation(): Vector3;
  70702. /**
  70703. * Fill a Vector3 with the extracted translation from the matrix
  70704. * @param result defines the Vector3 where to store the translation
  70705. * @returns the current matrix
  70706. */
  70707. getTranslationToRef(result: Vector3): Matrix;
  70708. /**
  70709. * Remove rotation and scaling part from the matrix
  70710. * @returns the updated matrix
  70711. */
  70712. removeRotationAndScaling(): Matrix;
  70713. /**
  70714. * Multiply two matrices
  70715. * @param other defines the second operand
  70716. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  70717. */
  70718. multiply(other: DeepImmutable<Matrix>): Matrix;
  70719. /**
  70720. * Copy the current matrix from the given one
  70721. * @param other defines the source matrix
  70722. * @returns the current updated matrix
  70723. */
  70724. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  70725. /**
  70726. * Populates the given array from the starting index with the current matrix values
  70727. * @param array defines the target array
  70728. * @param offset defines the offset in the target array where to start storing values
  70729. * @returns the current matrix
  70730. */
  70731. copyToArray(array: Float32Array, offset?: number): Matrix;
  70732. /**
  70733. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  70734. * @param other defines the second operand
  70735. * @param result defines the matrix where to store the multiplication
  70736. * @returns the current matrix
  70737. */
  70738. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  70739. /**
  70740. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  70741. * @param other defines the second operand
  70742. * @param result defines the array where to store the multiplication
  70743. * @param offset defines the offset in the target array where to start storing values
  70744. * @returns the current matrix
  70745. */
  70746. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  70747. /**
  70748. * Check equality between this matrix and a second one
  70749. * @param value defines the second matrix to compare
  70750. * @returns true is the current matrix and the given one values are strictly equal
  70751. */
  70752. equals(value: DeepImmutable<Matrix>): boolean;
  70753. /**
  70754. * Clone the current matrix
  70755. * @returns a new matrix from the current matrix
  70756. */
  70757. clone(): Matrix;
  70758. /**
  70759. * Returns the name of the current matrix class
  70760. * @returns the string "Matrix"
  70761. */
  70762. getClassName(): string;
  70763. /**
  70764. * Gets the hash code of the current matrix
  70765. * @returns the hash code
  70766. */
  70767. getHashCode(): number;
  70768. /**
  70769. * Decomposes the current Matrix into a translation, rotation and scaling components
  70770. * @param scale defines the scale vector3 given as a reference to update
  70771. * @param rotation defines the rotation quaternion given as a reference to update
  70772. * @param translation defines the translation vector3 given as a reference to update
  70773. * @returns true if operation was successful
  70774. */
  70775. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  70776. /**
  70777. * Gets specific row of the matrix
  70778. * @param index defines the number of the row to get
  70779. * @returns the index-th row of the current matrix as a new Vector4
  70780. */
  70781. getRow(index: number): Nullable<Vector4>;
  70782. /**
  70783. * Sets the index-th row of the current matrix to the vector4 values
  70784. * @param index defines the number of the row to set
  70785. * @param row defines the target vector4
  70786. * @returns the updated current matrix
  70787. */
  70788. setRow(index: number, row: Vector4): Matrix;
  70789. /**
  70790. * Compute the transpose of the matrix
  70791. * @returns the new transposed matrix
  70792. */
  70793. transpose(): Matrix;
  70794. /**
  70795. * Compute the transpose of the matrix and store it in a given matrix
  70796. * @param result defines the target matrix
  70797. * @returns the current matrix
  70798. */
  70799. transposeToRef(result: Matrix): Matrix;
  70800. /**
  70801. * Sets the index-th row of the current matrix with the given 4 x float values
  70802. * @param index defines the row index
  70803. * @param x defines the x component to set
  70804. * @param y defines the y component to set
  70805. * @param z defines the z component to set
  70806. * @param w defines the w component to set
  70807. * @returns the updated current matrix
  70808. */
  70809. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  70810. /**
  70811. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  70812. * @param scale defines the scale factor
  70813. * @returns a new matrix
  70814. */
  70815. scale(scale: number): Matrix;
  70816. /**
  70817. * Scale the current matrix values by a factor to a given result matrix
  70818. * @param scale defines the scale factor
  70819. * @param result defines the matrix to store the result
  70820. * @returns the current matrix
  70821. */
  70822. scaleToRef(scale: number, result: Matrix): Matrix;
  70823. /**
  70824. * Scale the current matrix values by a factor and add the result to a given matrix
  70825. * @param scale defines the scale factor
  70826. * @param result defines the Matrix to store the result
  70827. * @returns the current matrix
  70828. */
  70829. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  70830. /**
  70831. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  70832. * @param ref matrix to store the result
  70833. */
  70834. toNormalMatrix(ref: Matrix): void;
  70835. /**
  70836. * Gets only rotation part of the current matrix
  70837. * @returns a new matrix sets to the extracted rotation matrix from the current one
  70838. */
  70839. getRotationMatrix(): Matrix;
  70840. /**
  70841. * Extracts the rotation matrix from the current one and sets it as the given "result"
  70842. * @param result defines the target matrix to store data to
  70843. * @returns the current matrix
  70844. */
  70845. getRotationMatrixToRef(result: Matrix): Matrix;
  70846. /**
  70847. * Toggles model matrix from being right handed to left handed in place and vice versa
  70848. */
  70849. toggleModelMatrixHandInPlace(): void;
  70850. /**
  70851. * Toggles projection matrix from being right handed to left handed in place and vice versa
  70852. */
  70853. toggleProjectionMatrixHandInPlace(): void;
  70854. /**
  70855. * Creates a matrix from an array
  70856. * @param array defines the source array
  70857. * @param offset defines an offset in the source array
  70858. * @returns a new Matrix set from the starting index of the given array
  70859. */
  70860. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  70861. /**
  70862. * Copy the content of an array into a given matrix
  70863. * @param array defines the source array
  70864. * @param offset defines an offset in the source array
  70865. * @param result defines the target matrix
  70866. */
  70867. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  70868. /**
  70869. * Stores an array into a matrix after having multiplied each component by a given factor
  70870. * @param array defines the source array
  70871. * @param offset defines the offset in the source array
  70872. * @param scale defines the scaling factor
  70873. * @param result defines the target matrix
  70874. */
  70875. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  70876. /**
  70877. * Gets an identity matrix that must not be updated
  70878. */
  70879. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  70880. /**
  70881. * Stores a list of values (16) inside a given matrix
  70882. * @param initialM11 defines 1st value of 1st row
  70883. * @param initialM12 defines 2nd value of 1st row
  70884. * @param initialM13 defines 3rd value of 1st row
  70885. * @param initialM14 defines 4th value of 1st row
  70886. * @param initialM21 defines 1st value of 2nd row
  70887. * @param initialM22 defines 2nd value of 2nd row
  70888. * @param initialM23 defines 3rd value of 2nd row
  70889. * @param initialM24 defines 4th value of 2nd row
  70890. * @param initialM31 defines 1st value of 3rd row
  70891. * @param initialM32 defines 2nd value of 3rd row
  70892. * @param initialM33 defines 3rd value of 3rd row
  70893. * @param initialM34 defines 4th value of 3rd row
  70894. * @param initialM41 defines 1st value of 4th row
  70895. * @param initialM42 defines 2nd value of 4th row
  70896. * @param initialM43 defines 3rd value of 4th row
  70897. * @param initialM44 defines 4th value of 4th row
  70898. * @param result defines the target matrix
  70899. */
  70900. 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;
  70901. /**
  70902. * Creates new matrix from a list of values (16)
  70903. * @param initialM11 defines 1st value of 1st row
  70904. * @param initialM12 defines 2nd value of 1st row
  70905. * @param initialM13 defines 3rd value of 1st row
  70906. * @param initialM14 defines 4th value of 1st row
  70907. * @param initialM21 defines 1st value of 2nd row
  70908. * @param initialM22 defines 2nd value of 2nd row
  70909. * @param initialM23 defines 3rd value of 2nd row
  70910. * @param initialM24 defines 4th value of 2nd row
  70911. * @param initialM31 defines 1st value of 3rd row
  70912. * @param initialM32 defines 2nd value of 3rd row
  70913. * @param initialM33 defines 3rd value of 3rd row
  70914. * @param initialM34 defines 4th value of 3rd row
  70915. * @param initialM41 defines 1st value of 4th row
  70916. * @param initialM42 defines 2nd value of 4th row
  70917. * @param initialM43 defines 3rd value of 4th row
  70918. * @param initialM44 defines 4th value of 4th row
  70919. * @returns the new matrix
  70920. */
  70921. 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;
  70922. /**
  70923. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  70924. * @param scale defines the scale vector3
  70925. * @param rotation defines the rotation quaternion
  70926. * @param translation defines the translation vector3
  70927. * @returns a new matrix
  70928. */
  70929. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  70930. /**
  70931. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  70932. * @param scale defines the scale vector3
  70933. * @param rotation defines the rotation quaternion
  70934. * @param translation defines the translation vector3
  70935. * @param result defines the target matrix
  70936. */
  70937. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  70938. /**
  70939. * Creates a new identity matrix
  70940. * @returns a new identity matrix
  70941. */
  70942. static Identity(): Matrix;
  70943. /**
  70944. * Creates a new identity matrix and stores the result in a given matrix
  70945. * @param result defines the target matrix
  70946. */
  70947. static IdentityToRef(result: Matrix): void;
  70948. /**
  70949. * Creates a new zero matrix
  70950. * @returns a new zero matrix
  70951. */
  70952. static Zero(): Matrix;
  70953. /**
  70954. * Creates a new rotation matrix for "angle" radians around the X axis
  70955. * @param angle defines the angle (in radians) to use
  70956. * @return the new matrix
  70957. */
  70958. static RotationX(angle: number): Matrix;
  70959. /**
  70960. * Creates a new matrix as the invert of a given matrix
  70961. * @param source defines the source matrix
  70962. * @returns the new matrix
  70963. */
  70964. static Invert(source: DeepImmutable<Matrix>): Matrix;
  70965. /**
  70966. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  70967. * @param angle defines the angle (in radians) to use
  70968. * @param result defines the target matrix
  70969. */
  70970. static RotationXToRef(angle: number, result: Matrix): void;
  70971. /**
  70972. * Creates a new rotation matrix for "angle" radians around the Y axis
  70973. * @param angle defines the angle (in radians) to use
  70974. * @return the new matrix
  70975. */
  70976. static RotationY(angle: number): Matrix;
  70977. /**
  70978. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  70979. * @param angle defines the angle (in radians) to use
  70980. * @param result defines the target matrix
  70981. */
  70982. static RotationYToRef(angle: number, result: Matrix): void;
  70983. /**
  70984. * Creates a new rotation matrix for "angle" radians around the Z axis
  70985. * @param angle defines the angle (in radians) to use
  70986. * @return the new matrix
  70987. */
  70988. static RotationZ(angle: number): Matrix;
  70989. /**
  70990. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  70991. * @param angle defines the angle (in radians) to use
  70992. * @param result defines the target matrix
  70993. */
  70994. static RotationZToRef(angle: number, result: Matrix): void;
  70995. /**
  70996. * Creates a new rotation matrix for "angle" radians around the given axis
  70997. * @param axis defines the axis to use
  70998. * @param angle defines the angle (in radians) to use
  70999. * @return the new matrix
  71000. */
  71001. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  71002. /**
  71003. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  71004. * @param axis defines the axis to use
  71005. * @param angle defines the angle (in radians) to use
  71006. * @param result defines the target matrix
  71007. */
  71008. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  71009. /**
  71010. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  71011. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  71012. * @param from defines the vector to align
  71013. * @param to defines the vector to align to
  71014. * @param result defines the target matrix
  71015. */
  71016. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  71017. /**
  71018. * Creates a rotation matrix
  71019. * @param yaw defines the yaw angle in radians (Y axis)
  71020. * @param pitch defines the pitch angle in radians (X axis)
  71021. * @param roll defines the roll angle in radians (X axis)
  71022. * @returns the new rotation matrix
  71023. */
  71024. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  71025. /**
  71026. * Creates a rotation matrix and stores it in a given matrix
  71027. * @param yaw defines the yaw angle in radians (Y axis)
  71028. * @param pitch defines the pitch angle in radians (X axis)
  71029. * @param roll defines the roll angle in radians (X axis)
  71030. * @param result defines the target matrix
  71031. */
  71032. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  71033. /**
  71034. * Creates a scaling matrix
  71035. * @param x defines the scale factor on X axis
  71036. * @param y defines the scale factor on Y axis
  71037. * @param z defines the scale factor on Z axis
  71038. * @returns the new matrix
  71039. */
  71040. static Scaling(x: number, y: number, z: number): Matrix;
  71041. /**
  71042. * Creates a scaling matrix and stores it in a given matrix
  71043. * @param x defines the scale factor on X axis
  71044. * @param y defines the scale factor on Y axis
  71045. * @param z defines the scale factor on Z axis
  71046. * @param result defines the target matrix
  71047. */
  71048. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  71049. /**
  71050. * Creates a translation matrix
  71051. * @param x defines the translation on X axis
  71052. * @param y defines the translation on Y axis
  71053. * @param z defines the translationon Z axis
  71054. * @returns the new matrix
  71055. */
  71056. static Translation(x: number, y: number, z: number): Matrix;
  71057. /**
  71058. * Creates a translation matrix and stores it in a given matrix
  71059. * @param x defines the translation on X axis
  71060. * @param y defines the translation on Y axis
  71061. * @param z defines the translationon Z axis
  71062. * @param result defines the target matrix
  71063. */
  71064. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  71065. /**
  71066. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71067. * @param startValue defines the start value
  71068. * @param endValue defines the end value
  71069. * @param gradient defines the gradient factor
  71070. * @returns the new matrix
  71071. */
  71072. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71073. /**
  71074. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71075. * @param startValue defines the start value
  71076. * @param endValue defines the end value
  71077. * @param gradient defines the gradient factor
  71078. * @param result defines the Matrix object where to store data
  71079. */
  71080. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71081. /**
  71082. * Builds a new matrix whose values are computed by:
  71083. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71084. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71085. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71086. * @param startValue defines the first matrix
  71087. * @param endValue defines the second matrix
  71088. * @param gradient defines the gradient between the two matrices
  71089. * @returns the new matrix
  71090. */
  71091. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71092. /**
  71093. * Update a matrix to values which are computed by:
  71094. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71095. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71096. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71097. * @param startValue defines the first matrix
  71098. * @param endValue defines the second matrix
  71099. * @param gradient defines the gradient between the two matrices
  71100. * @param result defines the target matrix
  71101. */
  71102. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71103. /**
  71104. * 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"
  71105. * This function works in left handed mode
  71106. * @param eye defines the final position of the entity
  71107. * @param target defines where the entity should look at
  71108. * @param up defines the up vector for the entity
  71109. * @returns the new matrix
  71110. */
  71111. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71112. /**
  71113. * 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".
  71114. * This function works in left handed mode
  71115. * @param eye defines the final position of the entity
  71116. * @param target defines where the entity should look at
  71117. * @param up defines the up vector for the entity
  71118. * @param result defines the target matrix
  71119. */
  71120. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71121. /**
  71122. * 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"
  71123. * This function works in right handed mode
  71124. * @param eye defines the final position of the entity
  71125. * @param target defines where the entity should look at
  71126. * @param up defines the up vector for the entity
  71127. * @returns the new matrix
  71128. */
  71129. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71130. /**
  71131. * 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".
  71132. * This function works in right handed mode
  71133. * @param eye defines the final position of the entity
  71134. * @param target defines where the entity should look at
  71135. * @param up defines the up vector for the entity
  71136. * @param result defines the target matrix
  71137. */
  71138. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71139. /**
  71140. * Create a left-handed orthographic projection matrix
  71141. * @param width defines the viewport width
  71142. * @param height defines the viewport height
  71143. * @param znear defines the near clip plane
  71144. * @param zfar defines the far clip plane
  71145. * @returns a new matrix as a left-handed orthographic projection matrix
  71146. */
  71147. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71148. /**
  71149. * Store a left-handed orthographic projection to a given matrix
  71150. * @param width defines the viewport width
  71151. * @param height defines the viewport height
  71152. * @param znear defines the near clip plane
  71153. * @param zfar defines the far clip plane
  71154. * @param result defines the target matrix
  71155. */
  71156. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  71157. /**
  71158. * Create a left-handed orthographic projection matrix
  71159. * @param left defines the viewport left coordinate
  71160. * @param right defines the viewport right coordinate
  71161. * @param bottom defines the viewport bottom coordinate
  71162. * @param top defines the viewport top coordinate
  71163. * @param znear defines the near clip plane
  71164. * @param zfar defines the far clip plane
  71165. * @returns a new matrix as a left-handed orthographic projection matrix
  71166. */
  71167. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71168. /**
  71169. * Stores a left-handed orthographic projection into a given matrix
  71170. * @param left defines the viewport left coordinate
  71171. * @param right defines the viewport right coordinate
  71172. * @param bottom defines the viewport bottom coordinate
  71173. * @param top defines the viewport top coordinate
  71174. * @param znear defines the near clip plane
  71175. * @param zfar defines the far clip plane
  71176. * @param result defines the target matrix
  71177. */
  71178. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71179. /**
  71180. * Creates a right-handed orthographic projection matrix
  71181. * @param left defines the viewport left coordinate
  71182. * @param right defines the viewport right coordinate
  71183. * @param bottom defines the viewport bottom coordinate
  71184. * @param top defines the viewport top coordinate
  71185. * @param znear defines the near clip plane
  71186. * @param zfar defines the far clip plane
  71187. * @returns a new matrix as a right-handed orthographic projection matrix
  71188. */
  71189. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71190. /**
  71191. * Stores a right-handed orthographic projection into a given matrix
  71192. * @param left defines the viewport left coordinate
  71193. * @param right defines the viewport right coordinate
  71194. * @param bottom defines the viewport bottom coordinate
  71195. * @param top defines the viewport top coordinate
  71196. * @param znear defines the near clip plane
  71197. * @param zfar defines the far clip plane
  71198. * @param result defines the target matrix
  71199. */
  71200. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71201. /**
  71202. * Creates a left-handed perspective projection matrix
  71203. * @param width defines the viewport width
  71204. * @param height defines the viewport height
  71205. * @param znear defines the near clip plane
  71206. * @param zfar defines the far clip plane
  71207. * @returns a new matrix as a left-handed perspective projection matrix
  71208. */
  71209. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71210. /**
  71211. * Creates a left-handed perspective projection matrix
  71212. * @param fov defines the horizontal field of view
  71213. * @param aspect defines the aspect ratio
  71214. * @param znear defines the near clip plane
  71215. * @param zfar defines the far clip plane
  71216. * @returns a new matrix as a left-handed perspective projection matrix
  71217. */
  71218. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71219. /**
  71220. * Stores a left-handed perspective projection into a given matrix
  71221. * @param fov defines the horizontal field of view
  71222. * @param aspect defines the aspect ratio
  71223. * @param znear defines the near clip plane
  71224. * @param zfar defines the far clip plane
  71225. * @param result defines the target matrix
  71226. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71227. */
  71228. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71229. /**
  71230. * Creates a right-handed perspective projection matrix
  71231. * @param fov defines the horizontal field of view
  71232. * @param aspect defines the aspect ratio
  71233. * @param znear defines the near clip plane
  71234. * @param zfar defines the far clip plane
  71235. * @returns a new matrix as a right-handed perspective projection matrix
  71236. */
  71237. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71238. /**
  71239. * Stores a right-handed perspective projection into a given matrix
  71240. * @param fov defines the horizontal field of view
  71241. * @param aspect defines the aspect ratio
  71242. * @param znear defines the near clip plane
  71243. * @param zfar defines the far clip plane
  71244. * @param result defines the target matrix
  71245. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71246. */
  71247. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71248. /**
  71249. * Stores a perspective projection for WebVR info a given matrix
  71250. * @param fov defines the field of view
  71251. * @param znear defines the near clip plane
  71252. * @param zfar defines the far clip plane
  71253. * @param result defines the target matrix
  71254. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  71255. */
  71256. static PerspectiveFovWebVRToRef(fov: {
  71257. upDegrees: number;
  71258. downDegrees: number;
  71259. leftDegrees: number;
  71260. rightDegrees: number;
  71261. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  71262. /**
  71263. * Computes a complete transformation matrix
  71264. * @param viewport defines the viewport to use
  71265. * @param world defines the world matrix
  71266. * @param view defines the view matrix
  71267. * @param projection defines the projection matrix
  71268. * @param zmin defines the near clip plane
  71269. * @param zmax defines the far clip plane
  71270. * @returns the transformation matrix
  71271. */
  71272. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  71273. /**
  71274. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  71275. * @param matrix defines the matrix to use
  71276. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  71277. */
  71278. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  71279. /**
  71280. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  71281. * @param matrix defines the matrix to use
  71282. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  71283. */
  71284. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  71285. /**
  71286. * Compute the transpose of a given matrix
  71287. * @param matrix defines the matrix to transpose
  71288. * @returns the new matrix
  71289. */
  71290. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  71291. /**
  71292. * Compute the transpose of a matrix and store it in a target matrix
  71293. * @param matrix defines the matrix to transpose
  71294. * @param result defines the target matrix
  71295. */
  71296. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  71297. /**
  71298. * Computes a reflection matrix from a plane
  71299. * @param plane defines the reflection plane
  71300. * @returns a new matrix
  71301. */
  71302. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  71303. /**
  71304. * Computes a reflection matrix from a plane
  71305. * @param plane defines the reflection plane
  71306. * @param result defines the target matrix
  71307. */
  71308. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  71309. /**
  71310. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  71311. * @param xaxis defines the value of the 1st axis
  71312. * @param yaxis defines the value of the 2nd axis
  71313. * @param zaxis defines the value of the 3rd axis
  71314. * @param result defines the target matrix
  71315. */
  71316. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  71317. /**
  71318. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  71319. * @param quat defines the quaternion to use
  71320. * @param result defines the target matrix
  71321. */
  71322. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  71323. }
  71324. /**
  71325. * @hidden
  71326. */
  71327. export class TmpVectors {
  71328. static Vector2: Vector2[];
  71329. static Vector3: Vector3[];
  71330. static Vector4: Vector4[];
  71331. static Quaternion: Quaternion[];
  71332. static Matrix: Matrix[];
  71333. }
  71334. }
  71335. declare module BABYLON {
  71336. /**
  71337. * Defines potential orientation for back face culling
  71338. */
  71339. export enum Orientation {
  71340. /**
  71341. * Clockwise
  71342. */
  71343. CW = 0,
  71344. /** Counter clockwise */
  71345. CCW = 1
  71346. }
  71347. /** Class used to represent a Bezier curve */
  71348. export class BezierCurve {
  71349. /**
  71350. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71351. * @param t defines the time
  71352. * @param x1 defines the left coordinate on X axis
  71353. * @param y1 defines the left coordinate on Y axis
  71354. * @param x2 defines the right coordinate on X axis
  71355. * @param y2 defines the right coordinate on Y axis
  71356. * @returns the interpolated value
  71357. */
  71358. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71359. }
  71360. /**
  71361. * Defines angle representation
  71362. */
  71363. export class Angle {
  71364. private _radians;
  71365. /**
  71366. * Creates an Angle object of "radians" radians (float).
  71367. * @param radians the angle in radians
  71368. */
  71369. constructor(radians: number);
  71370. /**
  71371. * Get value in degrees
  71372. * @returns the Angle value in degrees (float)
  71373. */
  71374. degrees(): number;
  71375. /**
  71376. * Get value in radians
  71377. * @returns the Angle value in radians (float)
  71378. */
  71379. radians(): number;
  71380. /**
  71381. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71382. * @param a defines first vector
  71383. * @param b defines second vector
  71384. * @returns a new Angle
  71385. */
  71386. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71387. /**
  71388. * Gets a new Angle object from the given float in radians
  71389. * @param radians defines the angle value in radians
  71390. * @returns a new Angle
  71391. */
  71392. static FromRadians(radians: number): Angle;
  71393. /**
  71394. * Gets a new Angle object from the given float in degrees
  71395. * @param degrees defines the angle value in degrees
  71396. * @returns a new Angle
  71397. */
  71398. static FromDegrees(degrees: number): Angle;
  71399. }
  71400. /**
  71401. * This represents an arc in a 2d space.
  71402. */
  71403. export class Arc2 {
  71404. /** Defines the start point of the arc */
  71405. startPoint: Vector2;
  71406. /** Defines the mid point of the arc */
  71407. midPoint: Vector2;
  71408. /** Defines the end point of the arc */
  71409. endPoint: Vector2;
  71410. /**
  71411. * Defines the center point of the arc.
  71412. */
  71413. centerPoint: Vector2;
  71414. /**
  71415. * Defines the radius of the arc.
  71416. */
  71417. radius: number;
  71418. /**
  71419. * Defines the angle of the arc (from mid point to end point).
  71420. */
  71421. angle: Angle;
  71422. /**
  71423. * Defines the start angle of the arc (from start point to middle point).
  71424. */
  71425. startAngle: Angle;
  71426. /**
  71427. * Defines the orientation of the arc (clock wise/counter clock wise).
  71428. */
  71429. orientation: Orientation;
  71430. /**
  71431. * Creates an Arc object from the three given points : start, middle and end.
  71432. * @param startPoint Defines the start point of the arc
  71433. * @param midPoint Defines the midlle point of the arc
  71434. * @param endPoint Defines the end point of the arc
  71435. */
  71436. constructor(
  71437. /** Defines the start point of the arc */
  71438. startPoint: Vector2,
  71439. /** Defines the mid point of the arc */
  71440. midPoint: Vector2,
  71441. /** Defines the end point of the arc */
  71442. endPoint: Vector2);
  71443. }
  71444. /**
  71445. * Represents a 2D path made up of multiple 2D points
  71446. */
  71447. export class Path2 {
  71448. private _points;
  71449. private _length;
  71450. /**
  71451. * If the path start and end point are the same
  71452. */
  71453. closed: boolean;
  71454. /**
  71455. * Creates a Path2 object from the starting 2D coordinates x and y.
  71456. * @param x the starting points x value
  71457. * @param y the starting points y value
  71458. */
  71459. constructor(x: number, y: number);
  71460. /**
  71461. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71462. * @param x the added points x value
  71463. * @param y the added points y value
  71464. * @returns the updated Path2.
  71465. */
  71466. addLineTo(x: number, y: number): Path2;
  71467. /**
  71468. * 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.
  71469. * @param midX middle point x value
  71470. * @param midY middle point y value
  71471. * @param endX end point x value
  71472. * @param endY end point y value
  71473. * @param numberOfSegments (default: 36)
  71474. * @returns the updated Path2.
  71475. */
  71476. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71477. /**
  71478. * Closes the Path2.
  71479. * @returns the Path2.
  71480. */
  71481. close(): Path2;
  71482. /**
  71483. * Gets the sum of the distance between each sequential point in the path
  71484. * @returns the Path2 total length (float).
  71485. */
  71486. length(): number;
  71487. /**
  71488. * Gets the points which construct the path
  71489. * @returns the Path2 internal array of points.
  71490. */
  71491. getPoints(): Vector2[];
  71492. /**
  71493. * Retreives the point at the distance aways from the starting point
  71494. * @param normalizedLengthPosition the length along the path to retreive the point from
  71495. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71496. */
  71497. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71498. /**
  71499. * Creates a new path starting from an x and y position
  71500. * @param x starting x value
  71501. * @param y starting y value
  71502. * @returns a new Path2 starting at the coordinates (x, y).
  71503. */
  71504. static StartingAt(x: number, y: number): Path2;
  71505. }
  71506. /**
  71507. * Represents a 3D path made up of multiple 3D points
  71508. */
  71509. export class Path3D {
  71510. /**
  71511. * an array of Vector3, the curve axis of the Path3D
  71512. */
  71513. path: Vector3[];
  71514. private _curve;
  71515. private _distances;
  71516. private _tangents;
  71517. private _normals;
  71518. private _binormals;
  71519. private _raw;
  71520. /**
  71521. * new Path3D(path, normal, raw)
  71522. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71523. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71524. * @param path an array of Vector3, the curve axis of the Path3D
  71525. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71526. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71527. */
  71528. constructor(
  71529. /**
  71530. * an array of Vector3, the curve axis of the Path3D
  71531. */
  71532. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71533. /**
  71534. * Returns the Path3D array of successive Vector3 designing its curve.
  71535. * @returns the Path3D array of successive Vector3 designing its curve.
  71536. */
  71537. getCurve(): Vector3[];
  71538. /**
  71539. * Returns an array populated with tangent vectors on each Path3D curve point.
  71540. * @returns an array populated with tangent vectors on each Path3D curve point.
  71541. */
  71542. getTangents(): Vector3[];
  71543. /**
  71544. * Returns an array populated with normal vectors on each Path3D curve point.
  71545. * @returns an array populated with normal vectors on each Path3D curve point.
  71546. */
  71547. getNormals(): Vector3[];
  71548. /**
  71549. * Returns an array populated with binormal vectors on each Path3D curve point.
  71550. * @returns an array populated with binormal vectors on each Path3D curve point.
  71551. */
  71552. getBinormals(): Vector3[];
  71553. /**
  71554. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71555. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71556. */
  71557. getDistances(): number[];
  71558. /**
  71559. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71560. * @param path path which all values are copied into the curves points
  71561. * @param firstNormal which should be projected onto the curve
  71562. * @returns the same object updated.
  71563. */
  71564. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71565. private _compute;
  71566. private _getFirstNonNullVector;
  71567. private _getLastNonNullVector;
  71568. private _normalVector;
  71569. }
  71570. /**
  71571. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71572. * A Curve3 is designed from a series of successive Vector3.
  71573. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71574. */
  71575. export class Curve3 {
  71576. private _points;
  71577. private _length;
  71578. /**
  71579. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71580. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71581. * @param v1 (Vector3) the control point
  71582. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71583. * @param nbPoints (integer) the wanted number of points in the curve
  71584. * @returns the created Curve3
  71585. */
  71586. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71587. /**
  71588. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71589. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71590. * @param v1 (Vector3) the first control point
  71591. * @param v2 (Vector3) the second control point
  71592. * @param v3 (Vector3) the end point of the Cubic Bezier
  71593. * @param nbPoints (integer) the wanted number of points in the curve
  71594. * @returns the created Curve3
  71595. */
  71596. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71597. /**
  71598. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71599. * @param p1 (Vector3) the origin point of the Hermite Spline
  71600. * @param t1 (Vector3) the tangent vector at the origin point
  71601. * @param p2 (Vector3) the end point of the Hermite Spline
  71602. * @param t2 (Vector3) the tangent vector at the end point
  71603. * @param nbPoints (integer) the wanted number of points in the curve
  71604. * @returns the created Curve3
  71605. */
  71606. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71607. /**
  71608. * Returns a Curve3 object along a CatmullRom Spline curve :
  71609. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71610. * @param nbPoints (integer) the wanted number of points between each curve control points
  71611. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71612. * @returns the created Curve3
  71613. */
  71614. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71615. /**
  71616. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71617. * A Curve3 is designed from a series of successive Vector3.
  71618. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71619. * @param points points which make up the curve
  71620. */
  71621. constructor(points: Vector3[]);
  71622. /**
  71623. * @returns the Curve3 stored array of successive Vector3
  71624. */
  71625. getPoints(): Vector3[];
  71626. /**
  71627. * @returns the computed length (float) of the curve.
  71628. */
  71629. length(): number;
  71630. /**
  71631. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71632. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71633. * curveA and curveB keep unchanged.
  71634. * @param curve the curve to continue from this curve
  71635. * @returns the newly constructed curve
  71636. */
  71637. continue(curve: DeepImmutable<Curve3>): Curve3;
  71638. private _computeLength;
  71639. }
  71640. }
  71641. declare module BABYLON {
  71642. /**
  71643. * This represents the main contract an easing function should follow.
  71644. * Easing functions are used throughout the animation system.
  71645. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71646. */
  71647. export interface IEasingFunction {
  71648. /**
  71649. * Given an input gradient between 0 and 1, this returns the corrseponding value
  71650. * of the easing function.
  71651. * The link below provides some of the most common examples of easing functions.
  71652. * @see https://easings.net/
  71653. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71654. * @returns the corresponding value on the curve defined by the easing function
  71655. */
  71656. ease(gradient: number): number;
  71657. }
  71658. /**
  71659. * Base class used for every default easing function.
  71660. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71661. */
  71662. export class EasingFunction implements IEasingFunction {
  71663. /**
  71664. * Interpolation follows the mathematical formula associated with the easing function.
  71665. */
  71666. static readonly EASINGMODE_EASEIN: number;
  71667. /**
  71668. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  71669. */
  71670. static readonly EASINGMODE_EASEOUT: number;
  71671. /**
  71672. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71673. */
  71674. static readonly EASINGMODE_EASEINOUT: number;
  71675. private _easingMode;
  71676. /**
  71677. * Sets the easing mode of the current function.
  71678. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71679. */
  71680. setEasingMode(easingMode: number): void;
  71681. /**
  71682. * Gets the current easing mode.
  71683. * @returns the easing mode
  71684. */
  71685. getEasingMode(): number;
  71686. /**
  71687. * @hidden
  71688. */
  71689. easeInCore(gradient: number): number;
  71690. /**
  71691. * Given an input gradient between 0 and 1, this returns the corresponding value
  71692. * of the easing function.
  71693. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71694. * @returns the corresponding value on the curve defined by the easing function
  71695. */
  71696. ease(gradient: number): number;
  71697. }
  71698. /**
  71699. * Easing function with a circle shape (see link below).
  71700. * @see https://easings.net/#easeInCirc
  71701. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71702. */
  71703. export class CircleEase extends EasingFunction implements IEasingFunction {
  71704. /** @hidden */
  71705. easeInCore(gradient: number): number;
  71706. }
  71707. /**
  71708. * Easing function with a ease back shape (see link below).
  71709. * @see https://easings.net/#easeInBack
  71710. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71711. */
  71712. export class BackEase extends EasingFunction implements IEasingFunction {
  71713. /** Defines the amplitude of the function */
  71714. amplitude: number;
  71715. /**
  71716. * Instantiates a back ease easing
  71717. * @see https://easings.net/#easeInBack
  71718. * @param amplitude Defines the amplitude of the function
  71719. */
  71720. constructor(
  71721. /** Defines the amplitude of the function */
  71722. amplitude?: number);
  71723. /** @hidden */
  71724. easeInCore(gradient: number): number;
  71725. }
  71726. /**
  71727. * Easing function with a bouncing shape (see link below).
  71728. * @see https://easings.net/#easeInBounce
  71729. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71730. */
  71731. export class BounceEase extends EasingFunction implements IEasingFunction {
  71732. /** Defines the number of bounces */
  71733. bounces: number;
  71734. /** Defines the amplitude of the bounce */
  71735. bounciness: number;
  71736. /**
  71737. * Instantiates a bounce easing
  71738. * @see https://easings.net/#easeInBounce
  71739. * @param bounces Defines the number of bounces
  71740. * @param bounciness Defines the amplitude of the bounce
  71741. */
  71742. constructor(
  71743. /** Defines the number of bounces */
  71744. bounces?: number,
  71745. /** Defines the amplitude of the bounce */
  71746. bounciness?: number);
  71747. /** @hidden */
  71748. easeInCore(gradient: number): number;
  71749. }
  71750. /**
  71751. * Easing function with a power of 3 shape (see link below).
  71752. * @see https://easings.net/#easeInCubic
  71753. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71754. */
  71755. export class CubicEase extends EasingFunction implements IEasingFunction {
  71756. /** @hidden */
  71757. easeInCore(gradient: number): number;
  71758. }
  71759. /**
  71760. * Easing function with an elastic shape (see link below).
  71761. * @see https://easings.net/#easeInElastic
  71762. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71763. */
  71764. export class ElasticEase extends EasingFunction implements IEasingFunction {
  71765. /** Defines the number of oscillations*/
  71766. oscillations: number;
  71767. /** Defines the amplitude of the oscillations*/
  71768. springiness: number;
  71769. /**
  71770. * Instantiates an elastic easing function
  71771. * @see https://easings.net/#easeInElastic
  71772. * @param oscillations Defines the number of oscillations
  71773. * @param springiness Defines the amplitude of the oscillations
  71774. */
  71775. constructor(
  71776. /** Defines the number of oscillations*/
  71777. oscillations?: number,
  71778. /** Defines the amplitude of the oscillations*/
  71779. springiness?: number);
  71780. /** @hidden */
  71781. easeInCore(gradient: number): number;
  71782. }
  71783. /**
  71784. * Easing function with an exponential shape (see link below).
  71785. * @see https://easings.net/#easeInExpo
  71786. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71787. */
  71788. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  71789. /** Defines the exponent of the function */
  71790. exponent: number;
  71791. /**
  71792. * Instantiates an exponential easing function
  71793. * @see https://easings.net/#easeInExpo
  71794. * @param exponent Defines the exponent of the function
  71795. */
  71796. constructor(
  71797. /** Defines the exponent of the function */
  71798. exponent?: number);
  71799. /** @hidden */
  71800. easeInCore(gradient: number): number;
  71801. }
  71802. /**
  71803. * Easing function with a power shape (see link below).
  71804. * @see https://easings.net/#easeInQuad
  71805. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71806. */
  71807. export class PowerEase extends EasingFunction implements IEasingFunction {
  71808. /** Defines the power of the function */
  71809. power: number;
  71810. /**
  71811. * Instantiates an power base easing function
  71812. * @see https://easings.net/#easeInQuad
  71813. * @param power Defines the power of the function
  71814. */
  71815. constructor(
  71816. /** Defines the power of the function */
  71817. power?: number);
  71818. /** @hidden */
  71819. easeInCore(gradient: number): number;
  71820. }
  71821. /**
  71822. * Easing function with a power of 2 shape (see link below).
  71823. * @see https://easings.net/#easeInQuad
  71824. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71825. */
  71826. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  71827. /** @hidden */
  71828. easeInCore(gradient: number): number;
  71829. }
  71830. /**
  71831. * Easing function with a power of 4 shape (see link below).
  71832. * @see https://easings.net/#easeInQuart
  71833. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71834. */
  71835. export class QuarticEase extends EasingFunction implements IEasingFunction {
  71836. /** @hidden */
  71837. easeInCore(gradient: number): number;
  71838. }
  71839. /**
  71840. * Easing function with a power of 5 shape (see link below).
  71841. * @see https://easings.net/#easeInQuint
  71842. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71843. */
  71844. export class QuinticEase extends EasingFunction implements IEasingFunction {
  71845. /** @hidden */
  71846. easeInCore(gradient: number): number;
  71847. }
  71848. /**
  71849. * Easing function with a sin shape (see link below).
  71850. * @see https://easings.net/#easeInSine
  71851. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71852. */
  71853. export class SineEase extends EasingFunction implements IEasingFunction {
  71854. /** @hidden */
  71855. easeInCore(gradient: number): number;
  71856. }
  71857. /**
  71858. * Easing function with a bezier shape (see link below).
  71859. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71860. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71861. */
  71862. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  71863. /** Defines the x component of the start tangent in the bezier curve */
  71864. x1: number;
  71865. /** Defines the y component of the start tangent in the bezier curve */
  71866. y1: number;
  71867. /** Defines the x component of the end tangent in the bezier curve */
  71868. x2: number;
  71869. /** Defines the y component of the end tangent in the bezier curve */
  71870. y2: number;
  71871. /**
  71872. * Instantiates a bezier function
  71873. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71874. * @param x1 Defines the x component of the start tangent in the bezier curve
  71875. * @param y1 Defines the y component of the start tangent in the bezier curve
  71876. * @param x2 Defines the x component of the end tangent in the bezier curve
  71877. * @param y2 Defines the y component of the end tangent in the bezier curve
  71878. */
  71879. constructor(
  71880. /** Defines the x component of the start tangent in the bezier curve */
  71881. x1?: number,
  71882. /** Defines the y component of the start tangent in the bezier curve */
  71883. y1?: number,
  71884. /** Defines the x component of the end tangent in the bezier curve */
  71885. x2?: number,
  71886. /** Defines the y component of the end tangent in the bezier curve */
  71887. y2?: number);
  71888. /** @hidden */
  71889. easeInCore(gradient: number): number;
  71890. }
  71891. }
  71892. declare module BABYLON {
  71893. /**
  71894. * Class used to hold a RBG color
  71895. */
  71896. export class Color3 {
  71897. /**
  71898. * Defines the red component (between 0 and 1, default is 0)
  71899. */
  71900. r: number;
  71901. /**
  71902. * Defines the green component (between 0 and 1, default is 0)
  71903. */
  71904. g: number;
  71905. /**
  71906. * Defines the blue component (between 0 and 1, default is 0)
  71907. */
  71908. b: number;
  71909. /**
  71910. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  71911. * @param r defines the red component (between 0 and 1, default is 0)
  71912. * @param g defines the green component (between 0 and 1, default is 0)
  71913. * @param b defines the blue component (between 0 and 1, default is 0)
  71914. */
  71915. constructor(
  71916. /**
  71917. * Defines the red component (between 0 and 1, default is 0)
  71918. */
  71919. r?: number,
  71920. /**
  71921. * Defines the green component (between 0 and 1, default is 0)
  71922. */
  71923. g?: number,
  71924. /**
  71925. * Defines the blue component (between 0 and 1, default is 0)
  71926. */
  71927. b?: number);
  71928. /**
  71929. * Creates a string with the Color3 current values
  71930. * @returns the string representation of the Color3 object
  71931. */
  71932. toString(): string;
  71933. /**
  71934. * Returns the string "Color3"
  71935. * @returns "Color3"
  71936. */
  71937. getClassName(): string;
  71938. /**
  71939. * Compute the Color3 hash code
  71940. * @returns an unique number that can be used to hash Color3 objects
  71941. */
  71942. getHashCode(): number;
  71943. /**
  71944. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  71945. * @param array defines the array where to store the r,g,b components
  71946. * @param index defines an optional index in the target array to define where to start storing values
  71947. * @returns the current Color3 object
  71948. */
  71949. toArray(array: FloatArray, index?: number): Color3;
  71950. /**
  71951. * Returns a new Color4 object from the current Color3 and the given alpha
  71952. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  71953. * @returns a new Color4 object
  71954. */
  71955. toColor4(alpha?: number): Color4;
  71956. /**
  71957. * Returns a new array populated with 3 numeric elements : red, green and blue values
  71958. * @returns the new array
  71959. */
  71960. asArray(): number[];
  71961. /**
  71962. * Returns the luminance value
  71963. * @returns a float value
  71964. */
  71965. toLuminance(): number;
  71966. /**
  71967. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  71968. * @param otherColor defines the second operand
  71969. * @returns the new Color3 object
  71970. */
  71971. multiply(otherColor: DeepImmutable<Color3>): Color3;
  71972. /**
  71973. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  71974. * @param otherColor defines the second operand
  71975. * @param result defines the Color3 object where to store the result
  71976. * @returns the current Color3
  71977. */
  71978. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  71979. /**
  71980. * Determines equality between Color3 objects
  71981. * @param otherColor defines the second operand
  71982. * @returns true if the rgb values are equal to the given ones
  71983. */
  71984. equals(otherColor: DeepImmutable<Color3>): boolean;
  71985. /**
  71986. * Determines equality between the current Color3 object and a set of r,b,g values
  71987. * @param r defines the red component to check
  71988. * @param g defines the green component to check
  71989. * @param b defines the blue component to check
  71990. * @returns true if the rgb values are equal to the given ones
  71991. */
  71992. equalsFloats(r: number, g: number, b: number): boolean;
  71993. /**
  71994. * Multiplies in place each rgb value by scale
  71995. * @param scale defines the scaling factor
  71996. * @returns the updated Color3
  71997. */
  71998. scale(scale: number): Color3;
  71999. /**
  72000. * Multiplies the rgb values by scale and stores the result into "result"
  72001. * @param scale defines the scaling factor
  72002. * @param result defines the Color3 object where to store the result
  72003. * @returns the unmodified current Color3
  72004. */
  72005. scaleToRef(scale: number, result: Color3): Color3;
  72006. /**
  72007. * Scale the current Color3 values by a factor and add the result to a given Color3
  72008. * @param scale defines the scale factor
  72009. * @param result defines color to store the result into
  72010. * @returns the unmodified current Color3
  72011. */
  72012. scaleAndAddToRef(scale: number, result: Color3): Color3;
  72013. /**
  72014. * Clamps the rgb values by the min and max values and stores the result into "result"
  72015. * @param min defines minimum clamping value (default is 0)
  72016. * @param max defines maximum clamping value (default is 1)
  72017. * @param result defines color to store the result into
  72018. * @returns the original Color3
  72019. */
  72020. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  72021. /**
  72022. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  72023. * @param otherColor defines the second operand
  72024. * @returns the new Color3
  72025. */
  72026. add(otherColor: DeepImmutable<Color3>): Color3;
  72027. /**
  72028. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  72029. * @param otherColor defines the second operand
  72030. * @param result defines Color3 object to store the result into
  72031. * @returns the unmodified current Color3
  72032. */
  72033. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72034. /**
  72035. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  72036. * @param otherColor defines the second operand
  72037. * @returns the new Color3
  72038. */
  72039. subtract(otherColor: DeepImmutable<Color3>): Color3;
  72040. /**
  72041. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  72042. * @param otherColor defines the second operand
  72043. * @param result defines Color3 object to store the result into
  72044. * @returns the unmodified current Color3
  72045. */
  72046. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72047. /**
  72048. * Copy the current object
  72049. * @returns a new Color3 copied the current one
  72050. */
  72051. clone(): Color3;
  72052. /**
  72053. * Copies the rgb values from the source in the current Color3
  72054. * @param source defines the source Color3 object
  72055. * @returns the updated Color3 object
  72056. */
  72057. copyFrom(source: DeepImmutable<Color3>): Color3;
  72058. /**
  72059. * Updates the Color3 rgb values from the given floats
  72060. * @param r defines the red component to read from
  72061. * @param g defines the green component to read from
  72062. * @param b defines the blue component to read from
  72063. * @returns the current Color3 object
  72064. */
  72065. copyFromFloats(r: number, g: number, b: number): Color3;
  72066. /**
  72067. * Updates the Color3 rgb values from the given floats
  72068. * @param r defines the red component to read from
  72069. * @param g defines the green component to read from
  72070. * @param b defines the blue component to read from
  72071. * @returns the current Color3 object
  72072. */
  72073. set(r: number, g: number, b: number): Color3;
  72074. /**
  72075. * Compute the Color3 hexadecimal code as a string
  72076. * @returns a string containing the hexadecimal representation of the Color3 object
  72077. */
  72078. toHexString(): string;
  72079. /**
  72080. * Computes a new Color3 converted from the current one to linear space
  72081. * @returns a new Color3 object
  72082. */
  72083. toLinearSpace(): Color3;
  72084. /**
  72085. * Converts current color in rgb space to HSV values
  72086. * @returns a new color3 representing the HSV values
  72087. */
  72088. toHSV(): Color3;
  72089. /**
  72090. * Converts current color in rgb space to HSV values
  72091. * @param result defines the Color3 where to store the HSV values
  72092. */
  72093. toHSVToRef(result: Color3): void;
  72094. /**
  72095. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  72096. * @param convertedColor defines the Color3 object where to store the linear space version
  72097. * @returns the unmodified Color3
  72098. */
  72099. toLinearSpaceToRef(convertedColor: Color3): Color3;
  72100. /**
  72101. * Computes a new Color3 converted from the current one to gamma space
  72102. * @returns a new Color3 object
  72103. */
  72104. toGammaSpace(): Color3;
  72105. /**
  72106. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  72107. * @param convertedColor defines the Color3 object where to store the gamma space version
  72108. * @returns the unmodified Color3
  72109. */
  72110. toGammaSpaceToRef(convertedColor: Color3): Color3;
  72111. private static _BlackReadOnly;
  72112. /**
  72113. * Convert Hue, saturation and value to a Color3 (RGB)
  72114. * @param hue defines the hue
  72115. * @param saturation defines the saturation
  72116. * @param value defines the value
  72117. * @param result defines the Color3 where to store the RGB values
  72118. */
  72119. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  72120. /**
  72121. * Creates a new Color3 from the string containing valid hexadecimal values
  72122. * @param hex defines a string containing valid hexadecimal values
  72123. * @returns a new Color3 object
  72124. */
  72125. static FromHexString(hex: string): Color3;
  72126. /**
  72127. * Creates a new Color3 from the starting index of the given array
  72128. * @param array defines the source array
  72129. * @param offset defines an offset in the source array
  72130. * @returns a new Color3 object
  72131. */
  72132. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  72133. /**
  72134. * Creates a new Color3 from integer values (< 256)
  72135. * @param r defines the red component to read from (value between 0 and 255)
  72136. * @param g defines the green component to read from (value between 0 and 255)
  72137. * @param b defines the blue component to read from (value between 0 and 255)
  72138. * @returns a new Color3 object
  72139. */
  72140. static FromInts(r: number, g: number, b: number): Color3;
  72141. /**
  72142. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72143. * @param start defines the start Color3 value
  72144. * @param end defines the end Color3 value
  72145. * @param amount defines the gradient value between start and end
  72146. * @returns a new Color3 object
  72147. */
  72148. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  72149. /**
  72150. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72151. * @param left defines the start value
  72152. * @param right defines the end value
  72153. * @param amount defines the gradient factor
  72154. * @param result defines the Color3 object where to store the result
  72155. */
  72156. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  72157. /**
  72158. * Returns a Color3 value containing a red color
  72159. * @returns a new Color3 object
  72160. */
  72161. static Red(): Color3;
  72162. /**
  72163. * Returns a Color3 value containing a green color
  72164. * @returns a new Color3 object
  72165. */
  72166. static Green(): Color3;
  72167. /**
  72168. * Returns a Color3 value containing a blue color
  72169. * @returns a new Color3 object
  72170. */
  72171. static Blue(): Color3;
  72172. /**
  72173. * Returns a Color3 value containing a black color
  72174. * @returns a new Color3 object
  72175. */
  72176. static Black(): Color3;
  72177. /**
  72178. * Gets a Color3 value containing a black color that must not be updated
  72179. */
  72180. static readonly BlackReadOnly: DeepImmutable<Color3>;
  72181. /**
  72182. * Returns a Color3 value containing a white color
  72183. * @returns a new Color3 object
  72184. */
  72185. static White(): Color3;
  72186. /**
  72187. * Returns a Color3 value containing a purple color
  72188. * @returns a new Color3 object
  72189. */
  72190. static Purple(): Color3;
  72191. /**
  72192. * Returns a Color3 value containing a magenta color
  72193. * @returns a new Color3 object
  72194. */
  72195. static Magenta(): Color3;
  72196. /**
  72197. * Returns a Color3 value containing a yellow color
  72198. * @returns a new Color3 object
  72199. */
  72200. static Yellow(): Color3;
  72201. /**
  72202. * Returns a Color3 value containing a gray color
  72203. * @returns a new Color3 object
  72204. */
  72205. static Gray(): Color3;
  72206. /**
  72207. * Returns a Color3 value containing a teal color
  72208. * @returns a new Color3 object
  72209. */
  72210. static Teal(): Color3;
  72211. /**
  72212. * Returns a Color3 value containing a random color
  72213. * @returns a new Color3 object
  72214. */
  72215. static Random(): Color3;
  72216. }
  72217. /**
  72218. * Class used to hold a RBGA color
  72219. */
  72220. export class Color4 {
  72221. /**
  72222. * Defines the red component (between 0 and 1, default is 0)
  72223. */
  72224. r: number;
  72225. /**
  72226. * Defines the green component (between 0 and 1, default is 0)
  72227. */
  72228. g: number;
  72229. /**
  72230. * Defines the blue component (between 0 and 1, default is 0)
  72231. */
  72232. b: number;
  72233. /**
  72234. * Defines the alpha component (between 0 and 1, default is 1)
  72235. */
  72236. a: number;
  72237. /**
  72238. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  72239. * @param r defines the red component (between 0 and 1, default is 0)
  72240. * @param g defines the green component (between 0 and 1, default is 0)
  72241. * @param b defines the blue component (between 0 and 1, default is 0)
  72242. * @param a defines the alpha component (between 0 and 1, default is 1)
  72243. */
  72244. constructor(
  72245. /**
  72246. * Defines the red component (between 0 and 1, default is 0)
  72247. */
  72248. r?: number,
  72249. /**
  72250. * Defines the green component (between 0 and 1, default is 0)
  72251. */
  72252. g?: number,
  72253. /**
  72254. * Defines the blue component (between 0 and 1, default is 0)
  72255. */
  72256. b?: number,
  72257. /**
  72258. * Defines the alpha component (between 0 and 1, default is 1)
  72259. */
  72260. a?: number);
  72261. /**
  72262. * Adds in place the given Color4 values to the current Color4 object
  72263. * @param right defines the second operand
  72264. * @returns the current updated Color4 object
  72265. */
  72266. addInPlace(right: DeepImmutable<Color4>): Color4;
  72267. /**
  72268. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  72269. * @returns the new array
  72270. */
  72271. asArray(): number[];
  72272. /**
  72273. * Stores from the starting index in the given array the Color4 successive values
  72274. * @param array defines the array where to store the r,g,b components
  72275. * @param index defines an optional index in the target array to define where to start storing values
  72276. * @returns the current Color4 object
  72277. */
  72278. toArray(array: number[], index?: number): Color4;
  72279. /**
  72280. * Determines equality between Color4 objects
  72281. * @param otherColor defines the second operand
  72282. * @returns true if the rgba values are equal to the given ones
  72283. */
  72284. equals(otherColor: DeepImmutable<Color4>): boolean;
  72285. /**
  72286. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  72287. * @param right defines the second operand
  72288. * @returns a new Color4 object
  72289. */
  72290. add(right: DeepImmutable<Color4>): Color4;
  72291. /**
  72292. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  72293. * @param right defines the second operand
  72294. * @returns a new Color4 object
  72295. */
  72296. subtract(right: DeepImmutable<Color4>): Color4;
  72297. /**
  72298. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  72299. * @param right defines the second operand
  72300. * @param result defines the Color4 object where to store the result
  72301. * @returns the current Color4 object
  72302. */
  72303. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  72304. /**
  72305. * Creates a new Color4 with the current Color4 values multiplied by scale
  72306. * @param scale defines the scaling factor to apply
  72307. * @returns a new Color4 object
  72308. */
  72309. scale(scale: number): Color4;
  72310. /**
  72311. * Multiplies the current Color4 values by scale and stores the result in "result"
  72312. * @param scale defines the scaling factor to apply
  72313. * @param result defines the Color4 object where to store the result
  72314. * @returns the current unmodified Color4
  72315. */
  72316. scaleToRef(scale: number, result: Color4): Color4;
  72317. /**
  72318. * Scale the current Color4 values by a factor and add the result to a given Color4
  72319. * @param scale defines the scale factor
  72320. * @param result defines the Color4 object where to store the result
  72321. * @returns the unmodified current Color4
  72322. */
  72323. scaleAndAddToRef(scale: number, result: Color4): Color4;
  72324. /**
  72325. * Clamps the rgb values by the min and max values and stores the result into "result"
  72326. * @param min defines minimum clamping value (default is 0)
  72327. * @param max defines maximum clamping value (default is 1)
  72328. * @param result defines color to store the result into.
  72329. * @returns the cuurent Color4
  72330. */
  72331. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  72332. /**
  72333. * Multipy an Color4 value by another and return a new Color4 object
  72334. * @param color defines the Color4 value to multiply by
  72335. * @returns a new Color4 object
  72336. */
  72337. multiply(color: Color4): Color4;
  72338. /**
  72339. * Multipy a Color4 value by another and push the result in a reference value
  72340. * @param color defines the Color4 value to multiply by
  72341. * @param result defines the Color4 to fill the result in
  72342. * @returns the result Color4
  72343. */
  72344. multiplyToRef(color: Color4, result: Color4): Color4;
  72345. /**
  72346. * Creates a string with the Color4 current values
  72347. * @returns the string representation of the Color4 object
  72348. */
  72349. toString(): string;
  72350. /**
  72351. * Returns the string "Color4"
  72352. * @returns "Color4"
  72353. */
  72354. getClassName(): string;
  72355. /**
  72356. * Compute the Color4 hash code
  72357. * @returns an unique number that can be used to hash Color4 objects
  72358. */
  72359. getHashCode(): number;
  72360. /**
  72361. * Creates a new Color4 copied from the current one
  72362. * @returns a new Color4 object
  72363. */
  72364. clone(): Color4;
  72365. /**
  72366. * Copies the given Color4 values into the current one
  72367. * @param source defines the source Color4 object
  72368. * @returns the current updated Color4 object
  72369. */
  72370. copyFrom(source: Color4): Color4;
  72371. /**
  72372. * Copies the given float values into the current one
  72373. * @param r defines the red component to read from
  72374. * @param g defines the green component to read from
  72375. * @param b defines the blue component to read from
  72376. * @param a defines the alpha component to read from
  72377. * @returns the current updated Color4 object
  72378. */
  72379. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  72380. /**
  72381. * Copies the given float values into the current one
  72382. * @param r defines the red component to read from
  72383. * @param g defines the green component to read from
  72384. * @param b defines the blue component to read from
  72385. * @param a defines the alpha component to read from
  72386. * @returns the current updated Color4 object
  72387. */
  72388. set(r: number, g: number, b: number, a: number): Color4;
  72389. /**
  72390. * Compute the Color4 hexadecimal code as a string
  72391. * @returns a string containing the hexadecimal representation of the Color4 object
  72392. */
  72393. toHexString(): string;
  72394. /**
  72395. * Computes a new Color4 converted from the current one to linear space
  72396. * @returns a new Color4 object
  72397. */
  72398. toLinearSpace(): Color4;
  72399. /**
  72400. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  72401. * @param convertedColor defines the Color4 object where to store the linear space version
  72402. * @returns the unmodified Color4
  72403. */
  72404. toLinearSpaceToRef(convertedColor: Color4): Color4;
  72405. /**
  72406. * Computes a new Color4 converted from the current one to gamma space
  72407. * @returns a new Color4 object
  72408. */
  72409. toGammaSpace(): Color4;
  72410. /**
  72411. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  72412. * @param convertedColor defines the Color4 object where to store the gamma space version
  72413. * @returns the unmodified Color4
  72414. */
  72415. toGammaSpaceToRef(convertedColor: Color4): Color4;
  72416. /**
  72417. * Creates a new Color4 from the string containing valid hexadecimal values
  72418. * @param hex defines a string containing valid hexadecimal values
  72419. * @returns a new Color4 object
  72420. */
  72421. static FromHexString(hex: string): Color4;
  72422. /**
  72423. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  72424. * @param left defines the start value
  72425. * @param right defines the end value
  72426. * @param amount defines the gradient factor
  72427. * @returns a new Color4 object
  72428. */
  72429. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  72430. /**
  72431. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  72432. * @param left defines the start value
  72433. * @param right defines the end value
  72434. * @param amount defines the gradient factor
  72435. * @param result defines the Color4 object where to store data
  72436. */
  72437. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  72438. /**
  72439. * Creates a new Color4 from a Color3 and an alpha value
  72440. * @param color3 defines the source Color3 to read from
  72441. * @param alpha defines the alpha component (1.0 by default)
  72442. * @returns a new Color4 object
  72443. */
  72444. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  72445. /**
  72446. * Creates a new Color4 from the starting index element of the given array
  72447. * @param array defines the source array to read from
  72448. * @param offset defines the offset in the source array
  72449. * @returns a new Color4 object
  72450. */
  72451. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  72452. /**
  72453. * Creates a new Color3 from integer values (< 256)
  72454. * @param r defines the red component to read from (value between 0 and 255)
  72455. * @param g defines the green component to read from (value between 0 and 255)
  72456. * @param b defines the blue component to read from (value between 0 and 255)
  72457. * @param a defines the alpha component to read from (value between 0 and 255)
  72458. * @returns a new Color3 object
  72459. */
  72460. static FromInts(r: number, g: number, b: number, a: number): Color4;
  72461. /**
  72462. * Check the content of a given array and convert it to an array containing RGBA data
  72463. * If the original array was already containing count * 4 values then it is returned directly
  72464. * @param colors defines the array to check
  72465. * @param count defines the number of RGBA data to expect
  72466. * @returns an array containing count * 4 values (RGBA)
  72467. */
  72468. static CheckColors4(colors: number[], count: number): number[];
  72469. }
  72470. /**
  72471. * @hidden
  72472. */
  72473. export class TmpColors {
  72474. static Color3: Color3[];
  72475. static Color4: Color4[];
  72476. }
  72477. }
  72478. declare module BABYLON {
  72479. /**
  72480. * Defines an interface which represents an animation key frame
  72481. */
  72482. export interface IAnimationKey {
  72483. /**
  72484. * Frame of the key frame
  72485. */
  72486. frame: number;
  72487. /**
  72488. * Value at the specifies key frame
  72489. */
  72490. value: any;
  72491. /**
  72492. * The input tangent for the cubic hermite spline
  72493. */
  72494. inTangent?: any;
  72495. /**
  72496. * The output tangent for the cubic hermite spline
  72497. */
  72498. outTangent?: any;
  72499. /**
  72500. * The animation interpolation type
  72501. */
  72502. interpolation?: AnimationKeyInterpolation;
  72503. }
  72504. /**
  72505. * Enum for the animation key frame interpolation type
  72506. */
  72507. export enum AnimationKeyInterpolation {
  72508. /**
  72509. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72510. */
  72511. STEP = 1
  72512. }
  72513. }
  72514. declare module BABYLON {
  72515. /**
  72516. * Represents the range of an animation
  72517. */
  72518. export class AnimationRange {
  72519. /**The name of the animation range**/
  72520. name: string;
  72521. /**The starting frame of the animation */
  72522. from: number;
  72523. /**The ending frame of the animation*/
  72524. to: number;
  72525. /**
  72526. * Initializes the range of an animation
  72527. * @param name The name of the animation range
  72528. * @param from The starting frame of the animation
  72529. * @param to The ending frame of the animation
  72530. */
  72531. constructor(
  72532. /**The name of the animation range**/
  72533. name: string,
  72534. /**The starting frame of the animation */
  72535. from: number,
  72536. /**The ending frame of the animation*/
  72537. to: number);
  72538. /**
  72539. * Makes a copy of the animation range
  72540. * @returns A copy of the animation range
  72541. */
  72542. clone(): AnimationRange;
  72543. }
  72544. }
  72545. declare module BABYLON {
  72546. /**
  72547. * Composed of a frame, and an action function
  72548. */
  72549. export class AnimationEvent {
  72550. /** The frame for which the event is triggered **/
  72551. frame: number;
  72552. /** The event to perform when triggered **/
  72553. action: (currentFrame: number) => void;
  72554. /** Specifies if the event should be triggered only once**/
  72555. onlyOnce?: boolean | undefined;
  72556. /**
  72557. * Specifies if the animation event is done
  72558. */
  72559. isDone: boolean;
  72560. /**
  72561. * Initializes the animation event
  72562. * @param frame The frame for which the event is triggered
  72563. * @param action The event to perform when triggered
  72564. * @param onlyOnce Specifies if the event should be triggered only once
  72565. */
  72566. constructor(
  72567. /** The frame for which the event is triggered **/
  72568. frame: number,
  72569. /** The event to perform when triggered **/
  72570. action: (currentFrame: number) => void,
  72571. /** Specifies if the event should be triggered only once**/
  72572. onlyOnce?: boolean | undefined);
  72573. /** @hidden */
  72574. _clone(): AnimationEvent;
  72575. }
  72576. }
  72577. declare module BABYLON {
  72578. /**
  72579. * Interface used to define a behavior
  72580. */
  72581. export interface Behavior<T> {
  72582. /** gets or sets behavior's name */
  72583. name: string;
  72584. /**
  72585. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72586. */
  72587. init(): void;
  72588. /**
  72589. * Called when the behavior is attached to a target
  72590. * @param target defines the target where the behavior is attached to
  72591. */
  72592. attach(target: T): void;
  72593. /**
  72594. * Called when the behavior is detached from its target
  72595. */
  72596. detach(): void;
  72597. }
  72598. /**
  72599. * Interface implemented by classes supporting behaviors
  72600. */
  72601. export interface IBehaviorAware<T> {
  72602. /**
  72603. * Attach a behavior
  72604. * @param behavior defines the behavior to attach
  72605. * @returns the current host
  72606. */
  72607. addBehavior(behavior: Behavior<T>): T;
  72608. /**
  72609. * Remove a behavior from the current object
  72610. * @param behavior defines the behavior to detach
  72611. * @returns the current host
  72612. */
  72613. removeBehavior(behavior: Behavior<T>): T;
  72614. /**
  72615. * Gets a behavior using its name to search
  72616. * @param name defines the name to search
  72617. * @returns the behavior or null if not found
  72618. */
  72619. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72620. }
  72621. }
  72622. declare module BABYLON {
  72623. /**
  72624. * Defines an array and its length.
  72625. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72626. */
  72627. export interface ISmartArrayLike<T> {
  72628. /**
  72629. * The data of the array.
  72630. */
  72631. data: Array<T>;
  72632. /**
  72633. * The active length of the array.
  72634. */
  72635. length: number;
  72636. }
  72637. /**
  72638. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72639. */
  72640. export class SmartArray<T> implements ISmartArrayLike<T> {
  72641. /**
  72642. * The full set of data from the array.
  72643. */
  72644. data: Array<T>;
  72645. /**
  72646. * The active length of the array.
  72647. */
  72648. length: number;
  72649. protected _id: number;
  72650. /**
  72651. * Instantiates a Smart Array.
  72652. * @param capacity defines the default capacity of the array.
  72653. */
  72654. constructor(capacity: number);
  72655. /**
  72656. * Pushes a value at the end of the active data.
  72657. * @param value defines the object to push in the array.
  72658. */
  72659. push(value: T): void;
  72660. /**
  72661. * Iterates over the active data and apply the lambda to them.
  72662. * @param func defines the action to apply on each value.
  72663. */
  72664. forEach(func: (content: T) => void): void;
  72665. /**
  72666. * Sorts the full sets of data.
  72667. * @param compareFn defines the comparison function to apply.
  72668. */
  72669. sort(compareFn: (a: T, b: T) => number): void;
  72670. /**
  72671. * Resets the active data to an empty array.
  72672. */
  72673. reset(): void;
  72674. /**
  72675. * Releases all the data from the array as well as the array.
  72676. */
  72677. dispose(): void;
  72678. /**
  72679. * Concats the active data with a given array.
  72680. * @param array defines the data to concatenate with.
  72681. */
  72682. concat(array: any): void;
  72683. /**
  72684. * Returns the position of a value in the active data.
  72685. * @param value defines the value to find the index for
  72686. * @returns the index if found in the active data otherwise -1
  72687. */
  72688. indexOf(value: T): number;
  72689. /**
  72690. * Returns whether an element is part of the active data.
  72691. * @param value defines the value to look for
  72692. * @returns true if found in the active data otherwise false
  72693. */
  72694. contains(value: T): boolean;
  72695. private static _GlobalId;
  72696. }
  72697. /**
  72698. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72699. * The data in this array can only be present once
  72700. */
  72701. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72702. private _duplicateId;
  72703. /**
  72704. * Pushes a value at the end of the active data.
  72705. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72706. * @param value defines the object to push in the array.
  72707. */
  72708. push(value: T): void;
  72709. /**
  72710. * Pushes a value at the end of the active data.
  72711. * If the data is already present, it won t be added again
  72712. * @param value defines the object to push in the array.
  72713. * @returns true if added false if it was already present
  72714. */
  72715. pushNoDuplicate(value: T): boolean;
  72716. /**
  72717. * Resets the active data to an empty array.
  72718. */
  72719. reset(): void;
  72720. /**
  72721. * Concats the active data with a given array.
  72722. * This ensures no dupplicate will be present in the result.
  72723. * @param array defines the data to concatenate with.
  72724. */
  72725. concatWithNoDuplicate(array: any): void;
  72726. }
  72727. }
  72728. declare module BABYLON {
  72729. /**
  72730. * @ignore
  72731. * This is a list of all the different input types that are available in the application.
  72732. * Fo instance: ArcRotateCameraGamepadInput...
  72733. */
  72734. export var CameraInputTypes: {};
  72735. /**
  72736. * This is the contract to implement in order to create a new input class.
  72737. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72738. */
  72739. export interface ICameraInput<TCamera extends Camera> {
  72740. /**
  72741. * Defines the camera the input is attached to.
  72742. */
  72743. camera: Nullable<TCamera>;
  72744. /**
  72745. * Gets the class name of the current intput.
  72746. * @returns the class name
  72747. */
  72748. getClassName(): string;
  72749. /**
  72750. * Get the friendly name associated with the input class.
  72751. * @returns the input friendly name
  72752. */
  72753. getSimpleName(): string;
  72754. /**
  72755. * Attach the input controls to a specific dom element to get the input from.
  72756. * @param element Defines the element the controls should be listened from
  72757. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72758. */
  72759. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72760. /**
  72761. * Detach the current controls from the specified dom element.
  72762. * @param element Defines the element to stop listening the inputs from
  72763. */
  72764. detachControl(element: Nullable<HTMLElement>): void;
  72765. /**
  72766. * Update the current camera state depending on the inputs that have been used this frame.
  72767. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72768. */
  72769. checkInputs?: () => void;
  72770. }
  72771. /**
  72772. * Represents a map of input types to input instance or input index to input instance.
  72773. */
  72774. export interface CameraInputsMap<TCamera extends Camera> {
  72775. /**
  72776. * Accessor to the input by input type.
  72777. */
  72778. [name: string]: ICameraInput<TCamera>;
  72779. /**
  72780. * Accessor to the input by input index.
  72781. */
  72782. [idx: number]: ICameraInput<TCamera>;
  72783. }
  72784. /**
  72785. * This represents the input manager used within a camera.
  72786. * It helps dealing with all the different kind of input attached to a camera.
  72787. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72788. */
  72789. export class CameraInputsManager<TCamera extends Camera> {
  72790. /**
  72791. * Defines the list of inputs attahed to the camera.
  72792. */
  72793. attached: CameraInputsMap<TCamera>;
  72794. /**
  72795. * Defines the dom element the camera is collecting inputs from.
  72796. * This is null if the controls have not been attached.
  72797. */
  72798. attachedElement: Nullable<HTMLElement>;
  72799. /**
  72800. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72801. */
  72802. noPreventDefault: boolean;
  72803. /**
  72804. * Defined the camera the input manager belongs to.
  72805. */
  72806. camera: TCamera;
  72807. /**
  72808. * Update the current camera state depending on the inputs that have been used this frame.
  72809. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72810. */
  72811. checkInputs: () => void;
  72812. /**
  72813. * Instantiate a new Camera Input Manager.
  72814. * @param camera Defines the camera the input manager blongs to
  72815. */
  72816. constructor(camera: TCamera);
  72817. /**
  72818. * Add an input method to a camera
  72819. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72820. * @param input camera input method
  72821. */
  72822. add(input: ICameraInput<TCamera>): void;
  72823. /**
  72824. * Remove a specific input method from a camera
  72825. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72826. * @param inputToRemove camera input method
  72827. */
  72828. remove(inputToRemove: ICameraInput<TCamera>): void;
  72829. /**
  72830. * Remove a specific input type from a camera
  72831. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72832. * @param inputType the type of the input to remove
  72833. */
  72834. removeByType(inputType: string): void;
  72835. private _addCheckInputs;
  72836. /**
  72837. * Attach the input controls to the currently attached dom element to listen the events from.
  72838. * @param input Defines the input to attach
  72839. */
  72840. attachInput(input: ICameraInput<TCamera>): void;
  72841. /**
  72842. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72843. * @param element Defines the dom element to collect the events from
  72844. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72845. */
  72846. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72847. /**
  72848. * Detach the current manager inputs controls from a specific dom element.
  72849. * @param element Defines the dom element to collect the events from
  72850. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72851. */
  72852. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72853. /**
  72854. * Rebuild the dynamic inputCheck function from the current list of
  72855. * defined inputs in the manager.
  72856. */
  72857. rebuildInputCheck(): void;
  72858. /**
  72859. * Remove all attached input methods from a camera
  72860. */
  72861. clear(): void;
  72862. /**
  72863. * Serialize the current input manager attached to a camera.
  72864. * This ensures than once parsed,
  72865. * the input associated to the camera will be identical to the current ones
  72866. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72867. */
  72868. serialize(serializedCamera: any): void;
  72869. /**
  72870. * Parses an input manager serialized JSON to restore the previous list of inputs
  72871. * and states associated to a camera.
  72872. * @param parsedCamera Defines the JSON to parse
  72873. */
  72874. parse(parsedCamera: any): void;
  72875. }
  72876. }
  72877. declare module BABYLON {
  72878. /**
  72879. * Class used to store data that will be store in GPU memory
  72880. */
  72881. export class Buffer {
  72882. private _engine;
  72883. private _buffer;
  72884. /** @hidden */
  72885. _data: Nullable<DataArray>;
  72886. private _updatable;
  72887. private _instanced;
  72888. /**
  72889. * Gets the byte stride.
  72890. */
  72891. readonly byteStride: number;
  72892. /**
  72893. * Constructor
  72894. * @param engine the engine
  72895. * @param data the data to use for this buffer
  72896. * @param updatable whether the data is updatable
  72897. * @param stride the stride (optional)
  72898. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  72899. * @param instanced whether the buffer is instanced (optional)
  72900. * @param useBytes set to true if the stride in in bytes (optional)
  72901. */
  72902. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  72903. /**
  72904. * Create a new VertexBuffer based on the current buffer
  72905. * @param kind defines the vertex buffer kind (position, normal, etc.)
  72906. * @param offset defines offset in the buffer (0 by default)
  72907. * @param size defines the size in floats of attributes (position is 3 for instance)
  72908. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  72909. * @param instanced defines if the vertex buffer contains indexed data
  72910. * @param useBytes defines if the offset and stride are in bytes
  72911. * @returns the new vertex buffer
  72912. */
  72913. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  72914. /**
  72915. * Gets a boolean indicating if the Buffer is updatable?
  72916. * @returns true if the buffer is updatable
  72917. */
  72918. isUpdatable(): boolean;
  72919. /**
  72920. * Gets current buffer's data
  72921. * @returns a DataArray or null
  72922. */
  72923. getData(): Nullable<DataArray>;
  72924. /**
  72925. * Gets underlying native buffer
  72926. * @returns underlying native buffer
  72927. */
  72928. getBuffer(): Nullable<DataBuffer>;
  72929. /**
  72930. * Gets the stride in float32 units (i.e. byte stride / 4).
  72931. * May not be an integer if the byte stride is not divisible by 4.
  72932. * DEPRECATED. Use byteStride instead.
  72933. * @returns the stride in float32 units
  72934. */
  72935. getStrideSize(): number;
  72936. /**
  72937. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  72938. * @param data defines the data to store
  72939. */
  72940. create(data?: Nullable<DataArray>): void;
  72941. /** @hidden */
  72942. _rebuild(): void;
  72943. /**
  72944. * Update current buffer data
  72945. * @param data defines the data to store
  72946. */
  72947. update(data: DataArray): void;
  72948. /**
  72949. * Updates the data directly.
  72950. * @param data the new data
  72951. * @param offset the new offset
  72952. * @param vertexCount the vertex count (optional)
  72953. * @param useBytes set to true if the offset is in bytes
  72954. */
  72955. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  72956. /**
  72957. * Release all resources
  72958. */
  72959. dispose(): void;
  72960. }
  72961. /**
  72962. * Specialized buffer used to store vertex data
  72963. */
  72964. export class VertexBuffer {
  72965. /** @hidden */
  72966. _buffer: Buffer;
  72967. private _kind;
  72968. private _size;
  72969. private _ownsBuffer;
  72970. private _instanced;
  72971. private _instanceDivisor;
  72972. /**
  72973. * The byte type.
  72974. */
  72975. static readonly BYTE: number;
  72976. /**
  72977. * The unsigned byte type.
  72978. */
  72979. static readonly UNSIGNED_BYTE: number;
  72980. /**
  72981. * The short type.
  72982. */
  72983. static readonly SHORT: number;
  72984. /**
  72985. * The unsigned short type.
  72986. */
  72987. static readonly UNSIGNED_SHORT: number;
  72988. /**
  72989. * The integer type.
  72990. */
  72991. static readonly INT: number;
  72992. /**
  72993. * The unsigned integer type.
  72994. */
  72995. static readonly UNSIGNED_INT: number;
  72996. /**
  72997. * The float type.
  72998. */
  72999. static readonly FLOAT: number;
  73000. /**
  73001. * Gets or sets the instance divisor when in instanced mode
  73002. */
  73003. instanceDivisor: number;
  73004. /**
  73005. * Gets the byte stride.
  73006. */
  73007. readonly byteStride: number;
  73008. /**
  73009. * Gets the byte offset.
  73010. */
  73011. readonly byteOffset: number;
  73012. /**
  73013. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  73014. */
  73015. readonly normalized: boolean;
  73016. /**
  73017. * Gets the data type of each component in the array.
  73018. */
  73019. readonly type: number;
  73020. /**
  73021. * Constructor
  73022. * @param engine the engine
  73023. * @param data the data to use for this vertex buffer
  73024. * @param kind the vertex buffer kind
  73025. * @param updatable whether the data is updatable
  73026. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73027. * @param stride the stride (optional)
  73028. * @param instanced whether the buffer is instanced (optional)
  73029. * @param offset the offset of the data (optional)
  73030. * @param size the number of components (optional)
  73031. * @param type the type of the component (optional)
  73032. * @param normalized whether the data contains normalized data (optional)
  73033. * @param useBytes set to true if stride and offset are in bytes (optional)
  73034. */
  73035. 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);
  73036. /** @hidden */
  73037. _rebuild(): void;
  73038. /**
  73039. * Returns the kind of the VertexBuffer (string)
  73040. * @returns a string
  73041. */
  73042. getKind(): string;
  73043. /**
  73044. * Gets a boolean indicating if the VertexBuffer is updatable?
  73045. * @returns true if the buffer is updatable
  73046. */
  73047. isUpdatable(): boolean;
  73048. /**
  73049. * Gets current buffer's data
  73050. * @returns a DataArray or null
  73051. */
  73052. getData(): Nullable<DataArray>;
  73053. /**
  73054. * Gets underlying native buffer
  73055. * @returns underlying native buffer
  73056. */
  73057. getBuffer(): Nullable<DataBuffer>;
  73058. /**
  73059. * Gets the stride in float32 units (i.e. byte stride / 4).
  73060. * May not be an integer if the byte stride is not divisible by 4.
  73061. * DEPRECATED. Use byteStride instead.
  73062. * @returns the stride in float32 units
  73063. */
  73064. getStrideSize(): number;
  73065. /**
  73066. * Returns the offset as a multiple of the type byte length.
  73067. * DEPRECATED. Use byteOffset instead.
  73068. * @returns the offset in bytes
  73069. */
  73070. getOffset(): number;
  73071. /**
  73072. * Returns the number of components per vertex attribute (integer)
  73073. * @returns the size in float
  73074. */
  73075. getSize(): number;
  73076. /**
  73077. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  73078. * @returns true if this buffer is instanced
  73079. */
  73080. getIsInstanced(): boolean;
  73081. /**
  73082. * Returns the instancing divisor, zero for non-instanced (integer).
  73083. * @returns a number
  73084. */
  73085. getInstanceDivisor(): number;
  73086. /**
  73087. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73088. * @param data defines the data to store
  73089. */
  73090. create(data?: DataArray): void;
  73091. /**
  73092. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  73093. * This function will create a new buffer if the current one is not updatable
  73094. * @param data defines the data to store
  73095. */
  73096. update(data: DataArray): void;
  73097. /**
  73098. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  73099. * Returns the directly updated WebGLBuffer.
  73100. * @param data the new data
  73101. * @param offset the new offset
  73102. * @param useBytes set to true if the offset is in bytes
  73103. */
  73104. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  73105. /**
  73106. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  73107. */
  73108. dispose(): void;
  73109. /**
  73110. * Enumerates each value of this vertex buffer as numbers.
  73111. * @param count the number of values to enumerate
  73112. * @param callback the callback function called for each value
  73113. */
  73114. forEach(count: number, callback: (value: number, index: number) => void): void;
  73115. /**
  73116. * Positions
  73117. */
  73118. static readonly PositionKind: string;
  73119. /**
  73120. * Normals
  73121. */
  73122. static readonly NormalKind: string;
  73123. /**
  73124. * Tangents
  73125. */
  73126. static readonly TangentKind: string;
  73127. /**
  73128. * Texture coordinates
  73129. */
  73130. static readonly UVKind: string;
  73131. /**
  73132. * Texture coordinates 2
  73133. */
  73134. static readonly UV2Kind: string;
  73135. /**
  73136. * Texture coordinates 3
  73137. */
  73138. static readonly UV3Kind: string;
  73139. /**
  73140. * Texture coordinates 4
  73141. */
  73142. static readonly UV4Kind: string;
  73143. /**
  73144. * Texture coordinates 5
  73145. */
  73146. static readonly UV5Kind: string;
  73147. /**
  73148. * Texture coordinates 6
  73149. */
  73150. static readonly UV6Kind: string;
  73151. /**
  73152. * Colors
  73153. */
  73154. static readonly ColorKind: string;
  73155. /**
  73156. * Matrix indices (for bones)
  73157. */
  73158. static readonly MatricesIndicesKind: string;
  73159. /**
  73160. * Matrix weights (for bones)
  73161. */
  73162. static readonly MatricesWeightsKind: string;
  73163. /**
  73164. * Additional matrix indices (for bones)
  73165. */
  73166. static readonly MatricesIndicesExtraKind: string;
  73167. /**
  73168. * Additional matrix weights (for bones)
  73169. */
  73170. static readonly MatricesWeightsExtraKind: string;
  73171. /**
  73172. * Deduces the stride given a kind.
  73173. * @param kind The kind string to deduce
  73174. * @returns The deduced stride
  73175. */
  73176. static DeduceStride(kind: string): number;
  73177. /**
  73178. * Gets the byte length of the given type.
  73179. * @param type the type
  73180. * @returns the number of bytes
  73181. */
  73182. static GetTypeByteLength(type: number): number;
  73183. /**
  73184. * Enumerates each value of the given parameters as numbers.
  73185. * @param data the data to enumerate
  73186. * @param byteOffset the byte offset of the data
  73187. * @param byteStride the byte stride of the data
  73188. * @param componentCount the number of components per element
  73189. * @param componentType the type of the component
  73190. * @param count the number of values to enumerate
  73191. * @param normalized whether the data is normalized
  73192. * @param callback the callback function called for each value
  73193. */
  73194. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  73195. private static _GetFloatValue;
  73196. }
  73197. }
  73198. declare module BABYLON {
  73199. /**
  73200. * @hidden
  73201. */
  73202. export class IntersectionInfo {
  73203. bu: Nullable<number>;
  73204. bv: Nullable<number>;
  73205. distance: number;
  73206. faceId: number;
  73207. subMeshId: number;
  73208. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  73209. }
  73210. }
  73211. declare module BABYLON {
  73212. /**
  73213. * Represens a plane by the equation ax + by + cz + d = 0
  73214. */
  73215. export class Plane {
  73216. private static _TmpMatrix;
  73217. /**
  73218. * Normal of the plane (a,b,c)
  73219. */
  73220. normal: Vector3;
  73221. /**
  73222. * d component of the plane
  73223. */
  73224. d: number;
  73225. /**
  73226. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73227. * @param a a component of the plane
  73228. * @param b b component of the plane
  73229. * @param c c component of the plane
  73230. * @param d d component of the plane
  73231. */
  73232. constructor(a: number, b: number, c: number, d: number);
  73233. /**
  73234. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73235. */
  73236. asArray(): number[];
  73237. /**
  73238. * @returns a new plane copied from the current Plane.
  73239. */
  73240. clone(): Plane;
  73241. /**
  73242. * @returns the string "Plane".
  73243. */
  73244. getClassName(): string;
  73245. /**
  73246. * @returns the Plane hash code.
  73247. */
  73248. getHashCode(): number;
  73249. /**
  73250. * Normalize the current Plane in place.
  73251. * @returns the updated Plane.
  73252. */
  73253. normalize(): Plane;
  73254. /**
  73255. * Applies a transformation the plane and returns the result
  73256. * @param transformation the transformation matrix to be applied to the plane
  73257. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73258. */
  73259. transform(transformation: DeepImmutable<Matrix>): Plane;
  73260. /**
  73261. * Calcualtte the dot product between the point and the plane normal
  73262. * @param point point to calculate the dot product with
  73263. * @returns the dot product (float) of the point coordinates and the plane normal.
  73264. */
  73265. dotCoordinate(point: DeepImmutable<Vector3>): number;
  73266. /**
  73267. * Updates the current Plane from the plane defined by the three given points.
  73268. * @param point1 one of the points used to contruct the plane
  73269. * @param point2 one of the points used to contruct the plane
  73270. * @param point3 one of the points used to contruct the plane
  73271. * @returns the updated Plane.
  73272. */
  73273. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73274. /**
  73275. * Checks if the plane is facing a given direction
  73276. * @param direction the direction to check if the plane is facing
  73277. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73278. * @returns True is the vector "direction" is the same side than the plane normal.
  73279. */
  73280. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  73281. /**
  73282. * Calculates the distance to a point
  73283. * @param point point to calculate distance to
  73284. * @returns the signed distance (float) from the given point to the Plane.
  73285. */
  73286. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  73287. /**
  73288. * Creates a plane from an array
  73289. * @param array the array to create a plane from
  73290. * @returns a new Plane from the given array.
  73291. */
  73292. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  73293. /**
  73294. * Creates a plane from three points
  73295. * @param point1 point used to create the plane
  73296. * @param point2 point used to create the plane
  73297. * @param point3 point used to create the plane
  73298. * @returns a new Plane defined by the three given points.
  73299. */
  73300. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73301. /**
  73302. * Creates a plane from an origin point and a normal
  73303. * @param origin origin of the plane to be constructed
  73304. * @param normal normal of the plane to be constructed
  73305. * @returns a new Plane the normal vector to this plane at the given origin point.
  73306. * Note : the vector "normal" is updated because normalized.
  73307. */
  73308. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  73309. /**
  73310. * Calculates the distance from a plane and a point
  73311. * @param origin origin of the plane to be constructed
  73312. * @param normal normal of the plane to be constructed
  73313. * @param point point to calculate distance to
  73314. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73315. */
  73316. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  73317. }
  73318. }
  73319. declare module BABYLON {
  73320. /**
  73321. * Class used to store bounding sphere information
  73322. */
  73323. export class BoundingSphere {
  73324. /**
  73325. * Gets the center of the bounding sphere in local space
  73326. */
  73327. readonly center: Vector3;
  73328. /**
  73329. * Radius of the bounding sphere in local space
  73330. */
  73331. radius: number;
  73332. /**
  73333. * Gets the center of the bounding sphere in world space
  73334. */
  73335. readonly centerWorld: Vector3;
  73336. /**
  73337. * Radius of the bounding sphere in world space
  73338. */
  73339. radiusWorld: number;
  73340. /**
  73341. * Gets the minimum vector in local space
  73342. */
  73343. readonly minimum: Vector3;
  73344. /**
  73345. * Gets the maximum vector in local space
  73346. */
  73347. readonly maximum: Vector3;
  73348. private _worldMatrix;
  73349. private static readonly TmpVector3;
  73350. /**
  73351. * Creates a new bounding sphere
  73352. * @param min defines the minimum vector (in local space)
  73353. * @param max defines the maximum vector (in local space)
  73354. * @param worldMatrix defines the new world matrix
  73355. */
  73356. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73357. /**
  73358. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  73359. * @param min defines the new minimum vector (in local space)
  73360. * @param max defines the new maximum vector (in local space)
  73361. * @param worldMatrix defines the new world matrix
  73362. */
  73363. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73364. /**
  73365. * Scale the current bounding sphere by applying a scale factor
  73366. * @param factor defines the scale factor to apply
  73367. * @returns the current bounding box
  73368. */
  73369. scale(factor: number): BoundingSphere;
  73370. /**
  73371. * Gets the world matrix of the bounding box
  73372. * @returns a matrix
  73373. */
  73374. getWorldMatrix(): DeepImmutable<Matrix>;
  73375. /** @hidden */
  73376. _update(worldMatrix: DeepImmutable<Matrix>): void;
  73377. /**
  73378. * Tests if the bounding sphere is intersecting the frustum planes
  73379. * @param frustumPlanes defines the frustum planes to test
  73380. * @returns true if there is an intersection
  73381. */
  73382. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73383. /**
  73384. * Tests if the bounding sphere center is in between the frustum planes.
  73385. * Used for optimistic fast inclusion.
  73386. * @param frustumPlanes defines the frustum planes to test
  73387. * @returns true if the sphere center is in between the frustum planes
  73388. */
  73389. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73390. /**
  73391. * Tests if a point is inside the bounding sphere
  73392. * @param point defines the point to test
  73393. * @returns true if the point is inside the bounding sphere
  73394. */
  73395. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73396. /**
  73397. * Checks if two sphere intersct
  73398. * @param sphere0 sphere 0
  73399. * @param sphere1 sphere 1
  73400. * @returns true if the speres intersect
  73401. */
  73402. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  73403. }
  73404. }
  73405. declare module BABYLON {
  73406. /**
  73407. * Class used to store bounding box information
  73408. */
  73409. export class BoundingBox implements ICullable {
  73410. /**
  73411. * Gets the 8 vectors representing the bounding box in local space
  73412. */
  73413. readonly vectors: Vector3[];
  73414. /**
  73415. * Gets the center of the bounding box in local space
  73416. */
  73417. readonly center: Vector3;
  73418. /**
  73419. * Gets the center of the bounding box in world space
  73420. */
  73421. readonly centerWorld: Vector3;
  73422. /**
  73423. * Gets the extend size in local space
  73424. */
  73425. readonly extendSize: Vector3;
  73426. /**
  73427. * Gets the extend size in world space
  73428. */
  73429. readonly extendSizeWorld: Vector3;
  73430. /**
  73431. * Gets the OBB (object bounding box) directions
  73432. */
  73433. readonly directions: Vector3[];
  73434. /**
  73435. * Gets the 8 vectors representing the bounding box in world space
  73436. */
  73437. readonly vectorsWorld: Vector3[];
  73438. /**
  73439. * Gets the minimum vector in world space
  73440. */
  73441. readonly minimumWorld: Vector3;
  73442. /**
  73443. * Gets the maximum vector in world space
  73444. */
  73445. readonly maximumWorld: Vector3;
  73446. /**
  73447. * Gets the minimum vector in local space
  73448. */
  73449. readonly minimum: Vector3;
  73450. /**
  73451. * Gets the maximum vector in local space
  73452. */
  73453. readonly maximum: Vector3;
  73454. private _worldMatrix;
  73455. private static readonly TmpVector3;
  73456. /**
  73457. * @hidden
  73458. */
  73459. _tag: number;
  73460. /**
  73461. * Creates a new bounding box
  73462. * @param min defines the minimum vector (in local space)
  73463. * @param max defines the maximum vector (in local space)
  73464. * @param worldMatrix defines the new world matrix
  73465. */
  73466. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73467. /**
  73468. * Recreates the entire bounding box from scratch as if we call the constructor in place
  73469. * @param min defines the new minimum vector (in local space)
  73470. * @param max defines the new maximum vector (in local space)
  73471. * @param worldMatrix defines the new world matrix
  73472. */
  73473. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73474. /**
  73475. * Scale the current bounding box by applying a scale factor
  73476. * @param factor defines the scale factor to apply
  73477. * @returns the current bounding box
  73478. */
  73479. scale(factor: number): BoundingBox;
  73480. /**
  73481. * Gets the world matrix of the bounding box
  73482. * @returns a matrix
  73483. */
  73484. getWorldMatrix(): DeepImmutable<Matrix>;
  73485. /** @hidden */
  73486. _update(world: DeepImmutable<Matrix>): void;
  73487. /**
  73488. * Tests if the bounding box is intersecting the frustum planes
  73489. * @param frustumPlanes defines the frustum planes to test
  73490. * @returns true if there is an intersection
  73491. */
  73492. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73493. /**
  73494. * Tests if the bounding box is entirely inside the frustum planes
  73495. * @param frustumPlanes defines the frustum planes to test
  73496. * @returns true if there is an inclusion
  73497. */
  73498. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73499. /**
  73500. * Tests if a point is inside the bounding box
  73501. * @param point defines the point to test
  73502. * @returns true if the point is inside the bounding box
  73503. */
  73504. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73505. /**
  73506. * Tests if the bounding box intersects with a bounding sphere
  73507. * @param sphere defines the sphere to test
  73508. * @returns true if there is an intersection
  73509. */
  73510. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  73511. /**
  73512. * Tests if the bounding box intersects with a box defined by a min and max vectors
  73513. * @param min defines the min vector to use
  73514. * @param max defines the max vector to use
  73515. * @returns true if there is an intersection
  73516. */
  73517. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  73518. /**
  73519. * Tests if two bounding boxes are intersections
  73520. * @param box0 defines the first box to test
  73521. * @param box1 defines the second box to test
  73522. * @returns true if there is an intersection
  73523. */
  73524. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  73525. /**
  73526. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  73527. * @param minPoint defines the minimum vector of the bounding box
  73528. * @param maxPoint defines the maximum vector of the bounding box
  73529. * @param sphereCenter defines the sphere center
  73530. * @param sphereRadius defines the sphere radius
  73531. * @returns true if there is an intersection
  73532. */
  73533. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  73534. /**
  73535. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  73536. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73537. * @param frustumPlanes defines the frustum planes to test
  73538. * @return true if there is an inclusion
  73539. */
  73540. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73541. /**
  73542. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  73543. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73544. * @param frustumPlanes defines the frustum planes to test
  73545. * @return true if there is an intersection
  73546. */
  73547. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73548. }
  73549. }
  73550. declare module BABYLON {
  73551. /** @hidden */
  73552. export class Collider {
  73553. /** Define if a collision was found */
  73554. collisionFound: boolean;
  73555. /**
  73556. * Define last intersection point in local space
  73557. */
  73558. intersectionPoint: Vector3;
  73559. /**
  73560. * Define last collided mesh
  73561. */
  73562. collidedMesh: Nullable<AbstractMesh>;
  73563. private _collisionPoint;
  73564. private _planeIntersectionPoint;
  73565. private _tempVector;
  73566. private _tempVector2;
  73567. private _tempVector3;
  73568. private _tempVector4;
  73569. private _edge;
  73570. private _baseToVertex;
  73571. private _destinationPoint;
  73572. private _slidePlaneNormal;
  73573. private _displacementVector;
  73574. /** @hidden */
  73575. _radius: Vector3;
  73576. /** @hidden */
  73577. _retry: number;
  73578. private _velocity;
  73579. private _basePoint;
  73580. private _epsilon;
  73581. /** @hidden */
  73582. _velocityWorldLength: number;
  73583. /** @hidden */
  73584. _basePointWorld: Vector3;
  73585. private _velocityWorld;
  73586. private _normalizedVelocity;
  73587. /** @hidden */
  73588. _initialVelocity: Vector3;
  73589. /** @hidden */
  73590. _initialPosition: Vector3;
  73591. private _nearestDistance;
  73592. private _collisionMask;
  73593. collisionMask: number;
  73594. /**
  73595. * Gets the plane normal used to compute the sliding response (in local space)
  73596. */
  73597. readonly slidePlaneNormal: Vector3;
  73598. /** @hidden */
  73599. _initialize(source: Vector3, dir: Vector3, e: number): void;
  73600. /** @hidden */
  73601. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  73602. /** @hidden */
  73603. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  73604. /** @hidden */
  73605. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73606. /** @hidden */
  73607. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73608. /** @hidden */
  73609. _getResponse(pos: Vector3, vel: Vector3): void;
  73610. }
  73611. }
  73612. declare module BABYLON {
  73613. /**
  73614. * Interface for cullable objects
  73615. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  73616. */
  73617. export interface ICullable {
  73618. /**
  73619. * Checks if the object or part of the object is in the frustum
  73620. * @param frustumPlanes Camera near/planes
  73621. * @returns true if the object is in frustum otherwise false
  73622. */
  73623. isInFrustum(frustumPlanes: Plane[]): boolean;
  73624. /**
  73625. * Checks if a cullable object (mesh...) is in the camera frustum
  73626. * Unlike isInFrustum this cheks the full bounding box
  73627. * @param frustumPlanes Camera near/planes
  73628. * @returns true if the object is in frustum otherwise false
  73629. */
  73630. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  73631. }
  73632. /**
  73633. * Info for a bounding data of a mesh
  73634. */
  73635. export class BoundingInfo implements ICullable {
  73636. /**
  73637. * Bounding box for the mesh
  73638. */
  73639. readonly boundingBox: BoundingBox;
  73640. /**
  73641. * Bounding sphere for the mesh
  73642. */
  73643. readonly boundingSphere: BoundingSphere;
  73644. private _isLocked;
  73645. private static readonly TmpVector3;
  73646. /**
  73647. * Constructs bounding info
  73648. * @param minimum min vector of the bounding box/sphere
  73649. * @param maximum max vector of the bounding box/sphere
  73650. * @param worldMatrix defines the new world matrix
  73651. */
  73652. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73653. /**
  73654. * Recreates the entire bounding info from scratch as if we call the constructor in place
  73655. * @param min defines the new minimum vector (in local space)
  73656. * @param max defines the new maximum vector (in local space)
  73657. * @param worldMatrix defines the new world matrix
  73658. */
  73659. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73660. /**
  73661. * min vector of the bounding box/sphere
  73662. */
  73663. readonly minimum: Vector3;
  73664. /**
  73665. * max vector of the bounding box/sphere
  73666. */
  73667. readonly maximum: Vector3;
  73668. /**
  73669. * If the info is locked and won't be updated to avoid perf overhead
  73670. */
  73671. isLocked: boolean;
  73672. /**
  73673. * Updates the bounding sphere and box
  73674. * @param world world matrix to be used to update
  73675. */
  73676. update(world: DeepImmutable<Matrix>): void;
  73677. /**
  73678. * Recreate the bounding info to be centered around a specific point given a specific extend.
  73679. * @param center New center of the bounding info
  73680. * @param extend New extend of the bounding info
  73681. * @returns the current bounding info
  73682. */
  73683. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  73684. /**
  73685. * Scale the current bounding info by applying a scale factor
  73686. * @param factor defines the scale factor to apply
  73687. * @returns the current bounding info
  73688. */
  73689. scale(factor: number): BoundingInfo;
  73690. /**
  73691. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  73692. * @param frustumPlanes defines the frustum to test
  73693. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73694. * @returns true if the bounding info is in the frustum planes
  73695. */
  73696. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73697. /**
  73698. * Gets the world distance between the min and max points of the bounding box
  73699. */
  73700. readonly diagonalLength: number;
  73701. /**
  73702. * Checks if a cullable object (mesh...) is in the camera frustum
  73703. * Unlike isInFrustum this cheks the full bounding box
  73704. * @param frustumPlanes Camera near/planes
  73705. * @returns true if the object is in frustum otherwise false
  73706. */
  73707. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73708. /** @hidden */
  73709. _checkCollision(collider: Collider): boolean;
  73710. /**
  73711. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73712. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73713. * @param point the point to check intersection with
  73714. * @returns if the point intersects
  73715. */
  73716. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73717. /**
  73718. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73719. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73720. * @param boundingInfo the bounding info to check intersection with
  73721. * @param precise if the intersection should be done using OBB
  73722. * @returns if the bounding info intersects
  73723. */
  73724. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73725. }
  73726. }
  73727. declare module BABYLON {
  73728. /**
  73729. * Extracts minimum and maximum values from a list of indexed positions
  73730. * @param positions defines the positions to use
  73731. * @param indices defines the indices to the positions
  73732. * @param indexStart defines the start index
  73733. * @param indexCount defines the end index
  73734. * @param bias defines bias value to add to the result
  73735. * @return minimum and maximum values
  73736. */
  73737. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73738. minimum: Vector3;
  73739. maximum: Vector3;
  73740. };
  73741. /**
  73742. * Extracts minimum and maximum values from a list of positions
  73743. * @param positions defines the positions to use
  73744. * @param start defines the start index in the positions array
  73745. * @param count defines the number of positions to handle
  73746. * @param bias defines bias value to add to the result
  73747. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73748. * @return minimum and maximum values
  73749. */
  73750. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73751. minimum: Vector3;
  73752. maximum: Vector3;
  73753. };
  73754. }
  73755. declare module BABYLON {
  73756. /** @hidden */
  73757. export class WebGLDataBuffer extends DataBuffer {
  73758. private _buffer;
  73759. constructor(resource: WebGLBuffer);
  73760. readonly underlyingResource: any;
  73761. }
  73762. }
  73763. declare module BABYLON {
  73764. /** @hidden */
  73765. export class WebGLPipelineContext implements IPipelineContext {
  73766. engine: ThinEngine;
  73767. program: Nullable<WebGLProgram>;
  73768. context?: WebGLRenderingContext;
  73769. vertexShader?: WebGLShader;
  73770. fragmentShader?: WebGLShader;
  73771. isParallelCompiled: boolean;
  73772. onCompiled?: () => void;
  73773. transformFeedback?: WebGLTransformFeedback | null;
  73774. readonly isAsync: boolean;
  73775. readonly isReady: boolean;
  73776. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  73777. }
  73778. }
  73779. declare module BABYLON {
  73780. interface ThinEngine {
  73781. /**
  73782. * Create an uniform buffer
  73783. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73784. * @param elements defines the content of the uniform buffer
  73785. * @returns the webGL uniform buffer
  73786. */
  73787. createUniformBuffer(elements: FloatArray): DataBuffer;
  73788. /**
  73789. * Create a dynamic uniform buffer
  73790. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73791. * @param elements defines the content of the uniform buffer
  73792. * @returns the webGL uniform buffer
  73793. */
  73794. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  73795. /**
  73796. * Update an existing uniform buffer
  73797. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73798. * @param uniformBuffer defines the target uniform buffer
  73799. * @param elements defines the content to update
  73800. * @param offset defines the offset in the uniform buffer where update should start
  73801. * @param count defines the size of the data to update
  73802. */
  73803. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  73804. /**
  73805. * Bind an uniform buffer to the current webGL context
  73806. * @param buffer defines the buffer to bind
  73807. */
  73808. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  73809. /**
  73810. * Bind a buffer to the current webGL context at a given location
  73811. * @param buffer defines the buffer to bind
  73812. * @param location defines the index where to bind the buffer
  73813. */
  73814. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  73815. /**
  73816. * Bind a specific block at a given index in a specific shader program
  73817. * @param pipelineContext defines the pipeline context to use
  73818. * @param blockName defines the block name
  73819. * @param index defines the index where to bind the block
  73820. */
  73821. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  73822. }
  73823. }
  73824. declare module BABYLON {
  73825. /**
  73826. * Uniform buffer objects.
  73827. *
  73828. * Handles blocks of uniform on the GPU.
  73829. *
  73830. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73831. *
  73832. * For more information, please refer to :
  73833. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73834. */
  73835. export class UniformBuffer {
  73836. private _engine;
  73837. private _buffer;
  73838. private _data;
  73839. private _bufferData;
  73840. private _dynamic?;
  73841. private _uniformLocations;
  73842. private _uniformSizes;
  73843. private _uniformLocationPointer;
  73844. private _needSync;
  73845. private _noUBO;
  73846. private _currentEffect;
  73847. private static _MAX_UNIFORM_SIZE;
  73848. private static _tempBuffer;
  73849. /**
  73850. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  73851. * This is dynamic to allow compat with webgl 1 and 2.
  73852. * You will need to pass the name of the uniform as well as the value.
  73853. */
  73854. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  73855. /**
  73856. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  73857. * This is dynamic to allow compat with webgl 1 and 2.
  73858. * You will need to pass the name of the uniform as well as the value.
  73859. */
  73860. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  73861. /**
  73862. * Lambda to Update a single float in a uniform buffer.
  73863. * This is dynamic to allow compat with webgl 1 and 2.
  73864. * You will need to pass the name of the uniform as well as the value.
  73865. */
  73866. updateFloat: (name: string, x: number) => void;
  73867. /**
  73868. * Lambda to Update a vec2 of float in a uniform buffer.
  73869. * This is dynamic to allow compat with webgl 1 and 2.
  73870. * You will need to pass the name of the uniform as well as the value.
  73871. */
  73872. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  73873. /**
  73874. * Lambda to Update a vec3 of float in a uniform buffer.
  73875. * This is dynamic to allow compat with webgl 1 and 2.
  73876. * You will need to pass the name of the uniform as well as the value.
  73877. */
  73878. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  73879. /**
  73880. * Lambda to Update a vec4 of float in a uniform buffer.
  73881. * This is dynamic to allow compat with webgl 1 and 2.
  73882. * You will need to pass the name of the uniform as well as the value.
  73883. */
  73884. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  73885. /**
  73886. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  73887. * This is dynamic to allow compat with webgl 1 and 2.
  73888. * You will need to pass the name of the uniform as well as the value.
  73889. */
  73890. updateMatrix: (name: string, mat: Matrix) => void;
  73891. /**
  73892. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  73893. * This is dynamic to allow compat with webgl 1 and 2.
  73894. * You will need to pass the name of the uniform as well as the value.
  73895. */
  73896. updateVector3: (name: string, vector: Vector3) => void;
  73897. /**
  73898. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  73899. * This is dynamic to allow compat with webgl 1 and 2.
  73900. * You will need to pass the name of the uniform as well as the value.
  73901. */
  73902. updateVector4: (name: string, vector: Vector4) => void;
  73903. /**
  73904. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  73905. * This is dynamic to allow compat with webgl 1 and 2.
  73906. * You will need to pass the name of the uniform as well as the value.
  73907. */
  73908. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  73909. /**
  73910. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  73911. * This is dynamic to allow compat with webgl 1 and 2.
  73912. * You will need to pass the name of the uniform as well as the value.
  73913. */
  73914. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  73915. /**
  73916. * Instantiates a new Uniform buffer objects.
  73917. *
  73918. * Handles blocks of uniform on the GPU.
  73919. *
  73920. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73921. *
  73922. * For more information, please refer to :
  73923. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73924. * @param engine Define the engine the buffer is associated with
  73925. * @param data Define the data contained in the buffer
  73926. * @param dynamic Define if the buffer is updatable
  73927. */
  73928. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  73929. /**
  73930. * Indicates if the buffer is using the WebGL2 UBO implementation,
  73931. * or just falling back on setUniformXXX calls.
  73932. */
  73933. readonly useUbo: boolean;
  73934. /**
  73935. * Indicates if the WebGL underlying uniform buffer is in sync
  73936. * with the javascript cache data.
  73937. */
  73938. readonly isSync: boolean;
  73939. /**
  73940. * Indicates if the WebGL underlying uniform buffer is dynamic.
  73941. * Also, a dynamic UniformBuffer will disable cache verification and always
  73942. * update the underlying WebGL uniform buffer to the GPU.
  73943. * @returns if Dynamic, otherwise false
  73944. */
  73945. isDynamic(): boolean;
  73946. /**
  73947. * The data cache on JS side.
  73948. * @returns the underlying data as a float array
  73949. */
  73950. getData(): Float32Array;
  73951. /**
  73952. * The underlying WebGL Uniform buffer.
  73953. * @returns the webgl buffer
  73954. */
  73955. getBuffer(): Nullable<DataBuffer>;
  73956. /**
  73957. * std140 layout specifies how to align data within an UBO structure.
  73958. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  73959. * for specs.
  73960. */
  73961. private _fillAlignment;
  73962. /**
  73963. * Adds an uniform in the buffer.
  73964. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  73965. * for the layout to be correct !
  73966. * @param name Name of the uniform, as used in the uniform block in the shader.
  73967. * @param size Data size, or data directly.
  73968. */
  73969. addUniform(name: string, size: number | number[]): void;
  73970. /**
  73971. * Adds a Matrix 4x4 to the uniform buffer.
  73972. * @param name Name of the uniform, as used in the uniform block in the shader.
  73973. * @param mat A 4x4 matrix.
  73974. */
  73975. addMatrix(name: string, mat: Matrix): void;
  73976. /**
  73977. * Adds a vec2 to the uniform buffer.
  73978. * @param name Name of the uniform, as used in the uniform block in the shader.
  73979. * @param x Define the x component value of the vec2
  73980. * @param y Define the y component value of the vec2
  73981. */
  73982. addFloat2(name: string, x: number, y: number): void;
  73983. /**
  73984. * Adds a vec3 to the uniform buffer.
  73985. * @param name Name of the uniform, as used in the uniform block in the shader.
  73986. * @param x Define the x component value of the vec3
  73987. * @param y Define the y component value of the vec3
  73988. * @param z Define the z component value of the vec3
  73989. */
  73990. addFloat3(name: string, x: number, y: number, z: number): void;
  73991. /**
  73992. * Adds a vec3 to the uniform buffer.
  73993. * @param name Name of the uniform, as used in the uniform block in the shader.
  73994. * @param color Define the vec3 from a Color
  73995. */
  73996. addColor3(name: string, color: Color3): void;
  73997. /**
  73998. * Adds a vec4 to the uniform buffer.
  73999. * @param name Name of the uniform, as used in the uniform block in the shader.
  74000. * @param color Define the rgb components from a Color
  74001. * @param alpha Define the a component of the vec4
  74002. */
  74003. addColor4(name: string, color: Color3, alpha: number): void;
  74004. /**
  74005. * Adds a vec3 to the uniform buffer.
  74006. * @param name Name of the uniform, as used in the uniform block in the shader.
  74007. * @param vector Define the vec3 components from a Vector
  74008. */
  74009. addVector3(name: string, vector: Vector3): void;
  74010. /**
  74011. * Adds a Matrix 3x3 to the uniform buffer.
  74012. * @param name Name of the uniform, as used in the uniform block in the shader.
  74013. */
  74014. addMatrix3x3(name: string): void;
  74015. /**
  74016. * Adds a Matrix 2x2 to the uniform buffer.
  74017. * @param name Name of the uniform, as used in the uniform block in the shader.
  74018. */
  74019. addMatrix2x2(name: string): void;
  74020. /**
  74021. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  74022. */
  74023. create(): void;
  74024. /** @hidden */
  74025. _rebuild(): void;
  74026. /**
  74027. * Updates the WebGL Uniform Buffer on the GPU.
  74028. * If the `dynamic` flag is set to true, no cache comparison is done.
  74029. * Otherwise, the buffer will be updated only if the cache differs.
  74030. */
  74031. update(): void;
  74032. /**
  74033. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  74034. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74035. * @param data Define the flattened data
  74036. * @param size Define the size of the data.
  74037. */
  74038. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  74039. private _valueCache;
  74040. private _cacheMatrix;
  74041. private _updateMatrix3x3ForUniform;
  74042. private _updateMatrix3x3ForEffect;
  74043. private _updateMatrix2x2ForEffect;
  74044. private _updateMatrix2x2ForUniform;
  74045. private _updateFloatForEffect;
  74046. private _updateFloatForUniform;
  74047. private _updateFloat2ForEffect;
  74048. private _updateFloat2ForUniform;
  74049. private _updateFloat3ForEffect;
  74050. private _updateFloat3ForUniform;
  74051. private _updateFloat4ForEffect;
  74052. private _updateFloat4ForUniform;
  74053. private _updateMatrixForEffect;
  74054. private _updateMatrixForUniform;
  74055. private _updateVector3ForEffect;
  74056. private _updateVector3ForUniform;
  74057. private _updateVector4ForEffect;
  74058. private _updateVector4ForUniform;
  74059. private _updateColor3ForEffect;
  74060. private _updateColor3ForUniform;
  74061. private _updateColor4ForEffect;
  74062. private _updateColor4ForUniform;
  74063. /**
  74064. * Sets a sampler uniform on the effect.
  74065. * @param name Define the name of the sampler.
  74066. * @param texture Define the texture to set in the sampler
  74067. */
  74068. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  74069. /**
  74070. * Directly updates the value of the uniform in the cache AND on the GPU.
  74071. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74072. * @param data Define the flattened data
  74073. */
  74074. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  74075. /**
  74076. * Binds this uniform buffer to an effect.
  74077. * @param effect Define the effect to bind the buffer to
  74078. * @param name Name of the uniform block in the shader.
  74079. */
  74080. bindToEffect(effect: Effect, name: string): void;
  74081. /**
  74082. * Disposes the uniform buffer.
  74083. */
  74084. dispose(): void;
  74085. }
  74086. }
  74087. declare module BABYLON {
  74088. /**
  74089. * Enum that determines the text-wrapping mode to use.
  74090. */
  74091. export enum InspectableType {
  74092. /**
  74093. * Checkbox for booleans
  74094. */
  74095. Checkbox = 0,
  74096. /**
  74097. * Sliders for numbers
  74098. */
  74099. Slider = 1,
  74100. /**
  74101. * Vector3
  74102. */
  74103. Vector3 = 2,
  74104. /**
  74105. * Quaternions
  74106. */
  74107. Quaternion = 3,
  74108. /**
  74109. * Color3
  74110. */
  74111. Color3 = 4,
  74112. /**
  74113. * String
  74114. */
  74115. String = 5
  74116. }
  74117. /**
  74118. * Interface used to define custom inspectable properties.
  74119. * This interface is used by the inspector to display custom property grids
  74120. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74121. */
  74122. export interface IInspectable {
  74123. /**
  74124. * Gets the label to display
  74125. */
  74126. label: string;
  74127. /**
  74128. * Gets the name of the property to edit
  74129. */
  74130. propertyName: string;
  74131. /**
  74132. * Gets the type of the editor to use
  74133. */
  74134. type: InspectableType;
  74135. /**
  74136. * Gets the minimum value of the property when using in "slider" mode
  74137. */
  74138. min?: number;
  74139. /**
  74140. * Gets the maximum value of the property when using in "slider" mode
  74141. */
  74142. max?: number;
  74143. /**
  74144. * Gets the setp to use when using in "slider" mode
  74145. */
  74146. step?: number;
  74147. }
  74148. }
  74149. declare module BABYLON {
  74150. /**
  74151. * Class used to provide helper for timing
  74152. */
  74153. export class TimingTools {
  74154. /**
  74155. * Polyfill for setImmediate
  74156. * @param action defines the action to execute after the current execution block
  74157. */
  74158. static SetImmediate(action: () => void): void;
  74159. }
  74160. }
  74161. declare module BABYLON {
  74162. /**
  74163. * Class used to enable instatition of objects by class name
  74164. */
  74165. export class InstantiationTools {
  74166. /**
  74167. * Use this object to register external classes like custom textures or material
  74168. * to allow the laoders to instantiate them
  74169. */
  74170. static RegisteredExternalClasses: {
  74171. [key: string]: Object;
  74172. };
  74173. /**
  74174. * Tries to instantiate a new object from a given class name
  74175. * @param className defines the class name to instantiate
  74176. * @returns the new object or null if the system was not able to do the instantiation
  74177. */
  74178. static Instantiate(className: string): any;
  74179. }
  74180. }
  74181. declare module BABYLON {
  74182. /**
  74183. * Define options used to create a depth texture
  74184. */
  74185. export class DepthTextureCreationOptions {
  74186. /** Specifies whether or not a stencil should be allocated in the texture */
  74187. generateStencil?: boolean;
  74188. /** Specifies whether or not bilinear filtering is enable on the texture */
  74189. bilinearFiltering?: boolean;
  74190. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  74191. comparisonFunction?: number;
  74192. /** Specifies if the created texture is a cube texture */
  74193. isCube?: boolean;
  74194. }
  74195. }
  74196. declare module BABYLON {
  74197. interface ThinEngine {
  74198. /**
  74199. * Creates a depth stencil cube texture.
  74200. * This is only available in WebGL 2.
  74201. * @param size The size of face edge in the cube texture.
  74202. * @param options The options defining the cube texture.
  74203. * @returns The cube texture
  74204. */
  74205. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  74206. /**
  74207. * Creates a cube texture
  74208. * @param rootUrl defines the url where the files to load is located
  74209. * @param scene defines the current scene
  74210. * @param files defines the list of files to load (1 per face)
  74211. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74212. * @param onLoad defines an optional callback raised when the texture is loaded
  74213. * @param onError defines an optional callback raised if there is an issue to load the texture
  74214. * @param format defines the format of the data
  74215. * @param forcedExtension defines the extension to use to pick the right loader
  74216. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74217. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74218. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74219. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  74220. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  74221. * @returns the cube texture as an InternalTexture
  74222. */
  74223. 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;
  74224. /**
  74225. * Creates a cube texture
  74226. * @param rootUrl defines the url where the files to load is located
  74227. * @param scene defines the current scene
  74228. * @param files defines the list of files to load (1 per face)
  74229. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74230. * @param onLoad defines an optional callback raised when the texture is loaded
  74231. * @param onError defines an optional callback raised if there is an issue to load the texture
  74232. * @param format defines the format of the data
  74233. * @param forcedExtension defines the extension to use to pick the right loader
  74234. * @returns the cube texture as an InternalTexture
  74235. */
  74236. 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;
  74237. /**
  74238. * Creates a cube texture
  74239. * @param rootUrl defines the url where the files to load is located
  74240. * @param scene defines the current scene
  74241. * @param files defines the list of files to load (1 per face)
  74242. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74243. * @param onLoad defines an optional callback raised when the texture is loaded
  74244. * @param onError defines an optional callback raised if there is an issue to load the texture
  74245. * @param format defines the format of the data
  74246. * @param forcedExtension defines the extension to use to pick the right loader
  74247. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74248. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74249. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74250. * @returns the cube texture as an InternalTexture
  74251. */
  74252. 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;
  74253. /** @hidden */
  74254. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74255. /** @hidden */
  74256. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74257. /** @hidden */
  74258. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74259. /** @hidden */
  74260. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74261. }
  74262. }
  74263. declare module BABYLON {
  74264. /**
  74265. * Class for creating a cube texture
  74266. */
  74267. export class CubeTexture extends BaseTexture {
  74268. private _delayedOnLoad;
  74269. /**
  74270. * The url of the texture
  74271. */
  74272. url: string;
  74273. /**
  74274. * Gets or sets the center of the bounding box associated with the cube texture.
  74275. * It must define where the camera used to render the texture was set
  74276. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74277. */
  74278. boundingBoxPosition: Vector3;
  74279. private _boundingBoxSize;
  74280. /**
  74281. * Gets or sets the size of the bounding box associated with the cube texture
  74282. * When defined, the cubemap will switch to local mode
  74283. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74284. * @example https://www.babylonjs-playground.com/#RNASML
  74285. */
  74286. /**
  74287. * Returns the bounding box size
  74288. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74289. */
  74290. boundingBoxSize: Vector3;
  74291. protected _rotationY: number;
  74292. /**
  74293. * Sets texture matrix rotation angle around Y axis in radians.
  74294. */
  74295. /**
  74296. * Gets texture matrix rotation angle around Y axis radians.
  74297. */
  74298. rotationY: number;
  74299. /**
  74300. * Are mip maps generated for this texture or not.
  74301. */
  74302. readonly noMipmap: boolean;
  74303. private _noMipmap;
  74304. private _files;
  74305. protected _forcedExtension: Nullable<string>;
  74306. private _extensions;
  74307. private _textureMatrix;
  74308. private _format;
  74309. private _createPolynomials;
  74310. /** @hidden */
  74311. _prefiltered: boolean;
  74312. /**
  74313. * Creates a cube texture from an array of image urls
  74314. * @param files defines an array of image urls
  74315. * @param scene defines the hosting scene
  74316. * @param noMipmap specifies if mip maps are not used
  74317. * @returns a cube texture
  74318. */
  74319. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  74320. /**
  74321. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  74322. * @param url defines the url of the prefiltered texture
  74323. * @param scene defines the scene the texture is attached to
  74324. * @param forcedExtension defines the extension of the file if different from the url
  74325. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74326. * @return the prefiltered texture
  74327. */
  74328. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  74329. /**
  74330. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  74331. * as prefiltered data.
  74332. * @param rootUrl defines the url of the texture or the root name of the six images
  74333. * @param scene defines the scene the texture is attached to
  74334. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  74335. * @param noMipmap defines if mipmaps should be created or not
  74336. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  74337. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  74338. * @param onError defines a callback triggered in case of error during load
  74339. * @param format defines the internal format to use for the texture once loaded
  74340. * @param prefiltered defines whether or not the texture is created from prefiltered data
  74341. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  74342. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74343. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74344. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74345. * @return the cube texture
  74346. */
  74347. 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);
  74348. /**
  74349. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  74350. */
  74351. readonly isPrefiltered: boolean;
  74352. /**
  74353. * Get the current class name of the texture useful for serialization or dynamic coding.
  74354. * @returns "CubeTexture"
  74355. */
  74356. getClassName(): string;
  74357. /**
  74358. * Update the url (and optional buffer) of this texture if url was null during construction.
  74359. * @param url the url of the texture
  74360. * @param forcedExtension defines the extension to use
  74361. * @param onLoad callback called when the texture is loaded (defaults to null)
  74362. */
  74363. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  74364. /**
  74365. * Delays loading of the cube texture
  74366. * @param forcedExtension defines the extension to use
  74367. */
  74368. delayLoad(forcedExtension?: string): void;
  74369. /**
  74370. * Returns the reflection texture matrix
  74371. * @returns the reflection texture matrix
  74372. */
  74373. getReflectionTextureMatrix(): Matrix;
  74374. /**
  74375. * Sets the reflection texture matrix
  74376. * @param value Reflection texture matrix
  74377. */
  74378. setReflectionTextureMatrix(value: Matrix): void;
  74379. /**
  74380. * Parses text to create a cube texture
  74381. * @param parsedTexture define the serialized text to read from
  74382. * @param scene defines the hosting scene
  74383. * @param rootUrl defines the root url of the cube texture
  74384. * @returns a cube texture
  74385. */
  74386. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  74387. /**
  74388. * Makes a clone, or deep copy, of the cube texture
  74389. * @returns a new cube texture
  74390. */
  74391. clone(): CubeTexture;
  74392. }
  74393. }
  74394. declare module BABYLON {
  74395. /**
  74396. * Manages the defines for the Material
  74397. */
  74398. export class MaterialDefines {
  74399. /** @hidden */
  74400. protected _keys: string[];
  74401. private _isDirty;
  74402. /** @hidden */
  74403. _renderId: number;
  74404. /** @hidden */
  74405. _areLightsDirty: boolean;
  74406. /** @hidden */
  74407. _areLightsDisposed: boolean;
  74408. /** @hidden */
  74409. _areAttributesDirty: boolean;
  74410. /** @hidden */
  74411. _areTexturesDirty: boolean;
  74412. /** @hidden */
  74413. _areFresnelDirty: boolean;
  74414. /** @hidden */
  74415. _areMiscDirty: boolean;
  74416. /** @hidden */
  74417. _areImageProcessingDirty: boolean;
  74418. /** @hidden */
  74419. _normals: boolean;
  74420. /** @hidden */
  74421. _uvs: boolean;
  74422. /** @hidden */
  74423. _needNormals: boolean;
  74424. /** @hidden */
  74425. _needUVs: boolean;
  74426. [id: string]: any;
  74427. /**
  74428. * Specifies if the material needs to be re-calculated
  74429. */
  74430. readonly isDirty: boolean;
  74431. /**
  74432. * Marks the material to indicate that it has been re-calculated
  74433. */
  74434. markAsProcessed(): void;
  74435. /**
  74436. * Marks the material to indicate that it needs to be re-calculated
  74437. */
  74438. markAsUnprocessed(): void;
  74439. /**
  74440. * Marks the material to indicate all of its defines need to be re-calculated
  74441. */
  74442. markAllAsDirty(): void;
  74443. /**
  74444. * Marks the material to indicate that image processing needs to be re-calculated
  74445. */
  74446. markAsImageProcessingDirty(): void;
  74447. /**
  74448. * Marks the material to indicate the lights need to be re-calculated
  74449. * @param disposed Defines whether the light is dirty due to dispose or not
  74450. */
  74451. markAsLightDirty(disposed?: boolean): void;
  74452. /**
  74453. * Marks the attribute state as changed
  74454. */
  74455. markAsAttributesDirty(): void;
  74456. /**
  74457. * Marks the texture state as changed
  74458. */
  74459. markAsTexturesDirty(): void;
  74460. /**
  74461. * Marks the fresnel state as changed
  74462. */
  74463. markAsFresnelDirty(): void;
  74464. /**
  74465. * Marks the misc state as changed
  74466. */
  74467. markAsMiscDirty(): void;
  74468. /**
  74469. * Rebuilds the material defines
  74470. */
  74471. rebuild(): void;
  74472. /**
  74473. * Specifies if two material defines are equal
  74474. * @param other - A material define instance to compare to
  74475. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  74476. */
  74477. isEqual(other: MaterialDefines): boolean;
  74478. /**
  74479. * Clones this instance's defines to another instance
  74480. * @param other - material defines to clone values to
  74481. */
  74482. cloneTo(other: MaterialDefines): void;
  74483. /**
  74484. * Resets the material define values
  74485. */
  74486. reset(): void;
  74487. /**
  74488. * Converts the material define values to a string
  74489. * @returns - String of material define information
  74490. */
  74491. toString(): string;
  74492. }
  74493. }
  74494. declare module BABYLON {
  74495. /**
  74496. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  74497. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  74498. * 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;
  74499. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  74500. */
  74501. export class ColorCurves {
  74502. private _dirty;
  74503. private _tempColor;
  74504. private _globalCurve;
  74505. private _highlightsCurve;
  74506. private _midtonesCurve;
  74507. private _shadowsCurve;
  74508. private _positiveCurve;
  74509. private _negativeCurve;
  74510. private _globalHue;
  74511. private _globalDensity;
  74512. private _globalSaturation;
  74513. private _globalExposure;
  74514. /**
  74515. * Gets the global Hue value.
  74516. * 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).
  74517. */
  74518. /**
  74519. * Sets the global Hue value.
  74520. * 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).
  74521. */
  74522. globalHue: number;
  74523. /**
  74524. * Gets the global Density value.
  74525. * 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.
  74526. * Values less than zero provide a filter of opposite hue.
  74527. */
  74528. /**
  74529. * Sets the global Density value.
  74530. * 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.
  74531. * Values less than zero provide a filter of opposite hue.
  74532. */
  74533. globalDensity: number;
  74534. /**
  74535. * Gets the global Saturation value.
  74536. * 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.
  74537. */
  74538. /**
  74539. * Sets the global Saturation value.
  74540. * 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.
  74541. */
  74542. globalSaturation: number;
  74543. /**
  74544. * Gets the global Exposure value.
  74545. * 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.
  74546. */
  74547. /**
  74548. * Sets the global Exposure value.
  74549. * 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.
  74550. */
  74551. globalExposure: number;
  74552. private _highlightsHue;
  74553. private _highlightsDensity;
  74554. private _highlightsSaturation;
  74555. private _highlightsExposure;
  74556. /**
  74557. * Gets the highlights Hue value.
  74558. * 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).
  74559. */
  74560. /**
  74561. * Sets the highlights Hue value.
  74562. * 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).
  74563. */
  74564. highlightsHue: number;
  74565. /**
  74566. * Gets the highlights Density value.
  74567. * 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.
  74568. * Values less than zero provide a filter of opposite hue.
  74569. */
  74570. /**
  74571. * Sets the highlights Density value.
  74572. * 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.
  74573. * Values less than zero provide a filter of opposite hue.
  74574. */
  74575. highlightsDensity: number;
  74576. /**
  74577. * Gets the highlights Saturation value.
  74578. * 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.
  74579. */
  74580. /**
  74581. * Sets the highlights Saturation value.
  74582. * 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.
  74583. */
  74584. highlightsSaturation: number;
  74585. /**
  74586. * Gets the highlights Exposure value.
  74587. * 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.
  74588. */
  74589. /**
  74590. * Sets the highlights Exposure value.
  74591. * 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.
  74592. */
  74593. highlightsExposure: number;
  74594. private _midtonesHue;
  74595. private _midtonesDensity;
  74596. private _midtonesSaturation;
  74597. private _midtonesExposure;
  74598. /**
  74599. * Gets the midtones Hue value.
  74600. * 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).
  74601. */
  74602. /**
  74603. * Sets the midtones Hue value.
  74604. * 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).
  74605. */
  74606. midtonesHue: number;
  74607. /**
  74608. * Gets the midtones Density value.
  74609. * 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.
  74610. * Values less than zero provide a filter of opposite hue.
  74611. */
  74612. /**
  74613. * Sets the midtones Density value.
  74614. * 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.
  74615. * Values less than zero provide a filter of opposite hue.
  74616. */
  74617. midtonesDensity: number;
  74618. /**
  74619. * Gets the midtones Saturation value.
  74620. * 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.
  74621. */
  74622. /**
  74623. * Sets the midtones Saturation value.
  74624. * 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.
  74625. */
  74626. midtonesSaturation: number;
  74627. /**
  74628. * Gets the midtones Exposure value.
  74629. * 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.
  74630. */
  74631. /**
  74632. * Sets the midtones Exposure value.
  74633. * 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.
  74634. */
  74635. midtonesExposure: number;
  74636. private _shadowsHue;
  74637. private _shadowsDensity;
  74638. private _shadowsSaturation;
  74639. private _shadowsExposure;
  74640. /**
  74641. * Gets the shadows Hue value.
  74642. * 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).
  74643. */
  74644. /**
  74645. * Sets the shadows Hue value.
  74646. * 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).
  74647. */
  74648. shadowsHue: number;
  74649. /**
  74650. * Gets the shadows Density value.
  74651. * 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.
  74652. * Values less than zero provide a filter of opposite hue.
  74653. */
  74654. /**
  74655. * Sets the shadows Density value.
  74656. * 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.
  74657. * Values less than zero provide a filter of opposite hue.
  74658. */
  74659. shadowsDensity: number;
  74660. /**
  74661. * Gets the shadows Saturation value.
  74662. * 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.
  74663. */
  74664. /**
  74665. * Sets the shadows Saturation value.
  74666. * 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.
  74667. */
  74668. shadowsSaturation: number;
  74669. /**
  74670. * Gets the shadows Exposure value.
  74671. * 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.
  74672. */
  74673. /**
  74674. * Sets the shadows Exposure value.
  74675. * 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.
  74676. */
  74677. shadowsExposure: number;
  74678. /**
  74679. * Returns the class name
  74680. * @returns The class name
  74681. */
  74682. getClassName(): string;
  74683. /**
  74684. * Binds the color curves to the shader.
  74685. * @param colorCurves The color curve to bind
  74686. * @param effect The effect to bind to
  74687. * @param positiveUniform The positive uniform shader parameter
  74688. * @param neutralUniform The neutral uniform shader parameter
  74689. * @param negativeUniform The negative uniform shader parameter
  74690. */
  74691. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  74692. /**
  74693. * Prepare the list of uniforms associated with the ColorCurves effects.
  74694. * @param uniformsList The list of uniforms used in the effect
  74695. */
  74696. static PrepareUniforms(uniformsList: string[]): void;
  74697. /**
  74698. * Returns color grading data based on a hue, density, saturation and exposure value.
  74699. * @param filterHue The hue of the color filter.
  74700. * @param filterDensity The density of the color filter.
  74701. * @param saturation The saturation.
  74702. * @param exposure The exposure.
  74703. * @param result The result data container.
  74704. */
  74705. private getColorGradingDataToRef;
  74706. /**
  74707. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  74708. * @param value The input slider value in range [-100,100].
  74709. * @returns Adjusted value.
  74710. */
  74711. private static applyColorGradingSliderNonlinear;
  74712. /**
  74713. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  74714. * @param hue The hue (H) input.
  74715. * @param saturation The saturation (S) input.
  74716. * @param brightness The brightness (B) input.
  74717. * @result An RGBA color represented as Vector4.
  74718. */
  74719. private static fromHSBToRef;
  74720. /**
  74721. * Returns a value clamped between min and max
  74722. * @param value The value to clamp
  74723. * @param min The minimum of value
  74724. * @param max The maximum of value
  74725. * @returns The clamped value.
  74726. */
  74727. private static clamp;
  74728. /**
  74729. * Clones the current color curve instance.
  74730. * @return The cloned curves
  74731. */
  74732. clone(): ColorCurves;
  74733. /**
  74734. * Serializes the current color curve instance to a json representation.
  74735. * @return a JSON representation
  74736. */
  74737. serialize(): any;
  74738. /**
  74739. * Parses the color curve from a json representation.
  74740. * @param source the JSON source to parse
  74741. * @return The parsed curves
  74742. */
  74743. static Parse(source: any): ColorCurves;
  74744. }
  74745. }
  74746. declare module BABYLON {
  74747. /**
  74748. * Interface to follow in your material defines to integrate easily the
  74749. * Image proccessing functions.
  74750. * @hidden
  74751. */
  74752. export interface IImageProcessingConfigurationDefines {
  74753. IMAGEPROCESSING: boolean;
  74754. VIGNETTE: boolean;
  74755. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74756. VIGNETTEBLENDMODEOPAQUE: boolean;
  74757. TONEMAPPING: boolean;
  74758. TONEMAPPING_ACES: boolean;
  74759. CONTRAST: boolean;
  74760. EXPOSURE: boolean;
  74761. COLORCURVES: boolean;
  74762. COLORGRADING: boolean;
  74763. COLORGRADING3D: boolean;
  74764. SAMPLER3DGREENDEPTH: boolean;
  74765. SAMPLER3DBGRMAP: boolean;
  74766. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74767. }
  74768. /**
  74769. * @hidden
  74770. */
  74771. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  74772. IMAGEPROCESSING: boolean;
  74773. VIGNETTE: boolean;
  74774. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74775. VIGNETTEBLENDMODEOPAQUE: boolean;
  74776. TONEMAPPING: boolean;
  74777. TONEMAPPING_ACES: boolean;
  74778. CONTRAST: boolean;
  74779. COLORCURVES: boolean;
  74780. COLORGRADING: boolean;
  74781. COLORGRADING3D: boolean;
  74782. SAMPLER3DGREENDEPTH: boolean;
  74783. SAMPLER3DBGRMAP: boolean;
  74784. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74785. EXPOSURE: boolean;
  74786. constructor();
  74787. }
  74788. /**
  74789. * This groups together the common properties used for image processing either in direct forward pass
  74790. * or through post processing effect depending on the use of the image processing pipeline in your scene
  74791. * or not.
  74792. */
  74793. export class ImageProcessingConfiguration {
  74794. /**
  74795. * Default tone mapping applied in BabylonJS.
  74796. */
  74797. static readonly TONEMAPPING_STANDARD: number;
  74798. /**
  74799. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  74800. * to other engines rendering to increase portability.
  74801. */
  74802. static readonly TONEMAPPING_ACES: number;
  74803. /**
  74804. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  74805. */
  74806. colorCurves: Nullable<ColorCurves>;
  74807. private _colorCurvesEnabled;
  74808. /**
  74809. * Gets wether the color curves effect is enabled.
  74810. */
  74811. /**
  74812. * Sets wether the color curves effect is enabled.
  74813. */
  74814. colorCurvesEnabled: boolean;
  74815. private _colorGradingTexture;
  74816. /**
  74817. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74818. */
  74819. /**
  74820. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74821. */
  74822. colorGradingTexture: Nullable<BaseTexture>;
  74823. private _colorGradingEnabled;
  74824. /**
  74825. * Gets wether the color grading effect is enabled.
  74826. */
  74827. /**
  74828. * Sets wether the color grading effect is enabled.
  74829. */
  74830. colorGradingEnabled: boolean;
  74831. private _colorGradingWithGreenDepth;
  74832. /**
  74833. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  74834. */
  74835. /**
  74836. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  74837. */
  74838. colorGradingWithGreenDepth: boolean;
  74839. private _colorGradingBGR;
  74840. /**
  74841. * Gets wether the color grading texture contains BGR values.
  74842. */
  74843. /**
  74844. * Sets wether the color grading texture contains BGR values.
  74845. */
  74846. colorGradingBGR: boolean;
  74847. /** @hidden */
  74848. _exposure: number;
  74849. /**
  74850. * Gets the Exposure used in the effect.
  74851. */
  74852. /**
  74853. * Sets the Exposure used in the effect.
  74854. */
  74855. exposure: number;
  74856. private _toneMappingEnabled;
  74857. /**
  74858. * Gets wether the tone mapping effect is enabled.
  74859. */
  74860. /**
  74861. * Sets wether the tone mapping effect is enabled.
  74862. */
  74863. toneMappingEnabled: boolean;
  74864. private _toneMappingType;
  74865. /**
  74866. * Gets the type of tone mapping effect.
  74867. */
  74868. /**
  74869. * Sets the type of tone mapping effect used in BabylonJS.
  74870. */
  74871. toneMappingType: number;
  74872. protected _contrast: number;
  74873. /**
  74874. * Gets the contrast used in the effect.
  74875. */
  74876. /**
  74877. * Sets the contrast used in the effect.
  74878. */
  74879. contrast: number;
  74880. /**
  74881. * Vignette stretch size.
  74882. */
  74883. vignetteStretch: number;
  74884. /**
  74885. * Vignette centre X Offset.
  74886. */
  74887. vignetteCentreX: number;
  74888. /**
  74889. * Vignette centre Y Offset.
  74890. */
  74891. vignetteCentreY: number;
  74892. /**
  74893. * Vignette weight or intensity of the vignette effect.
  74894. */
  74895. vignetteWeight: number;
  74896. /**
  74897. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  74898. * if vignetteEnabled is set to true.
  74899. */
  74900. vignetteColor: Color4;
  74901. /**
  74902. * Camera field of view used by the Vignette effect.
  74903. */
  74904. vignetteCameraFov: number;
  74905. private _vignetteBlendMode;
  74906. /**
  74907. * Gets the vignette blend mode allowing different kind of effect.
  74908. */
  74909. /**
  74910. * Sets the vignette blend mode allowing different kind of effect.
  74911. */
  74912. vignetteBlendMode: number;
  74913. private _vignetteEnabled;
  74914. /**
  74915. * Gets wether the vignette effect is enabled.
  74916. */
  74917. /**
  74918. * Sets wether the vignette effect is enabled.
  74919. */
  74920. vignetteEnabled: boolean;
  74921. private _applyByPostProcess;
  74922. /**
  74923. * Gets wether the image processing is applied through a post process or not.
  74924. */
  74925. /**
  74926. * Sets wether the image processing is applied through a post process or not.
  74927. */
  74928. applyByPostProcess: boolean;
  74929. private _isEnabled;
  74930. /**
  74931. * Gets wether the image processing is enabled or not.
  74932. */
  74933. /**
  74934. * Sets wether the image processing is enabled or not.
  74935. */
  74936. isEnabled: boolean;
  74937. /**
  74938. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  74939. */
  74940. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  74941. /**
  74942. * Method called each time the image processing information changes requires to recompile the effect.
  74943. */
  74944. protected _updateParameters(): void;
  74945. /**
  74946. * Gets the current class name.
  74947. * @return "ImageProcessingConfiguration"
  74948. */
  74949. getClassName(): string;
  74950. /**
  74951. * Prepare the list of uniforms associated with the Image Processing effects.
  74952. * @param uniforms The list of uniforms used in the effect
  74953. * @param defines the list of defines currently in use
  74954. */
  74955. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  74956. /**
  74957. * Prepare the list of samplers associated with the Image Processing effects.
  74958. * @param samplersList The list of uniforms used in the effect
  74959. * @param defines the list of defines currently in use
  74960. */
  74961. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  74962. /**
  74963. * Prepare the list of defines associated to the shader.
  74964. * @param defines the list of defines to complete
  74965. * @param forPostProcess Define if we are currently in post process mode or not
  74966. */
  74967. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  74968. /**
  74969. * Returns true if all the image processing information are ready.
  74970. * @returns True if ready, otherwise, false
  74971. */
  74972. isReady(): boolean;
  74973. /**
  74974. * Binds the image processing to the shader.
  74975. * @param effect The effect to bind to
  74976. * @param aspectRatio Define the current aspect ratio of the effect
  74977. */
  74978. bind(effect: Effect, aspectRatio?: number): void;
  74979. /**
  74980. * Clones the current image processing instance.
  74981. * @return The cloned image processing
  74982. */
  74983. clone(): ImageProcessingConfiguration;
  74984. /**
  74985. * Serializes the current image processing instance to a json representation.
  74986. * @return a JSON representation
  74987. */
  74988. serialize(): any;
  74989. /**
  74990. * Parses the image processing from a json representation.
  74991. * @param source the JSON source to parse
  74992. * @return The parsed image processing
  74993. */
  74994. static Parse(source: any): ImageProcessingConfiguration;
  74995. private static _VIGNETTEMODE_MULTIPLY;
  74996. private static _VIGNETTEMODE_OPAQUE;
  74997. /**
  74998. * Used to apply the vignette as a mix with the pixel color.
  74999. */
  75000. static readonly VIGNETTEMODE_MULTIPLY: number;
  75001. /**
  75002. * Used to apply the vignette as a replacement of the pixel color.
  75003. */
  75004. static readonly VIGNETTEMODE_OPAQUE: number;
  75005. }
  75006. }
  75007. declare module BABYLON {
  75008. /** @hidden */
  75009. export var postprocessVertexShader: {
  75010. name: string;
  75011. shader: string;
  75012. };
  75013. }
  75014. declare module BABYLON {
  75015. interface ThinEngine {
  75016. /**
  75017. * Creates a new render target texture
  75018. * @param size defines the size of the texture
  75019. * @param options defines the options used to create the texture
  75020. * @returns a new render target texture stored in an InternalTexture
  75021. */
  75022. createRenderTargetTexture(size: number | {
  75023. width: number;
  75024. height: number;
  75025. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  75026. }
  75027. }
  75028. declare module BABYLON {
  75029. /** Defines supported spaces */
  75030. export enum Space {
  75031. /** Local (object) space */
  75032. LOCAL = 0,
  75033. /** World space */
  75034. WORLD = 1,
  75035. /** Bone space */
  75036. BONE = 2
  75037. }
  75038. /** Defines the 3 main axes */
  75039. export class Axis {
  75040. /** X axis */
  75041. static X: Vector3;
  75042. /** Y axis */
  75043. static Y: Vector3;
  75044. /** Z axis */
  75045. static Z: Vector3;
  75046. }
  75047. }
  75048. declare module BABYLON {
  75049. /**
  75050. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  75051. * This is the base of the follow, arc rotate cameras and Free camera
  75052. * @see http://doc.babylonjs.com/features/cameras
  75053. */
  75054. export class TargetCamera extends Camera {
  75055. private static _RigCamTransformMatrix;
  75056. private static _TargetTransformMatrix;
  75057. private static _TargetFocalPoint;
  75058. /**
  75059. * Define the current direction the camera is moving to
  75060. */
  75061. cameraDirection: Vector3;
  75062. /**
  75063. * Define the current rotation the camera is rotating to
  75064. */
  75065. cameraRotation: Vector2;
  75066. /**
  75067. * When set, the up vector of the camera will be updated by the rotation of the camera
  75068. */
  75069. updateUpVectorFromRotation: boolean;
  75070. private _tmpQuaternion;
  75071. /**
  75072. * Define the current rotation of the camera
  75073. */
  75074. rotation: Vector3;
  75075. /**
  75076. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  75077. */
  75078. rotationQuaternion: Quaternion;
  75079. /**
  75080. * Define the current speed of the camera
  75081. */
  75082. speed: number;
  75083. /**
  75084. * Add cconstraint to the camera to prevent it to move freely in all directions and
  75085. * around all axis.
  75086. */
  75087. noRotationConstraint: boolean;
  75088. /**
  75089. * Define the current target of the camera as an object or a position.
  75090. */
  75091. lockedTarget: any;
  75092. /** @hidden */
  75093. _currentTarget: Vector3;
  75094. /** @hidden */
  75095. _initialFocalDistance: number;
  75096. /** @hidden */
  75097. _viewMatrix: Matrix;
  75098. /** @hidden */
  75099. _camMatrix: Matrix;
  75100. /** @hidden */
  75101. _cameraTransformMatrix: Matrix;
  75102. /** @hidden */
  75103. _cameraRotationMatrix: Matrix;
  75104. /** @hidden */
  75105. _referencePoint: Vector3;
  75106. /** @hidden */
  75107. _transformedReferencePoint: Vector3;
  75108. protected _globalCurrentTarget: Vector3;
  75109. protected _globalCurrentUpVector: Vector3;
  75110. /** @hidden */
  75111. _reset: () => void;
  75112. private _defaultUp;
  75113. /**
  75114. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  75115. * This is the base of the follow, arc rotate cameras and Free camera
  75116. * @see http://doc.babylonjs.com/features/cameras
  75117. * @param name Defines the name of the camera in the scene
  75118. * @param position Defines the start position of the camera in the scene
  75119. * @param scene Defines the scene the camera belongs to
  75120. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75121. */
  75122. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75123. /**
  75124. * Gets the position in front of the camera at a given distance.
  75125. * @param distance The distance from the camera we want the position to be
  75126. * @returns the position
  75127. */
  75128. getFrontPosition(distance: number): Vector3;
  75129. /** @hidden */
  75130. _getLockedTargetPosition(): Nullable<Vector3>;
  75131. private _storedPosition;
  75132. private _storedRotation;
  75133. private _storedRotationQuaternion;
  75134. /**
  75135. * Store current camera state of the camera (fov, position, rotation, etc..)
  75136. * @returns the camera
  75137. */
  75138. storeState(): Camera;
  75139. /**
  75140. * Restored camera state. You must call storeState() first
  75141. * @returns whether it was successful or not
  75142. * @hidden
  75143. */
  75144. _restoreStateValues(): boolean;
  75145. /** @hidden */
  75146. _initCache(): void;
  75147. /** @hidden */
  75148. _updateCache(ignoreParentClass?: boolean): void;
  75149. /** @hidden */
  75150. _isSynchronizedViewMatrix(): boolean;
  75151. /** @hidden */
  75152. _computeLocalCameraSpeed(): number;
  75153. /**
  75154. * Defines the target the camera should look at.
  75155. * @param target Defines the new target as a Vector or a mesh
  75156. */
  75157. setTarget(target: Vector3): void;
  75158. /**
  75159. * Return the current target position of the camera. This value is expressed in local space.
  75160. * @returns the target position
  75161. */
  75162. getTarget(): Vector3;
  75163. /** @hidden */
  75164. _decideIfNeedsToMove(): boolean;
  75165. /** @hidden */
  75166. _updatePosition(): void;
  75167. /** @hidden */
  75168. _checkInputs(): void;
  75169. protected _updateCameraRotationMatrix(): void;
  75170. /**
  75171. * 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)
  75172. * @returns the current camera
  75173. */
  75174. private _rotateUpVectorWithCameraRotationMatrix;
  75175. private _cachedRotationZ;
  75176. private _cachedQuaternionRotationZ;
  75177. /** @hidden */
  75178. _getViewMatrix(): Matrix;
  75179. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  75180. /**
  75181. * @hidden
  75182. */
  75183. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  75184. /**
  75185. * @hidden
  75186. */
  75187. _updateRigCameras(): void;
  75188. private _getRigCamPositionAndTarget;
  75189. /**
  75190. * Gets the current object class name.
  75191. * @return the class name
  75192. */
  75193. getClassName(): string;
  75194. }
  75195. }
  75196. declare module BABYLON {
  75197. /**
  75198. * Gather the list of keyboard event types as constants.
  75199. */
  75200. export class KeyboardEventTypes {
  75201. /**
  75202. * The keydown event is fired when a key becomes active (pressed).
  75203. */
  75204. static readonly KEYDOWN: number;
  75205. /**
  75206. * The keyup event is fired when a key has been released.
  75207. */
  75208. static readonly KEYUP: number;
  75209. }
  75210. /**
  75211. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75212. */
  75213. export class KeyboardInfo {
  75214. /**
  75215. * Defines the type of event (KeyboardEventTypes)
  75216. */
  75217. type: number;
  75218. /**
  75219. * Defines the related dom event
  75220. */
  75221. event: KeyboardEvent;
  75222. /**
  75223. * Instantiates a new keyboard info.
  75224. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75225. * @param type Defines the type of event (KeyboardEventTypes)
  75226. * @param event Defines the related dom event
  75227. */
  75228. constructor(
  75229. /**
  75230. * Defines the type of event (KeyboardEventTypes)
  75231. */
  75232. type: number,
  75233. /**
  75234. * Defines the related dom event
  75235. */
  75236. event: KeyboardEvent);
  75237. }
  75238. /**
  75239. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75240. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  75241. */
  75242. export class KeyboardInfoPre extends KeyboardInfo {
  75243. /**
  75244. * Defines the type of event (KeyboardEventTypes)
  75245. */
  75246. type: number;
  75247. /**
  75248. * Defines the related dom event
  75249. */
  75250. event: KeyboardEvent;
  75251. /**
  75252. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  75253. */
  75254. skipOnPointerObservable: boolean;
  75255. /**
  75256. * Instantiates a new keyboard pre info.
  75257. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75258. * @param type Defines the type of event (KeyboardEventTypes)
  75259. * @param event Defines the related dom event
  75260. */
  75261. constructor(
  75262. /**
  75263. * Defines the type of event (KeyboardEventTypes)
  75264. */
  75265. type: number,
  75266. /**
  75267. * Defines the related dom event
  75268. */
  75269. event: KeyboardEvent);
  75270. }
  75271. }
  75272. declare module BABYLON {
  75273. /**
  75274. * Manage the keyboard inputs to control the movement of a free camera.
  75275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75276. */
  75277. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  75278. /**
  75279. * Defines the camera the input is attached to.
  75280. */
  75281. camera: FreeCamera;
  75282. /**
  75283. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75284. */
  75285. keysUp: number[];
  75286. /**
  75287. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75288. */
  75289. keysDown: number[];
  75290. /**
  75291. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75292. */
  75293. keysLeft: number[];
  75294. /**
  75295. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75296. */
  75297. keysRight: number[];
  75298. private _keys;
  75299. private _onCanvasBlurObserver;
  75300. private _onKeyboardObserver;
  75301. private _engine;
  75302. private _scene;
  75303. /**
  75304. * Attach the input controls to a specific dom element to get the input from.
  75305. * @param element Defines the element the controls should be listened from
  75306. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75307. */
  75308. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75309. /**
  75310. * Detach the current controls from the specified dom element.
  75311. * @param element Defines the element to stop listening the inputs from
  75312. */
  75313. detachControl(element: Nullable<HTMLElement>): void;
  75314. /**
  75315. * Update the current camera state depending on the inputs that have been used this frame.
  75316. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75317. */
  75318. checkInputs(): void;
  75319. /**
  75320. * Gets the class name of the current intput.
  75321. * @returns the class name
  75322. */
  75323. getClassName(): string;
  75324. /** @hidden */
  75325. _onLostFocus(): void;
  75326. /**
  75327. * Get the friendly name associated with the input class.
  75328. * @returns the input friendly name
  75329. */
  75330. getSimpleName(): string;
  75331. }
  75332. }
  75333. declare module BABYLON {
  75334. /**
  75335. * Interface describing all the common properties and methods a shadow light needs to implement.
  75336. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  75337. * as well as binding the different shadow properties to the effects.
  75338. */
  75339. export interface IShadowLight extends Light {
  75340. /**
  75341. * The light id in the scene (used in scene.findLighById for instance)
  75342. */
  75343. id: string;
  75344. /**
  75345. * The position the shdow will be casted from.
  75346. */
  75347. position: Vector3;
  75348. /**
  75349. * In 2d mode (needCube being false), the direction used to cast the shadow.
  75350. */
  75351. direction: Vector3;
  75352. /**
  75353. * The transformed position. Position of the light in world space taking parenting in account.
  75354. */
  75355. transformedPosition: Vector3;
  75356. /**
  75357. * The transformed direction. Direction of the light in world space taking parenting in account.
  75358. */
  75359. transformedDirection: Vector3;
  75360. /**
  75361. * The friendly name of the light in the scene.
  75362. */
  75363. name: string;
  75364. /**
  75365. * Defines the shadow projection clipping minimum z value.
  75366. */
  75367. shadowMinZ: number;
  75368. /**
  75369. * Defines the shadow projection clipping maximum z value.
  75370. */
  75371. shadowMaxZ: number;
  75372. /**
  75373. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75374. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75375. */
  75376. computeTransformedInformation(): boolean;
  75377. /**
  75378. * Gets the scene the light belongs to.
  75379. * @returns The scene
  75380. */
  75381. getScene(): Scene;
  75382. /**
  75383. * Callback defining a custom Projection Matrix Builder.
  75384. * This can be used to override the default projection matrix computation.
  75385. */
  75386. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75387. /**
  75388. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75389. * @param matrix The materix to updated with the projection information
  75390. * @param viewMatrix The transform matrix of the light
  75391. * @param renderList The list of mesh to render in the map
  75392. * @returns The current light
  75393. */
  75394. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75395. /**
  75396. * Gets the current depth scale used in ESM.
  75397. * @returns The scale
  75398. */
  75399. getDepthScale(): number;
  75400. /**
  75401. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75402. * @returns true if a cube texture needs to be use
  75403. */
  75404. needCube(): boolean;
  75405. /**
  75406. * Detects if the projection matrix requires to be recomputed this frame.
  75407. * @returns true if it requires to be recomputed otherwise, false.
  75408. */
  75409. needProjectionMatrixCompute(): boolean;
  75410. /**
  75411. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75412. */
  75413. forceProjectionMatrixCompute(): void;
  75414. /**
  75415. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75416. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75417. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75418. */
  75419. getShadowDirection(faceIndex?: number): Vector3;
  75420. /**
  75421. * Gets the minZ used for shadow according to both the scene and the light.
  75422. * @param activeCamera The camera we are returning the min for
  75423. * @returns the depth min z
  75424. */
  75425. getDepthMinZ(activeCamera: Camera): number;
  75426. /**
  75427. * Gets the maxZ used for shadow according to both the scene and the light.
  75428. * @param activeCamera The camera we are returning the max for
  75429. * @returns the depth max z
  75430. */
  75431. getDepthMaxZ(activeCamera: Camera): number;
  75432. }
  75433. /**
  75434. * Base implementation IShadowLight
  75435. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  75436. */
  75437. export abstract class ShadowLight extends Light implements IShadowLight {
  75438. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  75439. protected _position: Vector3;
  75440. protected _setPosition(value: Vector3): void;
  75441. /**
  75442. * Sets the position the shadow will be casted from. Also use as the light position for both
  75443. * point and spot lights.
  75444. */
  75445. /**
  75446. * Sets the position the shadow will be casted from. Also use as the light position for both
  75447. * point and spot lights.
  75448. */
  75449. position: Vector3;
  75450. protected _direction: Vector3;
  75451. protected _setDirection(value: Vector3): void;
  75452. /**
  75453. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  75454. * Also use as the light direction on spot and directional lights.
  75455. */
  75456. /**
  75457. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  75458. * Also use as the light direction on spot and directional lights.
  75459. */
  75460. direction: Vector3;
  75461. private _shadowMinZ;
  75462. /**
  75463. * Gets the shadow projection clipping minimum z value.
  75464. */
  75465. /**
  75466. * Sets the shadow projection clipping minimum z value.
  75467. */
  75468. shadowMinZ: number;
  75469. private _shadowMaxZ;
  75470. /**
  75471. * Sets the shadow projection clipping maximum z value.
  75472. */
  75473. /**
  75474. * Gets the shadow projection clipping maximum z value.
  75475. */
  75476. shadowMaxZ: number;
  75477. /**
  75478. * Callback defining a custom Projection Matrix Builder.
  75479. * This can be used to override the default projection matrix computation.
  75480. */
  75481. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75482. /**
  75483. * The transformed position. Position of the light in world space taking parenting in account.
  75484. */
  75485. transformedPosition: Vector3;
  75486. /**
  75487. * The transformed direction. Direction of the light in world space taking parenting in account.
  75488. */
  75489. transformedDirection: Vector3;
  75490. private _needProjectionMatrixCompute;
  75491. /**
  75492. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75493. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75494. */
  75495. computeTransformedInformation(): boolean;
  75496. /**
  75497. * Return the depth scale used for the shadow map.
  75498. * @returns the depth scale.
  75499. */
  75500. getDepthScale(): number;
  75501. /**
  75502. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75503. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75504. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75505. */
  75506. getShadowDirection(faceIndex?: number): Vector3;
  75507. /**
  75508. * Returns the ShadowLight absolute position in the World.
  75509. * @returns the position vector in world space
  75510. */
  75511. getAbsolutePosition(): Vector3;
  75512. /**
  75513. * Sets the ShadowLight direction toward the passed target.
  75514. * @param target The point to target in local space
  75515. * @returns the updated ShadowLight direction
  75516. */
  75517. setDirectionToTarget(target: Vector3): Vector3;
  75518. /**
  75519. * Returns the light rotation in euler definition.
  75520. * @returns the x y z rotation in local space.
  75521. */
  75522. getRotation(): Vector3;
  75523. /**
  75524. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75525. * @returns true if a cube texture needs to be use
  75526. */
  75527. needCube(): boolean;
  75528. /**
  75529. * Detects if the projection matrix requires to be recomputed this frame.
  75530. * @returns true if it requires to be recomputed otherwise, false.
  75531. */
  75532. needProjectionMatrixCompute(): boolean;
  75533. /**
  75534. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75535. */
  75536. forceProjectionMatrixCompute(): void;
  75537. /** @hidden */
  75538. _initCache(): void;
  75539. /** @hidden */
  75540. _isSynchronized(): boolean;
  75541. /**
  75542. * Computes the world matrix of the node
  75543. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  75544. * @returns the world matrix
  75545. */
  75546. computeWorldMatrix(force?: boolean): Matrix;
  75547. /**
  75548. * Gets the minZ used for shadow according to both the scene and the light.
  75549. * @param activeCamera The camera we are returning the min for
  75550. * @returns the depth min z
  75551. */
  75552. getDepthMinZ(activeCamera: Camera): number;
  75553. /**
  75554. * Gets the maxZ used for shadow according to both the scene and the light.
  75555. * @param activeCamera The camera we are returning the max for
  75556. * @returns the depth max z
  75557. */
  75558. getDepthMaxZ(activeCamera: Camera): number;
  75559. /**
  75560. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75561. * @param matrix The materix to updated with the projection information
  75562. * @param viewMatrix The transform matrix of the light
  75563. * @param renderList The list of mesh to render in the map
  75564. * @returns The current light
  75565. */
  75566. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75567. }
  75568. }
  75569. declare module BABYLON {
  75570. /**
  75571. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  75572. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  75573. */
  75574. export class EffectFallbacks implements IEffectFallbacks {
  75575. private _defines;
  75576. private _currentRank;
  75577. private _maxRank;
  75578. private _mesh;
  75579. /**
  75580. * Removes the fallback from the bound mesh.
  75581. */
  75582. unBindMesh(): void;
  75583. /**
  75584. * Adds a fallback on the specified property.
  75585. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75586. * @param define The name of the define in the shader
  75587. */
  75588. addFallback(rank: number, define: string): void;
  75589. /**
  75590. * Sets the mesh to use CPU skinning when needing to fallback.
  75591. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75592. * @param mesh The mesh to use the fallbacks.
  75593. */
  75594. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  75595. /**
  75596. * Checks to see if more fallbacks are still availible.
  75597. */
  75598. readonly hasMoreFallbacks: boolean;
  75599. /**
  75600. * Removes the defines that should be removed when falling back.
  75601. * @param currentDefines defines the current define statements for the shader.
  75602. * @param effect defines the current effect we try to compile
  75603. * @returns The resulting defines with defines of the current rank removed.
  75604. */
  75605. reduce(currentDefines: string, effect: Effect): string;
  75606. }
  75607. }
  75608. declare module BABYLON {
  75609. /**
  75610. * "Static Class" containing the most commonly used helper while dealing with material for
  75611. * rendering purpose.
  75612. *
  75613. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  75614. *
  75615. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  75616. */
  75617. export class MaterialHelper {
  75618. /**
  75619. * Bind the current view position to an effect.
  75620. * @param effect The effect to be bound
  75621. * @param scene The scene the eyes position is used from
  75622. */
  75623. static BindEyePosition(effect: Effect, scene: Scene): void;
  75624. /**
  75625. * Helps preparing the defines values about the UVs in used in the effect.
  75626. * UVs are shared as much as we can accross channels in the shaders.
  75627. * @param texture The texture we are preparing the UVs for
  75628. * @param defines The defines to update
  75629. * @param key The channel key "diffuse", "specular"... used in the shader
  75630. */
  75631. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  75632. /**
  75633. * Binds a texture matrix value to its corrsponding uniform
  75634. * @param texture The texture to bind the matrix for
  75635. * @param uniformBuffer The uniform buffer receivin the data
  75636. * @param key The channel key "diffuse", "specular"... used in the shader
  75637. */
  75638. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  75639. /**
  75640. * Gets the current status of the fog (should it be enabled?)
  75641. * @param mesh defines the mesh to evaluate for fog support
  75642. * @param scene defines the hosting scene
  75643. * @returns true if fog must be enabled
  75644. */
  75645. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  75646. /**
  75647. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  75648. * @param mesh defines the current mesh
  75649. * @param scene defines the current scene
  75650. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  75651. * @param pointsCloud defines if point cloud rendering has to be turned on
  75652. * @param fogEnabled defines if fog has to be turned on
  75653. * @param alphaTest defines if alpha testing has to be turned on
  75654. * @param defines defines the current list of defines
  75655. */
  75656. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  75657. /**
  75658. * Helper used to prepare the list of defines associated with frame values for shader compilation
  75659. * @param scene defines the current scene
  75660. * @param engine defines the current engine
  75661. * @param defines specifies the list of active defines
  75662. * @param useInstances defines if instances have to be turned on
  75663. * @param useClipPlane defines if clip plane have to be turned on
  75664. */
  75665. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  75666. /**
  75667. * Prepares the defines for bones
  75668. * @param mesh The mesh containing the geometry data we will draw
  75669. * @param defines The defines to update
  75670. */
  75671. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  75672. /**
  75673. * Prepares the defines for morph targets
  75674. * @param mesh The mesh containing the geometry data we will draw
  75675. * @param defines The defines to update
  75676. */
  75677. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  75678. /**
  75679. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  75680. * @param mesh The mesh containing the geometry data we will draw
  75681. * @param defines The defines to update
  75682. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  75683. * @param useBones Precise whether bones should be used or not (override mesh info)
  75684. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  75685. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  75686. * @returns false if defines are considered not dirty and have not been checked
  75687. */
  75688. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  75689. /**
  75690. * Prepares the defines related to multiview
  75691. * @param scene The scene we are intending to draw
  75692. * @param defines The defines to update
  75693. */
  75694. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  75695. /**
  75696. * Prepares the defines related to the light information passed in parameter
  75697. * @param scene The scene we are intending to draw
  75698. * @param mesh The mesh the effect is compiling for
  75699. * @param light The light the effect is compiling for
  75700. * @param lightIndex The index of the light
  75701. * @param defines The defines to update
  75702. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75703. * @param state Defines the current state regarding what is needed (normals, etc...)
  75704. */
  75705. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  75706. needNormals: boolean;
  75707. needRebuild: boolean;
  75708. shadowEnabled: boolean;
  75709. specularEnabled: boolean;
  75710. lightmapMode: boolean;
  75711. }): void;
  75712. /**
  75713. * Prepares the defines related to the light information passed in parameter
  75714. * @param scene The scene we are intending to draw
  75715. * @param mesh The mesh the effect is compiling for
  75716. * @param defines The defines to update
  75717. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75718. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  75719. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  75720. * @returns true if normals will be required for the rest of the effect
  75721. */
  75722. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  75723. /**
  75724. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  75725. * @param lightIndex defines the light index
  75726. * @param uniformsList The uniform list
  75727. * @param samplersList The sampler list
  75728. * @param projectedLightTexture defines if projected texture must be used
  75729. * @param uniformBuffersList defines an optional list of uniform buffers
  75730. */
  75731. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  75732. /**
  75733. * Prepares the uniforms and samplers list to be used in the effect
  75734. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  75735. * @param samplersList The sampler list
  75736. * @param defines The defines helping in the list generation
  75737. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  75738. */
  75739. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  75740. /**
  75741. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  75742. * @param defines The defines to update while falling back
  75743. * @param fallbacks The authorized effect fallbacks
  75744. * @param maxSimultaneousLights The maximum number of lights allowed
  75745. * @param rank the current rank of the Effect
  75746. * @returns The newly affected rank
  75747. */
  75748. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  75749. private static _TmpMorphInfluencers;
  75750. /**
  75751. * Prepares the list of attributes required for morph targets according to the effect defines.
  75752. * @param attribs The current list of supported attribs
  75753. * @param mesh The mesh to prepare the morph targets attributes for
  75754. * @param influencers The number of influencers
  75755. */
  75756. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  75757. /**
  75758. * Prepares the list of attributes required for morph targets according to the effect defines.
  75759. * @param attribs The current list of supported attribs
  75760. * @param mesh The mesh to prepare the morph targets attributes for
  75761. * @param defines The current Defines of the effect
  75762. */
  75763. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  75764. /**
  75765. * Prepares the list of attributes required for bones according to the effect defines.
  75766. * @param attribs The current list of supported attribs
  75767. * @param mesh The mesh to prepare the bones attributes for
  75768. * @param defines The current Defines of the effect
  75769. * @param fallbacks The current efffect fallback strategy
  75770. */
  75771. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  75772. /**
  75773. * Check and prepare the list of attributes required for instances according to the effect defines.
  75774. * @param attribs The current list of supported attribs
  75775. * @param defines The current MaterialDefines of the effect
  75776. */
  75777. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  75778. /**
  75779. * Add the list of attributes required for instances to the attribs array.
  75780. * @param attribs The current list of supported attribs
  75781. */
  75782. static PushAttributesForInstances(attribs: string[]): void;
  75783. /**
  75784. * Binds the light shadow information to the effect for the given mesh.
  75785. * @param light The light containing the generator
  75786. * @param scene The scene the lights belongs to
  75787. * @param mesh The mesh we are binding the information to render
  75788. * @param lightIndex The light index in the effect used to render the mesh
  75789. * @param effect The effect we are binding the data to
  75790. */
  75791. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  75792. /**
  75793. * Binds the light information to the effect.
  75794. * @param light The light containing the generator
  75795. * @param effect The effect we are binding the data to
  75796. * @param lightIndex The light index in the effect used to render
  75797. */
  75798. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  75799. /**
  75800. * Binds the lights information from the scene to the effect for the given mesh.
  75801. * @param light Light to bind
  75802. * @param lightIndex Light index
  75803. * @param scene The scene where the light belongs to
  75804. * @param mesh The mesh we are binding the information to render
  75805. * @param effect The effect we are binding the data to
  75806. * @param useSpecular Defines if specular is supported
  75807. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75808. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75809. */
  75810. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75811. /**
  75812. * Binds the lights information from the scene to the effect for the given mesh.
  75813. * @param scene The scene the lights belongs to
  75814. * @param mesh The mesh we are binding the information to render
  75815. * @param effect The effect we are binding the data to
  75816. * @param defines The generated defines for the effect
  75817. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  75818. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75819. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75820. */
  75821. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75822. private static _tempFogColor;
  75823. /**
  75824. * Binds the fog information from the scene to the effect for the given mesh.
  75825. * @param scene The scene the lights belongs to
  75826. * @param mesh The mesh we are binding the information to render
  75827. * @param effect The effect we are binding the data to
  75828. * @param linearSpace Defines if the fog effect is applied in linear space
  75829. */
  75830. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  75831. /**
  75832. * Binds the bones information from the mesh to the effect.
  75833. * @param mesh The mesh we are binding the information to render
  75834. * @param effect The effect we are binding the data to
  75835. */
  75836. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  75837. /**
  75838. * Binds the morph targets information from the mesh to the effect.
  75839. * @param abstractMesh The mesh we are binding the information to render
  75840. * @param effect The effect we are binding the data to
  75841. */
  75842. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  75843. /**
  75844. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  75845. * @param defines The generated defines used in the effect
  75846. * @param effect The effect we are binding the data to
  75847. * @param scene The scene we are willing to render with logarithmic scale for
  75848. */
  75849. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  75850. /**
  75851. * Binds the clip plane information from the scene to the effect.
  75852. * @param scene The scene the clip plane information are extracted from
  75853. * @param effect The effect we are binding the data to
  75854. */
  75855. static BindClipPlane(effect: Effect, scene: Scene): void;
  75856. }
  75857. }
  75858. declare module BABYLON {
  75859. /** @hidden */
  75860. export var packingFunctions: {
  75861. name: string;
  75862. shader: string;
  75863. };
  75864. }
  75865. declare module BABYLON {
  75866. /** @hidden */
  75867. export var shadowMapPixelShader: {
  75868. name: string;
  75869. shader: string;
  75870. };
  75871. }
  75872. declare module BABYLON {
  75873. /** @hidden */
  75874. export var bonesDeclaration: {
  75875. name: string;
  75876. shader: string;
  75877. };
  75878. }
  75879. declare module BABYLON {
  75880. /** @hidden */
  75881. export var morphTargetsVertexGlobalDeclaration: {
  75882. name: string;
  75883. shader: string;
  75884. };
  75885. }
  75886. declare module BABYLON {
  75887. /** @hidden */
  75888. export var morphTargetsVertexDeclaration: {
  75889. name: string;
  75890. shader: string;
  75891. };
  75892. }
  75893. declare module BABYLON {
  75894. /** @hidden */
  75895. export var instancesDeclaration: {
  75896. name: string;
  75897. shader: string;
  75898. };
  75899. }
  75900. declare module BABYLON {
  75901. /** @hidden */
  75902. export var helperFunctions: {
  75903. name: string;
  75904. shader: string;
  75905. };
  75906. }
  75907. declare module BABYLON {
  75908. /** @hidden */
  75909. export var morphTargetsVertex: {
  75910. name: string;
  75911. shader: string;
  75912. };
  75913. }
  75914. declare module BABYLON {
  75915. /** @hidden */
  75916. export var instancesVertex: {
  75917. name: string;
  75918. shader: string;
  75919. };
  75920. }
  75921. declare module BABYLON {
  75922. /** @hidden */
  75923. export var bonesVertex: {
  75924. name: string;
  75925. shader: string;
  75926. };
  75927. }
  75928. declare module BABYLON {
  75929. /** @hidden */
  75930. export var shadowMapVertexShader: {
  75931. name: string;
  75932. shader: string;
  75933. };
  75934. }
  75935. declare module BABYLON {
  75936. /** @hidden */
  75937. export var depthBoxBlurPixelShader: {
  75938. name: string;
  75939. shader: string;
  75940. };
  75941. }
  75942. declare module BABYLON {
  75943. /**
  75944. * Defines the options associated with the creation of a custom shader for a shadow generator.
  75945. */
  75946. export interface ICustomShaderOptions {
  75947. /**
  75948. * Gets or sets the custom shader name to use
  75949. */
  75950. shaderName: string;
  75951. /**
  75952. * The list of attribute names used in the shader
  75953. */
  75954. attributes?: string[];
  75955. /**
  75956. * The list of unifrom names used in the shader
  75957. */
  75958. uniforms?: string[];
  75959. /**
  75960. * The list of sampler names used in the shader
  75961. */
  75962. samplers?: string[];
  75963. /**
  75964. * The list of defines used in the shader
  75965. */
  75966. defines?: string[];
  75967. }
  75968. /**
  75969. * Interface to implement to create a shadow generator compatible with BJS.
  75970. */
  75971. export interface IShadowGenerator {
  75972. /**
  75973. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75974. * @returns The render target texture if present otherwise, null
  75975. */
  75976. getShadowMap(): Nullable<RenderTargetTexture>;
  75977. /**
  75978. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75979. * @returns The render target texture if the shadow map is present otherwise, null
  75980. */
  75981. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75982. /**
  75983. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75984. * @param subMesh The submesh we want to render in the shadow map
  75985. * @param useInstances Defines wether will draw in the map using instances
  75986. * @returns true if ready otherwise, false
  75987. */
  75988. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75989. /**
  75990. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75991. * @param defines Defines of the material we want to update
  75992. * @param lightIndex Index of the light in the enabled light list of the material
  75993. */
  75994. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  75995. /**
  75996. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75997. * defined in the generator but impacting the effect).
  75998. * It implies the unifroms available on the materials are the standard BJS ones.
  75999. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76000. * @param effect The effect we are binfing the information for
  76001. */
  76002. bindShadowLight(lightIndex: string, effect: Effect): void;
  76003. /**
  76004. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76005. * (eq to shadow prjection matrix * light transform matrix)
  76006. * @returns The transform matrix used to create the shadow map
  76007. */
  76008. getTransformMatrix(): Matrix;
  76009. /**
  76010. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76011. * Cube and 2D textures for instance.
  76012. */
  76013. recreateShadowMap(): void;
  76014. /**
  76015. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76016. * @param onCompiled Callback triggered at the and of the effects compilation
  76017. * @param options Sets of optional options forcing the compilation with different modes
  76018. */
  76019. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76020. useInstances: boolean;
  76021. }>): void;
  76022. /**
  76023. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76024. * @param options Sets of optional options forcing the compilation with different modes
  76025. * @returns A promise that resolves when the compilation completes
  76026. */
  76027. forceCompilationAsync(options?: Partial<{
  76028. useInstances: boolean;
  76029. }>): Promise<void>;
  76030. /**
  76031. * Serializes the shadow generator setup to a json object.
  76032. * @returns The serialized JSON object
  76033. */
  76034. serialize(): any;
  76035. /**
  76036. * Disposes the Shadow map and related Textures and effects.
  76037. */
  76038. dispose(): void;
  76039. }
  76040. /**
  76041. * Default implementation IShadowGenerator.
  76042. * This is the main object responsible of generating shadows in the framework.
  76043. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  76044. */
  76045. export class ShadowGenerator implements IShadowGenerator {
  76046. /**
  76047. * Shadow generator mode None: no filtering applied.
  76048. */
  76049. static readonly FILTER_NONE: number;
  76050. /**
  76051. * Shadow generator mode ESM: Exponential Shadow Mapping.
  76052. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76053. */
  76054. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  76055. /**
  76056. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  76057. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  76058. */
  76059. static readonly FILTER_POISSONSAMPLING: number;
  76060. /**
  76061. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  76062. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76063. */
  76064. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  76065. /**
  76066. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  76067. * edge artifacts on steep falloff.
  76068. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76069. */
  76070. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  76071. /**
  76072. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  76073. * edge artifacts on steep falloff.
  76074. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76075. */
  76076. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  76077. /**
  76078. * Shadow generator mode PCF: Percentage Closer Filtering
  76079. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76080. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  76081. */
  76082. static readonly FILTER_PCF: number;
  76083. /**
  76084. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  76085. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76086. * Contact Hardening
  76087. */
  76088. static readonly FILTER_PCSS: number;
  76089. /**
  76090. * Reserved for PCF and PCSS
  76091. * Highest Quality.
  76092. *
  76093. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  76094. *
  76095. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  76096. */
  76097. static readonly QUALITY_HIGH: number;
  76098. /**
  76099. * Reserved for PCF and PCSS
  76100. * Good tradeoff for quality/perf cross devices
  76101. *
  76102. * Execute PCF on a 3*3 kernel.
  76103. *
  76104. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  76105. */
  76106. static readonly QUALITY_MEDIUM: number;
  76107. /**
  76108. * Reserved for PCF and PCSS
  76109. * The lowest quality but the fastest.
  76110. *
  76111. * Execute PCF on a 1*1 kernel.
  76112. *
  76113. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  76114. */
  76115. static readonly QUALITY_LOW: number;
  76116. /** Gets or sets the custom shader name to use */
  76117. customShaderOptions: ICustomShaderOptions;
  76118. /**
  76119. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  76120. */
  76121. onBeforeShadowMapRenderObservable: Observable<Effect>;
  76122. /**
  76123. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  76124. */
  76125. onAfterShadowMapRenderObservable: Observable<Effect>;
  76126. /**
  76127. * Observable triggered before a mesh is rendered in the shadow map.
  76128. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  76129. */
  76130. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  76131. /**
  76132. * Observable triggered after a mesh is rendered in the shadow map.
  76133. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  76134. */
  76135. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  76136. private _bias;
  76137. /**
  76138. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  76139. */
  76140. /**
  76141. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  76142. */
  76143. bias: number;
  76144. private _normalBias;
  76145. /**
  76146. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76147. */
  76148. /**
  76149. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76150. */
  76151. normalBias: number;
  76152. private _blurBoxOffset;
  76153. /**
  76154. * Gets the blur box offset: offset applied during the blur pass.
  76155. * Only useful if useKernelBlur = false
  76156. */
  76157. /**
  76158. * Sets the blur box offset: offset applied during the blur pass.
  76159. * Only useful if useKernelBlur = false
  76160. */
  76161. blurBoxOffset: number;
  76162. private _blurScale;
  76163. /**
  76164. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  76165. * 2 means half of the size.
  76166. */
  76167. /**
  76168. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  76169. * 2 means half of the size.
  76170. */
  76171. blurScale: number;
  76172. private _blurKernel;
  76173. /**
  76174. * Gets the blur kernel: kernel size of the blur pass.
  76175. * Only useful if useKernelBlur = true
  76176. */
  76177. /**
  76178. * Sets the blur kernel: kernel size of the blur pass.
  76179. * Only useful if useKernelBlur = true
  76180. */
  76181. blurKernel: number;
  76182. private _useKernelBlur;
  76183. /**
  76184. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  76185. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76186. */
  76187. /**
  76188. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  76189. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76190. */
  76191. useKernelBlur: boolean;
  76192. private _depthScale;
  76193. /**
  76194. * Gets the depth scale used in ESM mode.
  76195. */
  76196. /**
  76197. * Sets the depth scale used in ESM mode.
  76198. * This can override the scale stored on the light.
  76199. */
  76200. depthScale: number;
  76201. private _filter;
  76202. /**
  76203. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  76204. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76205. */
  76206. /**
  76207. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  76208. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76209. */
  76210. filter: number;
  76211. /**
  76212. * Gets if the current filter is set to Poisson Sampling.
  76213. */
  76214. /**
  76215. * Sets the current filter to Poisson Sampling.
  76216. */
  76217. usePoissonSampling: boolean;
  76218. /**
  76219. * Gets if the current filter is set to ESM.
  76220. */
  76221. /**
  76222. * Sets the current filter is to ESM.
  76223. */
  76224. useExponentialShadowMap: boolean;
  76225. /**
  76226. * Gets if the current filter is set to filtered ESM.
  76227. */
  76228. /**
  76229. * Gets if the current filter is set to filtered ESM.
  76230. */
  76231. useBlurExponentialShadowMap: boolean;
  76232. /**
  76233. * Gets if the current filter is set to "close ESM" (using the inverse of the
  76234. * exponential to prevent steep falloff artifacts).
  76235. */
  76236. /**
  76237. * Sets the current filter to "close ESM" (using the inverse of the
  76238. * exponential to prevent steep falloff artifacts).
  76239. */
  76240. useCloseExponentialShadowMap: boolean;
  76241. /**
  76242. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  76243. * exponential to prevent steep falloff artifacts).
  76244. */
  76245. /**
  76246. * Sets the current filter to filtered "close ESM" (using the inverse of the
  76247. * exponential to prevent steep falloff artifacts).
  76248. */
  76249. useBlurCloseExponentialShadowMap: boolean;
  76250. /**
  76251. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  76252. */
  76253. /**
  76254. * Sets the current filter to "PCF" (percentage closer filtering).
  76255. */
  76256. usePercentageCloserFiltering: boolean;
  76257. private _filteringQuality;
  76258. /**
  76259. * Gets the PCF or PCSS Quality.
  76260. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76261. */
  76262. /**
  76263. * Sets the PCF or PCSS Quality.
  76264. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76265. */
  76266. filteringQuality: number;
  76267. /**
  76268. * Gets if the current filter is set to "PCSS" (contact hardening).
  76269. */
  76270. /**
  76271. * Sets the current filter to "PCSS" (contact hardening).
  76272. */
  76273. useContactHardeningShadow: boolean;
  76274. private _contactHardeningLightSizeUVRatio;
  76275. /**
  76276. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76277. * Using a ratio helps keeping shape stability independently of the map size.
  76278. *
  76279. * It does not account for the light projection as it was having too much
  76280. * instability during the light setup or during light position changes.
  76281. *
  76282. * Only valid if useContactHardeningShadow is true.
  76283. */
  76284. /**
  76285. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76286. * Using a ratio helps keeping shape stability independently of the map size.
  76287. *
  76288. * It does not account for the light projection as it was having too much
  76289. * instability during the light setup or during light position changes.
  76290. *
  76291. * Only valid if useContactHardeningShadow is true.
  76292. */
  76293. contactHardeningLightSizeUVRatio: number;
  76294. private _darkness;
  76295. /** Gets or sets the actual darkness of a shadow */
  76296. darkness: number;
  76297. /**
  76298. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  76299. * 0 means strongest and 1 would means no shadow.
  76300. * @returns the darkness.
  76301. */
  76302. getDarkness(): number;
  76303. /**
  76304. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  76305. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  76306. * @returns the shadow generator allowing fluent coding.
  76307. */
  76308. setDarkness(darkness: number): ShadowGenerator;
  76309. private _transparencyShadow;
  76310. /** Gets or sets the ability to have transparent shadow */
  76311. transparencyShadow: boolean;
  76312. /**
  76313. * Sets the ability to have transparent shadow (boolean).
  76314. * @param transparent True if transparent else False
  76315. * @returns the shadow generator allowing fluent coding
  76316. */
  76317. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  76318. private _shadowMap;
  76319. private _shadowMap2;
  76320. /**
  76321. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76322. * @returns The render target texture if present otherwise, null
  76323. */
  76324. getShadowMap(): Nullable<RenderTargetTexture>;
  76325. /**
  76326. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76327. * @returns The render target texture if the shadow map is present otherwise, null
  76328. */
  76329. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76330. /**
  76331. * Gets the class name of that object
  76332. * @returns "ShadowGenerator"
  76333. */
  76334. getClassName(): string;
  76335. /**
  76336. * Helper function to add a mesh and its descendants to the list of shadow casters.
  76337. * @param mesh Mesh to add
  76338. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  76339. * @returns the Shadow Generator itself
  76340. */
  76341. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76342. /**
  76343. * Helper function to remove a mesh and its descendants from the list of shadow casters
  76344. * @param mesh Mesh to remove
  76345. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  76346. * @returns the Shadow Generator itself
  76347. */
  76348. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76349. /**
  76350. * Controls the extent to which the shadows fade out at the edge of the frustum
  76351. * Used only by directionals and spots
  76352. */
  76353. frustumEdgeFalloff: number;
  76354. private _light;
  76355. /**
  76356. * Returns the associated light object.
  76357. * @returns the light generating the shadow
  76358. */
  76359. getLight(): IShadowLight;
  76360. /**
  76361. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  76362. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  76363. * It might on the other hand introduce peter panning.
  76364. */
  76365. forceBackFacesOnly: boolean;
  76366. private _scene;
  76367. private _lightDirection;
  76368. private _effect;
  76369. private _viewMatrix;
  76370. private _projectionMatrix;
  76371. private _transformMatrix;
  76372. private _cachedPosition;
  76373. private _cachedDirection;
  76374. private _cachedDefines;
  76375. private _currentRenderID;
  76376. private _boxBlurPostprocess;
  76377. private _kernelBlurXPostprocess;
  76378. private _kernelBlurYPostprocess;
  76379. private _blurPostProcesses;
  76380. private _mapSize;
  76381. private _currentFaceIndex;
  76382. private _currentFaceIndexCache;
  76383. private _textureType;
  76384. private _defaultTextureMatrix;
  76385. private _storedUniqueId;
  76386. /** @hidden */
  76387. static _SceneComponentInitialization: (scene: Scene) => void;
  76388. /**
  76389. * Creates a ShadowGenerator object.
  76390. * A ShadowGenerator is the required tool to use the shadows.
  76391. * Each light casting shadows needs to use its own ShadowGenerator.
  76392. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  76393. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  76394. * @param light The light object generating the shadows.
  76395. * @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.
  76396. */
  76397. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  76398. private _initializeGenerator;
  76399. private _initializeShadowMap;
  76400. private _initializeBlurRTTAndPostProcesses;
  76401. private _renderForShadowMap;
  76402. private _renderSubMeshForShadowMap;
  76403. private _applyFilterValues;
  76404. /**
  76405. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76406. * @param onCompiled Callback triggered at the and of the effects compilation
  76407. * @param options Sets of optional options forcing the compilation with different modes
  76408. */
  76409. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76410. useInstances: boolean;
  76411. }>): void;
  76412. /**
  76413. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76414. * @param options Sets of optional options forcing the compilation with different modes
  76415. * @returns A promise that resolves when the compilation completes
  76416. */
  76417. forceCompilationAsync(options?: Partial<{
  76418. useInstances: boolean;
  76419. }>): Promise<void>;
  76420. /**
  76421. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76422. * @param subMesh The submesh we want to render in the shadow map
  76423. * @param useInstances Defines wether will draw in the map using instances
  76424. * @returns true if ready otherwise, false
  76425. */
  76426. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76427. /**
  76428. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76429. * @param defines Defines of the material we want to update
  76430. * @param lightIndex Index of the light in the enabled light list of the material
  76431. */
  76432. prepareDefines(defines: any, lightIndex: number): void;
  76433. /**
  76434. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76435. * defined in the generator but impacting the effect).
  76436. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76437. * @param effect The effect we are binfing the information for
  76438. */
  76439. bindShadowLight(lightIndex: string, effect: Effect): void;
  76440. /**
  76441. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76442. * (eq to shadow prjection matrix * light transform matrix)
  76443. * @returns The transform matrix used to create the shadow map
  76444. */
  76445. getTransformMatrix(): Matrix;
  76446. /**
  76447. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76448. * Cube and 2D textures for instance.
  76449. */
  76450. recreateShadowMap(): void;
  76451. private _disposeBlurPostProcesses;
  76452. private _disposeRTTandPostProcesses;
  76453. /**
  76454. * Disposes the ShadowGenerator.
  76455. * Returns nothing.
  76456. */
  76457. dispose(): void;
  76458. /**
  76459. * Serializes the shadow generator setup to a json object.
  76460. * @returns The serialized JSON object
  76461. */
  76462. serialize(): any;
  76463. /**
  76464. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  76465. * @param parsedShadowGenerator The JSON object to parse
  76466. * @param scene The scene to create the shadow map for
  76467. * @returns The parsed shadow generator
  76468. */
  76469. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  76470. }
  76471. }
  76472. declare module BABYLON {
  76473. /**
  76474. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  76475. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  76476. * 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.
  76477. */
  76478. export abstract class Light extends Node {
  76479. /**
  76480. * Falloff Default: light is falling off following the material specification:
  76481. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  76482. */
  76483. static readonly FALLOFF_DEFAULT: number;
  76484. /**
  76485. * Falloff Physical: light is falling off following the inverse squared distance law.
  76486. */
  76487. static readonly FALLOFF_PHYSICAL: number;
  76488. /**
  76489. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  76490. * to enhance interoperability with other engines.
  76491. */
  76492. static readonly FALLOFF_GLTF: number;
  76493. /**
  76494. * Falloff Standard: light is falling off like in the standard material
  76495. * to enhance interoperability with other materials.
  76496. */
  76497. static readonly FALLOFF_STANDARD: number;
  76498. /**
  76499. * If every light affecting the material is in this lightmapMode,
  76500. * material.lightmapTexture adds or multiplies
  76501. * (depends on material.useLightmapAsShadowmap)
  76502. * after every other light calculations.
  76503. */
  76504. static readonly LIGHTMAP_DEFAULT: number;
  76505. /**
  76506. * material.lightmapTexture as only diffuse lighting from this light
  76507. * adds only specular lighting from this light
  76508. * adds dynamic shadows
  76509. */
  76510. static readonly LIGHTMAP_SPECULAR: number;
  76511. /**
  76512. * material.lightmapTexture as only lighting
  76513. * no light calculation from this light
  76514. * only adds dynamic shadows from this light
  76515. */
  76516. static readonly LIGHTMAP_SHADOWSONLY: number;
  76517. /**
  76518. * Each light type uses the default quantity according to its type:
  76519. * point/spot lights use luminous intensity
  76520. * directional lights use illuminance
  76521. */
  76522. static readonly INTENSITYMODE_AUTOMATIC: number;
  76523. /**
  76524. * lumen (lm)
  76525. */
  76526. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  76527. /**
  76528. * candela (lm/sr)
  76529. */
  76530. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  76531. /**
  76532. * lux (lm/m^2)
  76533. */
  76534. static readonly INTENSITYMODE_ILLUMINANCE: number;
  76535. /**
  76536. * nit (cd/m^2)
  76537. */
  76538. static readonly INTENSITYMODE_LUMINANCE: number;
  76539. /**
  76540. * Light type const id of the point light.
  76541. */
  76542. static readonly LIGHTTYPEID_POINTLIGHT: number;
  76543. /**
  76544. * Light type const id of the directional light.
  76545. */
  76546. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  76547. /**
  76548. * Light type const id of the spot light.
  76549. */
  76550. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  76551. /**
  76552. * Light type const id of the hemispheric light.
  76553. */
  76554. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  76555. /**
  76556. * Diffuse gives the basic color to an object.
  76557. */
  76558. diffuse: Color3;
  76559. /**
  76560. * Specular produces a highlight color on an object.
  76561. * Note: This is note affecting PBR materials.
  76562. */
  76563. specular: Color3;
  76564. /**
  76565. * Defines the falloff type for this light. This lets overrriding how punctual light are
  76566. * falling off base on range or angle.
  76567. * This can be set to any values in Light.FALLOFF_x.
  76568. *
  76569. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  76570. * other types of materials.
  76571. */
  76572. falloffType: number;
  76573. /**
  76574. * Strength of the light.
  76575. * Note: By default it is define in the framework own unit.
  76576. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  76577. */
  76578. intensity: number;
  76579. private _range;
  76580. protected _inverseSquaredRange: number;
  76581. /**
  76582. * Defines how far from the source the light is impacting in scene units.
  76583. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76584. */
  76585. /**
  76586. * Defines how far from the source the light is impacting in scene units.
  76587. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76588. */
  76589. range: number;
  76590. /**
  76591. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  76592. * of light.
  76593. */
  76594. private _photometricScale;
  76595. private _intensityMode;
  76596. /**
  76597. * Gets the photometric scale used to interpret the intensity.
  76598. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76599. */
  76600. /**
  76601. * Sets the photometric scale used to interpret the intensity.
  76602. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76603. */
  76604. intensityMode: number;
  76605. private _radius;
  76606. /**
  76607. * Gets the light radius used by PBR Materials to simulate soft area lights.
  76608. */
  76609. /**
  76610. * sets the light radius used by PBR Materials to simulate soft area lights.
  76611. */
  76612. radius: number;
  76613. private _renderPriority;
  76614. /**
  76615. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  76616. * exceeding the number allowed of the materials.
  76617. */
  76618. renderPriority: number;
  76619. private _shadowEnabled;
  76620. /**
  76621. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76622. * the current shadow generator.
  76623. */
  76624. /**
  76625. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76626. * the current shadow generator.
  76627. */
  76628. shadowEnabled: boolean;
  76629. private _includedOnlyMeshes;
  76630. /**
  76631. * Gets the only meshes impacted by this light.
  76632. */
  76633. /**
  76634. * Sets the only meshes impacted by this light.
  76635. */
  76636. includedOnlyMeshes: AbstractMesh[];
  76637. private _excludedMeshes;
  76638. /**
  76639. * Gets the meshes not impacted by this light.
  76640. */
  76641. /**
  76642. * Sets the meshes not impacted by this light.
  76643. */
  76644. excludedMeshes: AbstractMesh[];
  76645. private _excludeWithLayerMask;
  76646. /**
  76647. * Gets the layer id use to find what meshes are not impacted by the light.
  76648. * Inactive if 0
  76649. */
  76650. /**
  76651. * Sets the layer id use to find what meshes are not impacted by the light.
  76652. * Inactive if 0
  76653. */
  76654. excludeWithLayerMask: number;
  76655. private _includeOnlyWithLayerMask;
  76656. /**
  76657. * Gets the layer id use to find what meshes are impacted by the light.
  76658. * Inactive if 0
  76659. */
  76660. /**
  76661. * Sets the layer id use to find what meshes are impacted by the light.
  76662. * Inactive if 0
  76663. */
  76664. includeOnlyWithLayerMask: number;
  76665. private _lightmapMode;
  76666. /**
  76667. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76668. */
  76669. /**
  76670. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76671. */
  76672. lightmapMode: number;
  76673. /**
  76674. * Shadow generator associted to the light.
  76675. * @hidden Internal use only.
  76676. */
  76677. _shadowGenerator: Nullable<IShadowGenerator>;
  76678. /**
  76679. * @hidden Internal use only.
  76680. */
  76681. _excludedMeshesIds: string[];
  76682. /**
  76683. * @hidden Internal use only.
  76684. */
  76685. _includedOnlyMeshesIds: string[];
  76686. /**
  76687. * The current light unifom buffer.
  76688. * @hidden Internal use only.
  76689. */
  76690. _uniformBuffer: UniformBuffer;
  76691. /**
  76692. * Creates a Light object in the scene.
  76693. * Documentation : https://doc.babylonjs.com/babylon101/lights
  76694. * @param name The firendly name of the light
  76695. * @param scene The scene the light belongs too
  76696. */
  76697. constructor(name: string, scene: Scene);
  76698. protected abstract _buildUniformLayout(): void;
  76699. /**
  76700. * Sets the passed Effect "effect" with the Light information.
  76701. * @param effect The effect to update
  76702. * @param lightIndex The index of the light in the effect to update
  76703. * @returns The light
  76704. */
  76705. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  76706. /**
  76707. * Sets the passed Effect "effect" with the Light information.
  76708. * @param effect The effect to update
  76709. * @param lightDataUniformName The uniform used to store light data (position or direction)
  76710. * @returns The light
  76711. */
  76712. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  76713. /**
  76714. * Returns the string "Light".
  76715. * @returns the class name
  76716. */
  76717. getClassName(): string;
  76718. /** @hidden */
  76719. readonly _isLight: boolean;
  76720. /**
  76721. * Converts the light information to a readable string for debug purpose.
  76722. * @param fullDetails Supports for multiple levels of logging within scene loading
  76723. * @returns the human readable light info
  76724. */
  76725. toString(fullDetails?: boolean): string;
  76726. /** @hidden */
  76727. protected _syncParentEnabledState(): void;
  76728. /**
  76729. * Set the enabled state of this node.
  76730. * @param value - the new enabled state
  76731. */
  76732. setEnabled(value: boolean): void;
  76733. /**
  76734. * Returns the Light associated shadow generator if any.
  76735. * @return the associated shadow generator.
  76736. */
  76737. getShadowGenerator(): Nullable<IShadowGenerator>;
  76738. /**
  76739. * Returns a Vector3, the absolute light position in the World.
  76740. * @returns the world space position of the light
  76741. */
  76742. getAbsolutePosition(): Vector3;
  76743. /**
  76744. * Specifies if the light will affect the passed mesh.
  76745. * @param mesh The mesh to test against the light
  76746. * @return true the mesh is affected otherwise, false.
  76747. */
  76748. canAffectMesh(mesh: AbstractMesh): boolean;
  76749. /**
  76750. * Sort function to order lights for rendering.
  76751. * @param a First Light object to compare to second.
  76752. * @param b Second Light object to compare first.
  76753. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  76754. */
  76755. static CompareLightsPriority(a: Light, b: Light): number;
  76756. /**
  76757. * Releases resources associated with this node.
  76758. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  76759. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  76760. */
  76761. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76762. /**
  76763. * Returns the light type ID (integer).
  76764. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  76765. */
  76766. getTypeID(): number;
  76767. /**
  76768. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  76769. * @returns the scaled intensity in intensity mode unit
  76770. */
  76771. getScaledIntensity(): number;
  76772. /**
  76773. * Returns a new Light object, named "name", from the current one.
  76774. * @param name The name of the cloned light
  76775. * @returns the new created light
  76776. */
  76777. clone(name: string): Nullable<Light>;
  76778. /**
  76779. * Serializes the current light into a Serialization object.
  76780. * @returns the serialized object.
  76781. */
  76782. serialize(): any;
  76783. /**
  76784. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  76785. * This new light is named "name" and added to the passed scene.
  76786. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  76787. * @param name The friendly name of the light
  76788. * @param scene The scene the new light will belong to
  76789. * @returns the constructor function
  76790. */
  76791. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  76792. /**
  76793. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  76794. * @param parsedLight The JSON representation of the light
  76795. * @param scene The scene to create the parsed light in
  76796. * @returns the created light after parsing
  76797. */
  76798. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  76799. private _hookArrayForExcluded;
  76800. private _hookArrayForIncludedOnly;
  76801. private _resyncMeshes;
  76802. /**
  76803. * Forces the meshes to update their light related information in their rendering used effects
  76804. * @hidden Internal Use Only
  76805. */
  76806. _markMeshesAsLightDirty(): void;
  76807. /**
  76808. * Recomputes the cached photometric scale if needed.
  76809. */
  76810. private _computePhotometricScale;
  76811. /**
  76812. * Returns the Photometric Scale according to the light type and intensity mode.
  76813. */
  76814. private _getPhotometricScale;
  76815. /**
  76816. * Reorder the light in the scene according to their defined priority.
  76817. * @hidden Internal Use Only
  76818. */
  76819. _reorderLightsInScene(): void;
  76820. /**
  76821. * Prepares the list of defines specific to the light type.
  76822. * @param defines the list of defines
  76823. * @param lightIndex defines the index of the light for the effect
  76824. */
  76825. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  76826. }
  76827. }
  76828. declare module BABYLON {
  76829. /**
  76830. * Interface used to define Action
  76831. */
  76832. export interface IAction {
  76833. /**
  76834. * Trigger for the action
  76835. */
  76836. trigger: number;
  76837. /** Options of the trigger */
  76838. triggerOptions: any;
  76839. /**
  76840. * Gets the trigger parameters
  76841. * @returns the trigger parameters
  76842. */
  76843. getTriggerParameter(): any;
  76844. /**
  76845. * Internal only - executes current action event
  76846. * @hidden
  76847. */
  76848. _executeCurrent(evt?: ActionEvent): void;
  76849. /**
  76850. * Serialize placeholder for child classes
  76851. * @param parent of child
  76852. * @returns the serialized object
  76853. */
  76854. serialize(parent: any): any;
  76855. /**
  76856. * Internal only
  76857. * @hidden
  76858. */
  76859. _prepare(): void;
  76860. /**
  76861. * Internal only - manager for action
  76862. * @hidden
  76863. */
  76864. _actionManager: AbstractActionManager;
  76865. /**
  76866. * Adds action to chain of actions, may be a DoNothingAction
  76867. * @param action defines the next action to execute
  76868. * @returns The action passed in
  76869. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76870. */
  76871. then(action: IAction): IAction;
  76872. }
  76873. /**
  76874. * The action to be carried out following a trigger
  76875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  76876. */
  76877. export class Action implements IAction {
  76878. /** the trigger, with or without parameters, for the action */
  76879. triggerOptions: any;
  76880. /**
  76881. * Trigger for the action
  76882. */
  76883. trigger: number;
  76884. /**
  76885. * Internal only - manager for action
  76886. * @hidden
  76887. */
  76888. _actionManager: ActionManager;
  76889. private _nextActiveAction;
  76890. private _child;
  76891. private _condition?;
  76892. private _triggerParameter;
  76893. /**
  76894. * An event triggered prior to action being executed.
  76895. */
  76896. onBeforeExecuteObservable: Observable<Action>;
  76897. /**
  76898. * Creates a new Action
  76899. * @param triggerOptions the trigger, with or without parameters, for the action
  76900. * @param condition an optional determinant of action
  76901. */
  76902. constructor(
  76903. /** the trigger, with or without parameters, for the action */
  76904. triggerOptions: any, condition?: Condition);
  76905. /**
  76906. * Internal only
  76907. * @hidden
  76908. */
  76909. _prepare(): void;
  76910. /**
  76911. * Gets the trigger parameters
  76912. * @returns the trigger parameters
  76913. */
  76914. getTriggerParameter(): any;
  76915. /**
  76916. * Internal only - executes current action event
  76917. * @hidden
  76918. */
  76919. _executeCurrent(evt?: ActionEvent): void;
  76920. /**
  76921. * Execute placeholder for child classes
  76922. * @param evt optional action event
  76923. */
  76924. execute(evt?: ActionEvent): void;
  76925. /**
  76926. * Skips to next active action
  76927. */
  76928. skipToNextActiveAction(): void;
  76929. /**
  76930. * Adds action to chain of actions, may be a DoNothingAction
  76931. * @param action defines the next action to execute
  76932. * @returns The action passed in
  76933. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76934. */
  76935. then(action: Action): Action;
  76936. /**
  76937. * Internal only
  76938. * @hidden
  76939. */
  76940. _getProperty(propertyPath: string): string;
  76941. /**
  76942. * Internal only
  76943. * @hidden
  76944. */
  76945. _getEffectiveTarget(target: any, propertyPath: string): any;
  76946. /**
  76947. * Serialize placeholder for child classes
  76948. * @param parent of child
  76949. * @returns the serialized object
  76950. */
  76951. serialize(parent: any): any;
  76952. /**
  76953. * Internal only called by serialize
  76954. * @hidden
  76955. */
  76956. protected _serialize(serializedAction: any, parent?: any): any;
  76957. /**
  76958. * Internal only
  76959. * @hidden
  76960. */
  76961. static _SerializeValueAsString: (value: any) => string;
  76962. /**
  76963. * Internal only
  76964. * @hidden
  76965. */
  76966. static _GetTargetProperty: (target: Node | Scene) => {
  76967. name: string;
  76968. targetType: string;
  76969. value: string;
  76970. };
  76971. }
  76972. }
  76973. declare module BABYLON {
  76974. /**
  76975. * A Condition applied to an Action
  76976. */
  76977. export class Condition {
  76978. /**
  76979. * Internal only - manager for action
  76980. * @hidden
  76981. */
  76982. _actionManager: ActionManager;
  76983. /**
  76984. * Internal only
  76985. * @hidden
  76986. */
  76987. _evaluationId: number;
  76988. /**
  76989. * Internal only
  76990. * @hidden
  76991. */
  76992. _currentResult: boolean;
  76993. /**
  76994. * Creates a new Condition
  76995. * @param actionManager the manager of the action the condition is applied to
  76996. */
  76997. constructor(actionManager: ActionManager);
  76998. /**
  76999. * Check if the current condition is valid
  77000. * @returns a boolean
  77001. */
  77002. isValid(): boolean;
  77003. /**
  77004. * Internal only
  77005. * @hidden
  77006. */
  77007. _getProperty(propertyPath: string): string;
  77008. /**
  77009. * Internal only
  77010. * @hidden
  77011. */
  77012. _getEffectiveTarget(target: any, propertyPath: string): any;
  77013. /**
  77014. * Serialize placeholder for child classes
  77015. * @returns the serialized object
  77016. */
  77017. serialize(): any;
  77018. /**
  77019. * Internal only
  77020. * @hidden
  77021. */
  77022. protected _serialize(serializedCondition: any): any;
  77023. }
  77024. /**
  77025. * Defines specific conditional operators as extensions of Condition
  77026. */
  77027. export class ValueCondition extends Condition {
  77028. /** path to specify the property of the target the conditional operator uses */
  77029. propertyPath: string;
  77030. /** the value compared by the conditional operator against the current value of the property */
  77031. value: any;
  77032. /** the conditional operator, default ValueCondition.IsEqual */
  77033. operator: number;
  77034. /**
  77035. * Internal only
  77036. * @hidden
  77037. */
  77038. private static _IsEqual;
  77039. /**
  77040. * Internal only
  77041. * @hidden
  77042. */
  77043. private static _IsDifferent;
  77044. /**
  77045. * Internal only
  77046. * @hidden
  77047. */
  77048. private static _IsGreater;
  77049. /**
  77050. * Internal only
  77051. * @hidden
  77052. */
  77053. private static _IsLesser;
  77054. /**
  77055. * returns the number for IsEqual
  77056. */
  77057. static readonly IsEqual: number;
  77058. /**
  77059. * Returns the number for IsDifferent
  77060. */
  77061. static readonly IsDifferent: number;
  77062. /**
  77063. * Returns the number for IsGreater
  77064. */
  77065. static readonly IsGreater: number;
  77066. /**
  77067. * Returns the number for IsLesser
  77068. */
  77069. static readonly IsLesser: number;
  77070. /**
  77071. * Internal only The action manager for the condition
  77072. * @hidden
  77073. */
  77074. _actionManager: ActionManager;
  77075. /**
  77076. * Internal only
  77077. * @hidden
  77078. */
  77079. private _target;
  77080. /**
  77081. * Internal only
  77082. * @hidden
  77083. */
  77084. private _effectiveTarget;
  77085. /**
  77086. * Internal only
  77087. * @hidden
  77088. */
  77089. private _property;
  77090. /**
  77091. * Creates a new ValueCondition
  77092. * @param actionManager manager for the action the condition applies to
  77093. * @param target for the action
  77094. * @param propertyPath path to specify the property of the target the conditional operator uses
  77095. * @param value the value compared by the conditional operator against the current value of the property
  77096. * @param operator the conditional operator, default ValueCondition.IsEqual
  77097. */
  77098. constructor(actionManager: ActionManager, target: any,
  77099. /** path to specify the property of the target the conditional operator uses */
  77100. propertyPath: string,
  77101. /** the value compared by the conditional operator against the current value of the property */
  77102. value: any,
  77103. /** the conditional operator, default ValueCondition.IsEqual */
  77104. operator?: number);
  77105. /**
  77106. * Compares the given value with the property value for the specified conditional operator
  77107. * @returns the result of the comparison
  77108. */
  77109. isValid(): boolean;
  77110. /**
  77111. * Serialize the ValueCondition into a JSON compatible object
  77112. * @returns serialization object
  77113. */
  77114. serialize(): any;
  77115. /**
  77116. * Gets the name of the conditional operator for the ValueCondition
  77117. * @param operator the conditional operator
  77118. * @returns the name
  77119. */
  77120. static GetOperatorName(operator: number): string;
  77121. }
  77122. /**
  77123. * Defines a predicate condition as an extension of Condition
  77124. */
  77125. export class PredicateCondition extends Condition {
  77126. /** defines the predicate function used to validate the condition */
  77127. predicate: () => boolean;
  77128. /**
  77129. * Internal only - manager for action
  77130. * @hidden
  77131. */
  77132. _actionManager: ActionManager;
  77133. /**
  77134. * Creates a new PredicateCondition
  77135. * @param actionManager manager for the action the condition applies to
  77136. * @param predicate defines the predicate function used to validate the condition
  77137. */
  77138. constructor(actionManager: ActionManager,
  77139. /** defines the predicate function used to validate the condition */
  77140. predicate: () => boolean);
  77141. /**
  77142. * @returns the validity of the predicate condition
  77143. */
  77144. isValid(): boolean;
  77145. }
  77146. /**
  77147. * Defines a state condition as an extension of Condition
  77148. */
  77149. export class StateCondition extends Condition {
  77150. /** Value to compare with target state */
  77151. value: string;
  77152. /**
  77153. * Internal only - manager for action
  77154. * @hidden
  77155. */
  77156. _actionManager: ActionManager;
  77157. /**
  77158. * Internal only
  77159. * @hidden
  77160. */
  77161. private _target;
  77162. /**
  77163. * Creates a new StateCondition
  77164. * @param actionManager manager for the action the condition applies to
  77165. * @param target of the condition
  77166. * @param value to compare with target state
  77167. */
  77168. constructor(actionManager: ActionManager, target: any,
  77169. /** Value to compare with target state */
  77170. value: string);
  77171. /**
  77172. * Gets a boolean indicating if the current condition is met
  77173. * @returns the validity of the state
  77174. */
  77175. isValid(): boolean;
  77176. /**
  77177. * Serialize the StateCondition into a JSON compatible object
  77178. * @returns serialization object
  77179. */
  77180. serialize(): any;
  77181. }
  77182. }
  77183. declare module BABYLON {
  77184. /**
  77185. * This defines an action responsible to toggle a boolean once triggered.
  77186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77187. */
  77188. export class SwitchBooleanAction extends Action {
  77189. /**
  77190. * The path to the boolean property in the target object
  77191. */
  77192. propertyPath: string;
  77193. private _target;
  77194. private _effectiveTarget;
  77195. private _property;
  77196. /**
  77197. * Instantiate the action
  77198. * @param triggerOptions defines the trigger options
  77199. * @param target defines the object containing the boolean
  77200. * @param propertyPath defines the path to the boolean property in the target object
  77201. * @param condition defines the trigger related conditions
  77202. */
  77203. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77204. /** @hidden */
  77205. _prepare(): void;
  77206. /**
  77207. * Execute the action toggle the boolean value.
  77208. */
  77209. execute(): void;
  77210. /**
  77211. * Serializes the actions and its related information.
  77212. * @param parent defines the object to serialize in
  77213. * @returns the serialized object
  77214. */
  77215. serialize(parent: any): any;
  77216. }
  77217. /**
  77218. * This defines an action responsible to set a the state field of the target
  77219. * to a desired value once triggered.
  77220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77221. */
  77222. export class SetStateAction extends Action {
  77223. /**
  77224. * The value to store in the state field.
  77225. */
  77226. value: string;
  77227. private _target;
  77228. /**
  77229. * Instantiate the action
  77230. * @param triggerOptions defines the trigger options
  77231. * @param target defines the object containing the state property
  77232. * @param value defines the value to store in the state field
  77233. * @param condition defines the trigger related conditions
  77234. */
  77235. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  77236. /**
  77237. * Execute the action and store the value on the target state property.
  77238. */
  77239. execute(): void;
  77240. /**
  77241. * Serializes the actions and its related information.
  77242. * @param parent defines the object to serialize in
  77243. * @returns the serialized object
  77244. */
  77245. serialize(parent: any): any;
  77246. }
  77247. /**
  77248. * This defines an action responsible to set a property of the target
  77249. * to a desired value once triggered.
  77250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77251. */
  77252. export class SetValueAction extends Action {
  77253. /**
  77254. * The path of the property to set in the target.
  77255. */
  77256. propertyPath: string;
  77257. /**
  77258. * The value to set in the property
  77259. */
  77260. value: any;
  77261. private _target;
  77262. private _effectiveTarget;
  77263. private _property;
  77264. /**
  77265. * Instantiate the action
  77266. * @param triggerOptions defines the trigger options
  77267. * @param target defines the object containing the property
  77268. * @param propertyPath defines the path of the property to set in the target
  77269. * @param value defines the value to set in the property
  77270. * @param condition defines the trigger related conditions
  77271. */
  77272. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77273. /** @hidden */
  77274. _prepare(): void;
  77275. /**
  77276. * Execute the action and set the targetted property to the desired value.
  77277. */
  77278. execute(): void;
  77279. /**
  77280. * Serializes the actions and its related information.
  77281. * @param parent defines the object to serialize in
  77282. * @returns the serialized object
  77283. */
  77284. serialize(parent: any): any;
  77285. }
  77286. /**
  77287. * This defines an action responsible to increment the target value
  77288. * to a desired value once triggered.
  77289. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77290. */
  77291. export class IncrementValueAction extends Action {
  77292. /**
  77293. * The path of the property to increment in the target.
  77294. */
  77295. propertyPath: string;
  77296. /**
  77297. * The value we should increment the property by.
  77298. */
  77299. value: any;
  77300. private _target;
  77301. private _effectiveTarget;
  77302. private _property;
  77303. /**
  77304. * Instantiate the action
  77305. * @param triggerOptions defines the trigger options
  77306. * @param target defines the object containing the property
  77307. * @param propertyPath defines the path of the property to increment in the target
  77308. * @param value defines the value value we should increment the property by
  77309. * @param condition defines the trigger related conditions
  77310. */
  77311. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77312. /** @hidden */
  77313. _prepare(): void;
  77314. /**
  77315. * Execute the action and increment the target of the value amount.
  77316. */
  77317. execute(): void;
  77318. /**
  77319. * Serializes the actions and its related information.
  77320. * @param parent defines the object to serialize in
  77321. * @returns the serialized object
  77322. */
  77323. serialize(parent: any): any;
  77324. }
  77325. /**
  77326. * This defines an action responsible to start an animation once triggered.
  77327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77328. */
  77329. export class PlayAnimationAction extends Action {
  77330. /**
  77331. * Where the animation should start (animation frame)
  77332. */
  77333. from: number;
  77334. /**
  77335. * Where the animation should stop (animation frame)
  77336. */
  77337. to: number;
  77338. /**
  77339. * Define if the animation should loop or stop after the first play.
  77340. */
  77341. loop?: boolean;
  77342. private _target;
  77343. /**
  77344. * Instantiate the action
  77345. * @param triggerOptions defines the trigger options
  77346. * @param target defines the target animation or animation name
  77347. * @param from defines from where the animation should start (animation frame)
  77348. * @param end defines where the animation should stop (animation frame)
  77349. * @param loop defines if the animation should loop or stop after the first play
  77350. * @param condition defines the trigger related conditions
  77351. */
  77352. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  77353. /** @hidden */
  77354. _prepare(): void;
  77355. /**
  77356. * Execute the action and play the animation.
  77357. */
  77358. execute(): void;
  77359. /**
  77360. * Serializes the actions and its related information.
  77361. * @param parent defines the object to serialize in
  77362. * @returns the serialized object
  77363. */
  77364. serialize(parent: any): any;
  77365. }
  77366. /**
  77367. * This defines an action responsible to stop an animation once triggered.
  77368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77369. */
  77370. export class StopAnimationAction extends Action {
  77371. private _target;
  77372. /**
  77373. * Instantiate the action
  77374. * @param triggerOptions defines the trigger options
  77375. * @param target defines the target animation or animation name
  77376. * @param condition defines the trigger related conditions
  77377. */
  77378. constructor(triggerOptions: any, target: any, condition?: Condition);
  77379. /** @hidden */
  77380. _prepare(): void;
  77381. /**
  77382. * Execute the action and stop the animation.
  77383. */
  77384. execute(): void;
  77385. /**
  77386. * Serializes the actions and its related information.
  77387. * @param parent defines the object to serialize in
  77388. * @returns the serialized object
  77389. */
  77390. serialize(parent: any): any;
  77391. }
  77392. /**
  77393. * This defines an action responsible that does nothing once triggered.
  77394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77395. */
  77396. export class DoNothingAction extends Action {
  77397. /**
  77398. * Instantiate the action
  77399. * @param triggerOptions defines the trigger options
  77400. * @param condition defines the trigger related conditions
  77401. */
  77402. constructor(triggerOptions?: any, condition?: Condition);
  77403. /**
  77404. * Execute the action and do nothing.
  77405. */
  77406. execute(): void;
  77407. /**
  77408. * Serializes the actions and its related information.
  77409. * @param parent defines the object to serialize in
  77410. * @returns the serialized object
  77411. */
  77412. serialize(parent: any): any;
  77413. }
  77414. /**
  77415. * This defines an action responsible to trigger several actions once triggered.
  77416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77417. */
  77418. export class CombineAction extends Action {
  77419. /**
  77420. * The list of aggregated animations to run.
  77421. */
  77422. children: Action[];
  77423. /**
  77424. * Instantiate the action
  77425. * @param triggerOptions defines the trigger options
  77426. * @param children defines the list of aggregated animations to run
  77427. * @param condition defines the trigger related conditions
  77428. */
  77429. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  77430. /** @hidden */
  77431. _prepare(): void;
  77432. /**
  77433. * Execute the action and executes all the aggregated actions.
  77434. */
  77435. execute(evt: ActionEvent): void;
  77436. /**
  77437. * Serializes the actions and its related information.
  77438. * @param parent defines the object to serialize in
  77439. * @returns the serialized object
  77440. */
  77441. serialize(parent: any): any;
  77442. }
  77443. /**
  77444. * This defines an action responsible to run code (external event) once triggered.
  77445. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77446. */
  77447. export class ExecuteCodeAction extends Action {
  77448. /**
  77449. * The callback function to run.
  77450. */
  77451. func: (evt: ActionEvent) => void;
  77452. /**
  77453. * Instantiate the action
  77454. * @param triggerOptions defines the trigger options
  77455. * @param func defines the callback function to run
  77456. * @param condition defines the trigger related conditions
  77457. */
  77458. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  77459. /**
  77460. * Execute the action and run the attached code.
  77461. */
  77462. execute(evt: ActionEvent): void;
  77463. }
  77464. /**
  77465. * This defines an action responsible to set the parent property of the target once triggered.
  77466. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77467. */
  77468. export class SetParentAction extends Action {
  77469. private _parent;
  77470. private _target;
  77471. /**
  77472. * Instantiate the action
  77473. * @param triggerOptions defines the trigger options
  77474. * @param target defines the target containing the parent property
  77475. * @param parent defines from where the animation should start (animation frame)
  77476. * @param condition defines the trigger related conditions
  77477. */
  77478. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  77479. /** @hidden */
  77480. _prepare(): void;
  77481. /**
  77482. * Execute the action and set the parent property.
  77483. */
  77484. execute(): void;
  77485. /**
  77486. * Serializes the actions and its related information.
  77487. * @param parent defines the object to serialize in
  77488. * @returns the serialized object
  77489. */
  77490. serialize(parent: any): any;
  77491. }
  77492. }
  77493. declare module BABYLON {
  77494. /**
  77495. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  77496. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  77497. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77498. */
  77499. export class ActionManager extends AbstractActionManager {
  77500. /**
  77501. * Nothing
  77502. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77503. */
  77504. static readonly NothingTrigger: number;
  77505. /**
  77506. * On pick
  77507. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77508. */
  77509. static readonly OnPickTrigger: number;
  77510. /**
  77511. * On left pick
  77512. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77513. */
  77514. static readonly OnLeftPickTrigger: number;
  77515. /**
  77516. * On right pick
  77517. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77518. */
  77519. static readonly OnRightPickTrigger: number;
  77520. /**
  77521. * On center pick
  77522. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77523. */
  77524. static readonly OnCenterPickTrigger: number;
  77525. /**
  77526. * On pick down
  77527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77528. */
  77529. static readonly OnPickDownTrigger: number;
  77530. /**
  77531. * On double pick
  77532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77533. */
  77534. static readonly OnDoublePickTrigger: number;
  77535. /**
  77536. * On pick up
  77537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77538. */
  77539. static readonly OnPickUpTrigger: number;
  77540. /**
  77541. * On pick out.
  77542. * This trigger will only be raised if you also declared a OnPickDown
  77543. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77544. */
  77545. static readonly OnPickOutTrigger: number;
  77546. /**
  77547. * On long press
  77548. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77549. */
  77550. static readonly OnLongPressTrigger: number;
  77551. /**
  77552. * On pointer over
  77553. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77554. */
  77555. static readonly OnPointerOverTrigger: number;
  77556. /**
  77557. * On pointer out
  77558. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77559. */
  77560. static readonly OnPointerOutTrigger: number;
  77561. /**
  77562. * On every frame
  77563. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77564. */
  77565. static readonly OnEveryFrameTrigger: number;
  77566. /**
  77567. * On intersection enter
  77568. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77569. */
  77570. static readonly OnIntersectionEnterTrigger: number;
  77571. /**
  77572. * On intersection exit
  77573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77574. */
  77575. static readonly OnIntersectionExitTrigger: number;
  77576. /**
  77577. * On key down
  77578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77579. */
  77580. static readonly OnKeyDownTrigger: number;
  77581. /**
  77582. * On key up
  77583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77584. */
  77585. static readonly OnKeyUpTrigger: number;
  77586. private _scene;
  77587. /**
  77588. * Creates a new action manager
  77589. * @param scene defines the hosting scene
  77590. */
  77591. constructor(scene: Scene);
  77592. /**
  77593. * Releases all associated resources
  77594. */
  77595. dispose(): void;
  77596. /**
  77597. * Gets hosting scene
  77598. * @returns the hosting scene
  77599. */
  77600. getScene(): Scene;
  77601. /**
  77602. * Does this action manager handles actions of any of the given triggers
  77603. * @param triggers defines the triggers to be tested
  77604. * @return a boolean indicating whether one (or more) of the triggers is handled
  77605. */
  77606. hasSpecificTriggers(triggers: number[]): boolean;
  77607. /**
  77608. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  77609. * speed.
  77610. * @param triggerA defines the trigger to be tested
  77611. * @param triggerB defines the trigger to be tested
  77612. * @return a boolean indicating whether one (or more) of the triggers is handled
  77613. */
  77614. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  77615. /**
  77616. * Does this action manager handles actions of a given trigger
  77617. * @param trigger defines the trigger to be tested
  77618. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  77619. * @return whether the trigger is handled
  77620. */
  77621. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  77622. /**
  77623. * Does this action manager has pointer triggers
  77624. */
  77625. readonly hasPointerTriggers: boolean;
  77626. /**
  77627. * Does this action manager has pick triggers
  77628. */
  77629. readonly hasPickTriggers: boolean;
  77630. /**
  77631. * Registers an action to this action manager
  77632. * @param action defines the action to be registered
  77633. * @return the action amended (prepared) after registration
  77634. */
  77635. registerAction(action: IAction): Nullable<IAction>;
  77636. /**
  77637. * Unregisters an action to this action manager
  77638. * @param action defines the action to be unregistered
  77639. * @return a boolean indicating whether the action has been unregistered
  77640. */
  77641. unregisterAction(action: IAction): Boolean;
  77642. /**
  77643. * Process a specific trigger
  77644. * @param trigger defines the trigger to process
  77645. * @param evt defines the event details to be processed
  77646. */
  77647. processTrigger(trigger: number, evt?: IActionEvent): void;
  77648. /** @hidden */
  77649. _getEffectiveTarget(target: any, propertyPath: string): any;
  77650. /** @hidden */
  77651. _getProperty(propertyPath: string): string;
  77652. /**
  77653. * Serialize this manager to a JSON object
  77654. * @param name defines the property name to store this manager
  77655. * @returns a JSON representation of this manager
  77656. */
  77657. serialize(name: string): any;
  77658. /**
  77659. * Creates a new ActionManager from a JSON data
  77660. * @param parsedActions defines the JSON data to read from
  77661. * @param object defines the hosting mesh
  77662. * @param scene defines the hosting scene
  77663. */
  77664. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  77665. /**
  77666. * Get a trigger name by index
  77667. * @param trigger defines the trigger index
  77668. * @returns a trigger name
  77669. */
  77670. static GetTriggerName(trigger: number): string;
  77671. }
  77672. }
  77673. declare module BABYLON {
  77674. /**
  77675. * Class representing a ray with position and direction
  77676. */
  77677. export class Ray {
  77678. /** origin point */
  77679. origin: Vector3;
  77680. /** direction */
  77681. direction: Vector3;
  77682. /** length of the ray */
  77683. length: number;
  77684. private static readonly TmpVector3;
  77685. private _tmpRay;
  77686. /**
  77687. * Creates a new ray
  77688. * @param origin origin point
  77689. * @param direction direction
  77690. * @param length length of the ray
  77691. */
  77692. constructor(
  77693. /** origin point */
  77694. origin: Vector3,
  77695. /** direction */
  77696. direction: Vector3,
  77697. /** length of the ray */
  77698. length?: number);
  77699. /**
  77700. * Checks if the ray intersects a box
  77701. * @param minimum bound of the box
  77702. * @param maximum bound of the box
  77703. * @param intersectionTreshold extra extend to be added to the box in all direction
  77704. * @returns if the box was hit
  77705. */
  77706. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  77707. /**
  77708. * Checks if the ray intersects a box
  77709. * @param box the bounding box to check
  77710. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  77711. * @returns if the box was hit
  77712. */
  77713. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  77714. /**
  77715. * If the ray hits a sphere
  77716. * @param sphere the bounding sphere to check
  77717. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  77718. * @returns true if it hits the sphere
  77719. */
  77720. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  77721. /**
  77722. * If the ray hits a triange
  77723. * @param vertex0 triangle vertex
  77724. * @param vertex1 triangle vertex
  77725. * @param vertex2 triangle vertex
  77726. * @returns intersection information if hit
  77727. */
  77728. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  77729. /**
  77730. * Checks if ray intersects a plane
  77731. * @param plane the plane to check
  77732. * @returns the distance away it was hit
  77733. */
  77734. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  77735. /**
  77736. * Calculate the intercept of a ray on a given axis
  77737. * @param axis to check 'x' | 'y' | 'z'
  77738. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  77739. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  77740. */
  77741. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  77742. /**
  77743. * Checks if ray intersects a mesh
  77744. * @param mesh the mesh to check
  77745. * @param fastCheck if only the bounding box should checked
  77746. * @returns picking info of the intersecton
  77747. */
  77748. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  77749. /**
  77750. * Checks if ray intersects a mesh
  77751. * @param meshes the meshes to check
  77752. * @param fastCheck if only the bounding box should checked
  77753. * @param results array to store result in
  77754. * @returns Array of picking infos
  77755. */
  77756. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  77757. private _comparePickingInfo;
  77758. private static smallnum;
  77759. private static rayl;
  77760. /**
  77761. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  77762. * @param sega the first point of the segment to test the intersection against
  77763. * @param segb the second point of the segment to test the intersection against
  77764. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  77765. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  77766. */
  77767. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  77768. /**
  77769. * Update the ray from viewport position
  77770. * @param x position
  77771. * @param y y position
  77772. * @param viewportWidth viewport width
  77773. * @param viewportHeight viewport height
  77774. * @param world world matrix
  77775. * @param view view matrix
  77776. * @param projection projection matrix
  77777. * @returns this ray updated
  77778. */
  77779. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77780. /**
  77781. * Creates a ray with origin and direction of 0,0,0
  77782. * @returns the new ray
  77783. */
  77784. static Zero(): Ray;
  77785. /**
  77786. * Creates a new ray from screen space and viewport
  77787. * @param x position
  77788. * @param y y position
  77789. * @param viewportWidth viewport width
  77790. * @param viewportHeight viewport height
  77791. * @param world world matrix
  77792. * @param view view matrix
  77793. * @param projection projection matrix
  77794. * @returns new ray
  77795. */
  77796. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77797. /**
  77798. * 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
  77799. * transformed to the given world matrix.
  77800. * @param origin The origin point
  77801. * @param end The end point
  77802. * @param world a matrix to transform the ray to. Default is the identity matrix.
  77803. * @returns the new ray
  77804. */
  77805. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  77806. /**
  77807. * Transforms a ray by a matrix
  77808. * @param ray ray to transform
  77809. * @param matrix matrix to apply
  77810. * @returns the resulting new ray
  77811. */
  77812. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  77813. /**
  77814. * Transforms a ray by a matrix
  77815. * @param ray ray to transform
  77816. * @param matrix matrix to apply
  77817. * @param result ray to store result in
  77818. */
  77819. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  77820. /**
  77821. * Unproject a ray from screen space to object space
  77822. * @param sourceX defines the screen space x coordinate to use
  77823. * @param sourceY defines the screen space y coordinate to use
  77824. * @param viewportWidth defines the current width of the viewport
  77825. * @param viewportHeight defines the current height of the viewport
  77826. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77827. * @param view defines the view matrix to use
  77828. * @param projection defines the projection matrix to use
  77829. */
  77830. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  77831. }
  77832. /**
  77833. * Type used to define predicate used to select faces when a mesh intersection is detected
  77834. */
  77835. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  77836. interface Scene {
  77837. /** @hidden */
  77838. _tempPickingRay: Nullable<Ray>;
  77839. /** @hidden */
  77840. _cachedRayForTransform: Ray;
  77841. /** @hidden */
  77842. _pickWithRayInverseMatrix: Matrix;
  77843. /** @hidden */
  77844. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  77845. /** @hidden */
  77846. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  77847. }
  77848. }
  77849. declare module BABYLON {
  77850. /**
  77851. * Groups all the scene component constants in one place to ease maintenance.
  77852. * @hidden
  77853. */
  77854. export class SceneComponentConstants {
  77855. static readonly NAME_EFFECTLAYER: string;
  77856. static readonly NAME_LAYER: string;
  77857. static readonly NAME_LENSFLARESYSTEM: string;
  77858. static readonly NAME_BOUNDINGBOXRENDERER: string;
  77859. static readonly NAME_PARTICLESYSTEM: string;
  77860. static readonly NAME_GAMEPAD: string;
  77861. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  77862. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  77863. static readonly NAME_DEPTHRENDERER: string;
  77864. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  77865. static readonly NAME_SPRITE: string;
  77866. static readonly NAME_OUTLINERENDERER: string;
  77867. static readonly NAME_PROCEDURALTEXTURE: string;
  77868. static readonly NAME_SHADOWGENERATOR: string;
  77869. static readonly NAME_OCTREE: string;
  77870. static readonly NAME_PHYSICSENGINE: string;
  77871. static readonly NAME_AUDIO: string;
  77872. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  77873. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77874. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  77875. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77876. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  77877. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  77878. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  77879. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  77880. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  77881. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  77882. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  77883. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  77884. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  77885. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  77886. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  77887. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  77888. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  77889. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  77890. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  77891. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  77892. static readonly STEP_AFTERRENDER_AUDIO: number;
  77893. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  77894. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  77895. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  77896. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  77897. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  77898. static readonly STEP_POINTERMOVE_SPRITE: number;
  77899. static readonly STEP_POINTERDOWN_SPRITE: number;
  77900. static readonly STEP_POINTERUP_SPRITE: number;
  77901. }
  77902. /**
  77903. * This represents a scene component.
  77904. *
  77905. * This is used to decouple the dependency the scene is having on the different workloads like
  77906. * layers, post processes...
  77907. */
  77908. export interface ISceneComponent {
  77909. /**
  77910. * The name of the component. Each component must have a unique name.
  77911. */
  77912. name: string;
  77913. /**
  77914. * The scene the component belongs to.
  77915. */
  77916. scene: Scene;
  77917. /**
  77918. * Register the component to one instance of a scene.
  77919. */
  77920. register(): void;
  77921. /**
  77922. * Rebuilds the elements related to this component in case of
  77923. * context lost for instance.
  77924. */
  77925. rebuild(): void;
  77926. /**
  77927. * Disposes the component and the associated ressources.
  77928. */
  77929. dispose(): void;
  77930. }
  77931. /**
  77932. * This represents a SERIALIZABLE scene component.
  77933. *
  77934. * This extends Scene Component to add Serialization methods on top.
  77935. */
  77936. export interface ISceneSerializableComponent extends ISceneComponent {
  77937. /**
  77938. * Adds all the elements from the container to the scene
  77939. * @param container the container holding the elements
  77940. */
  77941. addFromContainer(container: AbstractScene): void;
  77942. /**
  77943. * Removes all the elements in the container from the scene
  77944. * @param container contains the elements to remove
  77945. * @param dispose if the removed element should be disposed (default: false)
  77946. */
  77947. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77948. /**
  77949. * Serializes the component data to the specified json object
  77950. * @param serializationObject The object to serialize to
  77951. */
  77952. serialize(serializationObject: any): void;
  77953. }
  77954. /**
  77955. * Strong typing of a Mesh related stage step action
  77956. */
  77957. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  77958. /**
  77959. * Strong typing of a Evaluate Sub Mesh related stage step action
  77960. */
  77961. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  77962. /**
  77963. * Strong typing of a Active Mesh related stage step action
  77964. */
  77965. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  77966. /**
  77967. * Strong typing of a Camera related stage step action
  77968. */
  77969. export type CameraStageAction = (camera: Camera) => void;
  77970. /**
  77971. * Strong typing of a Camera Frame buffer related stage step action
  77972. */
  77973. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  77974. /**
  77975. * Strong typing of a Render Target related stage step action
  77976. */
  77977. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  77978. /**
  77979. * Strong typing of a RenderingGroup related stage step action
  77980. */
  77981. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  77982. /**
  77983. * Strong typing of a Mesh Render related stage step action
  77984. */
  77985. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  77986. /**
  77987. * Strong typing of a simple stage step action
  77988. */
  77989. export type SimpleStageAction = () => void;
  77990. /**
  77991. * Strong typing of a render target action.
  77992. */
  77993. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  77994. /**
  77995. * Strong typing of a pointer move action.
  77996. */
  77997. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  77998. /**
  77999. * Strong typing of a pointer up/down action.
  78000. */
  78001. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  78002. /**
  78003. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  78004. * @hidden
  78005. */
  78006. export class Stage<T extends Function> extends Array<{
  78007. index: number;
  78008. component: ISceneComponent;
  78009. action: T;
  78010. }> {
  78011. /**
  78012. * Hide ctor from the rest of the world.
  78013. * @param items The items to add.
  78014. */
  78015. private constructor();
  78016. /**
  78017. * Creates a new Stage.
  78018. * @returns A new instance of a Stage
  78019. */
  78020. static Create<T extends Function>(): Stage<T>;
  78021. /**
  78022. * Registers a step in an ordered way in the targeted stage.
  78023. * @param index Defines the position to register the step in
  78024. * @param component Defines the component attached to the step
  78025. * @param action Defines the action to launch during the step
  78026. */
  78027. registerStep(index: number, component: ISceneComponent, action: T): void;
  78028. /**
  78029. * Clears all the steps from the stage.
  78030. */
  78031. clear(): void;
  78032. }
  78033. }
  78034. declare module BABYLON {
  78035. interface Scene {
  78036. /** @hidden */
  78037. _pointerOverSprite: Nullable<Sprite>;
  78038. /** @hidden */
  78039. _pickedDownSprite: Nullable<Sprite>;
  78040. /** @hidden */
  78041. _tempSpritePickingRay: Nullable<Ray>;
  78042. /**
  78043. * All of the sprite managers added to this scene
  78044. * @see http://doc.babylonjs.com/babylon101/sprites
  78045. */
  78046. spriteManagers: Array<ISpriteManager>;
  78047. /**
  78048. * An event triggered when sprites rendering is about to start
  78049. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78050. */
  78051. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78052. /**
  78053. * An event triggered when sprites rendering is done
  78054. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78055. */
  78056. onAfterSpritesRenderingObservable: Observable<Scene>;
  78057. /** @hidden */
  78058. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78059. /** Launch a ray to try to pick a sprite in the scene
  78060. * @param x position on screen
  78061. * @param y position on screen
  78062. * @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
  78063. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78064. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78065. * @returns a PickingInfo
  78066. */
  78067. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78068. /** Use the given ray to pick a sprite in the scene
  78069. * @param ray The ray (in world space) to use to pick meshes
  78070. * @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
  78071. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78072. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78073. * @returns a PickingInfo
  78074. */
  78075. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78076. /** @hidden */
  78077. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78078. /** Launch a ray to try to pick sprites in the scene
  78079. * @param x position on screen
  78080. * @param y position on screen
  78081. * @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
  78082. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78083. * @returns a PickingInfo array
  78084. */
  78085. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78086. /** Use the given ray to pick sprites in the scene
  78087. * @param ray The ray (in world space) to use to pick meshes
  78088. * @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
  78089. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78090. * @returns a PickingInfo array
  78091. */
  78092. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78093. /**
  78094. * Force the sprite under the pointer
  78095. * @param sprite defines the sprite to use
  78096. */
  78097. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78098. /**
  78099. * Gets the sprite under the pointer
  78100. * @returns a Sprite or null if no sprite is under the pointer
  78101. */
  78102. getPointerOverSprite(): Nullable<Sprite>;
  78103. }
  78104. /**
  78105. * Defines the sprite scene component responsible to manage sprites
  78106. * in a given scene.
  78107. */
  78108. export class SpriteSceneComponent implements ISceneComponent {
  78109. /**
  78110. * The component name helpfull to identify the component in the list of scene components.
  78111. */
  78112. readonly name: string;
  78113. /**
  78114. * The scene the component belongs to.
  78115. */
  78116. scene: Scene;
  78117. /** @hidden */
  78118. private _spritePredicate;
  78119. /**
  78120. * Creates a new instance of the component for the given scene
  78121. * @param scene Defines the scene to register the component in
  78122. */
  78123. constructor(scene: Scene);
  78124. /**
  78125. * Registers the component in a given scene
  78126. */
  78127. register(): void;
  78128. /**
  78129. * Rebuilds the elements related to this component in case of
  78130. * context lost for instance.
  78131. */
  78132. rebuild(): void;
  78133. /**
  78134. * Disposes the component and the associated ressources.
  78135. */
  78136. dispose(): void;
  78137. private _pickSpriteButKeepRay;
  78138. private _pointerMove;
  78139. private _pointerDown;
  78140. private _pointerUp;
  78141. }
  78142. }
  78143. declare module BABYLON {
  78144. /** @hidden */
  78145. export var fogFragmentDeclaration: {
  78146. name: string;
  78147. shader: string;
  78148. };
  78149. }
  78150. declare module BABYLON {
  78151. /** @hidden */
  78152. export var fogFragment: {
  78153. name: string;
  78154. shader: string;
  78155. };
  78156. }
  78157. declare module BABYLON {
  78158. /** @hidden */
  78159. export var spritesPixelShader: {
  78160. name: string;
  78161. shader: string;
  78162. };
  78163. }
  78164. declare module BABYLON {
  78165. /** @hidden */
  78166. export var fogVertexDeclaration: {
  78167. name: string;
  78168. shader: string;
  78169. };
  78170. }
  78171. declare module BABYLON {
  78172. /** @hidden */
  78173. export var spritesVertexShader: {
  78174. name: string;
  78175. shader: string;
  78176. };
  78177. }
  78178. declare module BABYLON {
  78179. /**
  78180. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78181. */
  78182. export interface ISpriteManager extends IDisposable {
  78183. /**
  78184. * Restricts the camera to viewing objects with the same layerMask.
  78185. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78186. */
  78187. layerMask: number;
  78188. /**
  78189. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78190. */
  78191. isPickable: boolean;
  78192. /**
  78193. * Specifies the rendering group id for this mesh (0 by default)
  78194. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78195. */
  78196. renderingGroupId: number;
  78197. /**
  78198. * Defines the list of sprites managed by the manager.
  78199. */
  78200. sprites: Array<Sprite>;
  78201. /**
  78202. * Tests the intersection of a sprite with a specific ray.
  78203. * @param ray The ray we are sending to test the collision
  78204. * @param camera The camera space we are sending rays in
  78205. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78206. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78207. * @returns picking info or null.
  78208. */
  78209. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78210. /**
  78211. * Intersects the sprites with a ray
  78212. * @param ray defines the ray to intersect with
  78213. * @param camera defines the current active camera
  78214. * @param predicate defines a predicate used to select candidate sprites
  78215. * @returns null if no hit or a PickingInfo array
  78216. */
  78217. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78218. /**
  78219. * Renders the list of sprites on screen.
  78220. */
  78221. render(): void;
  78222. }
  78223. /**
  78224. * Class used to manage multiple sprites on the same spritesheet
  78225. * @see http://doc.babylonjs.com/babylon101/sprites
  78226. */
  78227. export class SpriteManager implements ISpriteManager {
  78228. /** defines the manager's name */
  78229. name: string;
  78230. /** Gets the list of sprites */
  78231. sprites: Sprite[];
  78232. /** Gets or sets the rendering group id (0 by default) */
  78233. renderingGroupId: number;
  78234. /** Gets or sets camera layer mask */
  78235. layerMask: number;
  78236. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78237. fogEnabled: boolean;
  78238. /** Gets or sets a boolean indicating if the sprites are pickable */
  78239. isPickable: boolean;
  78240. /** Defines the default width of a cell in the spritesheet */
  78241. cellWidth: number;
  78242. /** Defines the default height of a cell in the spritesheet */
  78243. cellHeight: number;
  78244. /** Associative array from JSON sprite data file */
  78245. private _cellData;
  78246. /** Array of sprite names from JSON sprite data file */
  78247. private _spriteMap;
  78248. /** True when packed cell data from JSON file is ready*/
  78249. private _packedAndReady;
  78250. /**
  78251. * An event triggered when the manager is disposed.
  78252. */
  78253. onDisposeObservable: Observable<SpriteManager>;
  78254. private _onDisposeObserver;
  78255. /**
  78256. * Callback called when the manager is disposed
  78257. */
  78258. onDispose: () => void;
  78259. private _capacity;
  78260. private _fromPacked;
  78261. private _spriteTexture;
  78262. private _epsilon;
  78263. private _scene;
  78264. private _vertexData;
  78265. private _buffer;
  78266. private _vertexBuffers;
  78267. private _indexBuffer;
  78268. private _effectBase;
  78269. private _effectFog;
  78270. /**
  78271. * Gets or sets the spritesheet texture
  78272. */
  78273. texture: Texture;
  78274. /**
  78275. * Creates a new sprite manager
  78276. * @param name defines the manager's name
  78277. * @param imgUrl defines the sprite sheet url
  78278. * @param capacity defines the maximum allowed number of sprites
  78279. * @param cellSize defines the size of a sprite cell
  78280. * @param scene defines the hosting scene
  78281. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78282. * @param samplingMode defines the smapling mode to use with spritesheet
  78283. * @param fromPacked set to false; do not alter
  78284. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  78285. */
  78286. constructor(
  78287. /** defines the manager's name */
  78288. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  78289. private _makePacked;
  78290. private _appendSpriteVertex;
  78291. /**
  78292. * Intersects the sprites with a ray
  78293. * @param ray defines the ray to intersect with
  78294. * @param camera defines the current active camera
  78295. * @param predicate defines a predicate used to select candidate sprites
  78296. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78297. * @returns null if no hit or a PickingInfo
  78298. */
  78299. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78300. /**
  78301. * Intersects the sprites with a ray
  78302. * @param ray defines the ray to intersect with
  78303. * @param camera defines the current active camera
  78304. * @param predicate defines a predicate used to select candidate sprites
  78305. * @returns null if no hit or a PickingInfo array
  78306. */
  78307. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78308. /**
  78309. * Render all child sprites
  78310. */
  78311. render(): void;
  78312. /**
  78313. * Release associated resources
  78314. */
  78315. dispose(): void;
  78316. }
  78317. }
  78318. declare module BABYLON {
  78319. /**
  78320. * Class used to represent a sprite
  78321. * @see http://doc.babylonjs.com/babylon101/sprites
  78322. */
  78323. export class Sprite {
  78324. /** defines the name */
  78325. name: string;
  78326. /** Gets or sets the current world position */
  78327. position: Vector3;
  78328. /** Gets or sets the main color */
  78329. color: Color4;
  78330. /** Gets or sets the width */
  78331. width: number;
  78332. /** Gets or sets the height */
  78333. height: number;
  78334. /** Gets or sets rotation angle */
  78335. angle: number;
  78336. /** Gets or sets the cell index in the sprite sheet */
  78337. cellIndex: number;
  78338. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  78339. cellRef: string;
  78340. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78341. invertU: number;
  78342. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78343. invertV: number;
  78344. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78345. disposeWhenFinishedAnimating: boolean;
  78346. /** Gets the list of attached animations */
  78347. animations: Animation[];
  78348. /** Gets or sets a boolean indicating if the sprite can be picked */
  78349. isPickable: boolean;
  78350. /**
  78351. * Gets or sets the associated action manager
  78352. */
  78353. actionManager: Nullable<ActionManager>;
  78354. private _animationStarted;
  78355. private _loopAnimation;
  78356. private _fromIndex;
  78357. private _toIndex;
  78358. private _delay;
  78359. private _direction;
  78360. private _manager;
  78361. private _time;
  78362. private _onAnimationEnd;
  78363. /**
  78364. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78365. */
  78366. isVisible: boolean;
  78367. /**
  78368. * Gets or sets the sprite size
  78369. */
  78370. size: number;
  78371. /**
  78372. * Creates a new Sprite
  78373. * @param name defines the name
  78374. * @param manager defines the manager
  78375. */
  78376. constructor(
  78377. /** defines the name */
  78378. name: string, manager: ISpriteManager);
  78379. /**
  78380. * Starts an animation
  78381. * @param from defines the initial key
  78382. * @param to defines the end key
  78383. * @param loop defines if the animation must loop
  78384. * @param delay defines the start delay (in ms)
  78385. * @param onAnimationEnd defines a callback to call when animation ends
  78386. */
  78387. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78388. /** Stops current animation (if any) */
  78389. stopAnimation(): void;
  78390. /** @hidden */
  78391. _animate(deltaTime: number): void;
  78392. /** Release associated resources */
  78393. dispose(): void;
  78394. }
  78395. }
  78396. declare module BABYLON {
  78397. /**
  78398. * Information about the result of picking within a scene
  78399. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78400. */
  78401. export class PickingInfo {
  78402. /** @hidden */
  78403. _pickingUnavailable: boolean;
  78404. /**
  78405. * If the pick collided with an object
  78406. */
  78407. hit: boolean;
  78408. /**
  78409. * Distance away where the pick collided
  78410. */
  78411. distance: number;
  78412. /**
  78413. * The location of pick collision
  78414. */
  78415. pickedPoint: Nullable<Vector3>;
  78416. /**
  78417. * The mesh corresponding the the pick collision
  78418. */
  78419. pickedMesh: Nullable<AbstractMesh>;
  78420. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78421. bu: number;
  78422. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78423. bv: number;
  78424. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78425. faceId: number;
  78426. /** Id of the the submesh that was picked */
  78427. subMeshId: number;
  78428. /** If a sprite was picked, this will be the sprite the pick collided with */
  78429. pickedSprite: Nullable<Sprite>;
  78430. /**
  78431. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78432. */
  78433. originMesh: Nullable<AbstractMesh>;
  78434. /**
  78435. * The ray that was used to perform the picking.
  78436. */
  78437. ray: Nullable<Ray>;
  78438. /**
  78439. * Gets the normal correspodning to the face the pick collided with
  78440. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  78441. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  78442. * @returns The normal correspodning to the face the pick collided with
  78443. */
  78444. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  78445. /**
  78446. * Gets the texture coordinates of where the pick occured
  78447. * @returns the vector containing the coordnates of the texture
  78448. */
  78449. getTextureCoordinates(): Nullable<Vector2>;
  78450. }
  78451. }
  78452. declare module BABYLON {
  78453. /**
  78454. * Gather the list of pointer event types as constants.
  78455. */
  78456. export class PointerEventTypes {
  78457. /**
  78458. * 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.
  78459. */
  78460. static readonly POINTERDOWN: number;
  78461. /**
  78462. * The pointerup event is fired when a pointer is no longer active.
  78463. */
  78464. static readonly POINTERUP: number;
  78465. /**
  78466. * The pointermove event is fired when a pointer changes coordinates.
  78467. */
  78468. static readonly POINTERMOVE: number;
  78469. /**
  78470. * The pointerwheel event is fired when a mouse wheel has been rotated.
  78471. */
  78472. static readonly POINTERWHEEL: number;
  78473. /**
  78474. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  78475. */
  78476. static readonly POINTERPICK: number;
  78477. /**
  78478. * The pointertap event is fired when a the object has been touched and released without drag.
  78479. */
  78480. static readonly POINTERTAP: number;
  78481. /**
  78482. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  78483. */
  78484. static readonly POINTERDOUBLETAP: number;
  78485. }
  78486. /**
  78487. * Base class of pointer info types.
  78488. */
  78489. export class PointerInfoBase {
  78490. /**
  78491. * Defines the type of event (PointerEventTypes)
  78492. */
  78493. type: number;
  78494. /**
  78495. * Defines the related dom event
  78496. */
  78497. event: PointerEvent | MouseWheelEvent;
  78498. /**
  78499. * Instantiates the base class of pointers info.
  78500. * @param type Defines the type of event (PointerEventTypes)
  78501. * @param event Defines the related dom event
  78502. */
  78503. constructor(
  78504. /**
  78505. * Defines the type of event (PointerEventTypes)
  78506. */
  78507. type: number,
  78508. /**
  78509. * Defines the related dom event
  78510. */
  78511. event: PointerEvent | MouseWheelEvent);
  78512. }
  78513. /**
  78514. * This class is used to store pointer related info for the onPrePointerObservable event.
  78515. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  78516. */
  78517. export class PointerInfoPre extends PointerInfoBase {
  78518. /**
  78519. * Ray from a pointer if availible (eg. 6dof controller)
  78520. */
  78521. ray: Nullable<Ray>;
  78522. /**
  78523. * Defines the local position of the pointer on the canvas.
  78524. */
  78525. localPosition: Vector2;
  78526. /**
  78527. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  78528. */
  78529. skipOnPointerObservable: boolean;
  78530. /**
  78531. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  78532. * @param type Defines the type of event (PointerEventTypes)
  78533. * @param event Defines the related dom event
  78534. * @param localX Defines the local x coordinates of the pointer when the event occured
  78535. * @param localY Defines the local y coordinates of the pointer when the event occured
  78536. */
  78537. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  78538. }
  78539. /**
  78540. * This type contains all the data related to a pointer event in Babylon.js.
  78541. * 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.
  78542. */
  78543. export class PointerInfo extends PointerInfoBase {
  78544. /**
  78545. * Defines the picking info associated to the info (if any)\
  78546. */
  78547. pickInfo: Nullable<PickingInfo>;
  78548. /**
  78549. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  78550. * @param type Defines the type of event (PointerEventTypes)
  78551. * @param event Defines the related dom event
  78552. * @param pickInfo Defines the picking info associated to the info (if any)\
  78553. */
  78554. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  78555. /**
  78556. * Defines the picking info associated to the info (if any)\
  78557. */
  78558. pickInfo: Nullable<PickingInfo>);
  78559. }
  78560. /**
  78561. * Data relating to a touch event on the screen.
  78562. */
  78563. export interface PointerTouch {
  78564. /**
  78565. * X coordinate of touch.
  78566. */
  78567. x: number;
  78568. /**
  78569. * Y coordinate of touch.
  78570. */
  78571. y: number;
  78572. /**
  78573. * Id of touch. Unique for each finger.
  78574. */
  78575. pointerId: number;
  78576. /**
  78577. * Event type passed from DOM.
  78578. */
  78579. type: any;
  78580. }
  78581. }
  78582. declare module BABYLON {
  78583. /**
  78584. * Manage the mouse inputs to control the movement of a free camera.
  78585. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78586. */
  78587. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  78588. /**
  78589. * Define if touch is enabled in the mouse input
  78590. */
  78591. touchEnabled: boolean;
  78592. /**
  78593. * Defines the camera the input is attached to.
  78594. */
  78595. camera: FreeCamera;
  78596. /**
  78597. * Defines the buttons associated with the input to handle camera move.
  78598. */
  78599. buttons: number[];
  78600. /**
  78601. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  78602. */
  78603. angularSensibility: number;
  78604. private _pointerInput;
  78605. private _onMouseMove;
  78606. private _observer;
  78607. private previousPosition;
  78608. /**
  78609. * Observable for when a pointer move event occurs containing the move offset
  78610. */
  78611. onPointerMovedObservable: Observable<{
  78612. offsetX: number;
  78613. offsetY: number;
  78614. }>;
  78615. /**
  78616. * @hidden
  78617. * If the camera should be rotated automatically based on pointer movement
  78618. */
  78619. _allowCameraRotation: boolean;
  78620. /**
  78621. * Manage the mouse inputs to control the movement of a free camera.
  78622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78623. * @param touchEnabled Defines if touch is enabled or not
  78624. */
  78625. constructor(
  78626. /**
  78627. * Define if touch is enabled in the mouse input
  78628. */
  78629. touchEnabled?: boolean);
  78630. /**
  78631. * Attach the input controls to a specific dom element to get the input from.
  78632. * @param element Defines the element the controls should be listened from
  78633. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78634. */
  78635. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78636. /**
  78637. * Called on JS contextmenu event.
  78638. * Override this method to provide functionality.
  78639. */
  78640. protected onContextMenu(evt: PointerEvent): void;
  78641. /**
  78642. * Detach the current controls from the specified dom element.
  78643. * @param element Defines the element to stop listening the inputs from
  78644. */
  78645. detachControl(element: Nullable<HTMLElement>): void;
  78646. /**
  78647. * Gets the class name of the current intput.
  78648. * @returns the class name
  78649. */
  78650. getClassName(): string;
  78651. /**
  78652. * Get the friendly name associated with the input class.
  78653. * @returns the input friendly name
  78654. */
  78655. getSimpleName(): string;
  78656. }
  78657. }
  78658. declare module BABYLON {
  78659. /**
  78660. * Manage the touch inputs to control the movement of a free camera.
  78661. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78662. */
  78663. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  78664. /**
  78665. * Defines the camera the input is attached to.
  78666. */
  78667. camera: FreeCamera;
  78668. /**
  78669. * Defines the touch sensibility for rotation.
  78670. * The higher the faster.
  78671. */
  78672. touchAngularSensibility: number;
  78673. /**
  78674. * Defines the touch sensibility for move.
  78675. * The higher the faster.
  78676. */
  78677. touchMoveSensibility: number;
  78678. private _offsetX;
  78679. private _offsetY;
  78680. private _pointerPressed;
  78681. private _pointerInput;
  78682. private _observer;
  78683. private _onLostFocus;
  78684. /**
  78685. * Attach the input controls to a specific dom element to get the input from.
  78686. * @param element Defines the element the controls should be listened from
  78687. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78688. */
  78689. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78690. /**
  78691. * Detach the current controls from the specified dom element.
  78692. * @param element Defines the element to stop listening the inputs from
  78693. */
  78694. detachControl(element: Nullable<HTMLElement>): void;
  78695. /**
  78696. * Update the current camera state depending on the inputs that have been used this frame.
  78697. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78698. */
  78699. checkInputs(): void;
  78700. /**
  78701. * Gets the class name of the current intput.
  78702. * @returns the class name
  78703. */
  78704. getClassName(): string;
  78705. /**
  78706. * Get the friendly name associated with the input class.
  78707. * @returns the input friendly name
  78708. */
  78709. getSimpleName(): string;
  78710. }
  78711. }
  78712. declare module BABYLON {
  78713. /**
  78714. * Default Inputs manager for the FreeCamera.
  78715. * It groups all the default supported inputs for ease of use.
  78716. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78717. */
  78718. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  78719. /**
  78720. * @hidden
  78721. */
  78722. _mouseInput: Nullable<FreeCameraMouseInput>;
  78723. /**
  78724. * Instantiates a new FreeCameraInputsManager.
  78725. * @param camera Defines the camera the inputs belong to
  78726. */
  78727. constructor(camera: FreeCamera);
  78728. /**
  78729. * Add keyboard input support to the input manager.
  78730. * @returns the current input manager
  78731. */
  78732. addKeyboard(): FreeCameraInputsManager;
  78733. /**
  78734. * Add mouse input support to the input manager.
  78735. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  78736. * @returns the current input manager
  78737. */
  78738. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  78739. /**
  78740. * Removes the mouse input support from the manager
  78741. * @returns the current input manager
  78742. */
  78743. removeMouse(): FreeCameraInputsManager;
  78744. /**
  78745. * Add touch input support to the input manager.
  78746. * @returns the current input manager
  78747. */
  78748. addTouch(): FreeCameraInputsManager;
  78749. /**
  78750. * Remove all attached input methods from a camera
  78751. */
  78752. clear(): void;
  78753. }
  78754. }
  78755. declare module BABYLON {
  78756. /**
  78757. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78758. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  78759. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78760. */
  78761. export class FreeCamera extends TargetCamera {
  78762. /**
  78763. * Define the collision ellipsoid of the camera.
  78764. * This is helpful to simulate a camera body like the player body around the camera
  78765. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  78766. */
  78767. ellipsoid: Vector3;
  78768. /**
  78769. * Define an offset for the position of the ellipsoid around the camera.
  78770. * This can be helpful to determine the center of the body near the gravity center of the body
  78771. * instead of its head.
  78772. */
  78773. ellipsoidOffset: Vector3;
  78774. /**
  78775. * Enable or disable collisions of the camera with the rest of the scene objects.
  78776. */
  78777. checkCollisions: boolean;
  78778. /**
  78779. * Enable or disable gravity on the camera.
  78780. */
  78781. applyGravity: boolean;
  78782. /**
  78783. * Define the input manager associated to the camera.
  78784. */
  78785. inputs: FreeCameraInputsManager;
  78786. /**
  78787. * Gets the input sensibility for a mouse input. (default is 2000.0)
  78788. * Higher values reduce sensitivity.
  78789. */
  78790. /**
  78791. * Sets the input sensibility for a mouse input. (default is 2000.0)
  78792. * Higher values reduce sensitivity.
  78793. */
  78794. angularSensibility: number;
  78795. /**
  78796. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  78797. */
  78798. keysUp: number[];
  78799. /**
  78800. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  78801. */
  78802. keysDown: number[];
  78803. /**
  78804. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  78805. */
  78806. keysLeft: number[];
  78807. /**
  78808. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  78809. */
  78810. keysRight: number[];
  78811. /**
  78812. * Event raised when the camera collide with a mesh in the scene.
  78813. */
  78814. onCollide: (collidedMesh: AbstractMesh) => void;
  78815. private _collider;
  78816. private _needMoveForGravity;
  78817. private _oldPosition;
  78818. private _diffPosition;
  78819. private _newPosition;
  78820. /** @hidden */
  78821. _localDirection: Vector3;
  78822. /** @hidden */
  78823. _transformedDirection: Vector3;
  78824. /**
  78825. * Instantiates a Free Camera.
  78826. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78827. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  78828. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78829. * @param name Define the name of the camera in the scene
  78830. * @param position Define the start position of the camera in the scene
  78831. * @param scene Define the scene the camera belongs to
  78832. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  78833. */
  78834. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  78835. /**
  78836. * Attached controls to the current camera.
  78837. * @param element Defines the element the controls should be listened from
  78838. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78839. */
  78840. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78841. /**
  78842. * Detach the current controls from the camera.
  78843. * The camera will stop reacting to inputs.
  78844. * @param element Defines the element to stop listening the inputs from
  78845. */
  78846. detachControl(element: HTMLElement): void;
  78847. private _collisionMask;
  78848. /**
  78849. * Define a collision mask to limit the list of object the camera can collide with
  78850. */
  78851. collisionMask: number;
  78852. /** @hidden */
  78853. _collideWithWorld(displacement: Vector3): void;
  78854. private _onCollisionPositionChange;
  78855. /** @hidden */
  78856. _checkInputs(): void;
  78857. /** @hidden */
  78858. _decideIfNeedsToMove(): boolean;
  78859. /** @hidden */
  78860. _updatePosition(): void;
  78861. /**
  78862. * Destroy the camera and release the current resources hold by it.
  78863. */
  78864. dispose(): void;
  78865. /**
  78866. * Gets the current object class name.
  78867. * @return the class name
  78868. */
  78869. getClassName(): string;
  78870. }
  78871. }
  78872. declare module BABYLON {
  78873. /**
  78874. * Represents a gamepad control stick position
  78875. */
  78876. export class StickValues {
  78877. /**
  78878. * The x component of the control stick
  78879. */
  78880. x: number;
  78881. /**
  78882. * The y component of the control stick
  78883. */
  78884. y: number;
  78885. /**
  78886. * Initializes the gamepad x and y control stick values
  78887. * @param x The x component of the gamepad control stick value
  78888. * @param y The y component of the gamepad control stick value
  78889. */
  78890. constructor(
  78891. /**
  78892. * The x component of the control stick
  78893. */
  78894. x: number,
  78895. /**
  78896. * The y component of the control stick
  78897. */
  78898. y: number);
  78899. }
  78900. /**
  78901. * An interface which manages callbacks for gamepad button changes
  78902. */
  78903. export interface GamepadButtonChanges {
  78904. /**
  78905. * Called when a gamepad has been changed
  78906. */
  78907. changed: boolean;
  78908. /**
  78909. * Called when a gamepad press event has been triggered
  78910. */
  78911. pressChanged: boolean;
  78912. /**
  78913. * Called when a touch event has been triggered
  78914. */
  78915. touchChanged: boolean;
  78916. /**
  78917. * Called when a value has changed
  78918. */
  78919. valueChanged: boolean;
  78920. }
  78921. /**
  78922. * Represents a gamepad
  78923. */
  78924. export class Gamepad {
  78925. /**
  78926. * The id of the gamepad
  78927. */
  78928. id: string;
  78929. /**
  78930. * The index of the gamepad
  78931. */
  78932. index: number;
  78933. /**
  78934. * The browser gamepad
  78935. */
  78936. browserGamepad: any;
  78937. /**
  78938. * Specifies what type of gamepad this represents
  78939. */
  78940. type: number;
  78941. private _leftStick;
  78942. private _rightStick;
  78943. /** @hidden */
  78944. _isConnected: boolean;
  78945. private _leftStickAxisX;
  78946. private _leftStickAxisY;
  78947. private _rightStickAxisX;
  78948. private _rightStickAxisY;
  78949. /**
  78950. * Triggered when the left control stick has been changed
  78951. */
  78952. private _onleftstickchanged;
  78953. /**
  78954. * Triggered when the right control stick has been changed
  78955. */
  78956. private _onrightstickchanged;
  78957. /**
  78958. * Represents a gamepad controller
  78959. */
  78960. static GAMEPAD: number;
  78961. /**
  78962. * Represents a generic controller
  78963. */
  78964. static GENERIC: number;
  78965. /**
  78966. * Represents an XBox controller
  78967. */
  78968. static XBOX: number;
  78969. /**
  78970. * Represents a pose-enabled controller
  78971. */
  78972. static POSE_ENABLED: number;
  78973. /**
  78974. * Represents an Dual Shock controller
  78975. */
  78976. static DUALSHOCK: number;
  78977. /**
  78978. * Specifies whether the left control stick should be Y-inverted
  78979. */
  78980. protected _invertLeftStickY: boolean;
  78981. /**
  78982. * Specifies if the gamepad has been connected
  78983. */
  78984. readonly isConnected: boolean;
  78985. /**
  78986. * Initializes the gamepad
  78987. * @param id The id of the gamepad
  78988. * @param index The index of the gamepad
  78989. * @param browserGamepad The browser gamepad
  78990. * @param leftStickX The x component of the left joystick
  78991. * @param leftStickY The y component of the left joystick
  78992. * @param rightStickX The x component of the right joystick
  78993. * @param rightStickY The y component of the right joystick
  78994. */
  78995. constructor(
  78996. /**
  78997. * The id of the gamepad
  78998. */
  78999. id: string,
  79000. /**
  79001. * The index of the gamepad
  79002. */
  79003. index: number,
  79004. /**
  79005. * The browser gamepad
  79006. */
  79007. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79008. /**
  79009. * Callback triggered when the left joystick has changed
  79010. * @param callback
  79011. */
  79012. onleftstickchanged(callback: (values: StickValues) => void): void;
  79013. /**
  79014. * Callback triggered when the right joystick has changed
  79015. * @param callback
  79016. */
  79017. onrightstickchanged(callback: (values: StickValues) => void): void;
  79018. /**
  79019. * Gets the left joystick
  79020. */
  79021. /**
  79022. * Sets the left joystick values
  79023. */
  79024. leftStick: StickValues;
  79025. /**
  79026. * Gets the right joystick
  79027. */
  79028. /**
  79029. * Sets the right joystick value
  79030. */
  79031. rightStick: StickValues;
  79032. /**
  79033. * Updates the gamepad joystick positions
  79034. */
  79035. update(): void;
  79036. /**
  79037. * Disposes the gamepad
  79038. */
  79039. dispose(): void;
  79040. }
  79041. /**
  79042. * Represents a generic gamepad
  79043. */
  79044. export class GenericPad extends Gamepad {
  79045. private _buttons;
  79046. private _onbuttondown;
  79047. private _onbuttonup;
  79048. /**
  79049. * Observable triggered when a button has been pressed
  79050. */
  79051. onButtonDownObservable: Observable<number>;
  79052. /**
  79053. * Observable triggered when a button has been released
  79054. */
  79055. onButtonUpObservable: Observable<number>;
  79056. /**
  79057. * Callback triggered when a button has been pressed
  79058. * @param callback Called when a button has been pressed
  79059. */
  79060. onbuttondown(callback: (buttonPressed: number) => void): void;
  79061. /**
  79062. * Callback triggered when a button has been released
  79063. * @param callback Called when a button has been released
  79064. */
  79065. onbuttonup(callback: (buttonReleased: number) => void): void;
  79066. /**
  79067. * Initializes the generic gamepad
  79068. * @param id The id of the generic gamepad
  79069. * @param index The index of the generic gamepad
  79070. * @param browserGamepad The browser gamepad
  79071. */
  79072. constructor(id: string, index: number, browserGamepad: any);
  79073. private _setButtonValue;
  79074. /**
  79075. * Updates the generic gamepad
  79076. */
  79077. update(): void;
  79078. /**
  79079. * Disposes the generic gamepad
  79080. */
  79081. dispose(): void;
  79082. }
  79083. }
  79084. declare module BABYLON {
  79085. interface Engine {
  79086. /**
  79087. * Creates a raw texture
  79088. * @param data defines the data to store in the texture
  79089. * @param width defines the width of the texture
  79090. * @param height defines the height of the texture
  79091. * @param format defines the format of the data
  79092. * @param generateMipMaps defines if the engine should generate the mip levels
  79093. * @param invertY defines if data must be stored with Y axis inverted
  79094. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  79095. * @param compression defines the compression used (null by default)
  79096. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79097. * @returns the raw texture inside an InternalTexture
  79098. */
  79099. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  79100. /**
  79101. * Update a raw texture
  79102. * @param texture defines the texture to update
  79103. * @param data defines the data to store in the texture
  79104. * @param format defines the format of the data
  79105. * @param invertY defines if data must be stored with Y axis inverted
  79106. */
  79107. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79108. /**
  79109. * Update a raw texture
  79110. * @param texture defines the texture to update
  79111. * @param data defines the data to store in the texture
  79112. * @param format defines the format of the data
  79113. * @param invertY defines if data must be stored with Y axis inverted
  79114. * @param compression defines the compression used (null by default)
  79115. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79116. */
  79117. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  79118. /**
  79119. * Creates a new raw cube texture
  79120. * @param data defines the array of data to use to create each face
  79121. * @param size defines the size of the textures
  79122. * @param format defines the format of the data
  79123. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79124. * @param generateMipMaps defines if the engine should generate the mip levels
  79125. * @param invertY defines if data must be stored with Y axis inverted
  79126. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79127. * @param compression defines the compression used (null by default)
  79128. * @returns the cube texture as an InternalTexture
  79129. */
  79130. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  79131. /**
  79132. * Update a raw cube texture
  79133. * @param texture defines the texture to udpdate
  79134. * @param data defines the data to store
  79135. * @param format defines the data format
  79136. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79137. * @param invertY defines if data must be stored with Y axis inverted
  79138. */
  79139. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  79140. /**
  79141. * Update a raw cube texture
  79142. * @param texture defines the texture to udpdate
  79143. * @param data defines the data to store
  79144. * @param format defines the data format
  79145. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79146. * @param invertY defines if data must be stored with Y axis inverted
  79147. * @param compression defines the compression used (null by default)
  79148. */
  79149. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  79150. /**
  79151. * Update a raw cube texture
  79152. * @param texture defines the texture to udpdate
  79153. * @param data defines the data to store
  79154. * @param format defines the data format
  79155. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79156. * @param invertY defines if data must be stored with Y axis inverted
  79157. * @param compression defines the compression used (null by default)
  79158. * @param level defines which level of the texture to update
  79159. */
  79160. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  79161. /**
  79162. * Creates a new raw cube texture from a specified url
  79163. * @param url defines the url where the data is located
  79164. * @param scene defines the current scene
  79165. * @param size defines the size of the textures
  79166. * @param format defines the format of the data
  79167. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79168. * @param noMipmap defines if the engine should avoid generating the mip levels
  79169. * @param callback defines a callback used to extract texture data from loaded data
  79170. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79171. * @param onLoad defines a callback called when texture is loaded
  79172. * @param onError defines a callback called if there is an error
  79173. * @returns the cube texture as an InternalTexture
  79174. */
  79175. 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;
  79176. /**
  79177. * Creates a new raw cube texture from a specified url
  79178. * @param url defines the url where the data is located
  79179. * @param scene defines the current scene
  79180. * @param size defines the size of the textures
  79181. * @param format defines the format of the data
  79182. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79183. * @param noMipmap defines if the engine should avoid generating the mip levels
  79184. * @param callback defines a callback used to extract texture data from loaded data
  79185. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79186. * @param onLoad defines a callback called when texture is loaded
  79187. * @param onError defines a callback called if there is an error
  79188. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79189. * @param invertY defines if data must be stored with Y axis inverted
  79190. * @returns the cube texture as an InternalTexture
  79191. */
  79192. 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;
  79193. /**
  79194. * Creates a new raw 3D texture
  79195. * @param data defines the data used to create the texture
  79196. * @param width defines the width of the texture
  79197. * @param height defines the height of the texture
  79198. * @param depth defines the depth of the texture
  79199. * @param format defines the format of the texture
  79200. * @param generateMipMaps defines if the engine must generate mip levels
  79201. * @param invertY defines if data must be stored with Y axis inverted
  79202. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79203. * @param compression defines the compressed used (can be null)
  79204. * @param textureType defines the compressed used (can be null)
  79205. * @returns a new raw 3D texture (stored in an InternalTexture)
  79206. */
  79207. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  79208. /**
  79209. * Update a raw 3D texture
  79210. * @param texture defines the texture to update
  79211. * @param data defines the data to store
  79212. * @param format defines the data format
  79213. * @param invertY defines if data must be stored with Y axis inverted
  79214. */
  79215. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79216. /**
  79217. * Update a raw 3D texture
  79218. * @param texture defines the texture to update
  79219. * @param data defines the data to store
  79220. * @param format defines the data format
  79221. * @param invertY defines if data must be stored with Y axis inverted
  79222. * @param compression defines the used compression (can be null)
  79223. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  79224. */
  79225. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  79226. }
  79227. }
  79228. declare module BABYLON {
  79229. /**
  79230. * Raw texture can help creating a texture directly from an array of data.
  79231. * This can be super useful if you either get the data from an uncompressed source or
  79232. * if you wish to create your texture pixel by pixel.
  79233. */
  79234. export class RawTexture extends Texture {
  79235. /**
  79236. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79237. */
  79238. format: number;
  79239. private _engine;
  79240. /**
  79241. * Instantiates a new RawTexture.
  79242. * Raw texture can help creating a texture directly from an array of data.
  79243. * This can be super useful if you either get the data from an uncompressed source or
  79244. * if you wish to create your texture pixel by pixel.
  79245. * @param data define the array of data to use to create the texture
  79246. * @param width define the width of the texture
  79247. * @param height define the height of the texture
  79248. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79249. * @param scene define the scene the texture belongs to
  79250. * @param generateMipMaps define whether mip maps should be generated or not
  79251. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79252. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79253. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79254. */
  79255. constructor(data: ArrayBufferView, width: number, height: number,
  79256. /**
  79257. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79258. */
  79259. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  79260. /**
  79261. * Updates the texture underlying data.
  79262. * @param data Define the new data of the texture
  79263. */
  79264. update(data: ArrayBufferView): void;
  79265. /**
  79266. * Creates a luminance texture from some data.
  79267. * @param data Define the texture data
  79268. * @param width Define the width of the texture
  79269. * @param height Define the height of the texture
  79270. * @param scene Define the scene the texture belongs to
  79271. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79272. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79273. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79274. * @returns the luminance texture
  79275. */
  79276. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79277. /**
  79278. * Creates a luminance alpha texture from some data.
  79279. * @param data Define the texture data
  79280. * @param width Define the width of the texture
  79281. * @param height Define the height of the texture
  79282. * @param scene Define the scene the texture belongs to
  79283. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79284. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79285. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79286. * @returns the luminance alpha texture
  79287. */
  79288. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79289. /**
  79290. * Creates an alpha texture from some data.
  79291. * @param data Define the texture data
  79292. * @param width Define the width of the texture
  79293. * @param height Define the height of the texture
  79294. * @param scene Define the scene the texture belongs to
  79295. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79296. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79297. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79298. * @returns the alpha texture
  79299. */
  79300. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79301. /**
  79302. * Creates a RGB texture from some data.
  79303. * @param data Define the texture data
  79304. * @param width Define the width of the texture
  79305. * @param height Define the height of the texture
  79306. * @param scene Define the scene the texture belongs to
  79307. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79308. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79309. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79310. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79311. * @returns the RGB alpha texture
  79312. */
  79313. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79314. /**
  79315. * Creates a RGBA texture from some data.
  79316. * @param data Define the texture data
  79317. * @param width Define the width of the texture
  79318. * @param height Define the height of the texture
  79319. * @param scene Define the scene the texture belongs to
  79320. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79321. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79322. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79323. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79324. * @returns the RGBA texture
  79325. */
  79326. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79327. /**
  79328. * Creates a R texture from some data.
  79329. * @param data Define the texture data
  79330. * @param width Define the width of the texture
  79331. * @param height Define the height of the texture
  79332. * @param scene Define the scene the texture belongs to
  79333. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79334. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79335. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79336. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79337. * @returns the R texture
  79338. */
  79339. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79340. }
  79341. }
  79342. declare module BABYLON {
  79343. /**
  79344. * Interface for the size containing width and height
  79345. */
  79346. export interface ISize {
  79347. /**
  79348. * Width
  79349. */
  79350. width: number;
  79351. /**
  79352. * Heighht
  79353. */
  79354. height: number;
  79355. }
  79356. /**
  79357. * Size containing widht and height
  79358. */
  79359. export class Size implements ISize {
  79360. /**
  79361. * Width
  79362. */
  79363. width: number;
  79364. /**
  79365. * Height
  79366. */
  79367. height: number;
  79368. /**
  79369. * Creates a Size object from the given width and height (floats).
  79370. * @param width width of the new size
  79371. * @param height height of the new size
  79372. */
  79373. constructor(width: number, height: number);
  79374. /**
  79375. * Returns a string with the Size width and height
  79376. * @returns a string with the Size width and height
  79377. */
  79378. toString(): string;
  79379. /**
  79380. * "Size"
  79381. * @returns the string "Size"
  79382. */
  79383. getClassName(): string;
  79384. /**
  79385. * Returns the Size hash code.
  79386. * @returns a hash code for a unique width and height
  79387. */
  79388. getHashCode(): number;
  79389. /**
  79390. * Updates the current size from the given one.
  79391. * @param src the given size
  79392. */
  79393. copyFrom(src: Size): void;
  79394. /**
  79395. * Updates in place the current Size from the given floats.
  79396. * @param width width of the new size
  79397. * @param height height of the new size
  79398. * @returns the updated Size.
  79399. */
  79400. copyFromFloats(width: number, height: number): Size;
  79401. /**
  79402. * Updates in place the current Size from the given floats.
  79403. * @param width width to set
  79404. * @param height height to set
  79405. * @returns the updated Size.
  79406. */
  79407. set(width: number, height: number): Size;
  79408. /**
  79409. * Multiplies the width and height by numbers
  79410. * @param w factor to multiple the width by
  79411. * @param h factor to multiple the height by
  79412. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  79413. */
  79414. multiplyByFloats(w: number, h: number): Size;
  79415. /**
  79416. * Clones the size
  79417. * @returns a new Size copied from the given one.
  79418. */
  79419. clone(): Size;
  79420. /**
  79421. * True if the current Size and the given one width and height are strictly equal.
  79422. * @param other the other size to compare against
  79423. * @returns True if the current Size and the given one width and height are strictly equal.
  79424. */
  79425. equals(other: Size): boolean;
  79426. /**
  79427. * The surface of the Size : width * height (float).
  79428. */
  79429. readonly surface: number;
  79430. /**
  79431. * Create a new size of zero
  79432. * @returns a new Size set to (0.0, 0.0)
  79433. */
  79434. static Zero(): Size;
  79435. /**
  79436. * Sums the width and height of two sizes
  79437. * @param otherSize size to add to this size
  79438. * @returns a new Size set as the addition result of the current Size and the given one.
  79439. */
  79440. add(otherSize: Size): Size;
  79441. /**
  79442. * Subtracts the width and height of two
  79443. * @param otherSize size to subtract to this size
  79444. * @returns a new Size set as the subtraction result of the given one from the current Size.
  79445. */
  79446. subtract(otherSize: Size): Size;
  79447. /**
  79448. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  79449. * @param start starting size to lerp between
  79450. * @param end end size to lerp between
  79451. * @param amount amount to lerp between the start and end values
  79452. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  79453. */
  79454. static Lerp(start: Size, end: Size, amount: number): Size;
  79455. }
  79456. }
  79457. declare module BABYLON {
  79458. /**
  79459. * Defines a runtime animation
  79460. */
  79461. export class RuntimeAnimation {
  79462. private _events;
  79463. /**
  79464. * The current frame of the runtime animation
  79465. */
  79466. private _currentFrame;
  79467. /**
  79468. * The animation used by the runtime animation
  79469. */
  79470. private _animation;
  79471. /**
  79472. * The target of the runtime animation
  79473. */
  79474. private _target;
  79475. /**
  79476. * The initiating animatable
  79477. */
  79478. private _host;
  79479. /**
  79480. * The original value of the runtime animation
  79481. */
  79482. private _originalValue;
  79483. /**
  79484. * The original blend value of the runtime animation
  79485. */
  79486. private _originalBlendValue;
  79487. /**
  79488. * The offsets cache of the runtime animation
  79489. */
  79490. private _offsetsCache;
  79491. /**
  79492. * The high limits cache of the runtime animation
  79493. */
  79494. private _highLimitsCache;
  79495. /**
  79496. * Specifies if the runtime animation has been stopped
  79497. */
  79498. private _stopped;
  79499. /**
  79500. * The blending factor of the runtime animation
  79501. */
  79502. private _blendingFactor;
  79503. /**
  79504. * The BabylonJS scene
  79505. */
  79506. private _scene;
  79507. /**
  79508. * The current value of the runtime animation
  79509. */
  79510. private _currentValue;
  79511. /** @hidden */
  79512. _animationState: _IAnimationState;
  79513. /**
  79514. * The active target of the runtime animation
  79515. */
  79516. private _activeTargets;
  79517. private _currentActiveTarget;
  79518. private _directTarget;
  79519. /**
  79520. * The target path of the runtime animation
  79521. */
  79522. private _targetPath;
  79523. /**
  79524. * The weight of the runtime animation
  79525. */
  79526. private _weight;
  79527. /**
  79528. * The ratio offset of the runtime animation
  79529. */
  79530. private _ratioOffset;
  79531. /**
  79532. * The previous delay of the runtime animation
  79533. */
  79534. private _previousDelay;
  79535. /**
  79536. * The previous ratio of the runtime animation
  79537. */
  79538. private _previousRatio;
  79539. private _enableBlending;
  79540. private _keys;
  79541. private _minFrame;
  79542. private _maxFrame;
  79543. private _minValue;
  79544. private _maxValue;
  79545. private _targetIsArray;
  79546. /**
  79547. * Gets the current frame of the runtime animation
  79548. */
  79549. readonly currentFrame: number;
  79550. /**
  79551. * Gets the weight of the runtime animation
  79552. */
  79553. readonly weight: number;
  79554. /**
  79555. * Gets the current value of the runtime animation
  79556. */
  79557. readonly currentValue: any;
  79558. /**
  79559. * Gets the target path of the runtime animation
  79560. */
  79561. readonly targetPath: string;
  79562. /**
  79563. * Gets the actual target of the runtime animation
  79564. */
  79565. readonly target: any;
  79566. /** @hidden */
  79567. _onLoop: () => void;
  79568. /**
  79569. * Create a new RuntimeAnimation object
  79570. * @param target defines the target of the animation
  79571. * @param animation defines the source animation object
  79572. * @param scene defines the hosting scene
  79573. * @param host defines the initiating Animatable
  79574. */
  79575. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  79576. private _preparePath;
  79577. /**
  79578. * Gets the animation from the runtime animation
  79579. */
  79580. readonly animation: Animation;
  79581. /**
  79582. * Resets the runtime animation to the beginning
  79583. * @param restoreOriginal defines whether to restore the target property to the original value
  79584. */
  79585. reset(restoreOriginal?: boolean): void;
  79586. /**
  79587. * Specifies if the runtime animation is stopped
  79588. * @returns Boolean specifying if the runtime animation is stopped
  79589. */
  79590. isStopped(): boolean;
  79591. /**
  79592. * Disposes of the runtime animation
  79593. */
  79594. dispose(): void;
  79595. /**
  79596. * Apply the interpolated value to the target
  79597. * @param currentValue defines the value computed by the animation
  79598. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  79599. */
  79600. setValue(currentValue: any, weight: number): void;
  79601. private _getOriginalValues;
  79602. private _setValue;
  79603. /**
  79604. * Gets the loop pmode of the runtime animation
  79605. * @returns Loop Mode
  79606. */
  79607. private _getCorrectLoopMode;
  79608. /**
  79609. * Move the current animation to a given frame
  79610. * @param frame defines the frame to move to
  79611. */
  79612. goToFrame(frame: number): void;
  79613. /**
  79614. * @hidden Internal use only
  79615. */
  79616. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  79617. /**
  79618. * Execute the current animation
  79619. * @param delay defines the delay to add to the current frame
  79620. * @param from defines the lower bound of the animation range
  79621. * @param to defines the upper bound of the animation range
  79622. * @param loop defines if the current animation must loop
  79623. * @param speedRatio defines the current speed ratio
  79624. * @param weight defines the weight of the animation (default is -1 so no weight)
  79625. * @param onLoop optional callback called when animation loops
  79626. * @returns a boolean indicating if the animation is running
  79627. */
  79628. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  79629. }
  79630. }
  79631. declare module BABYLON {
  79632. /**
  79633. * Class used to store an actual running animation
  79634. */
  79635. export class Animatable {
  79636. /** defines the target object */
  79637. target: any;
  79638. /** defines the starting frame number (default is 0) */
  79639. fromFrame: number;
  79640. /** defines the ending frame number (default is 100) */
  79641. toFrame: number;
  79642. /** defines if the animation must loop (default is false) */
  79643. loopAnimation: boolean;
  79644. /** defines a callback to call when animation ends if it is not looping */
  79645. onAnimationEnd?: (() => void) | null | undefined;
  79646. /** defines a callback to call when animation loops */
  79647. onAnimationLoop?: (() => void) | null | undefined;
  79648. private _localDelayOffset;
  79649. private _pausedDelay;
  79650. private _runtimeAnimations;
  79651. private _paused;
  79652. private _scene;
  79653. private _speedRatio;
  79654. private _weight;
  79655. private _syncRoot;
  79656. /**
  79657. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  79658. * This will only apply for non looping animation (default is true)
  79659. */
  79660. disposeOnEnd: boolean;
  79661. /**
  79662. * Gets a boolean indicating if the animation has started
  79663. */
  79664. animationStarted: boolean;
  79665. /**
  79666. * Observer raised when the animation ends
  79667. */
  79668. onAnimationEndObservable: Observable<Animatable>;
  79669. /**
  79670. * Observer raised when the animation loops
  79671. */
  79672. onAnimationLoopObservable: Observable<Animatable>;
  79673. /**
  79674. * Gets the root Animatable used to synchronize and normalize animations
  79675. */
  79676. readonly syncRoot: Nullable<Animatable>;
  79677. /**
  79678. * Gets the current frame of the first RuntimeAnimation
  79679. * Used to synchronize Animatables
  79680. */
  79681. readonly masterFrame: number;
  79682. /**
  79683. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  79684. */
  79685. weight: number;
  79686. /**
  79687. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  79688. */
  79689. speedRatio: number;
  79690. /**
  79691. * Creates a new Animatable
  79692. * @param scene defines the hosting scene
  79693. * @param target defines the target object
  79694. * @param fromFrame defines the starting frame number (default is 0)
  79695. * @param toFrame defines the ending frame number (default is 100)
  79696. * @param loopAnimation defines if the animation must loop (default is false)
  79697. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  79698. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  79699. * @param animations defines a group of animation to add to the new Animatable
  79700. * @param onAnimationLoop defines a callback to call when animation loops
  79701. */
  79702. constructor(scene: Scene,
  79703. /** defines the target object */
  79704. target: any,
  79705. /** defines the starting frame number (default is 0) */
  79706. fromFrame?: number,
  79707. /** defines the ending frame number (default is 100) */
  79708. toFrame?: number,
  79709. /** defines if the animation must loop (default is false) */
  79710. loopAnimation?: boolean, speedRatio?: number,
  79711. /** defines a callback to call when animation ends if it is not looping */
  79712. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  79713. /** defines a callback to call when animation loops */
  79714. onAnimationLoop?: (() => void) | null | undefined);
  79715. /**
  79716. * Synchronize and normalize current Animatable with a source Animatable
  79717. * This is useful when using animation weights and when animations are not of the same length
  79718. * @param root defines the root Animatable to synchronize with
  79719. * @returns the current Animatable
  79720. */
  79721. syncWith(root: Animatable): Animatable;
  79722. /**
  79723. * Gets the list of runtime animations
  79724. * @returns an array of RuntimeAnimation
  79725. */
  79726. getAnimations(): RuntimeAnimation[];
  79727. /**
  79728. * Adds more animations to the current animatable
  79729. * @param target defines the target of the animations
  79730. * @param animations defines the new animations to add
  79731. */
  79732. appendAnimations(target: any, animations: Animation[]): void;
  79733. /**
  79734. * Gets the source animation for a specific property
  79735. * @param property defines the propertyu to look for
  79736. * @returns null or the source animation for the given property
  79737. */
  79738. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  79739. /**
  79740. * Gets the runtime animation for a specific property
  79741. * @param property defines the propertyu to look for
  79742. * @returns null or the runtime animation for the given property
  79743. */
  79744. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  79745. /**
  79746. * Resets the animatable to its original state
  79747. */
  79748. reset(): void;
  79749. /**
  79750. * Allows the animatable to blend with current running animations
  79751. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79752. * @param blendingSpeed defines the blending speed to use
  79753. */
  79754. enableBlending(blendingSpeed: number): void;
  79755. /**
  79756. * Disable animation blending
  79757. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79758. */
  79759. disableBlending(): void;
  79760. /**
  79761. * Jump directly to a given frame
  79762. * @param frame defines the frame to jump to
  79763. */
  79764. goToFrame(frame: number): void;
  79765. /**
  79766. * Pause the animation
  79767. */
  79768. pause(): void;
  79769. /**
  79770. * Restart the animation
  79771. */
  79772. restart(): void;
  79773. private _raiseOnAnimationEnd;
  79774. /**
  79775. * Stop and delete the current animation
  79776. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  79777. * @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)
  79778. */
  79779. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  79780. /**
  79781. * Wait asynchronously for the animation to end
  79782. * @returns a promise which will be fullfilled when the animation ends
  79783. */
  79784. waitAsync(): Promise<Animatable>;
  79785. /** @hidden */
  79786. _animate(delay: number): boolean;
  79787. }
  79788. interface Scene {
  79789. /** @hidden */
  79790. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  79791. /** @hidden */
  79792. _processLateAnimationBindingsForMatrices(holder: {
  79793. totalWeight: number;
  79794. animations: RuntimeAnimation[];
  79795. originalValue: Matrix;
  79796. }): any;
  79797. /** @hidden */
  79798. _processLateAnimationBindingsForQuaternions(holder: {
  79799. totalWeight: number;
  79800. animations: RuntimeAnimation[];
  79801. originalValue: Quaternion;
  79802. }, refQuaternion: Quaternion): Quaternion;
  79803. /** @hidden */
  79804. _processLateAnimationBindings(): void;
  79805. /**
  79806. * Will start the animation sequence of a given target
  79807. * @param target defines the target
  79808. * @param from defines from which frame should animation start
  79809. * @param to defines until which frame should animation run.
  79810. * @param weight defines the weight to apply to the animation (1.0 by default)
  79811. * @param loop defines if the animation loops
  79812. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79813. * @param onAnimationEnd defines the function to be executed when the animation ends
  79814. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79815. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79816. * @param onAnimationLoop defines the callback to call when an animation loops
  79817. * @returns the animatable object created for this animation
  79818. */
  79819. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79820. /**
  79821. * Will start the animation sequence of a given target
  79822. * @param target defines the target
  79823. * @param from defines from which frame should animation start
  79824. * @param to defines until which frame should animation run.
  79825. * @param loop defines if the animation loops
  79826. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79827. * @param onAnimationEnd defines the function to be executed when the animation ends
  79828. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79829. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79830. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  79831. * @param onAnimationLoop defines the callback to call when an animation loops
  79832. * @returns the animatable object created for this animation
  79833. */
  79834. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79835. /**
  79836. * Will start the animation sequence of a given target and its hierarchy
  79837. * @param target defines the target
  79838. * @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.
  79839. * @param from defines from which frame should animation start
  79840. * @param to defines until which frame should animation run.
  79841. * @param loop defines if the animation loops
  79842. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79843. * @param onAnimationEnd defines the function to be executed when the animation ends
  79844. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79845. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79846. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79847. * @param onAnimationLoop defines the callback to call when an animation loops
  79848. * @returns the list of created animatables
  79849. */
  79850. 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[];
  79851. /**
  79852. * Begin a new animation on a given node
  79853. * @param target defines the target where the animation will take place
  79854. * @param animations defines the list of animations to start
  79855. * @param from defines the initial value
  79856. * @param to defines the final value
  79857. * @param loop defines if you want animation to loop (off by default)
  79858. * @param speedRatio defines the speed ratio to apply to all animations
  79859. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79860. * @param onAnimationLoop defines the callback to call when an animation loops
  79861. * @returns the list of created animatables
  79862. */
  79863. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79864. /**
  79865. * Begin a new animation on a given node and its hierarchy
  79866. * @param target defines the root node where the animation will take place
  79867. * @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.
  79868. * @param animations defines the list of animations to start
  79869. * @param from defines the initial value
  79870. * @param to defines the final value
  79871. * @param loop defines if you want animation to loop (off by default)
  79872. * @param speedRatio defines the speed ratio to apply to all animations
  79873. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79874. * @param onAnimationLoop defines the callback to call when an animation loops
  79875. * @returns the list of animatables created for all nodes
  79876. */
  79877. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79878. /**
  79879. * Gets the animatable associated with a specific target
  79880. * @param target defines the target of the animatable
  79881. * @returns the required animatable if found
  79882. */
  79883. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79884. /**
  79885. * Gets all animatables associated with a given target
  79886. * @param target defines the target to look animatables for
  79887. * @returns an array of Animatables
  79888. */
  79889. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79890. /**
  79891. * Stops and removes all animations that have been applied to the scene
  79892. */
  79893. stopAllAnimations(): void;
  79894. /**
  79895. * Gets the current delta time used by animation engine
  79896. */
  79897. deltaTime: number;
  79898. }
  79899. interface Bone {
  79900. /**
  79901. * Copy an animation range from another bone
  79902. * @param source defines the source bone
  79903. * @param rangeName defines the range name to copy
  79904. * @param frameOffset defines the frame offset
  79905. * @param rescaleAsRequired defines if rescaling must be applied if required
  79906. * @param skelDimensionsRatio defines the scaling ratio
  79907. * @returns true if operation was successful
  79908. */
  79909. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79910. }
  79911. }
  79912. declare module BABYLON {
  79913. /**
  79914. * Class used to override all child animations of a given target
  79915. */
  79916. export class AnimationPropertiesOverride {
  79917. /**
  79918. * Gets or sets a value indicating if animation blending must be used
  79919. */
  79920. enableBlending: boolean;
  79921. /**
  79922. * Gets or sets the blending speed to use when enableBlending is true
  79923. */
  79924. blendingSpeed: number;
  79925. /**
  79926. * Gets or sets the default loop mode to use
  79927. */
  79928. loopMode: number;
  79929. }
  79930. }
  79931. declare module BABYLON {
  79932. /**
  79933. * Class used to handle skinning animations
  79934. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79935. */
  79936. export class Skeleton implements IAnimatable {
  79937. /** defines the skeleton name */
  79938. name: string;
  79939. /** defines the skeleton Id */
  79940. id: string;
  79941. /**
  79942. * Defines the list of child bones
  79943. */
  79944. bones: Bone[];
  79945. /**
  79946. * Defines an estimate of the dimension of the skeleton at rest
  79947. */
  79948. dimensionsAtRest: Vector3;
  79949. /**
  79950. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79951. */
  79952. needInitialSkinMatrix: boolean;
  79953. /**
  79954. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79955. */
  79956. overrideMesh: Nullable<AbstractMesh>;
  79957. /**
  79958. * Gets the list of animations attached to this skeleton
  79959. */
  79960. animations: Array<Animation>;
  79961. private _scene;
  79962. private _isDirty;
  79963. private _transformMatrices;
  79964. private _transformMatrixTexture;
  79965. private _meshesWithPoseMatrix;
  79966. private _animatables;
  79967. private _identity;
  79968. private _synchronizedWithMesh;
  79969. private _ranges;
  79970. private _lastAbsoluteTransformsUpdateId;
  79971. private _canUseTextureForBones;
  79972. private _uniqueId;
  79973. /** @hidden */
  79974. _numBonesWithLinkedTransformNode: number;
  79975. /** @hidden */
  79976. _hasWaitingData: Nullable<boolean>;
  79977. /**
  79978. * Specifies if the skeleton should be serialized
  79979. */
  79980. doNotSerialize: boolean;
  79981. private _useTextureToStoreBoneMatrices;
  79982. /**
  79983. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79984. * Please note that this option is not available if the hardware does not support it
  79985. */
  79986. useTextureToStoreBoneMatrices: boolean;
  79987. private _animationPropertiesOverride;
  79988. /**
  79989. * Gets or sets the animation properties override
  79990. */
  79991. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79992. /**
  79993. * List of inspectable custom properties (used by the Inspector)
  79994. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79995. */
  79996. inspectableCustomProperties: IInspectable[];
  79997. /**
  79998. * An observable triggered before computing the skeleton's matrices
  79999. */
  80000. onBeforeComputeObservable: Observable<Skeleton>;
  80001. /**
  80002. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  80003. */
  80004. readonly isUsingTextureForMatrices: boolean;
  80005. /**
  80006. * Gets the unique ID of this skeleton
  80007. */
  80008. readonly uniqueId: number;
  80009. /**
  80010. * Creates a new skeleton
  80011. * @param name defines the skeleton name
  80012. * @param id defines the skeleton Id
  80013. * @param scene defines the hosting scene
  80014. */
  80015. constructor(
  80016. /** defines the skeleton name */
  80017. name: string,
  80018. /** defines the skeleton Id */
  80019. id: string, scene: Scene);
  80020. /**
  80021. * Gets the current object class name.
  80022. * @return the class name
  80023. */
  80024. getClassName(): string;
  80025. /**
  80026. * Returns an array containing the root bones
  80027. * @returns an array containing the root bones
  80028. */
  80029. getChildren(): Array<Bone>;
  80030. /**
  80031. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  80032. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80033. * @returns a Float32Array containing matrices data
  80034. */
  80035. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  80036. /**
  80037. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  80038. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80039. * @returns a raw texture containing the data
  80040. */
  80041. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  80042. /**
  80043. * Gets the current hosting scene
  80044. * @returns a scene object
  80045. */
  80046. getScene(): Scene;
  80047. /**
  80048. * Gets a string representing the current skeleton data
  80049. * @param fullDetails defines a boolean indicating if we want a verbose version
  80050. * @returns a string representing the current skeleton data
  80051. */
  80052. toString(fullDetails?: boolean): string;
  80053. /**
  80054. * Get bone's index searching by name
  80055. * @param name defines bone's name to search for
  80056. * @return the indice of the bone. Returns -1 if not found
  80057. */
  80058. getBoneIndexByName(name: string): number;
  80059. /**
  80060. * Creater a new animation range
  80061. * @param name defines the name of the range
  80062. * @param from defines the start key
  80063. * @param to defines the end key
  80064. */
  80065. createAnimationRange(name: string, from: number, to: number): void;
  80066. /**
  80067. * Delete a specific animation range
  80068. * @param name defines the name of the range
  80069. * @param deleteFrames defines if frames must be removed as well
  80070. */
  80071. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80072. /**
  80073. * Gets a specific animation range
  80074. * @param name defines the name of the range to look for
  80075. * @returns the requested animation range or null if not found
  80076. */
  80077. getAnimationRange(name: string): Nullable<AnimationRange>;
  80078. /**
  80079. * Gets the list of all animation ranges defined on this skeleton
  80080. * @returns an array
  80081. */
  80082. getAnimationRanges(): Nullable<AnimationRange>[];
  80083. /**
  80084. * Copy animation range from a source skeleton.
  80085. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  80086. * @param source defines the source skeleton
  80087. * @param name defines the name of the range to copy
  80088. * @param rescaleAsRequired defines if rescaling must be applied if required
  80089. * @returns true if operation was successful
  80090. */
  80091. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  80092. /**
  80093. * Forces the skeleton to go to rest pose
  80094. */
  80095. returnToRest(): void;
  80096. private _getHighestAnimationFrame;
  80097. /**
  80098. * Begin a specific animation range
  80099. * @param name defines the name of the range to start
  80100. * @param loop defines if looping must be turned on (false by default)
  80101. * @param speedRatio defines the speed ratio to apply (1 by default)
  80102. * @param onAnimationEnd defines a callback which will be called when animation will end
  80103. * @returns a new animatable
  80104. */
  80105. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80106. /** @hidden */
  80107. _markAsDirty(): void;
  80108. /** @hidden */
  80109. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80110. /** @hidden */
  80111. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80112. private _computeTransformMatrices;
  80113. /**
  80114. * Build all resources required to render a skeleton
  80115. */
  80116. prepare(): void;
  80117. /**
  80118. * Gets the list of animatables currently running for this skeleton
  80119. * @returns an array of animatables
  80120. */
  80121. getAnimatables(): IAnimatable[];
  80122. /**
  80123. * Clone the current skeleton
  80124. * @param name defines the name of the new skeleton
  80125. * @param id defines the id of the new skeleton
  80126. * @returns the new skeleton
  80127. */
  80128. clone(name: string, id: string): Skeleton;
  80129. /**
  80130. * Enable animation blending for this skeleton
  80131. * @param blendingSpeed defines the blending speed to apply
  80132. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80133. */
  80134. enableBlending(blendingSpeed?: number): void;
  80135. /**
  80136. * Releases all resources associated with the current skeleton
  80137. */
  80138. dispose(): void;
  80139. /**
  80140. * Serialize the skeleton in a JSON object
  80141. * @returns a JSON object
  80142. */
  80143. serialize(): any;
  80144. /**
  80145. * Creates a new skeleton from serialized data
  80146. * @param parsedSkeleton defines the serialized data
  80147. * @param scene defines the hosting scene
  80148. * @returns a new skeleton
  80149. */
  80150. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  80151. /**
  80152. * Compute all node absolute transforms
  80153. * @param forceUpdate defines if computation must be done even if cache is up to date
  80154. */
  80155. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  80156. /**
  80157. * Gets the root pose matrix
  80158. * @returns a matrix
  80159. */
  80160. getPoseMatrix(): Nullable<Matrix>;
  80161. /**
  80162. * Sorts bones per internal index
  80163. */
  80164. sortBones(): void;
  80165. private _sortBones;
  80166. }
  80167. }
  80168. declare module BABYLON {
  80169. /**
  80170. * Class used to store bone information
  80171. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80172. */
  80173. export class Bone extends Node {
  80174. /**
  80175. * defines the bone name
  80176. */
  80177. name: string;
  80178. private static _tmpVecs;
  80179. private static _tmpQuat;
  80180. private static _tmpMats;
  80181. /**
  80182. * Gets the list of child bones
  80183. */
  80184. children: Bone[];
  80185. /** Gets the animations associated with this bone */
  80186. animations: Animation[];
  80187. /**
  80188. * Gets or sets bone length
  80189. */
  80190. length: number;
  80191. /**
  80192. * @hidden Internal only
  80193. * Set this value to map this bone to a different index in the transform matrices
  80194. * Set this value to -1 to exclude the bone from the transform matrices
  80195. */
  80196. _index: Nullable<number>;
  80197. private _skeleton;
  80198. private _localMatrix;
  80199. private _restPose;
  80200. private _baseMatrix;
  80201. private _absoluteTransform;
  80202. private _invertedAbsoluteTransform;
  80203. private _parent;
  80204. private _scalingDeterminant;
  80205. private _worldTransform;
  80206. private _localScaling;
  80207. private _localRotation;
  80208. private _localPosition;
  80209. private _needToDecompose;
  80210. private _needToCompose;
  80211. /** @hidden */
  80212. _linkedTransformNode: Nullable<TransformNode>;
  80213. /** @hidden */
  80214. _waitingTransformNodeId: Nullable<string>;
  80215. /** @hidden */
  80216. /** @hidden */
  80217. _matrix: Matrix;
  80218. /**
  80219. * Create a new bone
  80220. * @param name defines the bone name
  80221. * @param skeleton defines the parent skeleton
  80222. * @param parentBone defines the parent (can be null if the bone is the root)
  80223. * @param localMatrix defines the local matrix
  80224. * @param restPose defines the rest pose matrix
  80225. * @param baseMatrix defines the base matrix
  80226. * @param index defines index of the bone in the hiearchy
  80227. */
  80228. constructor(
  80229. /**
  80230. * defines the bone name
  80231. */
  80232. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  80233. /**
  80234. * Gets the current object class name.
  80235. * @return the class name
  80236. */
  80237. getClassName(): string;
  80238. /**
  80239. * Gets the parent skeleton
  80240. * @returns a skeleton
  80241. */
  80242. getSkeleton(): Skeleton;
  80243. /**
  80244. * Gets parent bone
  80245. * @returns a bone or null if the bone is the root of the bone hierarchy
  80246. */
  80247. getParent(): Nullable<Bone>;
  80248. /**
  80249. * Returns an array containing the root bones
  80250. * @returns an array containing the root bones
  80251. */
  80252. getChildren(): Array<Bone>;
  80253. /**
  80254. * Sets the parent bone
  80255. * @param parent defines the parent (can be null if the bone is the root)
  80256. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80257. */
  80258. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  80259. /**
  80260. * Gets the local matrix
  80261. * @returns a matrix
  80262. */
  80263. getLocalMatrix(): Matrix;
  80264. /**
  80265. * Gets the base matrix (initial matrix which remains unchanged)
  80266. * @returns a matrix
  80267. */
  80268. getBaseMatrix(): Matrix;
  80269. /**
  80270. * Gets the rest pose matrix
  80271. * @returns a matrix
  80272. */
  80273. getRestPose(): Matrix;
  80274. /**
  80275. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  80276. */
  80277. getWorldMatrix(): Matrix;
  80278. /**
  80279. * Sets the local matrix to rest pose matrix
  80280. */
  80281. returnToRest(): void;
  80282. /**
  80283. * Gets the inverse of the absolute transform matrix.
  80284. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  80285. * @returns a matrix
  80286. */
  80287. getInvertedAbsoluteTransform(): Matrix;
  80288. /**
  80289. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  80290. * @returns a matrix
  80291. */
  80292. getAbsoluteTransform(): Matrix;
  80293. /**
  80294. * Links with the given transform node.
  80295. * The local matrix of this bone is copied from the transform node every frame.
  80296. * @param transformNode defines the transform node to link to
  80297. */
  80298. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  80299. /**
  80300. * Gets the node used to drive the bone's transformation
  80301. * @returns a transform node or null
  80302. */
  80303. getTransformNode(): Nullable<TransformNode>;
  80304. /** Gets or sets current position (in local space) */
  80305. position: Vector3;
  80306. /** Gets or sets current rotation (in local space) */
  80307. rotation: Vector3;
  80308. /** Gets or sets current rotation quaternion (in local space) */
  80309. rotationQuaternion: Quaternion;
  80310. /** Gets or sets current scaling (in local space) */
  80311. scaling: Vector3;
  80312. /**
  80313. * Gets the animation properties override
  80314. */
  80315. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80316. private _decompose;
  80317. private _compose;
  80318. /**
  80319. * Update the base and local matrices
  80320. * @param matrix defines the new base or local matrix
  80321. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80322. * @param updateLocalMatrix defines if the local matrix should be updated
  80323. */
  80324. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80325. /** @hidden */
  80326. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80327. /**
  80328. * Flag the bone as dirty (Forcing it to update everything)
  80329. */
  80330. markAsDirty(): void;
  80331. /** @hidden */
  80332. _markAsDirtyAndCompose(): void;
  80333. private _markAsDirtyAndDecompose;
  80334. /**
  80335. * Translate the bone in local or world space
  80336. * @param vec The amount to translate the bone
  80337. * @param space The space that the translation is in
  80338. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80339. */
  80340. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80341. /**
  80342. * Set the postion of the bone in local or world space
  80343. * @param position The position to set the bone
  80344. * @param space The space that the position is in
  80345. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80346. */
  80347. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80348. /**
  80349. * Set the absolute position of the bone (world space)
  80350. * @param position The position to set the bone
  80351. * @param mesh The mesh that this bone is attached to
  80352. */
  80353. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  80354. /**
  80355. * Scale the bone on the x, y and z axes (in local space)
  80356. * @param x The amount to scale the bone on the x axis
  80357. * @param y The amount to scale the bone on the y axis
  80358. * @param z The amount to scale the bone on the z axis
  80359. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  80360. */
  80361. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  80362. /**
  80363. * Set the bone scaling in local space
  80364. * @param scale defines the scaling vector
  80365. */
  80366. setScale(scale: Vector3): void;
  80367. /**
  80368. * Gets the current scaling in local space
  80369. * @returns the current scaling vector
  80370. */
  80371. getScale(): Vector3;
  80372. /**
  80373. * Gets the current scaling in local space and stores it in a target vector
  80374. * @param result defines the target vector
  80375. */
  80376. getScaleToRef(result: Vector3): void;
  80377. /**
  80378. * Set the yaw, pitch, and roll of the bone in local or world space
  80379. * @param yaw The rotation of the bone on the y axis
  80380. * @param pitch The rotation of the bone on the x axis
  80381. * @param roll The rotation of the bone on the z axis
  80382. * @param space The space that the axes of rotation are in
  80383. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80384. */
  80385. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80386. /**
  80387. * Add a rotation to the bone on an axis in local or world space
  80388. * @param axis The axis to rotate the bone on
  80389. * @param amount The amount to rotate the bone
  80390. * @param space The space that the axis is in
  80391. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80392. */
  80393. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80394. /**
  80395. * Set the rotation of the bone to a particular axis angle in local or world space
  80396. * @param axis The axis to rotate the bone on
  80397. * @param angle The angle that the bone should be rotated to
  80398. * @param space The space that the axis is in
  80399. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80400. */
  80401. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80402. /**
  80403. * Set the euler rotation of the bone in local of world space
  80404. * @param rotation The euler rotation that the bone should be set to
  80405. * @param space The space that the rotation is in
  80406. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80407. */
  80408. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80409. /**
  80410. * Set the quaternion rotation of the bone in local of world space
  80411. * @param quat The quaternion rotation that the bone should be set to
  80412. * @param space The space that the rotation is in
  80413. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80414. */
  80415. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80416. /**
  80417. * Set the rotation matrix of the bone in local of world space
  80418. * @param rotMat The rotation matrix that the bone should be set to
  80419. * @param space The space that the rotation is in
  80420. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80421. */
  80422. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80423. private _rotateWithMatrix;
  80424. private _getNegativeRotationToRef;
  80425. /**
  80426. * Get the position of the bone in local or world space
  80427. * @param space The space that the returned position is in
  80428. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80429. * @returns The position of the bone
  80430. */
  80431. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80432. /**
  80433. * Copy the position of the bone to a vector3 in local or world space
  80434. * @param space The space that the returned position is in
  80435. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80436. * @param result The vector3 to copy the position to
  80437. */
  80438. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80439. /**
  80440. * Get the absolute position of the bone (world space)
  80441. * @param mesh The mesh that this bone is attached to
  80442. * @returns The absolute position of the bone
  80443. */
  80444. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80445. /**
  80446. * Copy the absolute position of the bone (world space) to the result param
  80447. * @param mesh The mesh that this bone is attached to
  80448. * @param result The vector3 to copy the absolute position to
  80449. */
  80450. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80451. /**
  80452. * Compute the absolute transforms of this bone and its children
  80453. */
  80454. computeAbsoluteTransforms(): void;
  80455. /**
  80456. * Get the world direction from an axis that is in the local space of the bone
  80457. * @param localAxis The local direction that is used to compute the world direction
  80458. * @param mesh The mesh that this bone is attached to
  80459. * @returns The world direction
  80460. */
  80461. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80462. /**
  80463. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80464. * @param localAxis The local direction that is used to compute the world direction
  80465. * @param mesh The mesh that this bone is attached to
  80466. * @param result The vector3 that the world direction will be copied to
  80467. */
  80468. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80469. /**
  80470. * Get the euler rotation of the bone in local or world space
  80471. * @param space The space that the rotation should be in
  80472. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80473. * @returns The euler rotation
  80474. */
  80475. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80476. /**
  80477. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  80478. * @param space The space that the rotation should be in
  80479. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80480. * @param result The vector3 that the rotation should be copied to
  80481. */
  80482. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80483. /**
  80484. * Get the quaternion rotation of the bone in either local or world space
  80485. * @param space The space that the rotation should be in
  80486. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80487. * @returns The quaternion rotation
  80488. */
  80489. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  80490. /**
  80491. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  80492. * @param space The space that the rotation should be in
  80493. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80494. * @param result The quaternion that the rotation should be copied to
  80495. */
  80496. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  80497. /**
  80498. * Get the rotation matrix of the bone in local or world space
  80499. * @param space The space that the rotation should be in
  80500. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80501. * @returns The rotation matrix
  80502. */
  80503. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  80504. /**
  80505. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  80506. * @param space The space that the rotation should be in
  80507. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80508. * @param result The quaternion that the rotation should be copied to
  80509. */
  80510. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  80511. /**
  80512. * Get the world position of a point that is in the local space of the bone
  80513. * @param position The local position
  80514. * @param mesh The mesh that this bone is attached to
  80515. * @returns The world position
  80516. */
  80517. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80518. /**
  80519. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  80520. * @param position The local position
  80521. * @param mesh The mesh that this bone is attached to
  80522. * @param result The vector3 that the world position should be copied to
  80523. */
  80524. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80525. /**
  80526. * Get the local position of a point that is in world space
  80527. * @param position The world position
  80528. * @param mesh The mesh that this bone is attached to
  80529. * @returns The local position
  80530. */
  80531. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80532. /**
  80533. * Get the local position of a point that is in world space and copy it to the result param
  80534. * @param position The world position
  80535. * @param mesh The mesh that this bone is attached to
  80536. * @param result The vector3 that the local position should be copied to
  80537. */
  80538. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80539. }
  80540. }
  80541. declare module BABYLON {
  80542. /**
  80543. * 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.
  80544. * @see https://doc.babylonjs.com/how_to/transformnode
  80545. */
  80546. export class TransformNode extends Node {
  80547. /**
  80548. * Object will not rotate to face the camera
  80549. */
  80550. static BILLBOARDMODE_NONE: number;
  80551. /**
  80552. * Object will rotate to face the camera but only on the x axis
  80553. */
  80554. static BILLBOARDMODE_X: number;
  80555. /**
  80556. * Object will rotate to face the camera but only on the y axis
  80557. */
  80558. static BILLBOARDMODE_Y: number;
  80559. /**
  80560. * Object will rotate to face the camera but only on the z axis
  80561. */
  80562. static BILLBOARDMODE_Z: number;
  80563. /**
  80564. * Object will rotate to face the camera
  80565. */
  80566. static BILLBOARDMODE_ALL: number;
  80567. /**
  80568. * Object will rotate to face the camera's position instead of orientation
  80569. */
  80570. static BILLBOARDMODE_USE_POSITION: number;
  80571. private _forward;
  80572. private _forwardInverted;
  80573. private _up;
  80574. private _right;
  80575. private _rightInverted;
  80576. private _position;
  80577. private _rotation;
  80578. private _rotationQuaternion;
  80579. protected _scaling: Vector3;
  80580. protected _isDirty: boolean;
  80581. private _transformToBoneReferal;
  80582. private _isAbsoluteSynced;
  80583. private _billboardMode;
  80584. /**
  80585. * Gets or sets the billboard mode. Default is 0.
  80586. *
  80587. * | Value | Type | Description |
  80588. * | --- | --- | --- |
  80589. * | 0 | BILLBOARDMODE_NONE | |
  80590. * | 1 | BILLBOARDMODE_X | |
  80591. * | 2 | BILLBOARDMODE_Y | |
  80592. * | 4 | BILLBOARDMODE_Z | |
  80593. * | 7 | BILLBOARDMODE_ALL | |
  80594. *
  80595. */
  80596. billboardMode: number;
  80597. private _preserveParentRotationForBillboard;
  80598. /**
  80599. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  80600. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  80601. */
  80602. preserveParentRotationForBillboard: boolean;
  80603. /**
  80604. * 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
  80605. */
  80606. scalingDeterminant: number;
  80607. private _infiniteDistance;
  80608. /**
  80609. * Gets or sets the distance of the object to max, often used by skybox
  80610. */
  80611. infiniteDistance: boolean;
  80612. /**
  80613. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  80614. * By default the system will update normals to compensate
  80615. */
  80616. ignoreNonUniformScaling: boolean;
  80617. /**
  80618. * 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
  80619. */
  80620. reIntegrateRotationIntoRotationQuaternion: boolean;
  80621. /** @hidden */
  80622. _poseMatrix: Nullable<Matrix>;
  80623. /** @hidden */
  80624. _localMatrix: Matrix;
  80625. private _usePivotMatrix;
  80626. private _absolutePosition;
  80627. private _absoluteScaling;
  80628. private _absoluteRotationQuaternion;
  80629. private _pivotMatrix;
  80630. private _pivotMatrixInverse;
  80631. protected _postMultiplyPivotMatrix: boolean;
  80632. protected _isWorldMatrixFrozen: boolean;
  80633. /** @hidden */
  80634. _indexInSceneTransformNodesArray: number;
  80635. /**
  80636. * An event triggered after the world matrix is updated
  80637. */
  80638. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  80639. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  80640. /**
  80641. * Gets a string identifying the name of the class
  80642. * @returns "TransformNode" string
  80643. */
  80644. getClassName(): string;
  80645. /**
  80646. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  80647. */
  80648. position: Vector3;
  80649. /**
  80650. * 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)).
  80651. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  80652. */
  80653. rotation: Vector3;
  80654. /**
  80655. * 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)).
  80656. */
  80657. scaling: Vector3;
  80658. /**
  80659. * 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).
  80660. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  80661. */
  80662. rotationQuaternion: Nullable<Quaternion>;
  80663. /**
  80664. * The forward direction of that transform in world space.
  80665. */
  80666. readonly forward: Vector3;
  80667. /**
  80668. * The up direction of that transform in world space.
  80669. */
  80670. readonly up: Vector3;
  80671. /**
  80672. * The right direction of that transform in world space.
  80673. */
  80674. readonly right: Vector3;
  80675. /**
  80676. * Copies the parameter passed Matrix into the mesh Pose matrix.
  80677. * @param matrix the matrix to copy the pose from
  80678. * @returns this TransformNode.
  80679. */
  80680. updatePoseMatrix(matrix: Matrix): TransformNode;
  80681. /**
  80682. * Returns the mesh Pose matrix.
  80683. * @returns the pose matrix
  80684. */
  80685. getPoseMatrix(): Matrix;
  80686. /** @hidden */
  80687. _isSynchronized(): boolean;
  80688. /** @hidden */
  80689. _initCache(): void;
  80690. /**
  80691. * Flag the transform node as dirty (Forcing it to update everything)
  80692. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  80693. * @returns this transform node
  80694. */
  80695. markAsDirty(property: string): TransformNode;
  80696. /**
  80697. * Returns the current mesh absolute position.
  80698. * Returns a Vector3.
  80699. */
  80700. readonly absolutePosition: Vector3;
  80701. /**
  80702. * Returns the current mesh absolute scaling.
  80703. * Returns a Vector3.
  80704. */
  80705. readonly absoluteScaling: Vector3;
  80706. /**
  80707. * Returns the current mesh absolute rotation.
  80708. * Returns a Quaternion.
  80709. */
  80710. readonly absoluteRotationQuaternion: Quaternion;
  80711. /**
  80712. * Sets a new matrix to apply before all other transformation
  80713. * @param matrix defines the transform matrix
  80714. * @returns the current TransformNode
  80715. */
  80716. setPreTransformMatrix(matrix: Matrix): TransformNode;
  80717. /**
  80718. * Sets a new pivot matrix to the current node
  80719. * @param matrix defines the new pivot matrix to use
  80720. * @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
  80721. * @returns the current TransformNode
  80722. */
  80723. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  80724. /**
  80725. * Returns the mesh pivot matrix.
  80726. * Default : Identity.
  80727. * @returns the matrix
  80728. */
  80729. getPivotMatrix(): Matrix;
  80730. /**
  80731. * Instantiate (when possible) or clone that node with its hierarchy
  80732. * @param newParent defines the new parent to use for the instance (or clone)
  80733. * @returns an instance (or a clone) of the current node with its hiearchy
  80734. */
  80735. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  80736. /**
  80737. * Prevents the World matrix to be computed any longer
  80738. * @param newWorldMatrix defines an optional matrix to use as world matrix
  80739. * @returns the TransformNode.
  80740. */
  80741. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  80742. /**
  80743. * Allows back the World matrix computation.
  80744. * @returns the TransformNode.
  80745. */
  80746. unfreezeWorldMatrix(): this;
  80747. /**
  80748. * True if the World matrix has been frozen.
  80749. */
  80750. readonly isWorldMatrixFrozen: boolean;
  80751. /**
  80752. * Retuns the mesh absolute position in the World.
  80753. * @returns a Vector3.
  80754. */
  80755. getAbsolutePosition(): Vector3;
  80756. /**
  80757. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  80758. * @param absolutePosition the absolute position to set
  80759. * @returns the TransformNode.
  80760. */
  80761. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80762. /**
  80763. * Sets the mesh position in its local space.
  80764. * @param vector3 the position to set in localspace
  80765. * @returns the TransformNode.
  80766. */
  80767. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  80768. /**
  80769. * Returns the mesh position in the local space from the current World matrix values.
  80770. * @returns a new Vector3.
  80771. */
  80772. getPositionExpressedInLocalSpace(): Vector3;
  80773. /**
  80774. * Translates the mesh along the passed Vector3 in its local space.
  80775. * @param vector3 the distance to translate in localspace
  80776. * @returns the TransformNode.
  80777. */
  80778. locallyTranslate(vector3: Vector3): TransformNode;
  80779. private static _lookAtVectorCache;
  80780. /**
  80781. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  80782. * @param targetPoint the position (must be in same space as current mesh) to look at
  80783. * @param yawCor optional yaw (y-axis) correction in radians
  80784. * @param pitchCor optional pitch (x-axis) correction in radians
  80785. * @param rollCor optional roll (z-axis) correction in radians
  80786. * @param space the choosen space of the target
  80787. * @returns the TransformNode.
  80788. */
  80789. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  80790. /**
  80791. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80792. * This Vector3 is expressed in the World space.
  80793. * @param localAxis axis to rotate
  80794. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80795. */
  80796. getDirection(localAxis: Vector3): Vector3;
  80797. /**
  80798. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  80799. * localAxis is expressed in the mesh local space.
  80800. * result is computed in the Wordl space from the mesh World matrix.
  80801. * @param localAxis axis to rotate
  80802. * @param result the resulting transformnode
  80803. * @returns this TransformNode.
  80804. */
  80805. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  80806. /**
  80807. * Sets this transform node rotation to the given local axis.
  80808. * @param localAxis the axis in local space
  80809. * @param yawCor optional yaw (y-axis) correction in radians
  80810. * @param pitchCor optional pitch (x-axis) correction in radians
  80811. * @param rollCor optional roll (z-axis) correction in radians
  80812. * @returns this TransformNode
  80813. */
  80814. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  80815. /**
  80816. * Sets a new pivot point to the current node
  80817. * @param point defines the new pivot point to use
  80818. * @param space defines if the point is in world or local space (local by default)
  80819. * @returns the current TransformNode
  80820. */
  80821. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  80822. /**
  80823. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  80824. * @returns the pivot point
  80825. */
  80826. getPivotPoint(): Vector3;
  80827. /**
  80828. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  80829. * @param result the vector3 to store the result
  80830. * @returns this TransformNode.
  80831. */
  80832. getPivotPointToRef(result: Vector3): TransformNode;
  80833. /**
  80834. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  80835. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  80836. */
  80837. getAbsolutePivotPoint(): Vector3;
  80838. /**
  80839. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  80840. * @param result vector3 to store the result
  80841. * @returns this TransformNode.
  80842. */
  80843. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  80844. /**
  80845. * Defines the passed node as the parent of the current node.
  80846. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  80847. * @see https://doc.babylonjs.com/how_to/parenting
  80848. * @param node the node ot set as the parent
  80849. * @returns this TransformNode.
  80850. */
  80851. setParent(node: Nullable<Node>): TransformNode;
  80852. private _nonUniformScaling;
  80853. /**
  80854. * True if the scaling property of this object is non uniform eg. (1,2,1)
  80855. */
  80856. readonly nonUniformScaling: boolean;
  80857. /** @hidden */
  80858. _updateNonUniformScalingState(value: boolean): boolean;
  80859. /**
  80860. * Attach the current TransformNode to another TransformNode associated with a bone
  80861. * @param bone Bone affecting the TransformNode
  80862. * @param affectedTransformNode TransformNode associated with the bone
  80863. * @returns this object
  80864. */
  80865. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  80866. /**
  80867. * Detach the transform node if its associated with a bone
  80868. * @returns this object
  80869. */
  80870. detachFromBone(): TransformNode;
  80871. private static _rotationAxisCache;
  80872. /**
  80873. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  80874. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80875. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80876. * The passed axis is also normalized.
  80877. * @param axis the axis to rotate around
  80878. * @param amount the amount to rotate in radians
  80879. * @param space Space to rotate in (Default: local)
  80880. * @returns the TransformNode.
  80881. */
  80882. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80883. /**
  80884. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  80885. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80886. * The passed axis is also normalized. .
  80887. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  80888. * @param point the point to rotate around
  80889. * @param axis the axis to rotate around
  80890. * @param amount the amount to rotate in radians
  80891. * @returns the TransformNode
  80892. */
  80893. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  80894. /**
  80895. * Translates the mesh along the axis vector for the passed distance in the given space.
  80896. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80897. * @param axis the axis to translate in
  80898. * @param distance the distance to translate
  80899. * @param space Space to rotate in (Default: local)
  80900. * @returns the TransformNode.
  80901. */
  80902. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80903. /**
  80904. * Adds a rotation step to the mesh current rotation.
  80905. * x, y, z are Euler angles expressed in radians.
  80906. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  80907. * This means this rotation is made in the mesh local space only.
  80908. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  80909. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  80910. * ```javascript
  80911. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  80912. * ```
  80913. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  80914. * 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.
  80915. * @param x Rotation to add
  80916. * @param y Rotation to add
  80917. * @param z Rotation to add
  80918. * @returns the TransformNode.
  80919. */
  80920. addRotation(x: number, y: number, z: number): TransformNode;
  80921. /**
  80922. * @hidden
  80923. */
  80924. protected _getEffectiveParent(): Nullable<Node>;
  80925. /**
  80926. * Computes the world matrix of the node
  80927. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80928. * @returns the world matrix
  80929. */
  80930. computeWorldMatrix(force?: boolean): Matrix;
  80931. protected _afterComputeWorldMatrix(): void;
  80932. /**
  80933. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  80934. * @param func callback function to add
  80935. *
  80936. * @returns the TransformNode.
  80937. */
  80938. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80939. /**
  80940. * Removes a registered callback function.
  80941. * @param func callback function to remove
  80942. * @returns the TransformNode.
  80943. */
  80944. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80945. /**
  80946. * Gets the position of the current mesh in camera space
  80947. * @param camera defines the camera to use
  80948. * @returns a position
  80949. */
  80950. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  80951. /**
  80952. * Returns the distance from the mesh to the active camera
  80953. * @param camera defines the camera to use
  80954. * @returns the distance
  80955. */
  80956. getDistanceToCamera(camera?: Nullable<Camera>): number;
  80957. /**
  80958. * Clone the current transform node
  80959. * @param name Name of the new clone
  80960. * @param newParent New parent for the clone
  80961. * @param doNotCloneChildren Do not clone children hierarchy
  80962. * @returns the new transform node
  80963. */
  80964. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  80965. /**
  80966. * Serializes the objects information.
  80967. * @param currentSerializationObject defines the object to serialize in
  80968. * @returns the serialized object
  80969. */
  80970. serialize(currentSerializationObject?: any): any;
  80971. /**
  80972. * Returns a new TransformNode object parsed from the source provided.
  80973. * @param parsedTransformNode is the source.
  80974. * @param scene the scne the object belongs to
  80975. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  80976. * @returns a new TransformNode object parsed from the source provided.
  80977. */
  80978. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  80979. /**
  80980. * Get all child-transformNodes of this node
  80981. * @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
  80982. * @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
  80983. * @returns an array of TransformNode
  80984. */
  80985. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  80986. /**
  80987. * Releases resources associated with this transform node.
  80988. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80989. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80990. */
  80991. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80992. /**
  80993. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  80994. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  80995. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  80996. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  80997. * @returns the current mesh
  80998. */
  80999. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  81000. private _syncAbsoluteScalingAndRotation;
  81001. }
  81002. }
  81003. declare module BABYLON {
  81004. /**
  81005. * Defines the types of pose enabled controllers that are supported
  81006. */
  81007. export enum PoseEnabledControllerType {
  81008. /**
  81009. * HTC Vive
  81010. */
  81011. VIVE = 0,
  81012. /**
  81013. * Oculus Rift
  81014. */
  81015. OCULUS = 1,
  81016. /**
  81017. * Windows mixed reality
  81018. */
  81019. WINDOWS = 2,
  81020. /**
  81021. * Samsung gear VR
  81022. */
  81023. GEAR_VR = 3,
  81024. /**
  81025. * Google Daydream
  81026. */
  81027. DAYDREAM = 4,
  81028. /**
  81029. * Generic
  81030. */
  81031. GENERIC = 5
  81032. }
  81033. /**
  81034. * Defines the MutableGamepadButton interface for the state of a gamepad button
  81035. */
  81036. export interface MutableGamepadButton {
  81037. /**
  81038. * Value of the button/trigger
  81039. */
  81040. value: number;
  81041. /**
  81042. * If the button/trigger is currently touched
  81043. */
  81044. touched: boolean;
  81045. /**
  81046. * If the button/trigger is currently pressed
  81047. */
  81048. pressed: boolean;
  81049. }
  81050. /**
  81051. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  81052. * @hidden
  81053. */
  81054. export interface ExtendedGamepadButton extends GamepadButton {
  81055. /**
  81056. * If the button/trigger is currently pressed
  81057. */
  81058. readonly pressed: boolean;
  81059. /**
  81060. * If the button/trigger is currently touched
  81061. */
  81062. readonly touched: boolean;
  81063. /**
  81064. * Value of the button/trigger
  81065. */
  81066. readonly value: number;
  81067. }
  81068. /** @hidden */
  81069. export interface _GamePadFactory {
  81070. /**
  81071. * Returns wether or not the current gamepad can be created for this type of controller.
  81072. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81073. * @returns true if it can be created, otherwise false
  81074. */
  81075. canCreate(gamepadInfo: any): boolean;
  81076. /**
  81077. * Creates a new instance of the Gamepad.
  81078. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81079. * @returns the new gamepad instance
  81080. */
  81081. create(gamepadInfo: any): Gamepad;
  81082. }
  81083. /**
  81084. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81085. */
  81086. export class PoseEnabledControllerHelper {
  81087. /** @hidden */
  81088. static _ControllerFactories: _GamePadFactory[];
  81089. /** @hidden */
  81090. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  81091. /**
  81092. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81093. * @param vrGamepad the gamepad to initialized
  81094. * @returns a vr controller of the type the gamepad identified as
  81095. */
  81096. static InitiateController(vrGamepad: any): Gamepad;
  81097. }
  81098. /**
  81099. * Defines the PoseEnabledController object that contains state of a vr capable controller
  81100. */
  81101. export class PoseEnabledController extends Gamepad implements PoseControlled {
  81102. /**
  81103. * If the controller is used in a webXR session
  81104. */
  81105. isXR: boolean;
  81106. private _deviceRoomPosition;
  81107. private _deviceRoomRotationQuaternion;
  81108. /**
  81109. * The device position in babylon space
  81110. */
  81111. devicePosition: Vector3;
  81112. /**
  81113. * The device rotation in babylon space
  81114. */
  81115. deviceRotationQuaternion: Quaternion;
  81116. /**
  81117. * The scale factor of the device in babylon space
  81118. */
  81119. deviceScaleFactor: number;
  81120. /**
  81121. * (Likely devicePosition should be used instead) The device position in its room space
  81122. */
  81123. position: Vector3;
  81124. /**
  81125. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  81126. */
  81127. rotationQuaternion: Quaternion;
  81128. /**
  81129. * The type of controller (Eg. Windows mixed reality)
  81130. */
  81131. controllerType: PoseEnabledControllerType;
  81132. protected _calculatedPosition: Vector3;
  81133. private _calculatedRotation;
  81134. /**
  81135. * The raw pose from the device
  81136. */
  81137. rawPose: DevicePose;
  81138. private _trackPosition;
  81139. private _maxRotationDistFromHeadset;
  81140. private _draggedRoomRotation;
  81141. /**
  81142. * @hidden
  81143. */
  81144. _disableTrackPosition(fixedPosition: Vector3): void;
  81145. /**
  81146. * Internal, the mesh attached to the controller
  81147. * @hidden
  81148. */
  81149. _mesh: Nullable<AbstractMesh>;
  81150. private _poseControlledCamera;
  81151. private _leftHandSystemQuaternion;
  81152. /**
  81153. * Internal, matrix used to convert room space to babylon space
  81154. * @hidden
  81155. */
  81156. _deviceToWorld: Matrix;
  81157. /**
  81158. * Node to be used when casting a ray from the controller
  81159. * @hidden
  81160. */
  81161. _pointingPoseNode: Nullable<TransformNode>;
  81162. /**
  81163. * Name of the child mesh that can be used to cast a ray from the controller
  81164. */
  81165. static readonly POINTING_POSE: string;
  81166. /**
  81167. * Creates a new PoseEnabledController from a gamepad
  81168. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  81169. */
  81170. constructor(browserGamepad: any);
  81171. private _workingMatrix;
  81172. /**
  81173. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  81174. */
  81175. update(): void;
  81176. /**
  81177. * Updates only the pose device and mesh without doing any button event checking
  81178. */
  81179. protected _updatePoseAndMesh(): void;
  81180. /**
  81181. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  81182. * @param poseData raw pose fromthe device
  81183. */
  81184. updateFromDevice(poseData: DevicePose): void;
  81185. /**
  81186. * @hidden
  81187. */
  81188. _meshAttachedObservable: Observable<AbstractMesh>;
  81189. /**
  81190. * Attaches a mesh to the controller
  81191. * @param mesh the mesh to be attached
  81192. */
  81193. attachToMesh(mesh: AbstractMesh): void;
  81194. /**
  81195. * Attaches the controllers mesh to a camera
  81196. * @param camera the camera the mesh should be attached to
  81197. */
  81198. attachToPoseControlledCamera(camera: TargetCamera): void;
  81199. /**
  81200. * Disposes of the controller
  81201. */
  81202. dispose(): void;
  81203. /**
  81204. * The mesh that is attached to the controller
  81205. */
  81206. readonly mesh: Nullable<AbstractMesh>;
  81207. /**
  81208. * Gets the ray of the controller in the direction the controller is pointing
  81209. * @param length the length the resulting ray should be
  81210. * @returns a ray in the direction the controller is pointing
  81211. */
  81212. getForwardRay(length?: number): Ray;
  81213. }
  81214. }
  81215. declare module BABYLON {
  81216. /**
  81217. * Defines the WebVRController object that represents controllers tracked in 3D space
  81218. */
  81219. export abstract class WebVRController extends PoseEnabledController {
  81220. /**
  81221. * Internal, the default controller model for the controller
  81222. */
  81223. protected _defaultModel: Nullable<AbstractMesh>;
  81224. /**
  81225. * Fired when the trigger state has changed
  81226. */
  81227. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  81228. /**
  81229. * Fired when the main button state has changed
  81230. */
  81231. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81232. /**
  81233. * Fired when the secondary button state has changed
  81234. */
  81235. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81236. /**
  81237. * Fired when the pad state has changed
  81238. */
  81239. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  81240. /**
  81241. * Fired when controllers stick values have changed
  81242. */
  81243. onPadValuesChangedObservable: Observable<StickValues>;
  81244. /**
  81245. * Array of button availible on the controller
  81246. */
  81247. protected _buttons: Array<MutableGamepadButton>;
  81248. private _onButtonStateChange;
  81249. /**
  81250. * Fired when a controller button's state has changed
  81251. * @param callback the callback containing the button that was modified
  81252. */
  81253. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  81254. /**
  81255. * X and Y axis corresponding to the controllers joystick
  81256. */
  81257. pad: StickValues;
  81258. /**
  81259. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  81260. */
  81261. hand: string;
  81262. /**
  81263. * The default controller model for the controller
  81264. */
  81265. readonly defaultModel: Nullable<AbstractMesh>;
  81266. /**
  81267. * Creates a new WebVRController from a gamepad
  81268. * @param vrGamepad the gamepad that the WebVRController should be created from
  81269. */
  81270. constructor(vrGamepad: any);
  81271. /**
  81272. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  81273. */
  81274. update(): void;
  81275. /**
  81276. * Function to be called when a button is modified
  81277. */
  81278. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  81279. /**
  81280. * Loads a mesh and attaches it to the controller
  81281. * @param scene the scene the mesh should be added to
  81282. * @param meshLoaded callback for when the mesh has been loaded
  81283. */
  81284. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  81285. private _setButtonValue;
  81286. private _changes;
  81287. private _checkChanges;
  81288. /**
  81289. * Disposes of th webVRCOntroller
  81290. */
  81291. dispose(): void;
  81292. }
  81293. }
  81294. declare module BABYLON {
  81295. /**
  81296. * The HemisphericLight simulates the ambient environment light,
  81297. * so the passed direction is the light reflection direction, not the incoming direction.
  81298. */
  81299. export class HemisphericLight extends Light {
  81300. /**
  81301. * The groundColor is the light in the opposite direction to the one specified during creation.
  81302. * 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.
  81303. */
  81304. groundColor: Color3;
  81305. /**
  81306. * The light reflection direction, not the incoming direction.
  81307. */
  81308. direction: Vector3;
  81309. /**
  81310. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  81311. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  81312. * The HemisphericLight can't cast shadows.
  81313. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81314. * @param name The friendly name of the light
  81315. * @param direction The direction of the light reflection
  81316. * @param scene The scene the light belongs to
  81317. */
  81318. constructor(name: string, direction: Vector3, scene: Scene);
  81319. protected _buildUniformLayout(): void;
  81320. /**
  81321. * Returns the string "HemisphericLight".
  81322. * @return The class name
  81323. */
  81324. getClassName(): string;
  81325. /**
  81326. * Sets the HemisphericLight direction towards the passed target (Vector3).
  81327. * Returns the updated direction.
  81328. * @param target The target the direction should point to
  81329. * @return The computed direction
  81330. */
  81331. setDirectionToTarget(target: Vector3): Vector3;
  81332. /**
  81333. * Returns the shadow generator associated to the light.
  81334. * @returns Always null for hemispheric lights because it does not support shadows.
  81335. */
  81336. getShadowGenerator(): Nullable<IShadowGenerator>;
  81337. /**
  81338. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  81339. * @param effect The effect to update
  81340. * @param lightIndex The index of the light in the effect to update
  81341. * @returns The hemispheric light
  81342. */
  81343. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  81344. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  81345. /**
  81346. * Computes the world matrix of the node
  81347. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81348. * @param useWasUpdatedFlag defines a reserved property
  81349. * @returns the world matrix
  81350. */
  81351. computeWorldMatrix(): Matrix;
  81352. /**
  81353. * Returns the integer 3.
  81354. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  81355. */
  81356. getTypeID(): number;
  81357. /**
  81358. * Prepares the list of defines specific to the light type.
  81359. * @param defines the list of defines
  81360. * @param lightIndex defines the index of the light for the effect
  81361. */
  81362. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  81363. }
  81364. }
  81365. declare module BABYLON {
  81366. /** @hidden */
  81367. export var vrMultiviewToSingleviewPixelShader: {
  81368. name: string;
  81369. shader: string;
  81370. };
  81371. }
  81372. declare module BABYLON {
  81373. /**
  81374. * Renders to multiple views with a single draw call
  81375. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  81376. */
  81377. export class MultiviewRenderTarget extends RenderTargetTexture {
  81378. /**
  81379. * Creates a multiview render target
  81380. * @param scene scene used with the render target
  81381. * @param size the size of the render target (used for each view)
  81382. */
  81383. constructor(scene: Scene, size?: number | {
  81384. width: number;
  81385. height: number;
  81386. } | {
  81387. ratio: number;
  81388. });
  81389. /**
  81390. * @hidden
  81391. * @param faceIndex the face index, if its a cube texture
  81392. */
  81393. _bindFrameBuffer(faceIndex?: number): void;
  81394. /**
  81395. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  81396. * @returns the view count
  81397. */
  81398. getViewCount(): number;
  81399. }
  81400. }
  81401. declare module BABYLON {
  81402. /**
  81403. * Represents a camera frustum
  81404. */
  81405. export class Frustum {
  81406. /**
  81407. * Gets the planes representing the frustum
  81408. * @param transform matrix to be applied to the returned planes
  81409. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  81410. */
  81411. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  81412. /**
  81413. * Gets the near frustum plane transformed by the transform matrix
  81414. * @param transform transformation matrix to be applied to the resulting frustum plane
  81415. * @param frustumPlane the resuling frustum plane
  81416. */
  81417. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81418. /**
  81419. * Gets the far frustum plane transformed by the transform matrix
  81420. * @param transform transformation matrix to be applied to the resulting frustum plane
  81421. * @param frustumPlane the resuling frustum plane
  81422. */
  81423. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81424. /**
  81425. * Gets the left frustum plane transformed by the transform matrix
  81426. * @param transform transformation matrix to be applied to the resulting frustum plane
  81427. * @param frustumPlane the resuling frustum plane
  81428. */
  81429. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81430. /**
  81431. * Gets the right frustum plane transformed by the transform matrix
  81432. * @param transform transformation matrix to be applied to the resulting frustum plane
  81433. * @param frustumPlane the resuling frustum plane
  81434. */
  81435. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81436. /**
  81437. * Gets the top frustum plane transformed by the transform matrix
  81438. * @param transform transformation matrix to be applied to the resulting frustum plane
  81439. * @param frustumPlane the resuling frustum plane
  81440. */
  81441. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81442. /**
  81443. * Gets the bottom frustum plane transformed by the transform matrix
  81444. * @param transform transformation matrix to be applied to the resulting frustum plane
  81445. * @param frustumPlane the resuling frustum plane
  81446. */
  81447. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81448. /**
  81449. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  81450. * @param transform transformation matrix to be applied to the resulting frustum planes
  81451. * @param frustumPlanes the resuling frustum planes
  81452. */
  81453. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  81454. }
  81455. }
  81456. declare module BABYLON {
  81457. interface Engine {
  81458. /**
  81459. * Creates a new multiview render target
  81460. * @param width defines the width of the texture
  81461. * @param height defines the height of the texture
  81462. * @returns the created multiview texture
  81463. */
  81464. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  81465. /**
  81466. * Binds a multiview framebuffer to be drawn to
  81467. * @param multiviewTexture texture to bind
  81468. */
  81469. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  81470. }
  81471. interface Camera {
  81472. /**
  81473. * @hidden
  81474. * 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)
  81475. */
  81476. _useMultiviewToSingleView: boolean;
  81477. /**
  81478. * @hidden
  81479. * 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)
  81480. */
  81481. _multiviewTexture: Nullable<RenderTargetTexture>;
  81482. /**
  81483. * @hidden
  81484. * ensures the multiview texture of the camera exists and has the specified width/height
  81485. * @param width height to set on the multiview texture
  81486. * @param height width to set on the multiview texture
  81487. */
  81488. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  81489. }
  81490. interface Scene {
  81491. /** @hidden */
  81492. _transformMatrixR: Matrix;
  81493. /** @hidden */
  81494. _multiviewSceneUbo: Nullable<UniformBuffer>;
  81495. /** @hidden */
  81496. _createMultiviewUbo(): void;
  81497. /** @hidden */
  81498. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  81499. /** @hidden */
  81500. _renderMultiviewToSingleView(camera: Camera): void;
  81501. }
  81502. }
  81503. declare module BABYLON {
  81504. /**
  81505. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  81506. * This will not be used for webXR as it supports displaying texture arrays directly
  81507. */
  81508. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  81509. /**
  81510. * Initializes a VRMultiviewToSingleview
  81511. * @param name name of the post process
  81512. * @param camera camera to be applied to
  81513. * @param scaleFactor scaling factor to the size of the output texture
  81514. */
  81515. constructor(name: string, camera: Camera, scaleFactor: number);
  81516. }
  81517. }
  81518. declare module BABYLON {
  81519. interface Engine {
  81520. /** @hidden */
  81521. _vrDisplay: any;
  81522. /** @hidden */
  81523. _vrSupported: boolean;
  81524. /** @hidden */
  81525. _oldSize: Size;
  81526. /** @hidden */
  81527. _oldHardwareScaleFactor: number;
  81528. /** @hidden */
  81529. _vrExclusivePointerMode: boolean;
  81530. /** @hidden */
  81531. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  81532. /** @hidden */
  81533. _onVRDisplayPointerRestricted: () => void;
  81534. /** @hidden */
  81535. _onVRDisplayPointerUnrestricted: () => void;
  81536. /** @hidden */
  81537. _onVrDisplayConnect: Nullable<(display: any) => void>;
  81538. /** @hidden */
  81539. _onVrDisplayDisconnect: Nullable<() => void>;
  81540. /** @hidden */
  81541. _onVrDisplayPresentChange: Nullable<() => void>;
  81542. /**
  81543. * Observable signaled when VR display mode changes
  81544. */
  81545. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  81546. /**
  81547. * Observable signaled when VR request present is complete
  81548. */
  81549. onVRRequestPresentComplete: Observable<boolean>;
  81550. /**
  81551. * Observable signaled when VR request present starts
  81552. */
  81553. onVRRequestPresentStart: Observable<Engine>;
  81554. /**
  81555. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  81556. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  81557. */
  81558. isInVRExclusivePointerMode: boolean;
  81559. /**
  81560. * Gets a boolean indicating if a webVR device was detected
  81561. * @returns true if a webVR device was detected
  81562. */
  81563. isVRDevicePresent(): boolean;
  81564. /**
  81565. * Gets the current webVR device
  81566. * @returns the current webVR device (or null)
  81567. */
  81568. getVRDevice(): any;
  81569. /**
  81570. * Initializes a webVR display and starts listening to display change events
  81571. * The onVRDisplayChangedObservable will be notified upon these changes
  81572. * @returns A promise containing a VRDisplay and if vr is supported
  81573. */
  81574. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  81575. /** @hidden */
  81576. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  81577. /**
  81578. * Call this function to switch to webVR mode
  81579. * Will do nothing if webVR is not supported or if there is no webVR device
  81580. * @see http://doc.babylonjs.com/how_to/webvr_camera
  81581. */
  81582. enableVR(): void;
  81583. /** @hidden */
  81584. _onVRFullScreenTriggered(): void;
  81585. }
  81586. }
  81587. declare module BABYLON {
  81588. /**
  81589. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  81590. * IMPORTANT!! The data is right-hand data.
  81591. * @export
  81592. * @interface DevicePose
  81593. */
  81594. export interface DevicePose {
  81595. /**
  81596. * The position of the device, values in array are [x,y,z].
  81597. */
  81598. readonly position: Nullable<Float32Array>;
  81599. /**
  81600. * The linearVelocity of the device, values in array are [x,y,z].
  81601. */
  81602. readonly linearVelocity: Nullable<Float32Array>;
  81603. /**
  81604. * The linearAcceleration of the device, values in array are [x,y,z].
  81605. */
  81606. readonly linearAcceleration: Nullable<Float32Array>;
  81607. /**
  81608. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  81609. */
  81610. readonly orientation: Nullable<Float32Array>;
  81611. /**
  81612. * The angularVelocity of the device, values in array are [x,y,z].
  81613. */
  81614. readonly angularVelocity: Nullable<Float32Array>;
  81615. /**
  81616. * The angularAcceleration of the device, values in array are [x,y,z].
  81617. */
  81618. readonly angularAcceleration: Nullable<Float32Array>;
  81619. }
  81620. /**
  81621. * Interface representing a pose controlled object in Babylon.
  81622. * A pose controlled object has both regular pose values as well as pose values
  81623. * from an external device such as a VR head mounted display
  81624. */
  81625. export interface PoseControlled {
  81626. /**
  81627. * The position of the object in babylon space.
  81628. */
  81629. position: Vector3;
  81630. /**
  81631. * The rotation quaternion of the object in babylon space.
  81632. */
  81633. rotationQuaternion: Quaternion;
  81634. /**
  81635. * The position of the device in babylon space.
  81636. */
  81637. devicePosition?: Vector3;
  81638. /**
  81639. * The rotation quaternion of the device in babylon space.
  81640. */
  81641. deviceRotationQuaternion: Quaternion;
  81642. /**
  81643. * The raw pose coming from the device.
  81644. */
  81645. rawPose: Nullable<DevicePose>;
  81646. /**
  81647. * The scale of the device to be used when translating from device space to babylon space.
  81648. */
  81649. deviceScaleFactor: number;
  81650. /**
  81651. * Updates the poseControlled values based on the input device pose.
  81652. * @param poseData the pose data to update the object with
  81653. */
  81654. updateFromDevice(poseData: DevicePose): void;
  81655. }
  81656. /**
  81657. * Set of options to customize the webVRCamera
  81658. */
  81659. export interface WebVROptions {
  81660. /**
  81661. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  81662. */
  81663. trackPosition?: boolean;
  81664. /**
  81665. * Sets the scale of the vrDevice in babylon space. (default: 1)
  81666. */
  81667. positionScale?: number;
  81668. /**
  81669. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  81670. */
  81671. displayName?: string;
  81672. /**
  81673. * Should the native controller meshes be initialized. (default: true)
  81674. */
  81675. controllerMeshes?: boolean;
  81676. /**
  81677. * Creating a default HemiLight only on controllers. (default: true)
  81678. */
  81679. defaultLightingOnControllers?: boolean;
  81680. /**
  81681. * If you don't want to use the default VR button of the helper. (default: false)
  81682. */
  81683. useCustomVRButton?: boolean;
  81684. /**
  81685. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  81686. */
  81687. customVRButton?: HTMLButtonElement;
  81688. /**
  81689. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  81690. */
  81691. rayLength?: number;
  81692. /**
  81693. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  81694. */
  81695. defaultHeight?: number;
  81696. /**
  81697. * If multiview should be used if availible (default: false)
  81698. */
  81699. useMultiview?: boolean;
  81700. }
  81701. /**
  81702. * This represents a WebVR camera.
  81703. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  81704. * @example http://doc.babylonjs.com/how_to/webvr_camera
  81705. */
  81706. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  81707. private webVROptions;
  81708. /**
  81709. * @hidden
  81710. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  81711. */
  81712. _vrDevice: any;
  81713. /**
  81714. * The rawPose of the vrDevice.
  81715. */
  81716. rawPose: Nullable<DevicePose>;
  81717. private _onVREnabled;
  81718. private _specsVersion;
  81719. private _attached;
  81720. private _frameData;
  81721. protected _descendants: Array<Node>;
  81722. private _deviceRoomPosition;
  81723. /** @hidden */
  81724. _deviceRoomRotationQuaternion: Quaternion;
  81725. private _standingMatrix;
  81726. /**
  81727. * Represents device position in babylon space.
  81728. */
  81729. devicePosition: Vector3;
  81730. /**
  81731. * Represents device rotation in babylon space.
  81732. */
  81733. deviceRotationQuaternion: Quaternion;
  81734. /**
  81735. * The scale of the device to be used when translating from device space to babylon space.
  81736. */
  81737. deviceScaleFactor: number;
  81738. private _deviceToWorld;
  81739. private _worldToDevice;
  81740. /**
  81741. * References to the webVR controllers for the vrDevice.
  81742. */
  81743. controllers: Array<WebVRController>;
  81744. /**
  81745. * Emits an event when a controller is attached.
  81746. */
  81747. onControllersAttachedObservable: Observable<WebVRController[]>;
  81748. /**
  81749. * Emits an event when a controller's mesh has been loaded;
  81750. */
  81751. onControllerMeshLoadedObservable: Observable<WebVRController>;
  81752. /**
  81753. * Emits an event when the HMD's pose has been updated.
  81754. */
  81755. onPoseUpdatedFromDeviceObservable: Observable<any>;
  81756. private _poseSet;
  81757. /**
  81758. * If the rig cameras be used as parent instead of this camera.
  81759. */
  81760. rigParenting: boolean;
  81761. private _lightOnControllers;
  81762. private _defaultHeight?;
  81763. /**
  81764. * Instantiates a WebVRFreeCamera.
  81765. * @param name The name of the WebVRFreeCamera
  81766. * @param position The starting anchor position for the camera
  81767. * @param scene The scene the camera belongs to
  81768. * @param webVROptions a set of customizable options for the webVRCamera
  81769. */
  81770. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  81771. /**
  81772. * Gets the device distance from the ground in meters.
  81773. * @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.
  81774. */
  81775. deviceDistanceToRoomGround(): number;
  81776. /**
  81777. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81778. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  81779. */
  81780. useStandingMatrix(callback?: (bool: boolean) => void): void;
  81781. /**
  81782. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81783. * @returns A promise with a boolean set to if the standing matrix is supported.
  81784. */
  81785. useStandingMatrixAsync(): Promise<boolean>;
  81786. /**
  81787. * Disposes the camera
  81788. */
  81789. dispose(): void;
  81790. /**
  81791. * Gets a vrController by name.
  81792. * @param name The name of the controller to retreive
  81793. * @returns the controller matching the name specified or null if not found
  81794. */
  81795. getControllerByName(name: string): Nullable<WebVRController>;
  81796. private _leftController;
  81797. /**
  81798. * The controller corresponding to the users left hand.
  81799. */
  81800. readonly leftController: Nullable<WebVRController>;
  81801. private _rightController;
  81802. /**
  81803. * The controller corresponding to the users right hand.
  81804. */
  81805. readonly rightController: Nullable<WebVRController>;
  81806. /**
  81807. * Casts a ray forward from the vrCamera's gaze.
  81808. * @param length Length of the ray (default: 100)
  81809. * @returns the ray corresponding to the gaze
  81810. */
  81811. getForwardRay(length?: number): Ray;
  81812. /**
  81813. * @hidden
  81814. * Updates the camera based on device's frame data
  81815. */
  81816. _checkInputs(): void;
  81817. /**
  81818. * Updates the poseControlled values based on the input device pose.
  81819. * @param poseData Pose coming from the device
  81820. */
  81821. updateFromDevice(poseData: DevicePose): void;
  81822. private _htmlElementAttached;
  81823. private _detachIfAttached;
  81824. /**
  81825. * WebVR's attach control will start broadcasting frames to the device.
  81826. * Note that in certain browsers (chrome for example) this function must be called
  81827. * within a user-interaction callback. Example:
  81828. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  81829. *
  81830. * @param element html element to attach the vrDevice to
  81831. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  81832. */
  81833. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81834. /**
  81835. * Detaches the camera from the html element and disables VR
  81836. *
  81837. * @param element html element to detach from
  81838. */
  81839. detachControl(element: HTMLElement): void;
  81840. /**
  81841. * @returns the name of this class
  81842. */
  81843. getClassName(): string;
  81844. /**
  81845. * Calls resetPose on the vrDisplay
  81846. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  81847. */
  81848. resetToCurrentRotation(): void;
  81849. /**
  81850. * @hidden
  81851. * Updates the rig cameras (left and right eye)
  81852. */
  81853. _updateRigCameras(): void;
  81854. private _workingVector;
  81855. private _oneVector;
  81856. private _workingMatrix;
  81857. private updateCacheCalled;
  81858. private _correctPositionIfNotTrackPosition;
  81859. /**
  81860. * @hidden
  81861. * Updates the cached values of the camera
  81862. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  81863. */
  81864. _updateCache(ignoreParentClass?: boolean): void;
  81865. /**
  81866. * @hidden
  81867. * Get current device position in babylon world
  81868. */
  81869. _computeDevicePosition(): void;
  81870. /**
  81871. * Updates the current device position and rotation in the babylon world
  81872. */
  81873. update(): void;
  81874. /**
  81875. * @hidden
  81876. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  81877. * @returns an identity matrix
  81878. */
  81879. _getViewMatrix(): Matrix;
  81880. private _tmpMatrix;
  81881. /**
  81882. * This function is called by the two RIG cameras.
  81883. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  81884. * @hidden
  81885. */
  81886. _getWebVRViewMatrix(): Matrix;
  81887. /** @hidden */
  81888. _getWebVRProjectionMatrix(): Matrix;
  81889. private _onGamepadConnectedObserver;
  81890. private _onGamepadDisconnectedObserver;
  81891. private _updateCacheWhenTrackingDisabledObserver;
  81892. /**
  81893. * Initializes the controllers and their meshes
  81894. */
  81895. initControllers(): void;
  81896. }
  81897. }
  81898. declare module BABYLON {
  81899. /**
  81900. * Size options for a post process
  81901. */
  81902. export type PostProcessOptions = {
  81903. width: number;
  81904. height: number;
  81905. };
  81906. /**
  81907. * PostProcess can be used to apply a shader to a texture after it has been rendered
  81908. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81909. */
  81910. export class PostProcess {
  81911. /** Name of the PostProcess. */
  81912. name: string;
  81913. /**
  81914. * Gets or sets the unique id of the post process
  81915. */
  81916. uniqueId: number;
  81917. /**
  81918. * Width of the texture to apply the post process on
  81919. */
  81920. width: number;
  81921. /**
  81922. * Height of the texture to apply the post process on
  81923. */
  81924. height: number;
  81925. /**
  81926. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  81927. * @hidden
  81928. */
  81929. _outputTexture: Nullable<InternalTexture>;
  81930. /**
  81931. * Sampling mode used by the shader
  81932. * See https://doc.babylonjs.com/classes/3.1/texture
  81933. */
  81934. renderTargetSamplingMode: number;
  81935. /**
  81936. * Clear color to use when screen clearing
  81937. */
  81938. clearColor: Color4;
  81939. /**
  81940. * If the buffer needs to be cleared before applying the post process. (default: true)
  81941. * Should be set to false if shader will overwrite all previous pixels.
  81942. */
  81943. autoClear: boolean;
  81944. /**
  81945. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  81946. */
  81947. alphaMode: number;
  81948. /**
  81949. * Sets the setAlphaBlendConstants of the babylon engine
  81950. */
  81951. alphaConstants: Color4;
  81952. /**
  81953. * Animations to be used for the post processing
  81954. */
  81955. animations: Animation[];
  81956. /**
  81957. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  81958. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  81959. */
  81960. enablePixelPerfectMode: boolean;
  81961. /**
  81962. * Force the postprocess to be applied without taking in account viewport
  81963. */
  81964. forceFullscreenViewport: boolean;
  81965. /**
  81966. * List of inspectable custom properties (used by the Inspector)
  81967. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81968. */
  81969. inspectableCustomProperties: IInspectable[];
  81970. /**
  81971. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  81972. *
  81973. * | Value | Type | Description |
  81974. * | ----- | ----------------------------------- | ----------- |
  81975. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  81976. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  81977. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  81978. *
  81979. */
  81980. scaleMode: number;
  81981. /**
  81982. * Force textures to be a power of two (default: false)
  81983. */
  81984. alwaysForcePOT: boolean;
  81985. private _samples;
  81986. /**
  81987. * Number of sample textures (default: 1)
  81988. */
  81989. samples: number;
  81990. /**
  81991. * Modify the scale of the post process to be the same as the viewport (default: false)
  81992. */
  81993. adaptScaleToCurrentViewport: boolean;
  81994. private _camera;
  81995. private _scene;
  81996. private _engine;
  81997. private _options;
  81998. private _reusable;
  81999. private _textureType;
  82000. /**
  82001. * Smart array of input and output textures for the post process.
  82002. * @hidden
  82003. */
  82004. _textures: SmartArray<InternalTexture>;
  82005. /**
  82006. * The index in _textures that corresponds to the output texture.
  82007. * @hidden
  82008. */
  82009. _currentRenderTextureInd: number;
  82010. private _effect;
  82011. private _samplers;
  82012. private _fragmentUrl;
  82013. private _vertexUrl;
  82014. private _parameters;
  82015. private _scaleRatio;
  82016. protected _indexParameters: any;
  82017. private _shareOutputWithPostProcess;
  82018. private _texelSize;
  82019. private _forcedOutputTexture;
  82020. /**
  82021. * Returns the fragment url or shader name used in the post process.
  82022. * @returns the fragment url or name in the shader store.
  82023. */
  82024. getEffectName(): string;
  82025. /**
  82026. * An event triggered when the postprocess is activated.
  82027. */
  82028. onActivateObservable: Observable<Camera>;
  82029. private _onActivateObserver;
  82030. /**
  82031. * A function that is added to the onActivateObservable
  82032. */
  82033. onActivate: Nullable<(camera: Camera) => void>;
  82034. /**
  82035. * An event triggered when the postprocess changes its size.
  82036. */
  82037. onSizeChangedObservable: Observable<PostProcess>;
  82038. private _onSizeChangedObserver;
  82039. /**
  82040. * A function that is added to the onSizeChangedObservable
  82041. */
  82042. onSizeChanged: (postProcess: PostProcess) => void;
  82043. /**
  82044. * An event triggered when the postprocess applies its effect.
  82045. */
  82046. onApplyObservable: Observable<Effect>;
  82047. private _onApplyObserver;
  82048. /**
  82049. * A function that is added to the onApplyObservable
  82050. */
  82051. onApply: (effect: Effect) => void;
  82052. /**
  82053. * An event triggered before rendering the postprocess
  82054. */
  82055. onBeforeRenderObservable: Observable<Effect>;
  82056. private _onBeforeRenderObserver;
  82057. /**
  82058. * A function that is added to the onBeforeRenderObservable
  82059. */
  82060. onBeforeRender: (effect: Effect) => void;
  82061. /**
  82062. * An event triggered after rendering the postprocess
  82063. */
  82064. onAfterRenderObservable: Observable<Effect>;
  82065. private _onAfterRenderObserver;
  82066. /**
  82067. * A function that is added to the onAfterRenderObservable
  82068. */
  82069. onAfterRender: (efect: Effect) => void;
  82070. /**
  82071. * 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
  82072. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  82073. */
  82074. inputTexture: InternalTexture;
  82075. /**
  82076. * Gets the camera which post process is applied to.
  82077. * @returns The camera the post process is applied to.
  82078. */
  82079. getCamera(): Camera;
  82080. /**
  82081. * Gets the texel size of the postprocess.
  82082. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  82083. */
  82084. readonly texelSize: Vector2;
  82085. /**
  82086. * Creates a new instance PostProcess
  82087. * @param name The name of the PostProcess.
  82088. * @param fragmentUrl The url of the fragment shader to be used.
  82089. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  82090. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  82091. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82092. * @param camera The camera to apply the render pass to.
  82093. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82094. * @param engine The engine which the post process will be applied. (default: current engine)
  82095. * @param reusable If the post process can be reused on the same frame. (default: false)
  82096. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  82097. * @param textureType Type of textures used when performing the post process. (default: 0)
  82098. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  82099. * @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
  82100. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  82101. */
  82102. constructor(
  82103. /** Name of the PostProcess. */
  82104. 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);
  82105. /**
  82106. * Gets a string idenfifying the name of the class
  82107. * @returns "PostProcess" string
  82108. */
  82109. getClassName(): string;
  82110. /**
  82111. * Gets the engine which this post process belongs to.
  82112. * @returns The engine the post process was enabled with.
  82113. */
  82114. getEngine(): Engine;
  82115. /**
  82116. * The effect that is created when initializing the post process.
  82117. * @returns The created effect corresponding the the postprocess.
  82118. */
  82119. getEffect(): Effect;
  82120. /**
  82121. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  82122. * @param postProcess The post process to share the output with.
  82123. * @returns This post process.
  82124. */
  82125. shareOutputWith(postProcess: PostProcess): PostProcess;
  82126. /**
  82127. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  82128. * This should be called if the post process that shares output with this post process is disabled/disposed.
  82129. */
  82130. useOwnOutput(): void;
  82131. /**
  82132. * Updates the effect with the current post process compile time values and recompiles the shader.
  82133. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82134. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82135. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82136. * @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
  82137. * @param onCompiled Called when the shader has been compiled.
  82138. * @param onError Called if there is an error when compiling a shader.
  82139. */
  82140. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82141. /**
  82142. * The post process is reusable if it can be used multiple times within one frame.
  82143. * @returns If the post process is reusable
  82144. */
  82145. isReusable(): boolean;
  82146. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  82147. markTextureDirty(): void;
  82148. /**
  82149. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  82150. * 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.
  82151. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  82152. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  82153. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  82154. * @returns The target texture that was bound to be written to.
  82155. */
  82156. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  82157. /**
  82158. * If the post process is supported.
  82159. */
  82160. readonly isSupported: boolean;
  82161. /**
  82162. * The aspect ratio of the output texture.
  82163. */
  82164. readonly aspectRatio: number;
  82165. /**
  82166. * Get a value indicating if the post-process is ready to be used
  82167. * @returns true if the post-process is ready (shader is compiled)
  82168. */
  82169. isReady(): boolean;
  82170. /**
  82171. * Binds all textures and uniforms to the shader, this will be run on every pass.
  82172. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  82173. */
  82174. apply(): Nullable<Effect>;
  82175. private _disposeTextures;
  82176. /**
  82177. * Disposes the post process.
  82178. * @param camera The camera to dispose the post process on.
  82179. */
  82180. dispose(camera?: Camera): void;
  82181. }
  82182. }
  82183. declare module BABYLON {
  82184. /** @hidden */
  82185. export var kernelBlurVaryingDeclaration: {
  82186. name: string;
  82187. shader: string;
  82188. };
  82189. }
  82190. declare module BABYLON {
  82191. /** @hidden */
  82192. export var kernelBlurFragment: {
  82193. name: string;
  82194. shader: string;
  82195. };
  82196. }
  82197. declare module BABYLON {
  82198. /** @hidden */
  82199. export var kernelBlurFragment2: {
  82200. name: string;
  82201. shader: string;
  82202. };
  82203. }
  82204. declare module BABYLON {
  82205. /** @hidden */
  82206. export var kernelBlurPixelShader: {
  82207. name: string;
  82208. shader: string;
  82209. };
  82210. }
  82211. declare module BABYLON {
  82212. /** @hidden */
  82213. export var kernelBlurVertex: {
  82214. name: string;
  82215. shader: string;
  82216. };
  82217. }
  82218. declare module BABYLON {
  82219. /** @hidden */
  82220. export var kernelBlurVertexShader: {
  82221. name: string;
  82222. shader: string;
  82223. };
  82224. }
  82225. declare module BABYLON {
  82226. /**
  82227. * The Blur Post Process which blurs an image based on a kernel and direction.
  82228. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  82229. */
  82230. export class BlurPostProcess extends PostProcess {
  82231. /** The direction in which to blur the image. */
  82232. direction: Vector2;
  82233. private blockCompilation;
  82234. protected _kernel: number;
  82235. protected _idealKernel: number;
  82236. protected _packedFloat: boolean;
  82237. private _staticDefines;
  82238. /**
  82239. * Sets the length in pixels of the blur sample region
  82240. */
  82241. /**
  82242. * Gets the length in pixels of the blur sample region
  82243. */
  82244. kernel: number;
  82245. /**
  82246. * Sets wether or not the blur needs to unpack/repack floats
  82247. */
  82248. /**
  82249. * Gets wether or not the blur is unpacking/repacking floats
  82250. */
  82251. packedFloat: boolean;
  82252. /**
  82253. * Creates a new instance BlurPostProcess
  82254. * @param name The name of the effect.
  82255. * @param direction The direction in which to blur the image.
  82256. * @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.
  82257. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82258. * @param camera The camera to apply the render pass to.
  82259. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82260. * @param engine The engine which the post process will be applied. (default: current engine)
  82261. * @param reusable If the post process can be reused on the same frame. (default: false)
  82262. * @param textureType Type of textures used when performing the post process. (default: 0)
  82263. * @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)
  82264. */
  82265. constructor(name: string,
  82266. /** The direction in which to blur the image. */
  82267. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  82268. /**
  82269. * Updates the effect with the current post process compile time values and recompiles the shader.
  82270. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82271. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82272. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82273. * @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
  82274. * @param onCompiled Called when the shader has been compiled.
  82275. * @param onError Called if there is an error when compiling a shader.
  82276. */
  82277. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82278. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82279. /**
  82280. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  82281. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  82282. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  82283. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  82284. * The gaps between physical kernels are compensated for in the weighting of the samples
  82285. * @param idealKernel Ideal blur kernel.
  82286. * @return Nearest best kernel.
  82287. */
  82288. protected _nearestBestKernel(idealKernel: number): number;
  82289. /**
  82290. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  82291. * @param x The point on the Gaussian distribution to sample.
  82292. * @return the value of the Gaussian function at x.
  82293. */
  82294. protected _gaussianWeight(x: number): number;
  82295. /**
  82296. * Generates a string that can be used as a floating point number in GLSL.
  82297. * @param x Value to print.
  82298. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  82299. * @return GLSL float string.
  82300. */
  82301. protected _glslFloat(x: number, decimalFigures?: number): string;
  82302. }
  82303. }
  82304. declare module BABYLON {
  82305. /**
  82306. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82307. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82308. * You can then easily use it as a reflectionTexture on a flat surface.
  82309. * In case the surface is not a plane, please consider relying on reflection probes.
  82310. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82311. */
  82312. export class MirrorTexture extends RenderTargetTexture {
  82313. private scene;
  82314. /**
  82315. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  82316. * 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.
  82317. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82318. */
  82319. mirrorPlane: Plane;
  82320. /**
  82321. * Define the blur ratio used to blur the reflection if needed.
  82322. */
  82323. blurRatio: number;
  82324. /**
  82325. * Define the adaptive blur kernel used to blur the reflection if needed.
  82326. * This will autocompute the closest best match for the `blurKernel`
  82327. */
  82328. adaptiveBlurKernel: number;
  82329. /**
  82330. * Define the blur kernel used to blur the reflection if needed.
  82331. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82332. */
  82333. blurKernel: number;
  82334. /**
  82335. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  82336. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82337. */
  82338. blurKernelX: number;
  82339. /**
  82340. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  82341. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82342. */
  82343. blurKernelY: number;
  82344. private _autoComputeBlurKernel;
  82345. protected _onRatioRescale(): void;
  82346. private _updateGammaSpace;
  82347. private _imageProcessingConfigChangeObserver;
  82348. private _transformMatrix;
  82349. private _mirrorMatrix;
  82350. private _savedViewMatrix;
  82351. private _blurX;
  82352. private _blurY;
  82353. private _adaptiveBlurKernel;
  82354. private _blurKernelX;
  82355. private _blurKernelY;
  82356. private _blurRatio;
  82357. /**
  82358. * Instantiates a Mirror Texture.
  82359. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82360. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82361. * You can then easily use it as a reflectionTexture on a flat surface.
  82362. * In case the surface is not a plane, please consider relying on reflection probes.
  82363. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82364. * @param name
  82365. * @param size
  82366. * @param scene
  82367. * @param generateMipMaps
  82368. * @param type
  82369. * @param samplingMode
  82370. * @param generateDepthBuffer
  82371. */
  82372. constructor(name: string, size: number | {
  82373. width: number;
  82374. height: number;
  82375. } | {
  82376. ratio: number;
  82377. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  82378. private _preparePostProcesses;
  82379. /**
  82380. * Clone the mirror texture.
  82381. * @returns the cloned texture
  82382. */
  82383. clone(): MirrorTexture;
  82384. /**
  82385. * Serialize the texture to a JSON representation you could use in Parse later on
  82386. * @returns the serialized JSON representation
  82387. */
  82388. serialize(): any;
  82389. /**
  82390. * Dispose the texture and release its associated resources.
  82391. */
  82392. dispose(): void;
  82393. }
  82394. }
  82395. declare module BABYLON {
  82396. /**
  82397. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82398. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82399. */
  82400. export class Texture extends BaseTexture {
  82401. /**
  82402. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  82403. */
  82404. static SerializeBuffers: boolean;
  82405. /** @hidden */
  82406. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  82407. /** @hidden */
  82408. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  82409. /** @hidden */
  82410. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  82411. /** nearest is mag = nearest and min = nearest and mip = linear */
  82412. static readonly NEAREST_SAMPLINGMODE: number;
  82413. /** nearest is mag = nearest and min = nearest and mip = linear */
  82414. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  82415. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82416. static readonly BILINEAR_SAMPLINGMODE: number;
  82417. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82418. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  82419. /** Trilinear is mag = linear and min = linear and mip = linear */
  82420. static readonly TRILINEAR_SAMPLINGMODE: number;
  82421. /** Trilinear is mag = linear and min = linear and mip = linear */
  82422. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  82423. /** mag = nearest and min = nearest and mip = nearest */
  82424. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  82425. /** mag = nearest and min = linear and mip = nearest */
  82426. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  82427. /** mag = nearest and min = linear and mip = linear */
  82428. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  82429. /** mag = nearest and min = linear and mip = none */
  82430. static readonly NEAREST_LINEAR: number;
  82431. /** mag = nearest and min = nearest and mip = none */
  82432. static readonly NEAREST_NEAREST: number;
  82433. /** mag = linear and min = nearest and mip = nearest */
  82434. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  82435. /** mag = linear and min = nearest and mip = linear */
  82436. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  82437. /** mag = linear and min = linear and mip = none */
  82438. static readonly LINEAR_LINEAR: number;
  82439. /** mag = linear and min = nearest and mip = none */
  82440. static readonly LINEAR_NEAREST: number;
  82441. /** Explicit coordinates mode */
  82442. static readonly EXPLICIT_MODE: number;
  82443. /** Spherical coordinates mode */
  82444. static readonly SPHERICAL_MODE: number;
  82445. /** Planar coordinates mode */
  82446. static readonly PLANAR_MODE: number;
  82447. /** Cubic coordinates mode */
  82448. static readonly CUBIC_MODE: number;
  82449. /** Projection coordinates mode */
  82450. static readonly PROJECTION_MODE: number;
  82451. /** Inverse Cubic coordinates mode */
  82452. static readonly SKYBOX_MODE: number;
  82453. /** Inverse Cubic coordinates mode */
  82454. static readonly INVCUBIC_MODE: number;
  82455. /** Equirectangular coordinates mode */
  82456. static readonly EQUIRECTANGULAR_MODE: number;
  82457. /** Equirectangular Fixed coordinates mode */
  82458. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  82459. /** Equirectangular Fixed Mirrored coordinates mode */
  82460. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82461. /** Texture is not repeating outside of 0..1 UVs */
  82462. static readonly CLAMP_ADDRESSMODE: number;
  82463. /** Texture is repeating outside of 0..1 UVs */
  82464. static readonly WRAP_ADDRESSMODE: number;
  82465. /** Texture is repeating and mirrored */
  82466. static readonly MIRROR_ADDRESSMODE: number;
  82467. /**
  82468. * 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
  82469. */
  82470. static UseSerializedUrlIfAny: boolean;
  82471. /**
  82472. * Define the url of the texture.
  82473. */
  82474. url: Nullable<string>;
  82475. /**
  82476. * Define an offset on the texture to offset the u coordinates of the UVs
  82477. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82478. */
  82479. uOffset: number;
  82480. /**
  82481. * Define an offset on the texture to offset the v coordinates of the UVs
  82482. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82483. */
  82484. vOffset: number;
  82485. /**
  82486. * Define an offset on the texture to scale the u coordinates of the UVs
  82487. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82488. */
  82489. uScale: number;
  82490. /**
  82491. * Define an offset on the texture to scale the v coordinates of the UVs
  82492. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82493. */
  82494. vScale: number;
  82495. /**
  82496. * Define an offset on the texture to rotate around the u coordinates of the UVs
  82497. * @see http://doc.babylonjs.com/how_to/more_materials
  82498. */
  82499. uAng: number;
  82500. /**
  82501. * Define an offset on the texture to rotate around the v coordinates of the UVs
  82502. * @see http://doc.babylonjs.com/how_to/more_materials
  82503. */
  82504. vAng: number;
  82505. /**
  82506. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  82507. * @see http://doc.babylonjs.com/how_to/more_materials
  82508. */
  82509. wAng: number;
  82510. /**
  82511. * Defines the center of rotation (U)
  82512. */
  82513. uRotationCenter: number;
  82514. /**
  82515. * Defines the center of rotation (V)
  82516. */
  82517. vRotationCenter: number;
  82518. /**
  82519. * Defines the center of rotation (W)
  82520. */
  82521. wRotationCenter: number;
  82522. /**
  82523. * Are mip maps generated for this texture or not.
  82524. */
  82525. readonly noMipmap: boolean;
  82526. /**
  82527. * List of inspectable custom properties (used by the Inspector)
  82528. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82529. */
  82530. inspectableCustomProperties: Nullable<IInspectable[]>;
  82531. private _noMipmap;
  82532. /** @hidden */
  82533. _invertY: boolean;
  82534. private _rowGenerationMatrix;
  82535. private _cachedTextureMatrix;
  82536. private _projectionModeMatrix;
  82537. private _t0;
  82538. private _t1;
  82539. private _t2;
  82540. private _cachedUOffset;
  82541. private _cachedVOffset;
  82542. private _cachedUScale;
  82543. private _cachedVScale;
  82544. private _cachedUAng;
  82545. private _cachedVAng;
  82546. private _cachedWAng;
  82547. private _cachedProjectionMatrixId;
  82548. private _cachedCoordinatesMode;
  82549. /** @hidden */
  82550. protected _initialSamplingMode: number;
  82551. /** @hidden */
  82552. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  82553. private _deleteBuffer;
  82554. protected _format: Nullable<number>;
  82555. private _delayedOnLoad;
  82556. private _delayedOnError;
  82557. /**
  82558. * Observable triggered once the texture has been loaded.
  82559. */
  82560. onLoadObservable: Observable<Texture>;
  82561. protected _isBlocking: boolean;
  82562. /**
  82563. * Is the texture preventing material to render while loading.
  82564. * If false, a default texture will be used instead of the loading one during the preparation step.
  82565. */
  82566. isBlocking: boolean;
  82567. /**
  82568. * Get the current sampling mode associated with the texture.
  82569. */
  82570. readonly samplingMode: number;
  82571. /**
  82572. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  82573. */
  82574. readonly invertY: boolean;
  82575. /**
  82576. * Instantiates a new texture.
  82577. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82578. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82579. * @param url define the url of the picture to load as a texture
  82580. * @param scene define the scene or engine the texture will belong to
  82581. * @param noMipmap define if the texture will require mip maps or not
  82582. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82583. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82584. * @param onLoad define a callback triggered when the texture has been loaded
  82585. * @param onError define a callback triggered when an error occurred during the loading session
  82586. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82587. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82588. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82589. */
  82590. 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);
  82591. /**
  82592. * Update the url (and optional buffer) of this texture if url was null during construction.
  82593. * @param url the url of the texture
  82594. * @param buffer the buffer of the texture (defaults to null)
  82595. * @param onLoad callback called when the texture is loaded (defaults to null)
  82596. */
  82597. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  82598. /**
  82599. * Finish the loading sequence of a texture flagged as delayed load.
  82600. * @hidden
  82601. */
  82602. delayLoad(): void;
  82603. private _prepareRowForTextureGeneration;
  82604. /**
  82605. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  82606. * @returns the transform matrix of the texture.
  82607. */
  82608. getTextureMatrix(): Matrix;
  82609. /**
  82610. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  82611. * @returns The reflection texture transform
  82612. */
  82613. getReflectionTextureMatrix(): Matrix;
  82614. /**
  82615. * Clones the texture.
  82616. * @returns the cloned texture
  82617. */
  82618. clone(): Texture;
  82619. /**
  82620. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  82621. * @returns The JSON representation of the texture
  82622. */
  82623. serialize(): any;
  82624. /**
  82625. * Get the current class name of the texture useful for serialization or dynamic coding.
  82626. * @returns "Texture"
  82627. */
  82628. getClassName(): string;
  82629. /**
  82630. * Dispose the texture and release its associated resources.
  82631. */
  82632. dispose(): void;
  82633. /**
  82634. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  82635. * @param parsedTexture Define the JSON representation of the texture
  82636. * @param scene Define the scene the parsed texture should be instantiated in
  82637. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  82638. * @returns The parsed texture if successful
  82639. */
  82640. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  82641. /**
  82642. * Creates a texture from its base 64 representation.
  82643. * @param data Define the base64 payload without the data: prefix
  82644. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82645. * @param scene Define the scene the texture should belong to
  82646. * @param noMipmap Forces the texture to not create mip map information if true
  82647. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82648. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82649. * @param onLoad define a callback triggered when the texture has been loaded
  82650. * @param onError define a callback triggered when an error occurred during the loading session
  82651. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82652. * @returns the created texture
  82653. */
  82654. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  82655. /**
  82656. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  82657. * @param data Define the base64 payload without the data: prefix
  82658. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82659. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82660. * @param scene Define the scene the texture should belong to
  82661. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82662. * @param noMipmap Forces the texture to not create mip map information if true
  82663. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82664. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82665. * @param onLoad define a callback triggered when the texture has been loaded
  82666. * @param onError define a callback triggered when an error occurred during the loading session
  82667. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82668. * @returns the created texture
  82669. */
  82670. 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;
  82671. }
  82672. }
  82673. declare module BABYLON {
  82674. /**
  82675. * PostProcessManager is used to manage one or more post processes or post process pipelines
  82676. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82677. */
  82678. export class PostProcessManager {
  82679. private _scene;
  82680. private _indexBuffer;
  82681. private _vertexBuffers;
  82682. /**
  82683. * Creates a new instance PostProcess
  82684. * @param scene The scene that the post process is associated with.
  82685. */
  82686. constructor(scene: Scene);
  82687. private _prepareBuffers;
  82688. private _buildIndexBuffer;
  82689. /**
  82690. * Rebuilds the vertex buffers of the manager.
  82691. * @hidden
  82692. */
  82693. _rebuild(): void;
  82694. /**
  82695. * Prepares a frame to be run through a post process.
  82696. * @param sourceTexture The input texture to the post procesess. (default: null)
  82697. * @param postProcesses An array of post processes to be run. (default: null)
  82698. * @returns True if the post processes were able to be run.
  82699. * @hidden
  82700. */
  82701. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  82702. /**
  82703. * Manually render a set of post processes to a texture.
  82704. * @param postProcesses An array of post processes to be run.
  82705. * @param targetTexture The target texture to render to.
  82706. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  82707. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  82708. * @param lodLevel defines which lod of the texture to render to
  82709. */
  82710. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  82711. /**
  82712. * Finalize the result of the output of the postprocesses.
  82713. * @param doNotPresent If true the result will not be displayed to the screen.
  82714. * @param targetTexture The target texture to render to.
  82715. * @param faceIndex The index of the face to bind the target texture to.
  82716. * @param postProcesses The array of post processes to render.
  82717. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  82718. * @hidden
  82719. */
  82720. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  82721. /**
  82722. * Disposes of the post process manager.
  82723. */
  82724. dispose(): void;
  82725. }
  82726. }
  82727. declare module BABYLON {
  82728. /** Interface used by value gradients (color, factor, ...) */
  82729. export interface IValueGradient {
  82730. /**
  82731. * Gets or sets the gradient value (between 0 and 1)
  82732. */
  82733. gradient: number;
  82734. }
  82735. /** Class used to store color4 gradient */
  82736. export class ColorGradient implements IValueGradient {
  82737. /**
  82738. * Gets or sets the gradient value (between 0 and 1)
  82739. */
  82740. gradient: number;
  82741. /**
  82742. * Gets or sets first associated color
  82743. */
  82744. color1: Color4;
  82745. /**
  82746. * Gets or sets second associated color
  82747. */
  82748. color2?: Color4;
  82749. /**
  82750. * Will get a color picked randomly between color1 and color2.
  82751. * If color2 is undefined then color1 will be used
  82752. * @param result defines the target Color4 to store the result in
  82753. */
  82754. getColorToRef(result: Color4): void;
  82755. }
  82756. /** Class used to store color 3 gradient */
  82757. export class Color3Gradient implements IValueGradient {
  82758. /**
  82759. * Gets or sets the gradient value (between 0 and 1)
  82760. */
  82761. gradient: number;
  82762. /**
  82763. * Gets or sets the associated color
  82764. */
  82765. color: Color3;
  82766. }
  82767. /** Class used to store factor gradient */
  82768. export class FactorGradient implements IValueGradient {
  82769. /**
  82770. * Gets or sets the gradient value (between 0 and 1)
  82771. */
  82772. gradient: number;
  82773. /**
  82774. * Gets or sets first associated factor
  82775. */
  82776. factor1: number;
  82777. /**
  82778. * Gets or sets second associated factor
  82779. */
  82780. factor2?: number;
  82781. /**
  82782. * Will get a number picked randomly between factor1 and factor2.
  82783. * If factor2 is undefined then factor1 will be used
  82784. * @returns the picked number
  82785. */
  82786. getFactor(): number;
  82787. }
  82788. /**
  82789. * Helper used to simplify some generic gradient tasks
  82790. */
  82791. export class GradientHelper {
  82792. /**
  82793. * Gets the current gradient from an array of IValueGradient
  82794. * @param ratio defines the current ratio to get
  82795. * @param gradients defines the array of IValueGradient
  82796. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  82797. */
  82798. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  82799. }
  82800. }
  82801. declare module BABYLON {
  82802. interface ThinEngine {
  82803. /**
  82804. * Creates a dynamic texture
  82805. * @param width defines the width of the texture
  82806. * @param height defines the height of the texture
  82807. * @param generateMipMaps defines if the engine should generate the mip levels
  82808. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82809. * @returns the dynamic texture inside an InternalTexture
  82810. */
  82811. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  82812. /**
  82813. * Update the content of a dynamic texture
  82814. * @param texture defines the texture to update
  82815. * @param canvas defines the canvas containing the source
  82816. * @param invertY defines if data must be stored with Y axis inverted
  82817. * @param premulAlpha defines if alpha is stored as premultiplied
  82818. * @param format defines the format of the data
  82819. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  82820. */
  82821. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  82822. }
  82823. }
  82824. declare module BABYLON {
  82825. /**
  82826. * A class extending Texture allowing drawing on a texture
  82827. * @see http://doc.babylonjs.com/how_to/dynamictexture
  82828. */
  82829. export class DynamicTexture extends Texture {
  82830. private _generateMipMaps;
  82831. private _canvas;
  82832. private _context;
  82833. private _engine;
  82834. /**
  82835. * Creates a DynamicTexture
  82836. * @param name defines the name of the texture
  82837. * @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
  82838. * @param scene defines the scene where you want the texture
  82839. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  82840. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  82841. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  82842. */
  82843. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  82844. /**
  82845. * Get the current class name of the texture useful for serialization or dynamic coding.
  82846. * @returns "DynamicTexture"
  82847. */
  82848. getClassName(): string;
  82849. /**
  82850. * Gets the current state of canRescale
  82851. */
  82852. readonly canRescale: boolean;
  82853. private _recreate;
  82854. /**
  82855. * Scales the texture
  82856. * @param ratio the scale factor to apply to both width and height
  82857. */
  82858. scale(ratio: number): void;
  82859. /**
  82860. * Resizes the texture
  82861. * @param width the new width
  82862. * @param height the new height
  82863. */
  82864. scaleTo(width: number, height: number): void;
  82865. /**
  82866. * Gets the context of the canvas used by the texture
  82867. * @returns the canvas context of the dynamic texture
  82868. */
  82869. getContext(): CanvasRenderingContext2D;
  82870. /**
  82871. * Clears the texture
  82872. */
  82873. clear(): void;
  82874. /**
  82875. * Updates the texture
  82876. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82877. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  82878. */
  82879. update(invertY?: boolean, premulAlpha?: boolean): void;
  82880. /**
  82881. * Draws text onto the texture
  82882. * @param text defines the text to be drawn
  82883. * @param x defines the placement of the text from the left
  82884. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  82885. * @param font defines the font to be used with font-style, font-size, font-name
  82886. * @param color defines the color used for the text
  82887. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  82888. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82889. * @param update defines whether texture is immediately update (default is true)
  82890. */
  82891. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  82892. /**
  82893. * Clones the texture
  82894. * @returns the clone of the texture.
  82895. */
  82896. clone(): DynamicTexture;
  82897. /**
  82898. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  82899. * @returns a serialized dynamic texture object
  82900. */
  82901. serialize(): any;
  82902. /** @hidden */
  82903. _rebuild(): void;
  82904. }
  82905. }
  82906. declare module BABYLON {
  82907. interface AbstractScene {
  82908. /**
  82909. * The list of procedural textures added to the scene
  82910. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82911. */
  82912. proceduralTextures: Array<ProceduralTexture>;
  82913. }
  82914. /**
  82915. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  82916. * in a given scene.
  82917. */
  82918. export class ProceduralTextureSceneComponent implements ISceneComponent {
  82919. /**
  82920. * The component name helpfull to identify the component in the list of scene components.
  82921. */
  82922. readonly name: string;
  82923. /**
  82924. * The scene the component belongs to.
  82925. */
  82926. scene: Scene;
  82927. /**
  82928. * Creates a new instance of the component for the given scene
  82929. * @param scene Defines the scene to register the component in
  82930. */
  82931. constructor(scene: Scene);
  82932. /**
  82933. * Registers the component in a given scene
  82934. */
  82935. register(): void;
  82936. /**
  82937. * Rebuilds the elements related to this component in case of
  82938. * context lost for instance.
  82939. */
  82940. rebuild(): void;
  82941. /**
  82942. * Disposes the component and the associated ressources.
  82943. */
  82944. dispose(): void;
  82945. private _beforeClear;
  82946. }
  82947. }
  82948. declare module BABYLON {
  82949. interface ThinEngine {
  82950. /**
  82951. * Creates a new render target cube texture
  82952. * @param size defines the size of the texture
  82953. * @param options defines the options used to create the texture
  82954. * @returns a new render target cube texture stored in an InternalTexture
  82955. */
  82956. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  82957. }
  82958. }
  82959. declare module BABYLON {
  82960. /** @hidden */
  82961. export var proceduralVertexShader: {
  82962. name: string;
  82963. shader: string;
  82964. };
  82965. }
  82966. declare module BABYLON {
  82967. /**
  82968. * 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.
  82969. * This is the base class of any Procedural texture and contains most of the shareable code.
  82970. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82971. */
  82972. export class ProceduralTexture extends Texture {
  82973. isCube: boolean;
  82974. /**
  82975. * Define if the texture is enabled or not (disabled texture will not render)
  82976. */
  82977. isEnabled: boolean;
  82978. /**
  82979. * Define if the texture must be cleared before rendering (default is true)
  82980. */
  82981. autoClear: boolean;
  82982. /**
  82983. * Callback called when the texture is generated
  82984. */
  82985. onGenerated: () => void;
  82986. /**
  82987. * Event raised when the texture is generated
  82988. */
  82989. onGeneratedObservable: Observable<ProceduralTexture>;
  82990. /** @hidden */
  82991. _generateMipMaps: boolean;
  82992. /** @hidden **/
  82993. _effect: Effect;
  82994. /** @hidden */
  82995. _textures: {
  82996. [key: string]: Texture;
  82997. };
  82998. private _size;
  82999. private _currentRefreshId;
  83000. private _refreshRate;
  83001. private _vertexBuffers;
  83002. private _indexBuffer;
  83003. private _uniforms;
  83004. private _samplers;
  83005. private _fragment;
  83006. private _floats;
  83007. private _ints;
  83008. private _floatsArrays;
  83009. private _colors3;
  83010. private _colors4;
  83011. private _vectors2;
  83012. private _vectors3;
  83013. private _matrices;
  83014. private _fallbackTexture;
  83015. private _fallbackTextureUsed;
  83016. private _engine;
  83017. private _cachedDefines;
  83018. private _contentUpdateId;
  83019. private _contentData;
  83020. /**
  83021. * Instantiates a new procedural texture.
  83022. * 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.
  83023. * This is the base class of any Procedural texture and contains most of the shareable code.
  83024. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83025. * @param name Define the name of the texture
  83026. * @param size Define the size of the texture to create
  83027. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  83028. * @param scene Define the scene the texture belongs to
  83029. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  83030. * @param generateMipMaps Define if the texture should creates mip maps or not
  83031. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  83032. */
  83033. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  83034. /**
  83035. * The effect that is created when initializing the post process.
  83036. * @returns The created effect corresponding the the postprocess.
  83037. */
  83038. getEffect(): Effect;
  83039. /**
  83040. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  83041. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  83042. */
  83043. getContent(): Nullable<ArrayBufferView>;
  83044. private _createIndexBuffer;
  83045. /** @hidden */
  83046. _rebuild(): void;
  83047. /**
  83048. * Resets the texture in order to recreate its associated resources.
  83049. * This can be called in case of context loss
  83050. */
  83051. reset(): void;
  83052. protected _getDefines(): string;
  83053. /**
  83054. * Is the texture ready to be used ? (rendered at least once)
  83055. * @returns true if ready, otherwise, false.
  83056. */
  83057. isReady(): boolean;
  83058. /**
  83059. * Resets the refresh counter of the texture and start bak from scratch.
  83060. * Could be useful to regenerate the texture if it is setup to render only once.
  83061. */
  83062. resetRefreshCounter(): void;
  83063. /**
  83064. * Set the fragment shader to use in order to render the texture.
  83065. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  83066. */
  83067. setFragment(fragment: any): void;
  83068. /**
  83069. * Define the refresh rate of the texture or the rendering frequency.
  83070. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83071. */
  83072. refreshRate: number;
  83073. /** @hidden */
  83074. _shouldRender(): boolean;
  83075. /**
  83076. * Get the size the texture is rendering at.
  83077. * @returns the size (texture is always squared)
  83078. */
  83079. getRenderSize(): number;
  83080. /**
  83081. * Resize the texture to new value.
  83082. * @param size Define the new size the texture should have
  83083. * @param generateMipMaps Define whether the new texture should create mip maps
  83084. */
  83085. resize(size: number, generateMipMaps: boolean): void;
  83086. private _checkUniform;
  83087. /**
  83088. * Set a texture in the shader program used to render.
  83089. * @param name Define the name of the uniform samplers as defined in the shader
  83090. * @param texture Define the texture to bind to this sampler
  83091. * @return the texture itself allowing "fluent" like uniform updates
  83092. */
  83093. setTexture(name: string, texture: Texture): ProceduralTexture;
  83094. /**
  83095. * Set a float in the shader.
  83096. * @param name Define the name of the uniform as defined in the shader
  83097. * @param value Define the value to give to the uniform
  83098. * @return the texture itself allowing "fluent" like uniform updates
  83099. */
  83100. setFloat(name: string, value: number): ProceduralTexture;
  83101. /**
  83102. * Set a int in the shader.
  83103. * @param name Define the name of the uniform as defined in the shader
  83104. * @param value Define the value to give to the uniform
  83105. * @return the texture itself allowing "fluent" like uniform updates
  83106. */
  83107. setInt(name: string, value: number): ProceduralTexture;
  83108. /**
  83109. * Set an array of floats in the shader.
  83110. * @param name Define the name of the uniform as defined in the shader
  83111. * @param value Define the value to give to the uniform
  83112. * @return the texture itself allowing "fluent" like uniform updates
  83113. */
  83114. setFloats(name: string, value: number[]): ProceduralTexture;
  83115. /**
  83116. * Set a vec3 in the shader from a Color3.
  83117. * @param name Define the name of the uniform as defined in the shader
  83118. * @param value Define the value to give to the uniform
  83119. * @return the texture itself allowing "fluent" like uniform updates
  83120. */
  83121. setColor3(name: string, value: Color3): ProceduralTexture;
  83122. /**
  83123. * Set a vec4 in the shader from a Color4.
  83124. * @param name Define the name of the uniform as defined in the shader
  83125. * @param value Define the value to give to the uniform
  83126. * @return the texture itself allowing "fluent" like uniform updates
  83127. */
  83128. setColor4(name: string, value: Color4): ProceduralTexture;
  83129. /**
  83130. * Set a vec2 in the shader from a Vector2.
  83131. * @param name Define the name of the uniform as defined in the shader
  83132. * @param value Define the value to give to the uniform
  83133. * @return the texture itself allowing "fluent" like uniform updates
  83134. */
  83135. setVector2(name: string, value: Vector2): ProceduralTexture;
  83136. /**
  83137. * Set a vec3 in the shader from a Vector3.
  83138. * @param name Define the name of the uniform as defined in the shader
  83139. * @param value Define the value to give to the uniform
  83140. * @return the texture itself allowing "fluent" like uniform updates
  83141. */
  83142. setVector3(name: string, value: Vector3): ProceduralTexture;
  83143. /**
  83144. * Set a mat4 in the shader from a MAtrix.
  83145. * @param name Define the name of the uniform as defined in the shader
  83146. * @param value Define the value to give to the uniform
  83147. * @return the texture itself allowing "fluent" like uniform updates
  83148. */
  83149. setMatrix(name: string, value: Matrix): ProceduralTexture;
  83150. /**
  83151. * Render the texture to its associated render target.
  83152. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  83153. */
  83154. render(useCameraPostProcess?: boolean): void;
  83155. /**
  83156. * Clone the texture.
  83157. * @returns the cloned texture
  83158. */
  83159. clone(): ProceduralTexture;
  83160. /**
  83161. * Dispose the texture and release its asoociated resources.
  83162. */
  83163. dispose(): void;
  83164. }
  83165. }
  83166. declare module BABYLON {
  83167. /**
  83168. * This represents the base class for particle system in Babylon.
  83169. * 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.
  83170. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83171. * @example https://doc.babylonjs.com/babylon101/particles
  83172. */
  83173. export class BaseParticleSystem {
  83174. /**
  83175. * Source color is added to the destination color without alpha affecting the result
  83176. */
  83177. static BLENDMODE_ONEONE: number;
  83178. /**
  83179. * Blend current color and particle color using particle’s alpha
  83180. */
  83181. static BLENDMODE_STANDARD: number;
  83182. /**
  83183. * Add current color and particle color multiplied by particle’s alpha
  83184. */
  83185. static BLENDMODE_ADD: number;
  83186. /**
  83187. * Multiply current color with particle color
  83188. */
  83189. static BLENDMODE_MULTIPLY: number;
  83190. /**
  83191. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  83192. */
  83193. static BLENDMODE_MULTIPLYADD: number;
  83194. /**
  83195. * List of animations used by the particle system.
  83196. */
  83197. animations: Animation[];
  83198. /**
  83199. * The id of the Particle system.
  83200. */
  83201. id: string;
  83202. /**
  83203. * The friendly name of the Particle system.
  83204. */
  83205. name: string;
  83206. /**
  83207. * The rendering group used by the Particle system to chose when to render.
  83208. */
  83209. renderingGroupId: number;
  83210. /**
  83211. * The emitter represents the Mesh or position we are attaching the particle system to.
  83212. */
  83213. emitter: Nullable<AbstractMesh | Vector3>;
  83214. /**
  83215. * The maximum number of particles to emit per frame
  83216. */
  83217. emitRate: number;
  83218. /**
  83219. * If you want to launch only a few particles at once, that can be done, as well.
  83220. */
  83221. manualEmitCount: number;
  83222. /**
  83223. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83224. */
  83225. updateSpeed: number;
  83226. /**
  83227. * The amount of time the particle system is running (depends of the overall update speed).
  83228. */
  83229. targetStopDuration: number;
  83230. /**
  83231. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83232. */
  83233. disposeOnStop: boolean;
  83234. /**
  83235. * Minimum power of emitting particles.
  83236. */
  83237. minEmitPower: number;
  83238. /**
  83239. * Maximum power of emitting particles.
  83240. */
  83241. maxEmitPower: number;
  83242. /**
  83243. * Minimum life time of emitting particles.
  83244. */
  83245. minLifeTime: number;
  83246. /**
  83247. * Maximum life time of emitting particles.
  83248. */
  83249. maxLifeTime: number;
  83250. /**
  83251. * Minimum Size of emitting particles.
  83252. */
  83253. minSize: number;
  83254. /**
  83255. * Maximum Size of emitting particles.
  83256. */
  83257. maxSize: number;
  83258. /**
  83259. * Minimum scale of emitting particles on X axis.
  83260. */
  83261. minScaleX: number;
  83262. /**
  83263. * Maximum scale of emitting particles on X axis.
  83264. */
  83265. maxScaleX: number;
  83266. /**
  83267. * Minimum scale of emitting particles on Y axis.
  83268. */
  83269. minScaleY: number;
  83270. /**
  83271. * Maximum scale of emitting particles on Y axis.
  83272. */
  83273. maxScaleY: number;
  83274. /**
  83275. * Gets or sets the minimal initial rotation in radians.
  83276. */
  83277. minInitialRotation: number;
  83278. /**
  83279. * Gets or sets the maximal initial rotation in radians.
  83280. */
  83281. maxInitialRotation: number;
  83282. /**
  83283. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83284. */
  83285. minAngularSpeed: number;
  83286. /**
  83287. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83288. */
  83289. maxAngularSpeed: number;
  83290. /**
  83291. * The texture used to render each particle. (this can be a spritesheet)
  83292. */
  83293. particleTexture: Nullable<Texture>;
  83294. /**
  83295. * The layer mask we are rendering the particles through.
  83296. */
  83297. layerMask: number;
  83298. /**
  83299. * This can help using your own shader to render the particle system.
  83300. * The according effect will be created
  83301. */
  83302. customShader: any;
  83303. /**
  83304. * By default particle system starts as soon as they are created. This prevents the
  83305. * automatic start to happen and let you decide when to start emitting particles.
  83306. */
  83307. preventAutoStart: boolean;
  83308. private _noiseTexture;
  83309. /**
  83310. * Gets or sets a texture used to add random noise to particle positions
  83311. */
  83312. noiseTexture: Nullable<ProceduralTexture>;
  83313. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83314. noiseStrength: Vector3;
  83315. /**
  83316. * Callback triggered when the particle animation is ending.
  83317. */
  83318. onAnimationEnd: Nullable<() => void>;
  83319. /**
  83320. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  83321. */
  83322. blendMode: number;
  83323. /**
  83324. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  83325. * to override the particles.
  83326. */
  83327. forceDepthWrite: boolean;
  83328. /** 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 */
  83329. preWarmCycles: number;
  83330. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  83331. preWarmStepOffset: number;
  83332. /**
  83333. * 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)
  83334. */
  83335. spriteCellChangeSpeed: number;
  83336. /**
  83337. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83338. */
  83339. startSpriteCellID: number;
  83340. /**
  83341. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83342. */
  83343. endSpriteCellID: number;
  83344. /**
  83345. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83346. */
  83347. spriteCellWidth: number;
  83348. /**
  83349. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83350. */
  83351. spriteCellHeight: number;
  83352. /**
  83353. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83354. */
  83355. spriteRandomStartCell: boolean;
  83356. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83357. translationPivot: Vector2;
  83358. /** @hidden */
  83359. protected _isAnimationSheetEnabled: boolean;
  83360. /**
  83361. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83362. */
  83363. beginAnimationOnStart: boolean;
  83364. /**
  83365. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83366. */
  83367. beginAnimationFrom: number;
  83368. /**
  83369. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83370. */
  83371. beginAnimationTo: number;
  83372. /**
  83373. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83374. */
  83375. beginAnimationLoop: boolean;
  83376. /**
  83377. * Gets or sets a world offset applied to all particles
  83378. */
  83379. worldOffset: Vector3;
  83380. /**
  83381. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  83382. */
  83383. isAnimationSheetEnabled: boolean;
  83384. /**
  83385. * Get hosting scene
  83386. * @returns the scene
  83387. */
  83388. getScene(): Scene;
  83389. /**
  83390. * You can use gravity if you want to give an orientation to your particles.
  83391. */
  83392. gravity: Vector3;
  83393. protected _colorGradients: Nullable<Array<ColorGradient>>;
  83394. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  83395. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  83396. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  83397. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  83398. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  83399. protected _dragGradients: Nullable<Array<FactorGradient>>;
  83400. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  83401. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  83402. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  83403. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  83404. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  83405. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  83406. /**
  83407. * Defines the delay in milliseconds before starting the system (0 by default)
  83408. */
  83409. startDelay: number;
  83410. /**
  83411. * Gets the current list of drag gradients.
  83412. * You must use addDragGradient and removeDragGradient to udpate this list
  83413. * @returns the list of drag gradients
  83414. */
  83415. getDragGradients(): Nullable<Array<FactorGradient>>;
  83416. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83417. limitVelocityDamping: number;
  83418. /**
  83419. * Gets the current list of limit velocity gradients.
  83420. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83421. * @returns the list of limit velocity gradients
  83422. */
  83423. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83424. /**
  83425. * Gets the current list of color gradients.
  83426. * You must use addColorGradient and removeColorGradient to udpate this list
  83427. * @returns the list of color gradients
  83428. */
  83429. getColorGradients(): Nullable<Array<ColorGradient>>;
  83430. /**
  83431. * Gets the current list of size gradients.
  83432. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83433. * @returns the list of size gradients
  83434. */
  83435. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83436. /**
  83437. * Gets the current list of color remap gradients.
  83438. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83439. * @returns the list of color remap gradients
  83440. */
  83441. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83442. /**
  83443. * Gets the current list of alpha remap gradients.
  83444. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83445. * @returns the list of alpha remap gradients
  83446. */
  83447. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83448. /**
  83449. * Gets the current list of life time gradients.
  83450. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83451. * @returns the list of life time gradients
  83452. */
  83453. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83454. /**
  83455. * Gets the current list of angular speed gradients.
  83456. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83457. * @returns the list of angular speed gradients
  83458. */
  83459. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83460. /**
  83461. * Gets the current list of velocity gradients.
  83462. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83463. * @returns the list of velocity gradients
  83464. */
  83465. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83466. /**
  83467. * Gets the current list of start size gradients.
  83468. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83469. * @returns the list of start size gradients
  83470. */
  83471. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83472. /**
  83473. * Gets the current list of emit rate gradients.
  83474. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83475. * @returns the list of emit rate gradients
  83476. */
  83477. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83478. /**
  83479. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83480. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83481. */
  83482. direction1: Vector3;
  83483. /**
  83484. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83485. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83486. */
  83487. direction2: Vector3;
  83488. /**
  83489. * 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.
  83490. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83491. */
  83492. minEmitBox: Vector3;
  83493. /**
  83494. * 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.
  83495. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83496. */
  83497. maxEmitBox: Vector3;
  83498. /**
  83499. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83500. */
  83501. color1: Color4;
  83502. /**
  83503. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83504. */
  83505. color2: Color4;
  83506. /**
  83507. * Color the particle will have at the end of its lifetime
  83508. */
  83509. colorDead: Color4;
  83510. /**
  83511. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  83512. */
  83513. textureMask: Color4;
  83514. /**
  83515. * The particle emitter type defines the emitter used by the particle system.
  83516. * It can be for example box, sphere, or cone...
  83517. */
  83518. particleEmitterType: IParticleEmitterType;
  83519. /** @hidden */
  83520. _isSubEmitter: boolean;
  83521. /**
  83522. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83523. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83524. */
  83525. billboardMode: number;
  83526. protected _isBillboardBased: boolean;
  83527. /**
  83528. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83529. */
  83530. isBillboardBased: boolean;
  83531. /**
  83532. * The scene the particle system belongs to.
  83533. */
  83534. protected _scene: Scene;
  83535. /**
  83536. * Local cache of defines for image processing.
  83537. */
  83538. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  83539. /**
  83540. * Default configuration related to image processing available in the standard Material.
  83541. */
  83542. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  83543. /**
  83544. * Gets the image processing configuration used either in this material.
  83545. */
  83546. /**
  83547. * Sets the Default image processing configuration used either in the this material.
  83548. *
  83549. * If sets to null, the scene one is in use.
  83550. */
  83551. imageProcessingConfiguration: ImageProcessingConfiguration;
  83552. /**
  83553. * Attaches a new image processing configuration to the Standard Material.
  83554. * @param configuration
  83555. */
  83556. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  83557. /** @hidden */
  83558. protected _reset(): void;
  83559. /** @hidden */
  83560. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  83561. /**
  83562. * Instantiates a particle system.
  83563. * 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.
  83564. * @param name The name of the particle system
  83565. */
  83566. constructor(name: string);
  83567. /**
  83568. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83569. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83570. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83571. * @returns the emitter
  83572. */
  83573. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83574. /**
  83575. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83576. * @param radius The radius of the hemisphere to emit from
  83577. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83578. * @returns the emitter
  83579. */
  83580. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  83581. /**
  83582. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83583. * @param radius The radius of the sphere to emit from
  83584. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83585. * @returns the emitter
  83586. */
  83587. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  83588. /**
  83589. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83590. * @param radius The radius of the sphere to emit from
  83591. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83592. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83593. * @returns the emitter
  83594. */
  83595. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  83596. /**
  83597. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83598. * @param radius The radius of the emission cylinder
  83599. * @param height The height of the emission cylinder
  83600. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83601. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83602. * @returns the emitter
  83603. */
  83604. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  83605. /**
  83606. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83607. * @param radius The radius of the cylinder to emit from
  83608. * @param height The height of the emission cylinder
  83609. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83610. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83611. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83612. * @returns the emitter
  83613. */
  83614. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  83615. /**
  83616. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83617. * @param radius The radius of the cone to emit from
  83618. * @param angle The base angle of the cone
  83619. * @returns the emitter
  83620. */
  83621. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  83622. /**
  83623. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83624. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83625. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83626. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83627. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83628. * @returns the emitter
  83629. */
  83630. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83631. }
  83632. }
  83633. declare module BABYLON {
  83634. /**
  83635. * Type of sub emitter
  83636. */
  83637. export enum SubEmitterType {
  83638. /**
  83639. * Attached to the particle over it's lifetime
  83640. */
  83641. ATTACHED = 0,
  83642. /**
  83643. * Created when the particle dies
  83644. */
  83645. END = 1
  83646. }
  83647. /**
  83648. * Sub emitter class used to emit particles from an existing particle
  83649. */
  83650. export class SubEmitter {
  83651. /**
  83652. * the particle system to be used by the sub emitter
  83653. */
  83654. particleSystem: ParticleSystem;
  83655. /**
  83656. * Type of the submitter (Default: END)
  83657. */
  83658. type: SubEmitterType;
  83659. /**
  83660. * 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)
  83661. * Note: This only is supported when using an emitter of type Mesh
  83662. */
  83663. inheritDirection: boolean;
  83664. /**
  83665. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  83666. */
  83667. inheritedVelocityAmount: number;
  83668. /**
  83669. * Creates a sub emitter
  83670. * @param particleSystem the particle system to be used by the sub emitter
  83671. */
  83672. constructor(
  83673. /**
  83674. * the particle system to be used by the sub emitter
  83675. */
  83676. particleSystem: ParticleSystem);
  83677. /**
  83678. * Clones the sub emitter
  83679. * @returns the cloned sub emitter
  83680. */
  83681. clone(): SubEmitter;
  83682. /**
  83683. * Serialize current object to a JSON object
  83684. * @returns the serialized object
  83685. */
  83686. serialize(): any;
  83687. /** @hidden */
  83688. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  83689. /**
  83690. * Creates a new SubEmitter from a serialized JSON version
  83691. * @param serializationObject defines the JSON object to read from
  83692. * @param scene defines the hosting scene
  83693. * @param rootUrl defines the rootUrl for data loading
  83694. * @returns a new SubEmitter
  83695. */
  83696. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  83697. /** Release associated resources */
  83698. dispose(): void;
  83699. }
  83700. }
  83701. declare module BABYLON {
  83702. /** @hidden */
  83703. export var clipPlaneFragmentDeclaration: {
  83704. name: string;
  83705. shader: string;
  83706. };
  83707. }
  83708. declare module BABYLON {
  83709. /** @hidden */
  83710. export var imageProcessingDeclaration: {
  83711. name: string;
  83712. shader: string;
  83713. };
  83714. }
  83715. declare module BABYLON {
  83716. /** @hidden */
  83717. export var imageProcessingFunctions: {
  83718. name: string;
  83719. shader: string;
  83720. };
  83721. }
  83722. declare module BABYLON {
  83723. /** @hidden */
  83724. export var clipPlaneFragment: {
  83725. name: string;
  83726. shader: string;
  83727. };
  83728. }
  83729. declare module BABYLON {
  83730. /** @hidden */
  83731. export var particlesPixelShader: {
  83732. name: string;
  83733. shader: string;
  83734. };
  83735. }
  83736. declare module BABYLON {
  83737. /** @hidden */
  83738. export var clipPlaneVertexDeclaration: {
  83739. name: string;
  83740. shader: string;
  83741. };
  83742. }
  83743. declare module BABYLON {
  83744. /** @hidden */
  83745. export var clipPlaneVertex: {
  83746. name: string;
  83747. shader: string;
  83748. };
  83749. }
  83750. declare module BABYLON {
  83751. /** @hidden */
  83752. export var particlesVertexShader: {
  83753. name: string;
  83754. shader: string;
  83755. };
  83756. }
  83757. declare module BABYLON {
  83758. /**
  83759. * This represents a particle system in Babylon.
  83760. * 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.
  83761. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83762. * @example https://doc.babylonjs.com/babylon101/particles
  83763. */
  83764. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  83765. /**
  83766. * Billboard mode will only apply to Y axis
  83767. */
  83768. static readonly BILLBOARDMODE_Y: number;
  83769. /**
  83770. * Billboard mode will apply to all axes
  83771. */
  83772. static readonly BILLBOARDMODE_ALL: number;
  83773. /**
  83774. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  83775. */
  83776. static readonly BILLBOARDMODE_STRETCHED: number;
  83777. /**
  83778. * This function can be defined to provide custom update for active particles.
  83779. * This function will be called instead of regular update (age, position, color, etc.).
  83780. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  83781. */
  83782. updateFunction: (particles: Particle[]) => void;
  83783. private _emitterWorldMatrix;
  83784. /**
  83785. * This function can be defined to specify initial direction for every new particle.
  83786. * It by default use the emitterType defined function
  83787. */
  83788. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  83789. /**
  83790. * This function can be defined to specify initial position for every new particle.
  83791. * It by default use the emitterType defined function
  83792. */
  83793. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  83794. /**
  83795. * @hidden
  83796. */
  83797. _inheritedVelocityOffset: Vector3;
  83798. /**
  83799. * An event triggered when the system is disposed
  83800. */
  83801. onDisposeObservable: Observable<ParticleSystem>;
  83802. private _onDisposeObserver;
  83803. /**
  83804. * Sets a callback that will be triggered when the system is disposed
  83805. */
  83806. onDispose: () => void;
  83807. private _particles;
  83808. private _epsilon;
  83809. private _capacity;
  83810. private _stockParticles;
  83811. private _newPartsExcess;
  83812. private _vertexData;
  83813. private _vertexBuffer;
  83814. private _vertexBuffers;
  83815. private _spriteBuffer;
  83816. private _indexBuffer;
  83817. private _effect;
  83818. private _customEffect;
  83819. private _cachedDefines;
  83820. private _scaledColorStep;
  83821. private _colorDiff;
  83822. private _scaledDirection;
  83823. private _scaledGravity;
  83824. private _currentRenderId;
  83825. private _alive;
  83826. private _useInstancing;
  83827. private _started;
  83828. private _stopped;
  83829. private _actualFrame;
  83830. private _scaledUpdateSpeed;
  83831. private _vertexBufferSize;
  83832. /** @hidden */
  83833. _currentEmitRateGradient: Nullable<FactorGradient>;
  83834. /** @hidden */
  83835. _currentEmitRate1: number;
  83836. /** @hidden */
  83837. _currentEmitRate2: number;
  83838. /** @hidden */
  83839. _currentStartSizeGradient: Nullable<FactorGradient>;
  83840. /** @hidden */
  83841. _currentStartSize1: number;
  83842. /** @hidden */
  83843. _currentStartSize2: number;
  83844. private readonly _rawTextureWidth;
  83845. private _rampGradientsTexture;
  83846. private _useRampGradients;
  83847. /** Gets or sets a boolean indicating that ramp gradients must be used
  83848. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83849. */
  83850. useRampGradients: boolean;
  83851. /**
  83852. * 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.
  83853. * 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: [])
  83854. */
  83855. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  83856. private _subEmitters;
  83857. /**
  83858. * @hidden
  83859. * If the particle systems emitter should be disposed when the particle system is disposed
  83860. */
  83861. _disposeEmitterOnDispose: boolean;
  83862. /**
  83863. * The current active Sub-systems, this property is used by the root particle system only.
  83864. */
  83865. activeSubSystems: Array<ParticleSystem>;
  83866. private _rootParticleSystem;
  83867. /**
  83868. * Gets the current list of active particles
  83869. */
  83870. readonly particles: Particle[];
  83871. /**
  83872. * Returns the string "ParticleSystem"
  83873. * @returns a string containing the class name
  83874. */
  83875. getClassName(): string;
  83876. /**
  83877. * Instantiates a particle system.
  83878. * 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.
  83879. * @param name The name of the particle system
  83880. * @param capacity The max number of particles alive at the same time
  83881. * @param scene The scene the particle system belongs to
  83882. * @param customEffect a custom effect used to change the way particles are rendered by default
  83883. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  83884. * @param epsilon Offset used to render the particles
  83885. */
  83886. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  83887. private _addFactorGradient;
  83888. private _removeFactorGradient;
  83889. /**
  83890. * Adds a new life time gradient
  83891. * @param gradient defines the gradient to use (between 0 and 1)
  83892. * @param factor defines the life time factor to affect to the specified gradient
  83893. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83894. * @returns the current particle system
  83895. */
  83896. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83897. /**
  83898. * Remove a specific life time gradient
  83899. * @param gradient defines the gradient to remove
  83900. * @returns the current particle system
  83901. */
  83902. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83903. /**
  83904. * Adds a new size gradient
  83905. * @param gradient defines the gradient to use (between 0 and 1)
  83906. * @param factor defines the size factor to affect to the specified gradient
  83907. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83908. * @returns the current particle system
  83909. */
  83910. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83911. /**
  83912. * Remove a specific size gradient
  83913. * @param gradient defines the gradient to remove
  83914. * @returns the current particle system
  83915. */
  83916. removeSizeGradient(gradient: number): IParticleSystem;
  83917. /**
  83918. * Adds a new color remap gradient
  83919. * @param gradient defines the gradient to use (between 0 and 1)
  83920. * @param min defines the color remap minimal range
  83921. * @param max defines the color remap maximal range
  83922. * @returns the current particle system
  83923. */
  83924. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83925. /**
  83926. * Remove a specific color remap gradient
  83927. * @param gradient defines the gradient to remove
  83928. * @returns the current particle system
  83929. */
  83930. removeColorRemapGradient(gradient: number): IParticleSystem;
  83931. /**
  83932. * Adds a new alpha remap gradient
  83933. * @param gradient defines the gradient to use (between 0 and 1)
  83934. * @param min defines the alpha remap minimal range
  83935. * @param max defines the alpha remap maximal range
  83936. * @returns the current particle system
  83937. */
  83938. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83939. /**
  83940. * Remove a specific alpha remap gradient
  83941. * @param gradient defines the gradient to remove
  83942. * @returns the current particle system
  83943. */
  83944. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  83945. /**
  83946. * Adds a new angular speed gradient
  83947. * @param gradient defines the gradient to use (between 0 and 1)
  83948. * @param factor defines the angular speed to affect to the specified gradient
  83949. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83950. * @returns the current particle system
  83951. */
  83952. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83953. /**
  83954. * Remove a specific angular speed gradient
  83955. * @param gradient defines the gradient to remove
  83956. * @returns the current particle system
  83957. */
  83958. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83959. /**
  83960. * Adds a new velocity gradient
  83961. * @param gradient defines the gradient to use (between 0 and 1)
  83962. * @param factor defines the velocity to affect to the specified gradient
  83963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83964. * @returns the current particle system
  83965. */
  83966. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83967. /**
  83968. * Remove a specific velocity gradient
  83969. * @param gradient defines the gradient to remove
  83970. * @returns the current particle system
  83971. */
  83972. removeVelocityGradient(gradient: number): IParticleSystem;
  83973. /**
  83974. * Adds a new limit velocity gradient
  83975. * @param gradient defines the gradient to use (between 0 and 1)
  83976. * @param factor defines the limit velocity value to affect to the specified gradient
  83977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83978. * @returns the current particle system
  83979. */
  83980. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83981. /**
  83982. * Remove a specific limit velocity gradient
  83983. * @param gradient defines the gradient to remove
  83984. * @returns the current particle system
  83985. */
  83986. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83987. /**
  83988. * Adds a new drag gradient
  83989. * @param gradient defines the gradient to use (between 0 and 1)
  83990. * @param factor defines the drag value to affect to the specified gradient
  83991. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83992. * @returns the current particle system
  83993. */
  83994. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83995. /**
  83996. * Remove a specific drag gradient
  83997. * @param gradient defines the gradient to remove
  83998. * @returns the current particle system
  83999. */
  84000. removeDragGradient(gradient: number): IParticleSystem;
  84001. /**
  84002. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84003. * @param gradient defines the gradient to use (between 0 and 1)
  84004. * @param factor defines the emit rate value to affect to the specified gradient
  84005. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84006. * @returns the current particle system
  84007. */
  84008. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84009. /**
  84010. * Remove a specific emit rate gradient
  84011. * @param gradient defines the gradient to remove
  84012. * @returns the current particle system
  84013. */
  84014. removeEmitRateGradient(gradient: number): IParticleSystem;
  84015. /**
  84016. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84017. * @param gradient defines the gradient to use (between 0 and 1)
  84018. * @param factor defines the start size value to affect to the specified gradient
  84019. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84020. * @returns the current particle system
  84021. */
  84022. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84023. /**
  84024. * Remove a specific start size gradient
  84025. * @param gradient defines the gradient to remove
  84026. * @returns the current particle system
  84027. */
  84028. removeStartSizeGradient(gradient: number): IParticleSystem;
  84029. private _createRampGradientTexture;
  84030. /**
  84031. * Gets the current list of ramp gradients.
  84032. * You must use addRampGradient and removeRampGradient to udpate this list
  84033. * @returns the list of ramp gradients
  84034. */
  84035. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84036. /**
  84037. * Adds a new ramp gradient used to remap particle colors
  84038. * @param gradient defines the gradient to use (between 0 and 1)
  84039. * @param color defines the color to affect to the specified gradient
  84040. * @returns the current particle system
  84041. */
  84042. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  84043. /**
  84044. * Remove a specific ramp gradient
  84045. * @param gradient defines the gradient to remove
  84046. * @returns the current particle system
  84047. */
  84048. removeRampGradient(gradient: number): ParticleSystem;
  84049. /**
  84050. * Adds a new color gradient
  84051. * @param gradient defines the gradient to use (between 0 and 1)
  84052. * @param color1 defines the color to affect to the specified gradient
  84053. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84054. * @returns this particle system
  84055. */
  84056. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84057. /**
  84058. * Remove a specific color gradient
  84059. * @param gradient defines the gradient to remove
  84060. * @returns this particle system
  84061. */
  84062. removeColorGradient(gradient: number): IParticleSystem;
  84063. private _fetchR;
  84064. protected _reset(): void;
  84065. private _resetEffect;
  84066. private _createVertexBuffers;
  84067. private _createIndexBuffer;
  84068. /**
  84069. * Gets the maximum number of particles active at the same time.
  84070. * @returns The max number of active particles.
  84071. */
  84072. getCapacity(): number;
  84073. /**
  84074. * Gets whether there are still active particles in the system.
  84075. * @returns True if it is alive, otherwise false.
  84076. */
  84077. isAlive(): boolean;
  84078. /**
  84079. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84080. * @returns True if it has been started, otherwise false.
  84081. */
  84082. isStarted(): boolean;
  84083. private _prepareSubEmitterInternalArray;
  84084. /**
  84085. * Starts the particle system and begins to emit
  84086. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  84087. */
  84088. start(delay?: number): void;
  84089. /**
  84090. * Stops the particle system.
  84091. * @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.
  84092. */
  84093. stop(stopSubEmitters?: boolean): void;
  84094. /**
  84095. * Remove all active particles
  84096. */
  84097. reset(): void;
  84098. /**
  84099. * @hidden (for internal use only)
  84100. */
  84101. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  84102. /**
  84103. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  84104. * Its lifetime will start back at 0.
  84105. */
  84106. recycleParticle: (particle: Particle) => void;
  84107. private _stopSubEmitters;
  84108. private _createParticle;
  84109. private _removeFromRoot;
  84110. private _emitFromParticle;
  84111. private _update;
  84112. /** @hidden */
  84113. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  84114. /** @hidden */
  84115. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  84116. /** @hidden */
  84117. private _getEffect;
  84118. /**
  84119. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  84120. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  84121. */
  84122. animate(preWarmOnly?: boolean): void;
  84123. private _appendParticleVertices;
  84124. /**
  84125. * Rebuilds the particle system.
  84126. */
  84127. rebuild(): void;
  84128. /**
  84129. * Is this system ready to be used/rendered
  84130. * @return true if the system is ready
  84131. */
  84132. isReady(): boolean;
  84133. private _render;
  84134. /**
  84135. * Renders the particle system in its current state.
  84136. * @returns the current number of particles
  84137. */
  84138. render(): number;
  84139. /**
  84140. * Disposes the particle system and free the associated resources
  84141. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84142. */
  84143. dispose(disposeTexture?: boolean): void;
  84144. /**
  84145. * Clones the particle system.
  84146. * @param name The name of the cloned object
  84147. * @param newEmitter The new emitter to use
  84148. * @returns the cloned particle system
  84149. */
  84150. clone(name: string, newEmitter: any): ParticleSystem;
  84151. /**
  84152. * Serializes the particle system to a JSON object.
  84153. * @returns the JSON object
  84154. */
  84155. serialize(): any;
  84156. /** @hidden */
  84157. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  84158. /** @hidden */
  84159. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  84160. /**
  84161. * Parses a JSON object to create a particle system.
  84162. * @param parsedParticleSystem The JSON object to parse
  84163. * @param scene The scene to create the particle system in
  84164. * @param rootUrl The root url to use to load external dependencies like texture
  84165. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  84166. * @returns the Parsed particle system
  84167. */
  84168. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  84169. }
  84170. }
  84171. declare module BABYLON {
  84172. /**
  84173. * A particle represents one of the element emitted by a particle system.
  84174. * This is mainly define by its coordinates, direction, velocity and age.
  84175. */
  84176. export class Particle {
  84177. /**
  84178. * The particle system the particle belongs to.
  84179. */
  84180. particleSystem: ParticleSystem;
  84181. private static _Count;
  84182. /**
  84183. * Unique ID of the particle
  84184. */
  84185. id: number;
  84186. /**
  84187. * The world position of the particle in the scene.
  84188. */
  84189. position: Vector3;
  84190. /**
  84191. * The world direction of the particle in the scene.
  84192. */
  84193. direction: Vector3;
  84194. /**
  84195. * The color of the particle.
  84196. */
  84197. color: Color4;
  84198. /**
  84199. * The color change of the particle per step.
  84200. */
  84201. colorStep: Color4;
  84202. /**
  84203. * Defines how long will the life of the particle be.
  84204. */
  84205. lifeTime: number;
  84206. /**
  84207. * The current age of the particle.
  84208. */
  84209. age: number;
  84210. /**
  84211. * The current size of the particle.
  84212. */
  84213. size: number;
  84214. /**
  84215. * The current scale of the particle.
  84216. */
  84217. scale: Vector2;
  84218. /**
  84219. * The current angle of the particle.
  84220. */
  84221. angle: number;
  84222. /**
  84223. * Defines how fast is the angle changing.
  84224. */
  84225. angularSpeed: number;
  84226. /**
  84227. * Defines the cell index used by the particle to be rendered from a sprite.
  84228. */
  84229. cellIndex: number;
  84230. /**
  84231. * The information required to support color remapping
  84232. */
  84233. remapData: Vector4;
  84234. /** @hidden */
  84235. _randomCellOffset?: number;
  84236. /** @hidden */
  84237. _initialDirection: Nullable<Vector3>;
  84238. /** @hidden */
  84239. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  84240. /** @hidden */
  84241. _initialStartSpriteCellID: number;
  84242. /** @hidden */
  84243. _initialEndSpriteCellID: number;
  84244. /** @hidden */
  84245. _currentColorGradient: Nullable<ColorGradient>;
  84246. /** @hidden */
  84247. _currentColor1: Color4;
  84248. /** @hidden */
  84249. _currentColor2: Color4;
  84250. /** @hidden */
  84251. _currentSizeGradient: Nullable<FactorGradient>;
  84252. /** @hidden */
  84253. _currentSize1: number;
  84254. /** @hidden */
  84255. _currentSize2: number;
  84256. /** @hidden */
  84257. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  84258. /** @hidden */
  84259. _currentAngularSpeed1: number;
  84260. /** @hidden */
  84261. _currentAngularSpeed2: number;
  84262. /** @hidden */
  84263. _currentVelocityGradient: Nullable<FactorGradient>;
  84264. /** @hidden */
  84265. _currentVelocity1: number;
  84266. /** @hidden */
  84267. _currentVelocity2: number;
  84268. /** @hidden */
  84269. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  84270. /** @hidden */
  84271. _currentLimitVelocity1: number;
  84272. /** @hidden */
  84273. _currentLimitVelocity2: number;
  84274. /** @hidden */
  84275. _currentDragGradient: Nullable<FactorGradient>;
  84276. /** @hidden */
  84277. _currentDrag1: number;
  84278. /** @hidden */
  84279. _currentDrag2: number;
  84280. /** @hidden */
  84281. _randomNoiseCoordinates1: Vector3;
  84282. /** @hidden */
  84283. _randomNoiseCoordinates2: Vector3;
  84284. /**
  84285. * Creates a new instance Particle
  84286. * @param particleSystem the particle system the particle belongs to
  84287. */
  84288. constructor(
  84289. /**
  84290. * The particle system the particle belongs to.
  84291. */
  84292. particleSystem: ParticleSystem);
  84293. private updateCellInfoFromSystem;
  84294. /**
  84295. * Defines how the sprite cell index is updated for the particle
  84296. */
  84297. updateCellIndex(): void;
  84298. /** @hidden */
  84299. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  84300. /** @hidden */
  84301. _inheritParticleInfoToSubEmitters(): void;
  84302. /** @hidden */
  84303. _reset(): void;
  84304. /**
  84305. * Copy the properties of particle to another one.
  84306. * @param other the particle to copy the information to.
  84307. */
  84308. copyTo(other: Particle): void;
  84309. }
  84310. }
  84311. declare module BABYLON {
  84312. /**
  84313. * Particle emitter represents a volume emitting particles.
  84314. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  84315. */
  84316. export interface IParticleEmitterType {
  84317. /**
  84318. * Called by the particle System when the direction is computed for the created particle.
  84319. * @param worldMatrix is the world matrix of the particle system
  84320. * @param directionToUpdate is the direction vector to update with the result
  84321. * @param particle is the particle we are computed the direction for
  84322. */
  84323. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84324. /**
  84325. * Called by the particle System when the position is computed for the created particle.
  84326. * @param worldMatrix is the world matrix of the particle system
  84327. * @param positionToUpdate is the position vector to update with the result
  84328. * @param particle is the particle we are computed the position for
  84329. */
  84330. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84331. /**
  84332. * Clones the current emitter and returns a copy of it
  84333. * @returns the new emitter
  84334. */
  84335. clone(): IParticleEmitterType;
  84336. /**
  84337. * Called by the GPUParticleSystem to setup the update shader
  84338. * @param effect defines the update shader
  84339. */
  84340. applyToShader(effect: Effect): void;
  84341. /**
  84342. * Returns a string to use to update the GPU particles update shader
  84343. * @returns the effect defines string
  84344. */
  84345. getEffectDefines(): string;
  84346. /**
  84347. * Returns a string representing the class name
  84348. * @returns a string containing the class name
  84349. */
  84350. getClassName(): string;
  84351. /**
  84352. * Serializes the particle system to a JSON object.
  84353. * @returns the JSON object
  84354. */
  84355. serialize(): any;
  84356. /**
  84357. * Parse properties from a JSON object
  84358. * @param serializationObject defines the JSON object
  84359. */
  84360. parse(serializationObject: any): void;
  84361. }
  84362. }
  84363. declare module BABYLON {
  84364. /**
  84365. * Particle emitter emitting particles from the inside of a box.
  84366. * It emits the particles randomly between 2 given directions.
  84367. */
  84368. export class BoxParticleEmitter implements IParticleEmitterType {
  84369. /**
  84370. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84371. */
  84372. direction1: Vector3;
  84373. /**
  84374. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84375. */
  84376. direction2: Vector3;
  84377. /**
  84378. * 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.
  84379. */
  84380. minEmitBox: Vector3;
  84381. /**
  84382. * 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.
  84383. */
  84384. maxEmitBox: Vector3;
  84385. /**
  84386. * Creates a new instance BoxParticleEmitter
  84387. */
  84388. constructor();
  84389. /**
  84390. * Called by the particle System when the direction is computed for the created particle.
  84391. * @param worldMatrix is the world matrix of the particle system
  84392. * @param directionToUpdate is the direction vector to update with the result
  84393. * @param particle is the particle we are computed the direction for
  84394. */
  84395. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84396. /**
  84397. * Called by the particle System when the position is computed for the created particle.
  84398. * @param worldMatrix is the world matrix of the particle system
  84399. * @param positionToUpdate is the position vector to update with the result
  84400. * @param particle is the particle we are computed the position for
  84401. */
  84402. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84403. /**
  84404. * Clones the current emitter and returns a copy of it
  84405. * @returns the new emitter
  84406. */
  84407. clone(): BoxParticleEmitter;
  84408. /**
  84409. * Called by the GPUParticleSystem to setup the update shader
  84410. * @param effect defines the update shader
  84411. */
  84412. applyToShader(effect: Effect): void;
  84413. /**
  84414. * Returns a string to use to update the GPU particles update shader
  84415. * @returns a string containng the defines string
  84416. */
  84417. getEffectDefines(): string;
  84418. /**
  84419. * Returns the string "BoxParticleEmitter"
  84420. * @returns a string containing the class name
  84421. */
  84422. getClassName(): string;
  84423. /**
  84424. * Serializes the particle system to a JSON object.
  84425. * @returns the JSON object
  84426. */
  84427. serialize(): any;
  84428. /**
  84429. * Parse properties from a JSON object
  84430. * @param serializationObject defines the JSON object
  84431. */
  84432. parse(serializationObject: any): void;
  84433. }
  84434. }
  84435. declare module BABYLON {
  84436. /**
  84437. * Particle emitter emitting particles from the inside of a cone.
  84438. * It emits the particles alongside the cone volume from the base to the particle.
  84439. * The emission direction might be randomized.
  84440. */
  84441. export class ConeParticleEmitter implements IParticleEmitterType {
  84442. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84443. directionRandomizer: number;
  84444. private _radius;
  84445. private _angle;
  84446. private _height;
  84447. /**
  84448. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  84449. */
  84450. radiusRange: number;
  84451. /**
  84452. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  84453. */
  84454. heightRange: number;
  84455. /**
  84456. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  84457. */
  84458. emitFromSpawnPointOnly: boolean;
  84459. /**
  84460. * Gets or sets the radius of the emission cone
  84461. */
  84462. radius: number;
  84463. /**
  84464. * Gets or sets the angle of the emission cone
  84465. */
  84466. angle: number;
  84467. private _buildHeight;
  84468. /**
  84469. * Creates a new instance ConeParticleEmitter
  84470. * @param radius the radius of the emission cone (1 by default)
  84471. * @param angle the cone base angle (PI by default)
  84472. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  84473. */
  84474. constructor(radius?: number, angle?: number,
  84475. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84476. directionRandomizer?: number);
  84477. /**
  84478. * Called by the particle System when the direction is computed for the created particle.
  84479. * @param worldMatrix is the world matrix of the particle system
  84480. * @param directionToUpdate is the direction vector to update with the result
  84481. * @param particle is the particle we are computed the direction for
  84482. */
  84483. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84484. /**
  84485. * Called by the particle System when the position is computed for the created particle.
  84486. * @param worldMatrix is the world matrix of the particle system
  84487. * @param positionToUpdate is the position vector to update with the result
  84488. * @param particle is the particle we are computed the position for
  84489. */
  84490. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84491. /**
  84492. * Clones the current emitter and returns a copy of it
  84493. * @returns the new emitter
  84494. */
  84495. clone(): ConeParticleEmitter;
  84496. /**
  84497. * Called by the GPUParticleSystem to setup the update shader
  84498. * @param effect defines the update shader
  84499. */
  84500. applyToShader(effect: Effect): void;
  84501. /**
  84502. * Returns a string to use to update the GPU particles update shader
  84503. * @returns a string containng the defines string
  84504. */
  84505. getEffectDefines(): string;
  84506. /**
  84507. * Returns the string "ConeParticleEmitter"
  84508. * @returns a string containing the class name
  84509. */
  84510. getClassName(): string;
  84511. /**
  84512. * Serializes the particle system to a JSON object.
  84513. * @returns the JSON object
  84514. */
  84515. serialize(): any;
  84516. /**
  84517. * Parse properties from a JSON object
  84518. * @param serializationObject defines the JSON object
  84519. */
  84520. parse(serializationObject: any): void;
  84521. }
  84522. }
  84523. declare module BABYLON {
  84524. /**
  84525. * Particle emitter emitting particles from the inside of a cylinder.
  84526. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  84527. */
  84528. export class CylinderParticleEmitter implements IParticleEmitterType {
  84529. /**
  84530. * The radius of the emission cylinder.
  84531. */
  84532. radius: number;
  84533. /**
  84534. * The height of the emission cylinder.
  84535. */
  84536. height: number;
  84537. /**
  84538. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84539. */
  84540. radiusRange: number;
  84541. /**
  84542. * How much to randomize the particle direction [0-1].
  84543. */
  84544. directionRandomizer: number;
  84545. /**
  84546. * Creates a new instance CylinderParticleEmitter
  84547. * @param radius the radius of the emission cylinder (1 by default)
  84548. * @param height the height of the emission cylinder (1 by default)
  84549. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84550. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84551. */
  84552. constructor(
  84553. /**
  84554. * The radius of the emission cylinder.
  84555. */
  84556. radius?: number,
  84557. /**
  84558. * The height of the emission cylinder.
  84559. */
  84560. height?: number,
  84561. /**
  84562. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84563. */
  84564. radiusRange?: number,
  84565. /**
  84566. * How much to randomize the particle direction [0-1].
  84567. */
  84568. directionRandomizer?: number);
  84569. /**
  84570. * Called by the particle System when the direction is computed for the created particle.
  84571. * @param worldMatrix is the world matrix of the particle system
  84572. * @param directionToUpdate is the direction vector to update with the result
  84573. * @param particle is the particle we are computed the direction for
  84574. */
  84575. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84576. /**
  84577. * Called by the particle System when the position is computed for the created particle.
  84578. * @param worldMatrix is the world matrix of the particle system
  84579. * @param positionToUpdate is the position vector to update with the result
  84580. * @param particle is the particle we are computed the position for
  84581. */
  84582. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84583. /**
  84584. * Clones the current emitter and returns a copy of it
  84585. * @returns the new emitter
  84586. */
  84587. clone(): CylinderParticleEmitter;
  84588. /**
  84589. * Called by the GPUParticleSystem to setup the update shader
  84590. * @param effect defines the update shader
  84591. */
  84592. applyToShader(effect: Effect): void;
  84593. /**
  84594. * Returns a string to use to update the GPU particles update shader
  84595. * @returns a string containng the defines string
  84596. */
  84597. getEffectDefines(): string;
  84598. /**
  84599. * Returns the string "CylinderParticleEmitter"
  84600. * @returns a string containing the class name
  84601. */
  84602. getClassName(): string;
  84603. /**
  84604. * Serializes the particle system to a JSON object.
  84605. * @returns the JSON object
  84606. */
  84607. serialize(): any;
  84608. /**
  84609. * Parse properties from a JSON object
  84610. * @param serializationObject defines the JSON object
  84611. */
  84612. parse(serializationObject: any): void;
  84613. }
  84614. /**
  84615. * Particle emitter emitting particles from the inside of a cylinder.
  84616. * It emits the particles randomly between two vectors.
  84617. */
  84618. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  84619. /**
  84620. * The min limit of the emission direction.
  84621. */
  84622. direction1: Vector3;
  84623. /**
  84624. * The max limit of the emission direction.
  84625. */
  84626. direction2: Vector3;
  84627. /**
  84628. * Creates a new instance CylinderDirectedParticleEmitter
  84629. * @param radius the radius of the emission cylinder (1 by default)
  84630. * @param height the height of the emission cylinder (1 by default)
  84631. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84632. * @param direction1 the min limit of the emission direction (up vector by default)
  84633. * @param direction2 the max limit of the emission direction (up vector by default)
  84634. */
  84635. constructor(radius?: number, height?: number, radiusRange?: number,
  84636. /**
  84637. * The min limit of the emission direction.
  84638. */
  84639. direction1?: Vector3,
  84640. /**
  84641. * The max limit of the emission direction.
  84642. */
  84643. direction2?: Vector3);
  84644. /**
  84645. * Called by the particle System when the direction is computed for the created particle.
  84646. * @param worldMatrix is the world matrix of the particle system
  84647. * @param directionToUpdate is the direction vector to update with the result
  84648. * @param particle is the particle we are computed the direction for
  84649. */
  84650. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84651. /**
  84652. * Clones the current emitter and returns a copy of it
  84653. * @returns the new emitter
  84654. */
  84655. clone(): CylinderDirectedParticleEmitter;
  84656. /**
  84657. * Called by the GPUParticleSystem to setup the update shader
  84658. * @param effect defines the update shader
  84659. */
  84660. applyToShader(effect: Effect): void;
  84661. /**
  84662. * Returns a string to use to update the GPU particles update shader
  84663. * @returns a string containng the defines string
  84664. */
  84665. getEffectDefines(): string;
  84666. /**
  84667. * Returns the string "CylinderDirectedParticleEmitter"
  84668. * @returns a string containing the class name
  84669. */
  84670. getClassName(): string;
  84671. /**
  84672. * Serializes the particle system to a JSON object.
  84673. * @returns the JSON object
  84674. */
  84675. serialize(): any;
  84676. /**
  84677. * Parse properties from a JSON object
  84678. * @param serializationObject defines the JSON object
  84679. */
  84680. parse(serializationObject: any): void;
  84681. }
  84682. }
  84683. declare module BABYLON {
  84684. /**
  84685. * Particle emitter emitting particles from the inside of a hemisphere.
  84686. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  84687. */
  84688. export class HemisphericParticleEmitter implements IParticleEmitterType {
  84689. /**
  84690. * The radius of the emission hemisphere.
  84691. */
  84692. radius: number;
  84693. /**
  84694. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84695. */
  84696. radiusRange: number;
  84697. /**
  84698. * How much to randomize the particle direction [0-1].
  84699. */
  84700. directionRandomizer: number;
  84701. /**
  84702. * Creates a new instance HemisphericParticleEmitter
  84703. * @param radius the radius of the emission hemisphere (1 by default)
  84704. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84705. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84706. */
  84707. constructor(
  84708. /**
  84709. * The radius of the emission hemisphere.
  84710. */
  84711. radius?: number,
  84712. /**
  84713. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84714. */
  84715. radiusRange?: number,
  84716. /**
  84717. * How much to randomize the particle direction [0-1].
  84718. */
  84719. directionRandomizer?: number);
  84720. /**
  84721. * Called by the particle System when the direction is computed for the created particle.
  84722. * @param worldMatrix is the world matrix of the particle system
  84723. * @param directionToUpdate is the direction vector to update with the result
  84724. * @param particle is the particle we are computed the direction for
  84725. */
  84726. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84727. /**
  84728. * Called by the particle System when the position is computed for the created particle.
  84729. * @param worldMatrix is the world matrix of the particle system
  84730. * @param positionToUpdate is the position vector to update with the result
  84731. * @param particle is the particle we are computed the position for
  84732. */
  84733. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84734. /**
  84735. * Clones the current emitter and returns a copy of it
  84736. * @returns the new emitter
  84737. */
  84738. clone(): HemisphericParticleEmitter;
  84739. /**
  84740. * Called by the GPUParticleSystem to setup the update shader
  84741. * @param effect defines the update shader
  84742. */
  84743. applyToShader(effect: Effect): void;
  84744. /**
  84745. * Returns a string to use to update the GPU particles update shader
  84746. * @returns a string containng the defines string
  84747. */
  84748. getEffectDefines(): string;
  84749. /**
  84750. * Returns the string "HemisphericParticleEmitter"
  84751. * @returns a string containing the class name
  84752. */
  84753. getClassName(): string;
  84754. /**
  84755. * Serializes the particle system to a JSON object.
  84756. * @returns the JSON object
  84757. */
  84758. serialize(): any;
  84759. /**
  84760. * Parse properties from a JSON object
  84761. * @param serializationObject defines the JSON object
  84762. */
  84763. parse(serializationObject: any): void;
  84764. }
  84765. }
  84766. declare module BABYLON {
  84767. /**
  84768. * Particle emitter emitting particles from a point.
  84769. * It emits the particles randomly between 2 given directions.
  84770. */
  84771. export class PointParticleEmitter implements IParticleEmitterType {
  84772. /**
  84773. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84774. */
  84775. direction1: Vector3;
  84776. /**
  84777. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84778. */
  84779. direction2: Vector3;
  84780. /**
  84781. * Creates a new instance PointParticleEmitter
  84782. */
  84783. constructor();
  84784. /**
  84785. * Called by the particle System when the direction is computed for the created particle.
  84786. * @param worldMatrix is the world matrix of the particle system
  84787. * @param directionToUpdate is the direction vector to update with the result
  84788. * @param particle is the particle we are computed the direction for
  84789. */
  84790. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84791. /**
  84792. * Called by the particle System when the position is computed for the created particle.
  84793. * @param worldMatrix is the world matrix of the particle system
  84794. * @param positionToUpdate is the position vector to update with the result
  84795. * @param particle is the particle we are computed the position for
  84796. */
  84797. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84798. /**
  84799. * Clones the current emitter and returns a copy of it
  84800. * @returns the new emitter
  84801. */
  84802. clone(): PointParticleEmitter;
  84803. /**
  84804. * Called by the GPUParticleSystem to setup the update shader
  84805. * @param effect defines the update shader
  84806. */
  84807. applyToShader(effect: Effect): void;
  84808. /**
  84809. * Returns a string to use to update the GPU particles update shader
  84810. * @returns a string containng the defines string
  84811. */
  84812. getEffectDefines(): string;
  84813. /**
  84814. * Returns the string "PointParticleEmitter"
  84815. * @returns a string containing the class name
  84816. */
  84817. getClassName(): string;
  84818. /**
  84819. * Serializes the particle system to a JSON object.
  84820. * @returns the JSON object
  84821. */
  84822. serialize(): any;
  84823. /**
  84824. * Parse properties from a JSON object
  84825. * @param serializationObject defines the JSON object
  84826. */
  84827. parse(serializationObject: any): void;
  84828. }
  84829. }
  84830. declare module BABYLON {
  84831. /**
  84832. * Particle emitter emitting particles from the inside of a sphere.
  84833. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  84834. */
  84835. export class SphereParticleEmitter implements IParticleEmitterType {
  84836. /**
  84837. * The radius of the emission sphere.
  84838. */
  84839. radius: number;
  84840. /**
  84841. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84842. */
  84843. radiusRange: number;
  84844. /**
  84845. * How much to randomize the particle direction [0-1].
  84846. */
  84847. directionRandomizer: number;
  84848. /**
  84849. * Creates a new instance SphereParticleEmitter
  84850. * @param radius the radius of the emission sphere (1 by default)
  84851. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84852. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84853. */
  84854. constructor(
  84855. /**
  84856. * The radius of the emission sphere.
  84857. */
  84858. radius?: number,
  84859. /**
  84860. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84861. */
  84862. radiusRange?: number,
  84863. /**
  84864. * How much to randomize the particle direction [0-1].
  84865. */
  84866. directionRandomizer?: number);
  84867. /**
  84868. * Called by the particle System when the direction is computed for the created particle.
  84869. * @param worldMatrix is the world matrix of the particle system
  84870. * @param directionToUpdate is the direction vector to update with the result
  84871. * @param particle is the particle we are computed the direction for
  84872. */
  84873. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84874. /**
  84875. * Called by the particle System when the position is computed for the created particle.
  84876. * @param worldMatrix is the world matrix of the particle system
  84877. * @param positionToUpdate is the position vector to update with the result
  84878. * @param particle is the particle we are computed the position for
  84879. */
  84880. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84881. /**
  84882. * Clones the current emitter and returns a copy of it
  84883. * @returns the new emitter
  84884. */
  84885. clone(): SphereParticleEmitter;
  84886. /**
  84887. * Called by the GPUParticleSystem to setup the update shader
  84888. * @param effect defines the update shader
  84889. */
  84890. applyToShader(effect: Effect): void;
  84891. /**
  84892. * Returns a string to use to update the GPU particles update shader
  84893. * @returns a string containng the defines string
  84894. */
  84895. getEffectDefines(): string;
  84896. /**
  84897. * Returns the string "SphereParticleEmitter"
  84898. * @returns a string containing the class name
  84899. */
  84900. getClassName(): string;
  84901. /**
  84902. * Serializes the particle system to a JSON object.
  84903. * @returns the JSON object
  84904. */
  84905. serialize(): any;
  84906. /**
  84907. * Parse properties from a JSON object
  84908. * @param serializationObject defines the JSON object
  84909. */
  84910. parse(serializationObject: any): void;
  84911. }
  84912. /**
  84913. * Particle emitter emitting particles from the inside of a sphere.
  84914. * It emits the particles randomly between two vectors.
  84915. */
  84916. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  84917. /**
  84918. * The min limit of the emission direction.
  84919. */
  84920. direction1: Vector3;
  84921. /**
  84922. * The max limit of the emission direction.
  84923. */
  84924. direction2: Vector3;
  84925. /**
  84926. * Creates a new instance SphereDirectedParticleEmitter
  84927. * @param radius the radius of the emission sphere (1 by default)
  84928. * @param direction1 the min limit of the emission direction (up vector by default)
  84929. * @param direction2 the max limit of the emission direction (up vector by default)
  84930. */
  84931. constructor(radius?: number,
  84932. /**
  84933. * The min limit of the emission direction.
  84934. */
  84935. direction1?: Vector3,
  84936. /**
  84937. * The max limit of the emission direction.
  84938. */
  84939. direction2?: Vector3);
  84940. /**
  84941. * Called by the particle System when the direction is computed for the created particle.
  84942. * @param worldMatrix is the world matrix of the particle system
  84943. * @param directionToUpdate is the direction vector to update with the result
  84944. * @param particle is the particle we are computed the direction for
  84945. */
  84946. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84947. /**
  84948. * Clones the current emitter and returns a copy of it
  84949. * @returns the new emitter
  84950. */
  84951. clone(): SphereDirectedParticleEmitter;
  84952. /**
  84953. * Called by the GPUParticleSystem to setup the update shader
  84954. * @param effect defines the update shader
  84955. */
  84956. applyToShader(effect: Effect): void;
  84957. /**
  84958. * Returns a string to use to update the GPU particles update shader
  84959. * @returns a string containng the defines string
  84960. */
  84961. getEffectDefines(): string;
  84962. /**
  84963. * Returns the string "SphereDirectedParticleEmitter"
  84964. * @returns a string containing the class name
  84965. */
  84966. getClassName(): string;
  84967. /**
  84968. * Serializes the particle system to a JSON object.
  84969. * @returns the JSON object
  84970. */
  84971. serialize(): any;
  84972. /**
  84973. * Parse properties from a JSON object
  84974. * @param serializationObject defines the JSON object
  84975. */
  84976. parse(serializationObject: any): void;
  84977. }
  84978. }
  84979. declare module BABYLON {
  84980. /**
  84981. * Interface representing a particle system in Babylon.js.
  84982. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  84983. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  84984. */
  84985. export interface IParticleSystem {
  84986. /**
  84987. * List of animations used by the particle system.
  84988. */
  84989. animations: Animation[];
  84990. /**
  84991. * The id of the Particle system.
  84992. */
  84993. id: string;
  84994. /**
  84995. * The name of the Particle system.
  84996. */
  84997. name: string;
  84998. /**
  84999. * The emitter represents the Mesh or position we are attaching the particle system to.
  85000. */
  85001. emitter: Nullable<AbstractMesh | Vector3>;
  85002. /**
  85003. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85004. */
  85005. isBillboardBased: boolean;
  85006. /**
  85007. * The rendering group used by the Particle system to chose when to render.
  85008. */
  85009. renderingGroupId: number;
  85010. /**
  85011. * The layer mask we are rendering the particles through.
  85012. */
  85013. layerMask: number;
  85014. /**
  85015. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85016. */
  85017. updateSpeed: number;
  85018. /**
  85019. * The amount of time the particle system is running (depends of the overall update speed).
  85020. */
  85021. targetStopDuration: number;
  85022. /**
  85023. * The texture used to render each particle. (this can be a spritesheet)
  85024. */
  85025. particleTexture: Nullable<Texture>;
  85026. /**
  85027. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  85028. */
  85029. blendMode: number;
  85030. /**
  85031. * Minimum life time of emitting particles.
  85032. */
  85033. minLifeTime: number;
  85034. /**
  85035. * Maximum life time of emitting particles.
  85036. */
  85037. maxLifeTime: number;
  85038. /**
  85039. * Minimum Size of emitting particles.
  85040. */
  85041. minSize: number;
  85042. /**
  85043. * Maximum Size of emitting particles.
  85044. */
  85045. maxSize: number;
  85046. /**
  85047. * Minimum scale of emitting particles on X axis.
  85048. */
  85049. minScaleX: number;
  85050. /**
  85051. * Maximum scale of emitting particles on X axis.
  85052. */
  85053. maxScaleX: number;
  85054. /**
  85055. * Minimum scale of emitting particles on Y axis.
  85056. */
  85057. minScaleY: number;
  85058. /**
  85059. * Maximum scale of emitting particles on Y axis.
  85060. */
  85061. maxScaleY: number;
  85062. /**
  85063. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85064. */
  85065. color1: Color4;
  85066. /**
  85067. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85068. */
  85069. color2: Color4;
  85070. /**
  85071. * Color the particle will have at the end of its lifetime.
  85072. */
  85073. colorDead: Color4;
  85074. /**
  85075. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  85076. */
  85077. emitRate: number;
  85078. /**
  85079. * You can use gravity if you want to give an orientation to your particles.
  85080. */
  85081. gravity: Vector3;
  85082. /**
  85083. * Minimum power of emitting particles.
  85084. */
  85085. minEmitPower: number;
  85086. /**
  85087. * Maximum power of emitting particles.
  85088. */
  85089. maxEmitPower: number;
  85090. /**
  85091. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85092. */
  85093. minAngularSpeed: number;
  85094. /**
  85095. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85096. */
  85097. maxAngularSpeed: number;
  85098. /**
  85099. * Gets or sets the minimal initial rotation in radians.
  85100. */
  85101. minInitialRotation: number;
  85102. /**
  85103. * Gets or sets the maximal initial rotation in radians.
  85104. */
  85105. maxInitialRotation: number;
  85106. /**
  85107. * The particle emitter type defines the emitter used by the particle system.
  85108. * It can be for example box, sphere, or cone...
  85109. */
  85110. particleEmitterType: Nullable<IParticleEmitterType>;
  85111. /**
  85112. * Defines the delay in milliseconds before starting the system (0 by default)
  85113. */
  85114. startDelay: number;
  85115. /**
  85116. * 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
  85117. */
  85118. preWarmCycles: number;
  85119. /**
  85120. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  85121. */
  85122. preWarmStepOffset: number;
  85123. /**
  85124. * 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)
  85125. */
  85126. spriteCellChangeSpeed: number;
  85127. /**
  85128. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85129. */
  85130. startSpriteCellID: number;
  85131. /**
  85132. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85133. */
  85134. endSpriteCellID: number;
  85135. /**
  85136. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85137. */
  85138. spriteCellWidth: number;
  85139. /**
  85140. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85141. */
  85142. spriteCellHeight: number;
  85143. /**
  85144. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85145. */
  85146. spriteRandomStartCell: boolean;
  85147. /**
  85148. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  85149. */
  85150. isAnimationSheetEnabled: boolean;
  85151. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85152. translationPivot: Vector2;
  85153. /**
  85154. * Gets or sets a texture used to add random noise to particle positions
  85155. */
  85156. noiseTexture: Nullable<BaseTexture>;
  85157. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85158. noiseStrength: Vector3;
  85159. /**
  85160. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85161. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85162. */
  85163. billboardMode: number;
  85164. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85165. limitVelocityDamping: number;
  85166. /**
  85167. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85168. */
  85169. beginAnimationOnStart: boolean;
  85170. /**
  85171. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85172. */
  85173. beginAnimationFrom: number;
  85174. /**
  85175. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85176. */
  85177. beginAnimationTo: number;
  85178. /**
  85179. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85180. */
  85181. beginAnimationLoop: boolean;
  85182. /**
  85183. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85184. */
  85185. disposeOnStop: boolean;
  85186. /**
  85187. * Gets the maximum number of particles active at the same time.
  85188. * @returns The max number of active particles.
  85189. */
  85190. getCapacity(): number;
  85191. /**
  85192. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85193. * @returns True if it has been started, otherwise false.
  85194. */
  85195. isStarted(): boolean;
  85196. /**
  85197. * Animates the particle system for this frame.
  85198. */
  85199. animate(): void;
  85200. /**
  85201. * Renders the particle system in its current state.
  85202. * @returns the current number of particles
  85203. */
  85204. render(): number;
  85205. /**
  85206. * Dispose the particle system and frees its associated resources.
  85207. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85208. */
  85209. dispose(disposeTexture?: boolean): void;
  85210. /**
  85211. * Clones the particle system.
  85212. * @param name The name of the cloned object
  85213. * @param newEmitter The new emitter to use
  85214. * @returns the cloned particle system
  85215. */
  85216. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  85217. /**
  85218. * Serializes the particle system to a JSON object.
  85219. * @returns the JSON object
  85220. */
  85221. serialize(): any;
  85222. /**
  85223. * Rebuild the particle system
  85224. */
  85225. rebuild(): void;
  85226. /**
  85227. * Starts the particle system and begins to emit
  85228. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  85229. */
  85230. start(delay?: number): void;
  85231. /**
  85232. * Stops the particle system.
  85233. */
  85234. stop(): void;
  85235. /**
  85236. * Remove all active particles
  85237. */
  85238. reset(): void;
  85239. /**
  85240. * Is this system ready to be used/rendered
  85241. * @return true if the system is ready
  85242. */
  85243. isReady(): boolean;
  85244. /**
  85245. * Adds a new color gradient
  85246. * @param gradient defines the gradient to use (between 0 and 1)
  85247. * @param color1 defines the color to affect to the specified gradient
  85248. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85249. * @returns the current particle system
  85250. */
  85251. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85252. /**
  85253. * Remove a specific color gradient
  85254. * @param gradient defines the gradient to remove
  85255. * @returns the current particle system
  85256. */
  85257. removeColorGradient(gradient: number): IParticleSystem;
  85258. /**
  85259. * Adds a new size gradient
  85260. * @param gradient defines the gradient to use (between 0 and 1)
  85261. * @param factor defines the size factor to affect to the specified gradient
  85262. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85263. * @returns the current particle system
  85264. */
  85265. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85266. /**
  85267. * Remove a specific size gradient
  85268. * @param gradient defines the gradient to remove
  85269. * @returns the current particle system
  85270. */
  85271. removeSizeGradient(gradient: number): IParticleSystem;
  85272. /**
  85273. * Gets the current list of color gradients.
  85274. * You must use addColorGradient and removeColorGradient to udpate this list
  85275. * @returns the list of color gradients
  85276. */
  85277. getColorGradients(): Nullable<Array<ColorGradient>>;
  85278. /**
  85279. * Gets the current list of size gradients.
  85280. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85281. * @returns the list of size gradients
  85282. */
  85283. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85284. /**
  85285. * Gets the current list of angular speed gradients.
  85286. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85287. * @returns the list of angular speed gradients
  85288. */
  85289. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85290. /**
  85291. * Adds a new angular speed gradient
  85292. * @param gradient defines the gradient to use (between 0 and 1)
  85293. * @param factor defines the angular speed to affect to the specified gradient
  85294. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85295. * @returns the current particle system
  85296. */
  85297. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85298. /**
  85299. * Remove a specific angular speed gradient
  85300. * @param gradient defines the gradient to remove
  85301. * @returns the current particle system
  85302. */
  85303. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85304. /**
  85305. * Gets the current list of velocity gradients.
  85306. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85307. * @returns the list of velocity gradients
  85308. */
  85309. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85310. /**
  85311. * Adds a new velocity gradient
  85312. * @param gradient defines the gradient to use (between 0 and 1)
  85313. * @param factor defines the velocity to affect to the specified gradient
  85314. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85315. * @returns the current particle system
  85316. */
  85317. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85318. /**
  85319. * Remove a specific velocity gradient
  85320. * @param gradient defines the gradient to remove
  85321. * @returns the current particle system
  85322. */
  85323. removeVelocityGradient(gradient: number): IParticleSystem;
  85324. /**
  85325. * Gets the current list of limit velocity gradients.
  85326. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85327. * @returns the list of limit velocity gradients
  85328. */
  85329. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85330. /**
  85331. * Adds a new limit velocity gradient
  85332. * @param gradient defines the gradient to use (between 0 and 1)
  85333. * @param factor defines the limit velocity to affect to the specified gradient
  85334. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85335. * @returns the current particle system
  85336. */
  85337. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85338. /**
  85339. * Remove a specific limit velocity gradient
  85340. * @param gradient defines the gradient to remove
  85341. * @returns the current particle system
  85342. */
  85343. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85344. /**
  85345. * Adds a new drag gradient
  85346. * @param gradient defines the gradient to use (between 0 and 1)
  85347. * @param factor defines the drag to affect to the specified gradient
  85348. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85349. * @returns the current particle system
  85350. */
  85351. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85352. /**
  85353. * Remove a specific drag gradient
  85354. * @param gradient defines the gradient to remove
  85355. * @returns the current particle system
  85356. */
  85357. removeDragGradient(gradient: number): IParticleSystem;
  85358. /**
  85359. * Gets the current list of drag gradients.
  85360. * You must use addDragGradient and removeDragGradient to udpate this list
  85361. * @returns the list of drag gradients
  85362. */
  85363. getDragGradients(): Nullable<Array<FactorGradient>>;
  85364. /**
  85365. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85366. * @param gradient defines the gradient to use (between 0 and 1)
  85367. * @param factor defines the emit rate to affect to the specified gradient
  85368. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85369. * @returns the current particle system
  85370. */
  85371. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85372. /**
  85373. * Remove a specific emit rate gradient
  85374. * @param gradient defines the gradient to remove
  85375. * @returns the current particle system
  85376. */
  85377. removeEmitRateGradient(gradient: number): IParticleSystem;
  85378. /**
  85379. * Gets the current list of emit rate gradients.
  85380. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85381. * @returns the list of emit rate gradients
  85382. */
  85383. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85384. /**
  85385. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85386. * @param gradient defines the gradient to use (between 0 and 1)
  85387. * @param factor defines the start size to affect to the specified gradient
  85388. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85389. * @returns the current particle system
  85390. */
  85391. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85392. /**
  85393. * Remove a specific start size gradient
  85394. * @param gradient defines the gradient to remove
  85395. * @returns the current particle system
  85396. */
  85397. removeStartSizeGradient(gradient: number): IParticleSystem;
  85398. /**
  85399. * Gets the current list of start size gradients.
  85400. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85401. * @returns the list of start size gradients
  85402. */
  85403. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85404. /**
  85405. * Adds a new life time gradient
  85406. * @param gradient defines the gradient to use (between 0 and 1)
  85407. * @param factor defines the life time factor to affect to the specified gradient
  85408. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85409. * @returns the current particle system
  85410. */
  85411. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85412. /**
  85413. * Remove a specific life time gradient
  85414. * @param gradient defines the gradient to remove
  85415. * @returns the current particle system
  85416. */
  85417. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85418. /**
  85419. * Gets the current list of life time gradients.
  85420. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85421. * @returns the list of life time gradients
  85422. */
  85423. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85424. /**
  85425. * Gets the current list of color gradients.
  85426. * You must use addColorGradient and removeColorGradient to udpate this list
  85427. * @returns the list of color gradients
  85428. */
  85429. getColorGradients(): Nullable<Array<ColorGradient>>;
  85430. /**
  85431. * Adds a new ramp gradient used to remap particle colors
  85432. * @param gradient defines the gradient to use (between 0 and 1)
  85433. * @param color defines the color to affect to the specified gradient
  85434. * @returns the current particle system
  85435. */
  85436. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  85437. /**
  85438. * Gets the current list of ramp gradients.
  85439. * You must use addRampGradient and removeRampGradient to udpate this list
  85440. * @returns the list of ramp gradients
  85441. */
  85442. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85443. /** Gets or sets a boolean indicating that ramp gradients must be used
  85444. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85445. */
  85446. useRampGradients: boolean;
  85447. /**
  85448. * Adds a new color remap gradient
  85449. * @param gradient defines the gradient to use (between 0 and 1)
  85450. * @param min defines the color remap minimal range
  85451. * @param max defines the color remap maximal range
  85452. * @returns the current particle system
  85453. */
  85454. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85455. /**
  85456. * Gets the current list of color remap gradients.
  85457. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85458. * @returns the list of color remap gradients
  85459. */
  85460. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85461. /**
  85462. * Adds a new alpha remap gradient
  85463. * @param gradient defines the gradient to use (between 0 and 1)
  85464. * @param min defines the alpha remap minimal range
  85465. * @param max defines the alpha remap maximal range
  85466. * @returns the current particle system
  85467. */
  85468. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85469. /**
  85470. * Gets the current list of alpha remap gradients.
  85471. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85472. * @returns the list of alpha remap gradients
  85473. */
  85474. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85475. /**
  85476. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85477. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85478. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85479. * @returns the emitter
  85480. */
  85481. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85482. /**
  85483. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85484. * @param radius The radius of the hemisphere to emit from
  85485. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85486. * @returns the emitter
  85487. */
  85488. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  85489. /**
  85490. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85491. * @param radius The radius of the sphere to emit from
  85492. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85493. * @returns the emitter
  85494. */
  85495. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  85496. /**
  85497. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85498. * @param radius The radius of the sphere to emit from
  85499. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85500. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85501. * @returns the emitter
  85502. */
  85503. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85504. /**
  85505. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85506. * @param radius The radius of the emission cylinder
  85507. * @param height The height of the emission cylinder
  85508. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85509. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85510. * @returns the emitter
  85511. */
  85512. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  85513. /**
  85514. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85515. * @param radius The radius of the cylinder to emit from
  85516. * @param height The height of the emission cylinder
  85517. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85518. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85519. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85520. * @returns the emitter
  85521. */
  85522. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85523. /**
  85524. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85525. * @param radius The radius of the cone to emit from
  85526. * @param angle The base angle of the cone
  85527. * @returns the emitter
  85528. */
  85529. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  85530. /**
  85531. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85532. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85533. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85534. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85535. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85536. * @returns the emitter
  85537. */
  85538. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85539. /**
  85540. * Get hosting scene
  85541. * @returns the scene
  85542. */
  85543. getScene(): Scene;
  85544. }
  85545. }
  85546. declare module BABYLON {
  85547. /**
  85548. * Defines the options associated with the creation of a shader material.
  85549. */
  85550. export interface IShaderMaterialOptions {
  85551. /**
  85552. * Does the material work in alpha blend mode
  85553. */
  85554. needAlphaBlending: boolean;
  85555. /**
  85556. * Does the material work in alpha test mode
  85557. */
  85558. needAlphaTesting: boolean;
  85559. /**
  85560. * The list of attribute names used in the shader
  85561. */
  85562. attributes: string[];
  85563. /**
  85564. * The list of unifrom names used in the shader
  85565. */
  85566. uniforms: string[];
  85567. /**
  85568. * The list of UBO names used in the shader
  85569. */
  85570. uniformBuffers: string[];
  85571. /**
  85572. * The list of sampler names used in the shader
  85573. */
  85574. samplers: string[];
  85575. /**
  85576. * The list of defines used in the shader
  85577. */
  85578. defines: string[];
  85579. }
  85580. /**
  85581. * 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.
  85582. *
  85583. * This returned material effects how the mesh will look based on the code in the shaders.
  85584. *
  85585. * @see http://doc.babylonjs.com/how_to/shader_material
  85586. */
  85587. export class ShaderMaterial extends Material {
  85588. private _shaderPath;
  85589. private _options;
  85590. private _textures;
  85591. private _textureArrays;
  85592. private _floats;
  85593. private _ints;
  85594. private _floatsArrays;
  85595. private _colors3;
  85596. private _colors3Arrays;
  85597. private _colors4;
  85598. private _colors4Arrays;
  85599. private _vectors2;
  85600. private _vectors3;
  85601. private _vectors4;
  85602. private _matrices;
  85603. private _matrices3x3;
  85604. private _matrices2x2;
  85605. private _vectors2Arrays;
  85606. private _vectors3Arrays;
  85607. private _vectors4Arrays;
  85608. private _cachedWorldViewMatrix;
  85609. private _cachedWorldViewProjectionMatrix;
  85610. private _renderId;
  85611. /**
  85612. * Instantiate a new shader material.
  85613. * 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.
  85614. * This returned material effects how the mesh will look based on the code in the shaders.
  85615. * @see http://doc.babylonjs.com/how_to/shader_material
  85616. * @param name Define the name of the material in the scene
  85617. * @param scene Define the scene the material belongs to
  85618. * @param shaderPath Defines the route to the shader code in one of three ways:
  85619. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  85620. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  85621. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  85622. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  85623. * @param options Define the options used to create the shader
  85624. */
  85625. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  85626. /**
  85627. * Gets the options used to compile the shader.
  85628. * They can be modified to trigger a new compilation
  85629. */
  85630. readonly options: IShaderMaterialOptions;
  85631. /**
  85632. * Gets the current class name of the material e.g. "ShaderMaterial"
  85633. * Mainly use in serialization.
  85634. * @returns the class name
  85635. */
  85636. getClassName(): string;
  85637. /**
  85638. * Specifies if the material will require alpha blending
  85639. * @returns a boolean specifying if alpha blending is needed
  85640. */
  85641. needAlphaBlending(): boolean;
  85642. /**
  85643. * Specifies if this material should be rendered in alpha test mode
  85644. * @returns a boolean specifying if an alpha test is needed.
  85645. */
  85646. needAlphaTesting(): boolean;
  85647. private _checkUniform;
  85648. /**
  85649. * Set a texture in the shader.
  85650. * @param name Define the name of the uniform samplers as defined in the shader
  85651. * @param texture Define the texture to bind to this sampler
  85652. * @return the material itself allowing "fluent" like uniform updates
  85653. */
  85654. setTexture(name: string, texture: Texture): ShaderMaterial;
  85655. /**
  85656. * Set a texture array in the shader.
  85657. * @param name Define the name of the uniform sampler array as defined in the shader
  85658. * @param textures Define the list of textures to bind to this sampler
  85659. * @return the material itself allowing "fluent" like uniform updates
  85660. */
  85661. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  85662. /**
  85663. * Set a float in the shader.
  85664. * @param name Define the name of the uniform as defined in the shader
  85665. * @param value Define the value to give to the uniform
  85666. * @return the material itself allowing "fluent" like uniform updates
  85667. */
  85668. setFloat(name: string, value: number): ShaderMaterial;
  85669. /**
  85670. * Set a int in the shader.
  85671. * @param name Define the name of the uniform as defined in the shader
  85672. * @param value Define the value to give to the uniform
  85673. * @return the material itself allowing "fluent" like uniform updates
  85674. */
  85675. setInt(name: string, value: number): ShaderMaterial;
  85676. /**
  85677. * Set an array of floats in the shader.
  85678. * @param name Define the name of the uniform as defined in the shader
  85679. * @param value Define the value to give to the uniform
  85680. * @return the material itself allowing "fluent" like uniform updates
  85681. */
  85682. setFloats(name: string, value: number[]): ShaderMaterial;
  85683. /**
  85684. * Set a vec3 in the shader from a Color3.
  85685. * @param name Define the name of the uniform as defined in the shader
  85686. * @param value Define the value to give to the uniform
  85687. * @return the material itself allowing "fluent" like uniform updates
  85688. */
  85689. setColor3(name: string, value: Color3): ShaderMaterial;
  85690. /**
  85691. * Set a vec3 array in the shader from a Color3 array.
  85692. * @param name Define the name of the uniform as defined in the shader
  85693. * @param value Define the value to give to the uniform
  85694. * @return the material itself allowing "fluent" like uniform updates
  85695. */
  85696. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  85697. /**
  85698. * Set a vec4 in the shader from a Color4.
  85699. * @param name Define the name of the uniform as defined in the shader
  85700. * @param value Define the value to give to the uniform
  85701. * @return the material itself allowing "fluent" like uniform updates
  85702. */
  85703. setColor4(name: string, value: Color4): ShaderMaterial;
  85704. /**
  85705. * Set a vec4 array in the shader from a Color4 array.
  85706. * @param name Define the name of the uniform as defined in the shader
  85707. * @param value Define the value to give to the uniform
  85708. * @return the material itself allowing "fluent" like uniform updates
  85709. */
  85710. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  85711. /**
  85712. * Set a vec2 in the shader from a Vector2.
  85713. * @param name Define the name of the uniform as defined in the shader
  85714. * @param value Define the value to give to the uniform
  85715. * @return the material itself allowing "fluent" like uniform updates
  85716. */
  85717. setVector2(name: string, value: Vector2): ShaderMaterial;
  85718. /**
  85719. * Set a vec3 in the shader from a Vector3.
  85720. * @param name Define the name of the uniform as defined in the shader
  85721. * @param value Define the value to give to the uniform
  85722. * @return the material itself allowing "fluent" like uniform updates
  85723. */
  85724. setVector3(name: string, value: Vector3): ShaderMaterial;
  85725. /**
  85726. * Set a vec4 in the shader from a Vector4.
  85727. * @param name Define the name of the uniform as defined in the shader
  85728. * @param value Define the value to give to the uniform
  85729. * @return the material itself allowing "fluent" like uniform updates
  85730. */
  85731. setVector4(name: string, value: Vector4): ShaderMaterial;
  85732. /**
  85733. * Set a mat4 in the shader from a Matrix.
  85734. * @param name Define the name of the uniform as defined in the shader
  85735. * @param value Define the value to give to the uniform
  85736. * @return the material itself allowing "fluent" like uniform updates
  85737. */
  85738. setMatrix(name: string, value: Matrix): ShaderMaterial;
  85739. /**
  85740. * Set a mat3 in the shader from a Float32Array.
  85741. * @param name Define the name of the uniform as defined in the shader
  85742. * @param value Define the value to give to the uniform
  85743. * @return the material itself allowing "fluent" like uniform updates
  85744. */
  85745. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  85746. /**
  85747. * Set a mat2 in the shader from a Float32Array.
  85748. * @param name Define the name of the uniform as defined in the shader
  85749. * @param value Define the value to give to the uniform
  85750. * @return the material itself allowing "fluent" like uniform updates
  85751. */
  85752. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  85753. /**
  85754. * Set a vec2 array in the shader from a number array.
  85755. * @param name Define the name of the uniform as defined in the shader
  85756. * @param value Define the value to give to the uniform
  85757. * @return the material itself allowing "fluent" like uniform updates
  85758. */
  85759. setArray2(name: string, value: number[]): ShaderMaterial;
  85760. /**
  85761. * Set a vec3 array in the shader from a number array.
  85762. * @param name Define the name of the uniform as defined in the shader
  85763. * @param value Define the value to give to the uniform
  85764. * @return the material itself allowing "fluent" like uniform updates
  85765. */
  85766. setArray3(name: string, value: number[]): ShaderMaterial;
  85767. /**
  85768. * Set a vec4 array in the shader from a number array.
  85769. * @param name Define the name of the uniform as defined in the shader
  85770. * @param value Define the value to give to the uniform
  85771. * @return the material itself allowing "fluent" like uniform updates
  85772. */
  85773. setArray4(name: string, value: number[]): ShaderMaterial;
  85774. private _checkCache;
  85775. /**
  85776. * Specifies that the submesh is ready to be used
  85777. * @param mesh defines the mesh to check
  85778. * @param subMesh defines which submesh to check
  85779. * @param useInstances specifies that instances should be used
  85780. * @returns a boolean indicating that the submesh is ready or not
  85781. */
  85782. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85783. /**
  85784. * Checks if the material is ready to render the requested mesh
  85785. * @param mesh Define the mesh to render
  85786. * @param useInstances Define whether or not the material is used with instances
  85787. * @returns true if ready, otherwise false
  85788. */
  85789. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85790. /**
  85791. * Binds the world matrix to the material
  85792. * @param world defines the world transformation matrix
  85793. */
  85794. bindOnlyWorldMatrix(world: Matrix): void;
  85795. /**
  85796. * Binds the material to the mesh
  85797. * @param world defines the world transformation matrix
  85798. * @param mesh defines the mesh to bind the material to
  85799. */
  85800. bind(world: Matrix, mesh?: Mesh): void;
  85801. /**
  85802. * Gets the active textures from the material
  85803. * @returns an array of textures
  85804. */
  85805. getActiveTextures(): BaseTexture[];
  85806. /**
  85807. * Specifies if the material uses a texture
  85808. * @param texture defines the texture to check against the material
  85809. * @returns a boolean specifying if the material uses the texture
  85810. */
  85811. hasTexture(texture: BaseTexture): boolean;
  85812. /**
  85813. * Makes a duplicate of the material, and gives it a new name
  85814. * @param name defines the new name for the duplicated material
  85815. * @returns the cloned material
  85816. */
  85817. clone(name: string): ShaderMaterial;
  85818. /**
  85819. * Disposes the material
  85820. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85821. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85822. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85823. */
  85824. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85825. /**
  85826. * Serializes this material in a JSON representation
  85827. * @returns the serialized material object
  85828. */
  85829. serialize(): any;
  85830. /**
  85831. * Creates a shader material from parsed shader material data
  85832. * @param source defines the JSON represnetation of the material
  85833. * @param scene defines the hosting scene
  85834. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  85835. * @returns a new material
  85836. */
  85837. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  85838. }
  85839. }
  85840. declare module BABYLON {
  85841. /** @hidden */
  85842. export var colorPixelShader: {
  85843. name: string;
  85844. shader: string;
  85845. };
  85846. }
  85847. declare module BABYLON {
  85848. /** @hidden */
  85849. export var colorVertexShader: {
  85850. name: string;
  85851. shader: string;
  85852. };
  85853. }
  85854. declare module BABYLON {
  85855. /**
  85856. * Line mesh
  85857. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  85858. */
  85859. export class LinesMesh extends Mesh {
  85860. /**
  85861. * If vertex color should be applied to the mesh
  85862. */
  85863. readonly useVertexColor?: boolean | undefined;
  85864. /**
  85865. * If vertex alpha should be applied to the mesh
  85866. */
  85867. readonly useVertexAlpha?: boolean | undefined;
  85868. /**
  85869. * Color of the line (Default: White)
  85870. */
  85871. color: Color3;
  85872. /**
  85873. * Alpha of the line (Default: 1)
  85874. */
  85875. alpha: number;
  85876. /**
  85877. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  85878. * This margin is expressed in world space coordinates, so its value may vary.
  85879. * Default value is 0.1
  85880. */
  85881. intersectionThreshold: number;
  85882. private _colorShader;
  85883. private color4;
  85884. /**
  85885. * Creates a new LinesMesh
  85886. * @param name defines the name
  85887. * @param scene defines the hosting scene
  85888. * @param parent defines the parent mesh if any
  85889. * @param source defines the optional source LinesMesh used to clone data from
  85890. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  85891. * When false, achieved by calling a clone(), also passing False.
  85892. * This will make creation of children, recursive.
  85893. * @param useVertexColor defines if this LinesMesh supports vertex color
  85894. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  85895. */
  85896. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  85897. /**
  85898. * If vertex color should be applied to the mesh
  85899. */
  85900. useVertexColor?: boolean | undefined,
  85901. /**
  85902. * If vertex alpha should be applied to the mesh
  85903. */
  85904. useVertexAlpha?: boolean | undefined);
  85905. private _addClipPlaneDefine;
  85906. private _removeClipPlaneDefine;
  85907. isReady(): boolean;
  85908. /**
  85909. * Returns the string "LineMesh"
  85910. */
  85911. getClassName(): string;
  85912. /**
  85913. * @hidden
  85914. */
  85915. /**
  85916. * @hidden
  85917. */
  85918. material: Material;
  85919. /**
  85920. * @hidden
  85921. */
  85922. readonly checkCollisions: boolean;
  85923. /** @hidden */
  85924. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  85925. /** @hidden */
  85926. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  85927. /**
  85928. * Disposes of the line mesh
  85929. * @param doNotRecurse If children should be disposed
  85930. */
  85931. dispose(doNotRecurse?: boolean): void;
  85932. /**
  85933. * Returns a new LineMesh object cloned from the current one.
  85934. */
  85935. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85936. /**
  85937. * Creates a new InstancedLinesMesh object from the mesh model.
  85938. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85939. * @param name defines the name of the new instance
  85940. * @returns a new InstancedLinesMesh
  85941. */
  85942. createInstance(name: string): InstancedLinesMesh;
  85943. }
  85944. /**
  85945. * Creates an instance based on a source LinesMesh
  85946. */
  85947. export class InstancedLinesMesh extends InstancedMesh {
  85948. /**
  85949. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  85950. * This margin is expressed in world space coordinates, so its value may vary.
  85951. * Initilized with the intersectionThreshold value of the source LinesMesh
  85952. */
  85953. intersectionThreshold: number;
  85954. constructor(name: string, source: LinesMesh);
  85955. /**
  85956. * Returns the string "InstancedLinesMesh".
  85957. */
  85958. getClassName(): string;
  85959. }
  85960. }
  85961. declare module BABYLON {
  85962. /** @hidden */
  85963. export var linePixelShader: {
  85964. name: string;
  85965. shader: string;
  85966. };
  85967. }
  85968. declare module BABYLON {
  85969. /** @hidden */
  85970. export var lineVertexShader: {
  85971. name: string;
  85972. shader: string;
  85973. };
  85974. }
  85975. declare module BABYLON {
  85976. interface AbstractMesh {
  85977. /**
  85978. * Gets the edgesRenderer associated with the mesh
  85979. */
  85980. edgesRenderer: Nullable<EdgesRenderer>;
  85981. }
  85982. interface LinesMesh {
  85983. /**
  85984. * Enables the edge rendering mode on the mesh.
  85985. * This mode makes the mesh edges visible
  85986. * @param epsilon defines the maximal distance between two angles to detect a face
  85987. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85988. * @returns the currentAbstractMesh
  85989. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85990. */
  85991. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  85992. }
  85993. interface InstancedLinesMesh {
  85994. /**
  85995. * Enables the edge rendering mode on the mesh.
  85996. * This mode makes the mesh edges visible
  85997. * @param epsilon defines the maximal distance between two angles to detect a face
  85998. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85999. * @returns the current InstancedLinesMesh
  86000. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86001. */
  86002. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  86003. }
  86004. /**
  86005. * Defines the minimum contract an Edges renderer should follow.
  86006. */
  86007. export interface IEdgesRenderer extends IDisposable {
  86008. /**
  86009. * Gets or sets a boolean indicating if the edgesRenderer is active
  86010. */
  86011. isEnabled: boolean;
  86012. /**
  86013. * Renders the edges of the attached mesh,
  86014. */
  86015. render(): void;
  86016. /**
  86017. * Checks wether or not the edges renderer is ready to render.
  86018. * @return true if ready, otherwise false.
  86019. */
  86020. isReady(): boolean;
  86021. }
  86022. /**
  86023. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  86024. */
  86025. export class EdgesRenderer implements IEdgesRenderer {
  86026. /**
  86027. * Define the size of the edges with an orthographic camera
  86028. */
  86029. edgesWidthScalerForOrthographic: number;
  86030. /**
  86031. * Define the size of the edges with a perspective camera
  86032. */
  86033. edgesWidthScalerForPerspective: number;
  86034. protected _source: AbstractMesh;
  86035. protected _linesPositions: number[];
  86036. protected _linesNormals: number[];
  86037. protected _linesIndices: number[];
  86038. protected _epsilon: number;
  86039. protected _indicesCount: number;
  86040. protected _lineShader: ShaderMaterial;
  86041. protected _ib: DataBuffer;
  86042. protected _buffers: {
  86043. [key: string]: Nullable<VertexBuffer>;
  86044. };
  86045. protected _checkVerticesInsteadOfIndices: boolean;
  86046. private _meshRebuildObserver;
  86047. private _meshDisposeObserver;
  86048. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  86049. isEnabled: boolean;
  86050. /**
  86051. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  86052. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  86053. * @param source Mesh used to create edges
  86054. * @param epsilon sum of angles in adjacency to check for edge
  86055. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  86056. * @param generateEdgesLines - should generate Lines or only prepare resources.
  86057. */
  86058. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  86059. protected _prepareRessources(): void;
  86060. /** @hidden */
  86061. _rebuild(): void;
  86062. /**
  86063. * Releases the required resources for the edges renderer
  86064. */
  86065. dispose(): void;
  86066. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  86067. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  86068. /**
  86069. * Checks if the pair of p0 and p1 is en edge
  86070. * @param faceIndex
  86071. * @param edge
  86072. * @param faceNormals
  86073. * @param p0
  86074. * @param p1
  86075. * @private
  86076. */
  86077. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  86078. /**
  86079. * push line into the position, normal and index buffer
  86080. * @protected
  86081. */
  86082. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  86083. /**
  86084. * Generates lines edges from adjacencjes
  86085. * @private
  86086. */
  86087. _generateEdgesLines(): void;
  86088. /**
  86089. * Checks wether or not the edges renderer is ready to render.
  86090. * @return true if ready, otherwise false.
  86091. */
  86092. isReady(): boolean;
  86093. /**
  86094. * Renders the edges of the attached mesh,
  86095. */
  86096. render(): void;
  86097. }
  86098. /**
  86099. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  86100. */
  86101. export class LineEdgesRenderer extends EdgesRenderer {
  86102. /**
  86103. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  86104. * @param source LineMesh used to generate edges
  86105. * @param epsilon not important (specified angle for edge detection)
  86106. * @param checkVerticesInsteadOfIndices not important for LineMesh
  86107. */
  86108. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  86109. /**
  86110. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  86111. */
  86112. _generateEdgesLines(): void;
  86113. }
  86114. }
  86115. declare module BABYLON {
  86116. /**
  86117. * This represents the object necessary to create a rendering group.
  86118. * This is exclusively used and created by the rendering manager.
  86119. * To modify the behavior, you use the available helpers in your scene or meshes.
  86120. * @hidden
  86121. */
  86122. export class RenderingGroup {
  86123. index: number;
  86124. private static _zeroVector;
  86125. private _scene;
  86126. private _opaqueSubMeshes;
  86127. private _transparentSubMeshes;
  86128. private _alphaTestSubMeshes;
  86129. private _depthOnlySubMeshes;
  86130. private _particleSystems;
  86131. private _spriteManagers;
  86132. private _opaqueSortCompareFn;
  86133. private _alphaTestSortCompareFn;
  86134. private _transparentSortCompareFn;
  86135. private _renderOpaque;
  86136. private _renderAlphaTest;
  86137. private _renderTransparent;
  86138. /** @hidden */
  86139. _edgesRenderers: SmartArray<IEdgesRenderer>;
  86140. onBeforeTransparentRendering: () => void;
  86141. /**
  86142. * Set the opaque sort comparison function.
  86143. * If null the sub meshes will be render in the order they were created
  86144. */
  86145. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86146. /**
  86147. * Set the alpha test sort comparison function.
  86148. * If null the sub meshes will be render in the order they were created
  86149. */
  86150. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86151. /**
  86152. * Set the transparent sort comparison function.
  86153. * If null the sub meshes will be render in the order they were created
  86154. */
  86155. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86156. /**
  86157. * Creates a new rendering group.
  86158. * @param index The rendering group index
  86159. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  86160. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  86161. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  86162. */
  86163. 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>);
  86164. /**
  86165. * Render all the sub meshes contained in the group.
  86166. * @param customRenderFunction Used to override the default render behaviour of the group.
  86167. * @returns true if rendered some submeshes.
  86168. */
  86169. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  86170. /**
  86171. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  86172. * @param subMeshes The submeshes to render
  86173. */
  86174. private renderOpaqueSorted;
  86175. /**
  86176. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  86177. * @param subMeshes The submeshes to render
  86178. */
  86179. private renderAlphaTestSorted;
  86180. /**
  86181. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  86182. * @param subMeshes The submeshes to render
  86183. */
  86184. private renderTransparentSorted;
  86185. /**
  86186. * Renders the submeshes in a specified order.
  86187. * @param subMeshes The submeshes to sort before render
  86188. * @param sortCompareFn The comparison function use to sort
  86189. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  86190. * @param transparent Specifies to activate blending if true
  86191. */
  86192. private static renderSorted;
  86193. /**
  86194. * Renders the submeshes in the order they were dispatched (no sort applied).
  86195. * @param subMeshes The submeshes to render
  86196. */
  86197. private static renderUnsorted;
  86198. /**
  86199. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86200. * are rendered back to front if in the same alpha index.
  86201. *
  86202. * @param a The first submesh
  86203. * @param b The second submesh
  86204. * @returns The result of the comparison
  86205. */
  86206. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  86207. /**
  86208. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86209. * are rendered back to front.
  86210. *
  86211. * @param a The first submesh
  86212. * @param b The second submesh
  86213. * @returns The result of the comparison
  86214. */
  86215. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  86216. /**
  86217. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86218. * are rendered front to back (prevent overdraw).
  86219. *
  86220. * @param a The first submesh
  86221. * @param b The second submesh
  86222. * @returns The result of the comparison
  86223. */
  86224. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  86225. /**
  86226. * Resets the different lists of submeshes to prepare a new frame.
  86227. */
  86228. prepare(): void;
  86229. dispose(): void;
  86230. /**
  86231. * Inserts the submesh in its correct queue depending on its material.
  86232. * @param subMesh The submesh to dispatch
  86233. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86234. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86235. */
  86236. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86237. dispatchSprites(spriteManager: ISpriteManager): void;
  86238. dispatchParticles(particleSystem: IParticleSystem): void;
  86239. private _renderParticles;
  86240. private _renderSprites;
  86241. }
  86242. }
  86243. declare module BABYLON {
  86244. /**
  86245. * Interface describing the different options available in the rendering manager
  86246. * regarding Auto Clear between groups.
  86247. */
  86248. export interface IRenderingManagerAutoClearSetup {
  86249. /**
  86250. * Defines whether or not autoclear is enable.
  86251. */
  86252. autoClear: boolean;
  86253. /**
  86254. * Defines whether or not to autoclear the depth buffer.
  86255. */
  86256. depth: boolean;
  86257. /**
  86258. * Defines whether or not to autoclear the stencil buffer.
  86259. */
  86260. stencil: boolean;
  86261. }
  86262. /**
  86263. * This class is used by the onRenderingGroupObservable
  86264. */
  86265. export class RenderingGroupInfo {
  86266. /**
  86267. * The Scene that being rendered
  86268. */
  86269. scene: Scene;
  86270. /**
  86271. * The camera currently used for the rendering pass
  86272. */
  86273. camera: Nullable<Camera>;
  86274. /**
  86275. * The ID of the renderingGroup being processed
  86276. */
  86277. renderingGroupId: number;
  86278. }
  86279. /**
  86280. * This is the manager responsible of all the rendering for meshes sprites and particles.
  86281. * It is enable to manage the different groups as well as the different necessary sort functions.
  86282. * This should not be used directly aside of the few static configurations
  86283. */
  86284. export class RenderingManager {
  86285. /**
  86286. * The max id used for rendering groups (not included)
  86287. */
  86288. static MAX_RENDERINGGROUPS: number;
  86289. /**
  86290. * The min id used for rendering groups (included)
  86291. */
  86292. static MIN_RENDERINGGROUPS: number;
  86293. /**
  86294. * Used to globally prevent autoclearing scenes.
  86295. */
  86296. static AUTOCLEAR: boolean;
  86297. /**
  86298. * @hidden
  86299. */
  86300. _useSceneAutoClearSetup: boolean;
  86301. private _scene;
  86302. private _renderingGroups;
  86303. private _depthStencilBufferAlreadyCleaned;
  86304. private _autoClearDepthStencil;
  86305. private _customOpaqueSortCompareFn;
  86306. private _customAlphaTestSortCompareFn;
  86307. private _customTransparentSortCompareFn;
  86308. private _renderingGroupInfo;
  86309. /**
  86310. * Instantiates a new rendering group for a particular scene
  86311. * @param scene Defines the scene the groups belongs to
  86312. */
  86313. constructor(scene: Scene);
  86314. private _clearDepthStencilBuffer;
  86315. /**
  86316. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  86317. * @hidden
  86318. */
  86319. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  86320. /**
  86321. * Resets the different information of the group to prepare a new frame
  86322. * @hidden
  86323. */
  86324. reset(): void;
  86325. /**
  86326. * Dispose and release the group and its associated resources.
  86327. * @hidden
  86328. */
  86329. dispose(): void;
  86330. /**
  86331. * Clear the info related to rendering groups preventing retention points during dispose.
  86332. */
  86333. freeRenderingGroups(): void;
  86334. private _prepareRenderingGroup;
  86335. /**
  86336. * Add a sprite manager to the rendering manager in order to render it this frame.
  86337. * @param spriteManager Define the sprite manager to render
  86338. */
  86339. dispatchSprites(spriteManager: ISpriteManager): void;
  86340. /**
  86341. * Add a particle system to the rendering manager in order to render it this frame.
  86342. * @param particleSystem Define the particle system to render
  86343. */
  86344. dispatchParticles(particleSystem: IParticleSystem): void;
  86345. /**
  86346. * Add a submesh to the manager in order to render it this frame
  86347. * @param subMesh The submesh to dispatch
  86348. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86349. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86350. */
  86351. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86352. /**
  86353. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86354. * This allowed control for front to back rendering or reversly depending of the special needs.
  86355. *
  86356. * @param renderingGroupId The rendering group id corresponding to its index
  86357. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86358. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86359. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86360. */
  86361. 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;
  86362. /**
  86363. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86364. *
  86365. * @param renderingGroupId The rendering group id corresponding to its index
  86366. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86367. * @param depth Automatically clears depth between groups if true and autoClear is true.
  86368. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  86369. */
  86370. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  86371. /**
  86372. * Gets the current auto clear configuration for one rendering group of the rendering
  86373. * manager.
  86374. * @param index the rendering group index to get the information for
  86375. * @returns The auto clear setup for the requested rendering group
  86376. */
  86377. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  86378. }
  86379. }
  86380. declare module BABYLON {
  86381. /**
  86382. * This Helps creating a texture that will be created from a camera in your scene.
  86383. * It is basically a dynamic texture that could be used to create special effects for instance.
  86384. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  86385. */
  86386. export class RenderTargetTexture extends Texture {
  86387. isCube: boolean;
  86388. /**
  86389. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  86390. */
  86391. static readonly REFRESHRATE_RENDER_ONCE: number;
  86392. /**
  86393. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  86394. */
  86395. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  86396. /**
  86397. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  86398. * the central point of your effect and can save a lot of performances.
  86399. */
  86400. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  86401. /**
  86402. * Use this predicate to dynamically define the list of mesh you want to render.
  86403. * If set, the renderList property will be overwritten.
  86404. */
  86405. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  86406. private _renderList;
  86407. /**
  86408. * Use this list to define the list of mesh you want to render.
  86409. */
  86410. renderList: Nullable<Array<AbstractMesh>>;
  86411. private _hookArray;
  86412. /**
  86413. * Define if particles should be rendered in your texture.
  86414. */
  86415. renderParticles: boolean;
  86416. /**
  86417. * Define if sprites should be rendered in your texture.
  86418. */
  86419. renderSprites: boolean;
  86420. /**
  86421. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  86422. */
  86423. coordinatesMode: number;
  86424. /**
  86425. * Define the camera used to render the texture.
  86426. */
  86427. activeCamera: Nullable<Camera>;
  86428. /**
  86429. * Override the render function of the texture with your own one.
  86430. */
  86431. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  86432. /**
  86433. * Define if camera post processes should be use while rendering the texture.
  86434. */
  86435. useCameraPostProcesses: boolean;
  86436. /**
  86437. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  86438. */
  86439. ignoreCameraViewport: boolean;
  86440. private _postProcessManager;
  86441. private _postProcesses;
  86442. private _resizeObserver;
  86443. /**
  86444. * An event triggered when the texture is unbind.
  86445. */
  86446. onBeforeBindObservable: Observable<RenderTargetTexture>;
  86447. /**
  86448. * An event triggered when the texture is unbind.
  86449. */
  86450. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  86451. private _onAfterUnbindObserver;
  86452. /**
  86453. * Set a after unbind callback in the texture.
  86454. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  86455. */
  86456. onAfterUnbind: () => void;
  86457. /**
  86458. * An event triggered before rendering the texture
  86459. */
  86460. onBeforeRenderObservable: Observable<number>;
  86461. private _onBeforeRenderObserver;
  86462. /**
  86463. * Set a before render callback in the texture.
  86464. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  86465. */
  86466. onBeforeRender: (faceIndex: number) => void;
  86467. /**
  86468. * An event triggered after rendering the texture
  86469. */
  86470. onAfterRenderObservable: Observable<number>;
  86471. private _onAfterRenderObserver;
  86472. /**
  86473. * Set a after render callback in the texture.
  86474. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  86475. */
  86476. onAfterRender: (faceIndex: number) => void;
  86477. /**
  86478. * An event triggered after the texture clear
  86479. */
  86480. onClearObservable: Observable<Engine>;
  86481. private _onClearObserver;
  86482. /**
  86483. * Set a clear callback in the texture.
  86484. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  86485. */
  86486. onClear: (Engine: Engine) => void;
  86487. /**
  86488. * An event triggered when the texture is resized.
  86489. */
  86490. onResizeObservable: Observable<RenderTargetTexture>;
  86491. /**
  86492. * Define the clear color of the Render Target if it should be different from the scene.
  86493. */
  86494. clearColor: Color4;
  86495. protected _size: number | {
  86496. width: number;
  86497. height: number;
  86498. };
  86499. protected _initialSizeParameter: number | {
  86500. width: number;
  86501. height: number;
  86502. } | {
  86503. ratio: number;
  86504. };
  86505. protected _sizeRatio: Nullable<number>;
  86506. /** @hidden */
  86507. _generateMipMaps: boolean;
  86508. protected _renderingManager: RenderingManager;
  86509. /** @hidden */
  86510. _waitingRenderList: string[];
  86511. protected _doNotChangeAspectRatio: boolean;
  86512. protected _currentRefreshId: number;
  86513. protected _refreshRate: number;
  86514. protected _textureMatrix: Matrix;
  86515. protected _samples: number;
  86516. protected _renderTargetOptions: RenderTargetCreationOptions;
  86517. /**
  86518. * Gets render target creation options that were used.
  86519. */
  86520. readonly renderTargetOptions: RenderTargetCreationOptions;
  86521. protected _engine: Engine;
  86522. protected _onRatioRescale(): void;
  86523. /**
  86524. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  86525. * It must define where the camera used to render the texture is set
  86526. */
  86527. boundingBoxPosition: Vector3;
  86528. private _boundingBoxSize;
  86529. /**
  86530. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  86531. * When defined, the cubemap will switch to local mode
  86532. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86533. * @example https://www.babylonjs-playground.com/#RNASML
  86534. */
  86535. boundingBoxSize: Vector3;
  86536. /**
  86537. * In case the RTT has been created with a depth texture, get the associated
  86538. * depth texture.
  86539. * Otherwise, return null.
  86540. */
  86541. depthStencilTexture: Nullable<InternalTexture>;
  86542. /**
  86543. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  86544. * or used a shadow, depth texture...
  86545. * @param name The friendly name of the texture
  86546. * @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)
  86547. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  86548. * @param generateMipMaps True if mip maps need to be generated after render.
  86549. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  86550. * @param type The type of the buffer in the RTT (int, half float, float...)
  86551. * @param isCube True if a cube texture needs to be created
  86552. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  86553. * @param generateDepthBuffer True to generate a depth buffer
  86554. * @param generateStencilBuffer True to generate a stencil buffer
  86555. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  86556. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  86557. * @param delayAllocation if the texture allocation should be delayed (default: false)
  86558. */
  86559. constructor(name: string, size: number | {
  86560. width: number;
  86561. height: number;
  86562. } | {
  86563. ratio: number;
  86564. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  86565. /**
  86566. * Creates a depth stencil texture.
  86567. * This is only available in WebGL 2 or with the depth texture extension available.
  86568. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  86569. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  86570. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  86571. */
  86572. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  86573. private _processSizeParameter;
  86574. /**
  86575. * Define the number of samples to use in case of MSAA.
  86576. * It defaults to one meaning no MSAA has been enabled.
  86577. */
  86578. samples: number;
  86579. /**
  86580. * Resets the refresh counter of the texture and start bak from scratch.
  86581. * Could be useful to regenerate the texture if it is setup to render only once.
  86582. */
  86583. resetRefreshCounter(): void;
  86584. /**
  86585. * Define the refresh rate of the texture or the rendering frequency.
  86586. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86587. */
  86588. refreshRate: number;
  86589. /**
  86590. * Adds a post process to the render target rendering passes.
  86591. * @param postProcess define the post process to add
  86592. */
  86593. addPostProcess(postProcess: PostProcess): void;
  86594. /**
  86595. * Clear all the post processes attached to the render target
  86596. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  86597. */
  86598. clearPostProcesses(dispose?: boolean): void;
  86599. /**
  86600. * Remove one of the post process from the list of attached post processes to the texture
  86601. * @param postProcess define the post process to remove from the list
  86602. */
  86603. removePostProcess(postProcess: PostProcess): void;
  86604. /** @hidden */
  86605. _shouldRender(): boolean;
  86606. /**
  86607. * Gets the actual render size of the texture.
  86608. * @returns the width of the render size
  86609. */
  86610. getRenderSize(): number;
  86611. /**
  86612. * Gets the actual render width of the texture.
  86613. * @returns the width of the render size
  86614. */
  86615. getRenderWidth(): number;
  86616. /**
  86617. * Gets the actual render height of the texture.
  86618. * @returns the height of the render size
  86619. */
  86620. getRenderHeight(): number;
  86621. /**
  86622. * Get if the texture can be rescaled or not.
  86623. */
  86624. readonly canRescale: boolean;
  86625. /**
  86626. * Resize the texture using a ratio.
  86627. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  86628. */
  86629. scale(ratio: number): void;
  86630. /**
  86631. * Get the texture reflection matrix used to rotate/transform the reflection.
  86632. * @returns the reflection matrix
  86633. */
  86634. getReflectionTextureMatrix(): Matrix;
  86635. /**
  86636. * Resize the texture to a new desired size.
  86637. * Be carrefull as it will recreate all the data in the new texture.
  86638. * @param size Define the new size. It can be:
  86639. * - a number for squared texture,
  86640. * - an object containing { width: number, height: number }
  86641. * - or an object containing a ratio { ratio: number }
  86642. */
  86643. resize(size: number | {
  86644. width: number;
  86645. height: number;
  86646. } | {
  86647. ratio: number;
  86648. }): void;
  86649. /**
  86650. * Renders all the objects from the render list into the texture.
  86651. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  86652. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  86653. */
  86654. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  86655. private _bestReflectionRenderTargetDimension;
  86656. /**
  86657. * @hidden
  86658. * @param faceIndex face index to bind to if this is a cubetexture
  86659. */
  86660. _bindFrameBuffer(faceIndex?: number): void;
  86661. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  86662. private renderToTarget;
  86663. /**
  86664. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86665. * This allowed control for front to back rendering or reversly depending of the special needs.
  86666. *
  86667. * @param renderingGroupId The rendering group id corresponding to its index
  86668. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86669. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86670. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86671. */
  86672. 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;
  86673. /**
  86674. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86675. *
  86676. * @param renderingGroupId The rendering group id corresponding to its index
  86677. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86678. */
  86679. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  86680. /**
  86681. * Clones the texture.
  86682. * @returns the cloned texture
  86683. */
  86684. clone(): RenderTargetTexture;
  86685. /**
  86686. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86687. * @returns The JSON representation of the texture
  86688. */
  86689. serialize(): any;
  86690. /**
  86691. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  86692. */
  86693. disposeFramebufferObjects(): void;
  86694. /**
  86695. * Dispose the texture and release its associated resources.
  86696. */
  86697. dispose(): void;
  86698. /** @hidden */
  86699. _rebuild(): void;
  86700. /**
  86701. * Clear the info related to rendering groups preventing retention point in material dispose.
  86702. */
  86703. freeRenderingGroups(): void;
  86704. /**
  86705. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  86706. * @returns the view count
  86707. */
  86708. getViewCount(): number;
  86709. }
  86710. }
  86711. declare module BABYLON {
  86712. /**
  86713. * Base class for the main features of a material in Babylon.js
  86714. */
  86715. export class Material implements IAnimatable {
  86716. /**
  86717. * Returns the triangle fill mode
  86718. */
  86719. static readonly TriangleFillMode: number;
  86720. /**
  86721. * Returns the wireframe mode
  86722. */
  86723. static readonly WireFrameFillMode: number;
  86724. /**
  86725. * Returns the point fill mode
  86726. */
  86727. static readonly PointFillMode: number;
  86728. /**
  86729. * Returns the point list draw mode
  86730. */
  86731. static readonly PointListDrawMode: number;
  86732. /**
  86733. * Returns the line list draw mode
  86734. */
  86735. static readonly LineListDrawMode: number;
  86736. /**
  86737. * Returns the line loop draw mode
  86738. */
  86739. static readonly LineLoopDrawMode: number;
  86740. /**
  86741. * Returns the line strip draw mode
  86742. */
  86743. static readonly LineStripDrawMode: number;
  86744. /**
  86745. * Returns the triangle strip draw mode
  86746. */
  86747. static readonly TriangleStripDrawMode: number;
  86748. /**
  86749. * Returns the triangle fan draw mode
  86750. */
  86751. static readonly TriangleFanDrawMode: number;
  86752. /**
  86753. * Stores the clock-wise side orientation
  86754. */
  86755. static readonly ClockWiseSideOrientation: number;
  86756. /**
  86757. * Stores the counter clock-wise side orientation
  86758. */
  86759. static readonly CounterClockWiseSideOrientation: number;
  86760. /**
  86761. * The dirty texture flag value
  86762. */
  86763. static readonly TextureDirtyFlag: number;
  86764. /**
  86765. * The dirty light flag value
  86766. */
  86767. static readonly LightDirtyFlag: number;
  86768. /**
  86769. * The dirty fresnel flag value
  86770. */
  86771. static readonly FresnelDirtyFlag: number;
  86772. /**
  86773. * The dirty attribute flag value
  86774. */
  86775. static readonly AttributesDirtyFlag: number;
  86776. /**
  86777. * The dirty misc flag value
  86778. */
  86779. static readonly MiscDirtyFlag: number;
  86780. /**
  86781. * The all dirty flag value
  86782. */
  86783. static readonly AllDirtyFlag: number;
  86784. /**
  86785. * The ID of the material
  86786. */
  86787. id: string;
  86788. /**
  86789. * Gets or sets the unique id of the material
  86790. */
  86791. uniqueId: number;
  86792. /**
  86793. * The name of the material
  86794. */
  86795. name: string;
  86796. /**
  86797. * Gets or sets user defined metadata
  86798. */
  86799. metadata: any;
  86800. /**
  86801. * For internal use only. Please do not use.
  86802. */
  86803. reservedDataStore: any;
  86804. /**
  86805. * Specifies if the ready state should be checked on each call
  86806. */
  86807. checkReadyOnEveryCall: boolean;
  86808. /**
  86809. * Specifies if the ready state should be checked once
  86810. */
  86811. checkReadyOnlyOnce: boolean;
  86812. /**
  86813. * The state of the material
  86814. */
  86815. state: string;
  86816. /**
  86817. * The alpha value of the material
  86818. */
  86819. protected _alpha: number;
  86820. /**
  86821. * List of inspectable custom properties (used by the Inspector)
  86822. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86823. */
  86824. inspectableCustomProperties: IInspectable[];
  86825. /**
  86826. * Sets the alpha value of the material
  86827. */
  86828. /**
  86829. * Gets the alpha value of the material
  86830. */
  86831. alpha: number;
  86832. /**
  86833. * Specifies if back face culling is enabled
  86834. */
  86835. protected _backFaceCulling: boolean;
  86836. /**
  86837. * Sets the back-face culling state
  86838. */
  86839. /**
  86840. * Gets the back-face culling state
  86841. */
  86842. backFaceCulling: boolean;
  86843. /**
  86844. * Stores the value for side orientation
  86845. */
  86846. sideOrientation: number;
  86847. /**
  86848. * Callback triggered when the material is compiled
  86849. */
  86850. onCompiled: Nullable<(effect: Effect) => void>;
  86851. /**
  86852. * Callback triggered when an error occurs
  86853. */
  86854. onError: Nullable<(effect: Effect, errors: string) => void>;
  86855. /**
  86856. * Callback triggered to get the render target textures
  86857. */
  86858. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  86859. /**
  86860. * Gets a boolean indicating that current material needs to register RTT
  86861. */
  86862. readonly hasRenderTargetTextures: boolean;
  86863. /**
  86864. * Specifies if the material should be serialized
  86865. */
  86866. doNotSerialize: boolean;
  86867. /**
  86868. * @hidden
  86869. */
  86870. _storeEffectOnSubMeshes: boolean;
  86871. /**
  86872. * Stores the animations for the material
  86873. */
  86874. animations: Nullable<Array<Animation>>;
  86875. /**
  86876. * An event triggered when the material is disposed
  86877. */
  86878. onDisposeObservable: Observable<Material>;
  86879. /**
  86880. * An observer which watches for dispose events
  86881. */
  86882. private _onDisposeObserver;
  86883. private _onUnBindObservable;
  86884. /**
  86885. * Called during a dispose event
  86886. */
  86887. onDispose: () => void;
  86888. private _onBindObservable;
  86889. /**
  86890. * An event triggered when the material is bound
  86891. */
  86892. readonly onBindObservable: Observable<AbstractMesh>;
  86893. /**
  86894. * An observer which watches for bind events
  86895. */
  86896. private _onBindObserver;
  86897. /**
  86898. * Called during a bind event
  86899. */
  86900. onBind: (Mesh: AbstractMesh) => void;
  86901. /**
  86902. * An event triggered when the material is unbound
  86903. */
  86904. readonly onUnBindObservable: Observable<Material>;
  86905. /**
  86906. * Stores the value of the alpha mode
  86907. */
  86908. private _alphaMode;
  86909. /**
  86910. * Sets the value of the alpha mode.
  86911. *
  86912. * | Value | Type | Description |
  86913. * | --- | --- | --- |
  86914. * | 0 | ALPHA_DISABLE | |
  86915. * | 1 | ALPHA_ADD | |
  86916. * | 2 | ALPHA_COMBINE | |
  86917. * | 3 | ALPHA_SUBTRACT | |
  86918. * | 4 | ALPHA_MULTIPLY | |
  86919. * | 5 | ALPHA_MAXIMIZED | |
  86920. * | 6 | ALPHA_ONEONE | |
  86921. * | 7 | ALPHA_PREMULTIPLIED | |
  86922. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  86923. * | 9 | ALPHA_INTERPOLATE | |
  86924. * | 10 | ALPHA_SCREENMODE | |
  86925. *
  86926. */
  86927. /**
  86928. * Gets the value of the alpha mode
  86929. */
  86930. alphaMode: number;
  86931. /**
  86932. * Stores the state of the need depth pre-pass value
  86933. */
  86934. private _needDepthPrePass;
  86935. /**
  86936. * Sets the need depth pre-pass value
  86937. */
  86938. /**
  86939. * Gets the depth pre-pass value
  86940. */
  86941. needDepthPrePass: boolean;
  86942. /**
  86943. * Specifies if depth writing should be disabled
  86944. */
  86945. disableDepthWrite: boolean;
  86946. /**
  86947. * Specifies if depth writing should be forced
  86948. */
  86949. forceDepthWrite: boolean;
  86950. /**
  86951. * Specifies if there should be a separate pass for culling
  86952. */
  86953. separateCullingPass: boolean;
  86954. /**
  86955. * Stores the state specifing if fog should be enabled
  86956. */
  86957. private _fogEnabled;
  86958. /**
  86959. * Sets the state for enabling fog
  86960. */
  86961. /**
  86962. * Gets the value of the fog enabled state
  86963. */
  86964. fogEnabled: boolean;
  86965. /**
  86966. * Stores the size of points
  86967. */
  86968. pointSize: number;
  86969. /**
  86970. * Stores the z offset value
  86971. */
  86972. zOffset: number;
  86973. /**
  86974. * Gets a value specifying if wireframe mode is enabled
  86975. */
  86976. /**
  86977. * Sets the state of wireframe mode
  86978. */
  86979. wireframe: boolean;
  86980. /**
  86981. * Gets the value specifying if point clouds are enabled
  86982. */
  86983. /**
  86984. * Sets the state of point cloud mode
  86985. */
  86986. pointsCloud: boolean;
  86987. /**
  86988. * Gets the material fill mode
  86989. */
  86990. /**
  86991. * Sets the material fill mode
  86992. */
  86993. fillMode: number;
  86994. /**
  86995. * @hidden
  86996. * Stores the effects for the material
  86997. */
  86998. _effect: Nullable<Effect>;
  86999. /**
  87000. * @hidden
  87001. * Specifies if the material was previously ready
  87002. */
  87003. _wasPreviouslyReady: boolean;
  87004. /**
  87005. * Specifies if uniform buffers should be used
  87006. */
  87007. private _useUBO;
  87008. /**
  87009. * Stores a reference to the scene
  87010. */
  87011. private _scene;
  87012. /**
  87013. * Stores the fill mode state
  87014. */
  87015. private _fillMode;
  87016. /**
  87017. * Specifies if the depth write state should be cached
  87018. */
  87019. private _cachedDepthWriteState;
  87020. /**
  87021. * Stores the uniform buffer
  87022. */
  87023. protected _uniformBuffer: UniformBuffer;
  87024. /** @hidden */
  87025. _indexInSceneMaterialArray: number;
  87026. /** @hidden */
  87027. meshMap: Nullable<{
  87028. [id: string]: AbstractMesh | undefined;
  87029. }>;
  87030. /**
  87031. * Creates a material instance
  87032. * @param name defines the name of the material
  87033. * @param scene defines the scene to reference
  87034. * @param doNotAdd specifies if the material should be added to the scene
  87035. */
  87036. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  87037. /**
  87038. * Returns a string representation of the current material
  87039. * @param fullDetails defines a boolean indicating which levels of logging is desired
  87040. * @returns a string with material information
  87041. */
  87042. toString(fullDetails?: boolean): string;
  87043. /**
  87044. * Gets the class name of the material
  87045. * @returns a string with the class name of the material
  87046. */
  87047. getClassName(): string;
  87048. /**
  87049. * Specifies if updates for the material been locked
  87050. */
  87051. readonly isFrozen: boolean;
  87052. /**
  87053. * Locks updates for the material
  87054. */
  87055. freeze(): void;
  87056. /**
  87057. * Unlocks updates for the material
  87058. */
  87059. unfreeze(): void;
  87060. /**
  87061. * Specifies if the material is ready to be used
  87062. * @param mesh defines the mesh to check
  87063. * @param useInstances specifies if instances should be used
  87064. * @returns a boolean indicating if the material is ready to be used
  87065. */
  87066. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87067. /**
  87068. * Specifies that the submesh is ready to be used
  87069. * @param mesh defines the mesh to check
  87070. * @param subMesh defines which submesh to check
  87071. * @param useInstances specifies that instances should be used
  87072. * @returns a boolean indicating that the submesh is ready or not
  87073. */
  87074. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87075. /**
  87076. * Returns the material effect
  87077. * @returns the effect associated with the material
  87078. */
  87079. getEffect(): Nullable<Effect>;
  87080. /**
  87081. * Returns the current scene
  87082. * @returns a Scene
  87083. */
  87084. getScene(): Scene;
  87085. /**
  87086. * Specifies if the material will require alpha blending
  87087. * @returns a boolean specifying if alpha blending is needed
  87088. */
  87089. needAlphaBlending(): boolean;
  87090. /**
  87091. * Specifies if the mesh will require alpha blending
  87092. * @param mesh defines the mesh to check
  87093. * @returns a boolean specifying if alpha blending is needed for the mesh
  87094. */
  87095. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  87096. /**
  87097. * Specifies if this material should be rendered in alpha test mode
  87098. * @returns a boolean specifying if an alpha test is needed.
  87099. */
  87100. needAlphaTesting(): boolean;
  87101. /**
  87102. * Gets the texture used for the alpha test
  87103. * @returns the texture to use for alpha testing
  87104. */
  87105. getAlphaTestTexture(): Nullable<BaseTexture>;
  87106. /**
  87107. * Marks the material to indicate that it needs to be re-calculated
  87108. */
  87109. markDirty(): void;
  87110. /** @hidden */
  87111. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  87112. /**
  87113. * Binds the material to the mesh
  87114. * @param world defines the world transformation matrix
  87115. * @param mesh defines the mesh to bind the material to
  87116. */
  87117. bind(world: Matrix, mesh?: Mesh): void;
  87118. /**
  87119. * Binds the submesh to the material
  87120. * @param world defines the world transformation matrix
  87121. * @param mesh defines the mesh containing the submesh
  87122. * @param subMesh defines the submesh to bind the material to
  87123. */
  87124. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  87125. /**
  87126. * Binds the world matrix to the material
  87127. * @param world defines the world transformation matrix
  87128. */
  87129. bindOnlyWorldMatrix(world: Matrix): void;
  87130. /**
  87131. * Binds the scene's uniform buffer to the effect.
  87132. * @param effect defines the effect to bind to the scene uniform buffer
  87133. * @param sceneUbo defines the uniform buffer storing scene data
  87134. */
  87135. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  87136. /**
  87137. * Binds the view matrix to the effect
  87138. * @param effect defines the effect to bind the view matrix to
  87139. */
  87140. bindView(effect: Effect): void;
  87141. /**
  87142. * Binds the view projection matrix to the effect
  87143. * @param effect defines the effect to bind the view projection matrix to
  87144. */
  87145. bindViewProjection(effect: Effect): void;
  87146. /**
  87147. * Specifies if material alpha testing should be turned on for the mesh
  87148. * @param mesh defines the mesh to check
  87149. */
  87150. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  87151. /**
  87152. * Processes to execute after binding the material to a mesh
  87153. * @param mesh defines the rendered mesh
  87154. */
  87155. protected _afterBind(mesh?: Mesh): void;
  87156. /**
  87157. * Unbinds the material from the mesh
  87158. */
  87159. unbind(): void;
  87160. /**
  87161. * Gets the active textures from the material
  87162. * @returns an array of textures
  87163. */
  87164. getActiveTextures(): BaseTexture[];
  87165. /**
  87166. * Specifies if the material uses a texture
  87167. * @param texture defines the texture to check against the material
  87168. * @returns a boolean specifying if the material uses the texture
  87169. */
  87170. hasTexture(texture: BaseTexture): boolean;
  87171. /**
  87172. * Makes a duplicate of the material, and gives it a new name
  87173. * @param name defines the new name for the duplicated material
  87174. * @returns the cloned material
  87175. */
  87176. clone(name: string): Nullable<Material>;
  87177. /**
  87178. * Gets the meshes bound to the material
  87179. * @returns an array of meshes bound to the material
  87180. */
  87181. getBindedMeshes(): AbstractMesh[];
  87182. /**
  87183. * Force shader compilation
  87184. * @param mesh defines the mesh associated with this material
  87185. * @param onCompiled defines a function to execute once the material is compiled
  87186. * @param options defines the options to configure the compilation
  87187. * @param onError defines a function to execute if the material fails compiling
  87188. */
  87189. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  87190. clipPlane: boolean;
  87191. }>, onError?: (reason: string) => void): void;
  87192. /**
  87193. * Force shader compilation
  87194. * @param mesh defines the mesh that will use this material
  87195. * @param options defines additional options for compiling the shaders
  87196. * @returns a promise that resolves when the compilation completes
  87197. */
  87198. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  87199. clipPlane: boolean;
  87200. }>): Promise<void>;
  87201. private static readonly _AllDirtyCallBack;
  87202. private static readonly _ImageProcessingDirtyCallBack;
  87203. private static readonly _TextureDirtyCallBack;
  87204. private static readonly _FresnelDirtyCallBack;
  87205. private static readonly _MiscDirtyCallBack;
  87206. private static readonly _LightsDirtyCallBack;
  87207. private static readonly _AttributeDirtyCallBack;
  87208. private static _FresnelAndMiscDirtyCallBack;
  87209. private static _TextureAndMiscDirtyCallBack;
  87210. private static readonly _DirtyCallbackArray;
  87211. private static readonly _RunDirtyCallBacks;
  87212. /**
  87213. * Marks a define in the material to indicate that it needs to be re-computed
  87214. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  87215. */
  87216. markAsDirty(flag: number): void;
  87217. /**
  87218. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  87219. * @param func defines a function which checks material defines against the submeshes
  87220. */
  87221. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  87222. /**
  87223. * Indicates that we need to re-calculated for all submeshes
  87224. */
  87225. protected _markAllSubMeshesAsAllDirty(): void;
  87226. /**
  87227. * Indicates that image processing needs to be re-calculated for all submeshes
  87228. */
  87229. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  87230. /**
  87231. * Indicates that textures need to be re-calculated for all submeshes
  87232. */
  87233. protected _markAllSubMeshesAsTexturesDirty(): void;
  87234. /**
  87235. * Indicates that fresnel needs to be re-calculated for all submeshes
  87236. */
  87237. protected _markAllSubMeshesAsFresnelDirty(): void;
  87238. /**
  87239. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  87240. */
  87241. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  87242. /**
  87243. * Indicates that lights need to be re-calculated for all submeshes
  87244. */
  87245. protected _markAllSubMeshesAsLightsDirty(): void;
  87246. /**
  87247. * Indicates that attributes need to be re-calculated for all submeshes
  87248. */
  87249. protected _markAllSubMeshesAsAttributesDirty(): void;
  87250. /**
  87251. * Indicates that misc needs to be re-calculated for all submeshes
  87252. */
  87253. protected _markAllSubMeshesAsMiscDirty(): void;
  87254. /**
  87255. * Indicates that textures and misc need to be re-calculated for all submeshes
  87256. */
  87257. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  87258. /**
  87259. * Disposes the material
  87260. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87261. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87262. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87263. */
  87264. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87265. /** @hidden */
  87266. private releaseVertexArrayObject;
  87267. /**
  87268. * Serializes this material
  87269. * @returns the serialized material object
  87270. */
  87271. serialize(): any;
  87272. /**
  87273. * Creates a material from parsed material data
  87274. * @param parsedMaterial defines parsed material data
  87275. * @param scene defines the hosting scene
  87276. * @param rootUrl defines the root URL to use to load textures
  87277. * @returns a new material
  87278. */
  87279. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  87280. }
  87281. }
  87282. declare module BABYLON {
  87283. /**
  87284. * Creates an instance based on a source mesh.
  87285. */
  87286. export class InstancedMesh extends AbstractMesh {
  87287. private _sourceMesh;
  87288. private _currentLOD;
  87289. /** @hidden */
  87290. _actAsRegularMesh: boolean;
  87291. /** @hidden */
  87292. _indexInSourceMeshInstanceArray: number;
  87293. constructor(name: string, source: Mesh);
  87294. /**
  87295. * Returns the string "InstancedMesh".
  87296. */
  87297. getClassName(): string;
  87298. /** Gets the list of lights affecting that mesh */
  87299. readonly lightSources: Light[];
  87300. _resyncLightSources(): void;
  87301. _resyncLighSource(light: Light): void;
  87302. _removeLightSource(light: Light, dispose: boolean): void;
  87303. /**
  87304. * If the source mesh receives shadows
  87305. */
  87306. readonly receiveShadows: boolean;
  87307. /**
  87308. * The material of the source mesh
  87309. */
  87310. readonly material: Nullable<Material>;
  87311. /**
  87312. * Visibility of the source mesh
  87313. */
  87314. readonly visibility: number;
  87315. /**
  87316. * Skeleton of the source mesh
  87317. */
  87318. readonly skeleton: Nullable<Skeleton>;
  87319. /**
  87320. * Rendering ground id of the source mesh
  87321. */
  87322. renderingGroupId: number;
  87323. /**
  87324. * Returns the total number of vertices (integer).
  87325. */
  87326. getTotalVertices(): number;
  87327. /**
  87328. * Returns a positive integer : the total number of indices in this mesh geometry.
  87329. * @returns the numner of indices or zero if the mesh has no geometry.
  87330. */
  87331. getTotalIndices(): number;
  87332. /**
  87333. * The source mesh of the instance
  87334. */
  87335. readonly sourceMesh: Mesh;
  87336. /**
  87337. * Is this node ready to be used/rendered
  87338. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87339. * @return {boolean} is it ready
  87340. */
  87341. isReady(completeCheck?: boolean): boolean;
  87342. /**
  87343. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87344. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  87345. * @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.
  87346. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  87347. */
  87348. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  87349. /**
  87350. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87351. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87352. * The `data` are either a numeric array either a Float32Array.
  87353. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  87354. * 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).
  87355. * Note that a new underlying VertexBuffer object is created each call.
  87356. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87357. *
  87358. * Possible `kind` values :
  87359. * - VertexBuffer.PositionKind
  87360. * - VertexBuffer.UVKind
  87361. * - VertexBuffer.UV2Kind
  87362. * - VertexBuffer.UV3Kind
  87363. * - VertexBuffer.UV4Kind
  87364. * - VertexBuffer.UV5Kind
  87365. * - VertexBuffer.UV6Kind
  87366. * - VertexBuffer.ColorKind
  87367. * - VertexBuffer.MatricesIndicesKind
  87368. * - VertexBuffer.MatricesIndicesExtraKind
  87369. * - VertexBuffer.MatricesWeightsKind
  87370. * - VertexBuffer.MatricesWeightsExtraKind
  87371. *
  87372. * Returns the Mesh.
  87373. */
  87374. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87375. /**
  87376. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87377. * If the mesh has no geometry, it is simply returned as it is.
  87378. * The `data` are either a numeric array either a Float32Array.
  87379. * No new underlying VertexBuffer object is created.
  87380. * 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.
  87381. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  87382. *
  87383. * Possible `kind` values :
  87384. * - VertexBuffer.PositionKind
  87385. * - VertexBuffer.UVKind
  87386. * - VertexBuffer.UV2Kind
  87387. * - VertexBuffer.UV3Kind
  87388. * - VertexBuffer.UV4Kind
  87389. * - VertexBuffer.UV5Kind
  87390. * - VertexBuffer.UV6Kind
  87391. * - VertexBuffer.ColorKind
  87392. * - VertexBuffer.MatricesIndicesKind
  87393. * - VertexBuffer.MatricesIndicesExtraKind
  87394. * - VertexBuffer.MatricesWeightsKind
  87395. * - VertexBuffer.MatricesWeightsExtraKind
  87396. *
  87397. * Returns the Mesh.
  87398. */
  87399. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  87400. /**
  87401. * Sets the mesh indices.
  87402. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  87403. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87404. * This method creates a new index buffer each call.
  87405. * Returns the Mesh.
  87406. */
  87407. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  87408. /**
  87409. * Boolean : True if the mesh owns the requested kind of data.
  87410. */
  87411. isVerticesDataPresent(kind: string): boolean;
  87412. /**
  87413. * Returns an array of indices (IndicesArray).
  87414. */
  87415. getIndices(): Nullable<IndicesArray>;
  87416. readonly _positions: Nullable<Vector3[]>;
  87417. /**
  87418. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87419. * This means the mesh underlying bounding box and sphere are recomputed.
  87420. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87421. * @returns the current mesh
  87422. */
  87423. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  87424. /** @hidden */
  87425. _preActivate(): InstancedMesh;
  87426. /** @hidden */
  87427. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87428. /** @hidden */
  87429. _postActivate(): void;
  87430. getWorldMatrix(): Matrix;
  87431. readonly isAnInstance: boolean;
  87432. /**
  87433. * Returns the current associated LOD AbstractMesh.
  87434. */
  87435. getLOD(camera: Camera): AbstractMesh;
  87436. /** @hidden */
  87437. _syncSubMeshes(): InstancedMesh;
  87438. /** @hidden */
  87439. _generatePointsArray(): boolean;
  87440. /**
  87441. * Creates a new InstancedMesh from the current mesh.
  87442. * - name (string) : the cloned mesh name
  87443. * - newParent (optional Node) : the optional Node to parent the clone to.
  87444. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  87445. *
  87446. * Returns the clone.
  87447. */
  87448. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87449. /**
  87450. * Disposes the InstancedMesh.
  87451. * Returns nothing.
  87452. */
  87453. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87454. }
  87455. }
  87456. declare module BABYLON {
  87457. /**
  87458. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87459. * separate meshes. This can be use to improve performances.
  87460. * @see http://doc.babylonjs.com/how_to/multi_materials
  87461. */
  87462. export class MultiMaterial extends Material {
  87463. private _subMaterials;
  87464. /**
  87465. * Gets or Sets the list of Materials used within the multi material.
  87466. * They need to be ordered according to the submeshes order in the associated mesh
  87467. */
  87468. subMaterials: Nullable<Material>[];
  87469. /**
  87470. * Function used to align with Node.getChildren()
  87471. * @returns the list of Materials used within the multi material
  87472. */
  87473. getChildren(): Nullable<Material>[];
  87474. /**
  87475. * Instantiates a new Multi Material
  87476. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87477. * separate meshes. This can be use to improve performances.
  87478. * @see http://doc.babylonjs.com/how_to/multi_materials
  87479. * @param name Define the name in the scene
  87480. * @param scene Define the scene the material belongs to
  87481. */
  87482. constructor(name: string, scene: Scene);
  87483. private _hookArray;
  87484. /**
  87485. * Get one of the submaterial by its index in the submaterials array
  87486. * @param index The index to look the sub material at
  87487. * @returns The Material if the index has been defined
  87488. */
  87489. getSubMaterial(index: number): Nullable<Material>;
  87490. /**
  87491. * Get the list of active textures for the whole sub materials list.
  87492. * @returns All the textures that will be used during the rendering
  87493. */
  87494. getActiveTextures(): BaseTexture[];
  87495. /**
  87496. * Gets the current class name of the material e.g. "MultiMaterial"
  87497. * Mainly use in serialization.
  87498. * @returns the class name
  87499. */
  87500. getClassName(): string;
  87501. /**
  87502. * Checks if the material is ready to render the requested sub mesh
  87503. * @param mesh Define the mesh the submesh belongs to
  87504. * @param subMesh Define the sub mesh to look readyness for
  87505. * @param useInstances Define whether or not the material is used with instances
  87506. * @returns true if ready, otherwise false
  87507. */
  87508. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87509. /**
  87510. * Clones the current material and its related sub materials
  87511. * @param name Define the name of the newly cloned material
  87512. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  87513. * @returns the cloned material
  87514. */
  87515. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  87516. /**
  87517. * Serializes the materials into a JSON representation.
  87518. * @returns the JSON representation
  87519. */
  87520. serialize(): any;
  87521. /**
  87522. * Dispose the material and release its associated resources
  87523. * @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)
  87524. * @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)
  87525. * @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)
  87526. */
  87527. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  87528. /**
  87529. * Creates a MultiMaterial from parsed MultiMaterial data.
  87530. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  87531. * @param scene defines the hosting scene
  87532. * @returns a new MultiMaterial
  87533. */
  87534. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  87535. }
  87536. }
  87537. declare module BABYLON {
  87538. /**
  87539. * Base class for submeshes
  87540. */
  87541. export class BaseSubMesh {
  87542. /** @hidden */
  87543. _materialDefines: Nullable<MaterialDefines>;
  87544. /** @hidden */
  87545. _materialEffect: Nullable<Effect>;
  87546. /**
  87547. * Gets associated effect
  87548. */
  87549. readonly effect: Nullable<Effect>;
  87550. /**
  87551. * Sets associated effect (effect used to render this submesh)
  87552. * @param effect defines the effect to associate with
  87553. * @param defines defines the set of defines used to compile this effect
  87554. */
  87555. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  87556. }
  87557. /**
  87558. * Defines a subdivision inside a mesh
  87559. */
  87560. export class SubMesh extends BaseSubMesh implements ICullable {
  87561. /** the material index to use */
  87562. materialIndex: number;
  87563. /** vertex index start */
  87564. verticesStart: number;
  87565. /** vertices count */
  87566. verticesCount: number;
  87567. /** index start */
  87568. indexStart: number;
  87569. /** indices count */
  87570. indexCount: number;
  87571. /** @hidden */
  87572. _linesIndexCount: number;
  87573. private _mesh;
  87574. private _renderingMesh;
  87575. private _boundingInfo;
  87576. private _linesIndexBuffer;
  87577. /** @hidden */
  87578. _lastColliderWorldVertices: Nullable<Vector3[]>;
  87579. /** @hidden */
  87580. _trianglePlanes: Plane[];
  87581. /** @hidden */
  87582. _lastColliderTransformMatrix: Nullable<Matrix>;
  87583. /** @hidden */
  87584. _renderId: number;
  87585. /** @hidden */
  87586. _alphaIndex: number;
  87587. /** @hidden */
  87588. _distanceToCamera: number;
  87589. /** @hidden */
  87590. _id: number;
  87591. private _currentMaterial;
  87592. /**
  87593. * Add a new submesh to a mesh
  87594. * @param materialIndex defines the material index to use
  87595. * @param verticesStart defines vertex index start
  87596. * @param verticesCount defines vertices count
  87597. * @param indexStart defines index start
  87598. * @param indexCount defines indices count
  87599. * @param mesh defines the parent mesh
  87600. * @param renderingMesh defines an optional rendering mesh
  87601. * @param createBoundingBox defines if bounding box should be created for this submesh
  87602. * @returns the new submesh
  87603. */
  87604. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  87605. /**
  87606. * Creates a new submesh
  87607. * @param materialIndex defines the material index to use
  87608. * @param verticesStart defines vertex index start
  87609. * @param verticesCount defines vertices count
  87610. * @param indexStart defines index start
  87611. * @param indexCount defines indices count
  87612. * @param mesh defines the parent mesh
  87613. * @param renderingMesh defines an optional rendering mesh
  87614. * @param createBoundingBox defines if bounding box should be created for this submesh
  87615. */
  87616. constructor(
  87617. /** the material index to use */
  87618. materialIndex: number,
  87619. /** vertex index start */
  87620. verticesStart: number,
  87621. /** vertices count */
  87622. verticesCount: number,
  87623. /** index start */
  87624. indexStart: number,
  87625. /** indices count */
  87626. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  87627. /**
  87628. * Returns true if this submesh covers the entire parent mesh
  87629. * @ignorenaming
  87630. */
  87631. readonly IsGlobal: boolean;
  87632. /**
  87633. * Returns the submesh BoudingInfo object
  87634. * @returns current bounding info (or mesh's one if the submesh is global)
  87635. */
  87636. getBoundingInfo(): BoundingInfo;
  87637. /**
  87638. * Sets the submesh BoundingInfo
  87639. * @param boundingInfo defines the new bounding info to use
  87640. * @returns the SubMesh
  87641. */
  87642. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  87643. /**
  87644. * Returns the mesh of the current submesh
  87645. * @return the parent mesh
  87646. */
  87647. getMesh(): AbstractMesh;
  87648. /**
  87649. * Returns the rendering mesh of the submesh
  87650. * @returns the rendering mesh (could be different from parent mesh)
  87651. */
  87652. getRenderingMesh(): Mesh;
  87653. /**
  87654. * Returns the submesh material
  87655. * @returns null or the current material
  87656. */
  87657. getMaterial(): Nullable<Material>;
  87658. /**
  87659. * Sets a new updated BoundingInfo object to the submesh
  87660. * @param data defines an optional position array to use to determine the bounding info
  87661. * @returns the SubMesh
  87662. */
  87663. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  87664. /** @hidden */
  87665. _checkCollision(collider: Collider): boolean;
  87666. /**
  87667. * Updates the submesh BoundingInfo
  87668. * @param world defines the world matrix to use to update the bounding info
  87669. * @returns the submesh
  87670. */
  87671. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  87672. /**
  87673. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  87674. * @param frustumPlanes defines the frustum planes
  87675. * @returns true if the submesh is intersecting with the frustum
  87676. */
  87677. isInFrustum(frustumPlanes: Plane[]): boolean;
  87678. /**
  87679. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  87680. * @param frustumPlanes defines the frustum planes
  87681. * @returns true if the submesh is inside the frustum
  87682. */
  87683. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87684. /**
  87685. * Renders the submesh
  87686. * @param enableAlphaMode defines if alpha needs to be used
  87687. * @returns the submesh
  87688. */
  87689. render(enableAlphaMode: boolean): SubMesh;
  87690. /**
  87691. * @hidden
  87692. */
  87693. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  87694. /**
  87695. * Checks if the submesh intersects with a ray
  87696. * @param ray defines the ray to test
  87697. * @returns true is the passed ray intersects the submesh bounding box
  87698. */
  87699. canIntersects(ray: Ray): boolean;
  87700. /**
  87701. * Intersects current submesh with a ray
  87702. * @param ray defines the ray to test
  87703. * @param positions defines mesh's positions array
  87704. * @param indices defines mesh's indices array
  87705. * @param fastCheck defines if only bounding info should be used
  87706. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87707. * @returns intersection info or null if no intersection
  87708. */
  87709. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  87710. /** @hidden */
  87711. private _intersectLines;
  87712. /** @hidden */
  87713. private _intersectUnIndexedLines;
  87714. /** @hidden */
  87715. private _intersectTriangles;
  87716. /** @hidden */
  87717. private _intersectUnIndexedTriangles;
  87718. /** @hidden */
  87719. _rebuild(): void;
  87720. /**
  87721. * Creates a new submesh from the passed mesh
  87722. * @param newMesh defines the new hosting mesh
  87723. * @param newRenderingMesh defines an optional rendering mesh
  87724. * @returns the new submesh
  87725. */
  87726. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  87727. /**
  87728. * Release associated resources
  87729. */
  87730. dispose(): void;
  87731. /**
  87732. * Gets the class name
  87733. * @returns the string "SubMesh".
  87734. */
  87735. getClassName(): string;
  87736. /**
  87737. * Creates a new submesh from indices data
  87738. * @param materialIndex the index of the main mesh material
  87739. * @param startIndex the index where to start the copy in the mesh indices array
  87740. * @param indexCount the number of indices to copy then from the startIndex
  87741. * @param mesh the main mesh to create the submesh from
  87742. * @param renderingMesh the optional rendering mesh
  87743. * @returns a new submesh
  87744. */
  87745. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  87746. }
  87747. }
  87748. declare module BABYLON {
  87749. /**
  87750. * Class used to represent data loading progression
  87751. */
  87752. export class SceneLoaderFlags {
  87753. private static _ForceFullSceneLoadingForIncremental;
  87754. private static _ShowLoadingScreen;
  87755. private static _CleanBoneMatrixWeights;
  87756. private static _loggingLevel;
  87757. /**
  87758. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  87759. */
  87760. static ForceFullSceneLoadingForIncremental: boolean;
  87761. /**
  87762. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  87763. */
  87764. static ShowLoadingScreen: boolean;
  87765. /**
  87766. * Defines the current logging level (while loading the scene)
  87767. * @ignorenaming
  87768. */
  87769. static loggingLevel: number;
  87770. /**
  87771. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  87772. */
  87773. static CleanBoneMatrixWeights: boolean;
  87774. }
  87775. }
  87776. declare module BABYLON {
  87777. /**
  87778. * Class used to store geometry data (vertex buffers + index buffer)
  87779. */
  87780. export class Geometry implements IGetSetVerticesData {
  87781. /**
  87782. * Gets or sets the ID of the geometry
  87783. */
  87784. id: string;
  87785. /**
  87786. * Gets or sets the unique ID of the geometry
  87787. */
  87788. uniqueId: number;
  87789. /**
  87790. * Gets the delay loading state of the geometry (none by default which means not delayed)
  87791. */
  87792. delayLoadState: number;
  87793. /**
  87794. * Gets the file containing the data to load when running in delay load state
  87795. */
  87796. delayLoadingFile: Nullable<string>;
  87797. /**
  87798. * Callback called when the geometry is updated
  87799. */
  87800. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  87801. private _scene;
  87802. private _engine;
  87803. private _meshes;
  87804. private _totalVertices;
  87805. /** @hidden */
  87806. _indices: IndicesArray;
  87807. /** @hidden */
  87808. _vertexBuffers: {
  87809. [key: string]: VertexBuffer;
  87810. };
  87811. private _isDisposed;
  87812. private _extend;
  87813. private _boundingBias;
  87814. /** @hidden */
  87815. _delayInfo: Array<string>;
  87816. private _indexBuffer;
  87817. private _indexBufferIsUpdatable;
  87818. /** @hidden */
  87819. _boundingInfo: Nullable<BoundingInfo>;
  87820. /** @hidden */
  87821. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  87822. /** @hidden */
  87823. _softwareSkinningFrameId: number;
  87824. private _vertexArrayObjects;
  87825. private _updatable;
  87826. /** @hidden */
  87827. _positions: Nullable<Vector3[]>;
  87828. /**
  87829. * 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
  87830. */
  87831. /**
  87832. * 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
  87833. */
  87834. boundingBias: Vector2;
  87835. /**
  87836. * Static function used to attach a new empty geometry to a mesh
  87837. * @param mesh defines the mesh to attach the geometry to
  87838. * @returns the new Geometry
  87839. */
  87840. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  87841. /**
  87842. * Creates a new geometry
  87843. * @param id defines the unique ID
  87844. * @param scene defines the hosting scene
  87845. * @param vertexData defines the VertexData used to get geometry data
  87846. * @param updatable defines if geometry must be updatable (false by default)
  87847. * @param mesh defines the mesh that will be associated with the geometry
  87848. */
  87849. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  87850. /**
  87851. * Gets the current extend of the geometry
  87852. */
  87853. readonly extend: {
  87854. minimum: Vector3;
  87855. maximum: Vector3;
  87856. };
  87857. /**
  87858. * Gets the hosting scene
  87859. * @returns the hosting Scene
  87860. */
  87861. getScene(): Scene;
  87862. /**
  87863. * Gets the hosting engine
  87864. * @returns the hosting Engine
  87865. */
  87866. getEngine(): Engine;
  87867. /**
  87868. * Defines if the geometry is ready to use
  87869. * @returns true if the geometry is ready to be used
  87870. */
  87871. isReady(): boolean;
  87872. /**
  87873. * Gets a value indicating that the geometry should not be serialized
  87874. */
  87875. readonly doNotSerialize: boolean;
  87876. /** @hidden */
  87877. _rebuild(): void;
  87878. /**
  87879. * Affects all geometry data in one call
  87880. * @param vertexData defines the geometry data
  87881. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  87882. */
  87883. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  87884. /**
  87885. * Set specific vertex data
  87886. * @param kind defines the data kind (Position, normal, etc...)
  87887. * @param data defines the vertex data to use
  87888. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87889. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87890. */
  87891. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  87892. /**
  87893. * Removes a specific vertex data
  87894. * @param kind defines the data kind (Position, normal, etc...)
  87895. */
  87896. removeVerticesData(kind: string): void;
  87897. /**
  87898. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  87899. * @param buffer defines the vertex buffer to use
  87900. * @param totalVertices defines the total number of vertices for position kind (could be null)
  87901. */
  87902. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  87903. /**
  87904. * Update a specific vertex buffer
  87905. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  87906. * It will do nothing if the buffer is not updatable
  87907. * @param kind defines the data kind (Position, normal, etc...)
  87908. * @param data defines the data to use
  87909. * @param offset defines the offset in the target buffer where to store the data
  87910. * @param useBytes set to true if the offset is in bytes
  87911. */
  87912. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  87913. /**
  87914. * Update a specific vertex buffer
  87915. * This function will create a new buffer if the current one is not updatable
  87916. * @param kind defines the data kind (Position, normal, etc...)
  87917. * @param data defines the data to use
  87918. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  87919. */
  87920. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  87921. private _updateBoundingInfo;
  87922. /** @hidden */
  87923. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  87924. /**
  87925. * Gets total number of vertices
  87926. * @returns the total number of vertices
  87927. */
  87928. getTotalVertices(): number;
  87929. /**
  87930. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87931. * @param kind defines the data kind (Position, normal, etc...)
  87932. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87933. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87934. * @returns a float array containing vertex data
  87935. */
  87936. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87937. /**
  87938. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  87939. * @param kind defines the data kind (Position, normal, etc...)
  87940. * @returns true if the vertex buffer with the specified kind is updatable
  87941. */
  87942. isVertexBufferUpdatable(kind: string): boolean;
  87943. /**
  87944. * Gets a specific vertex buffer
  87945. * @param kind defines the data kind (Position, normal, etc...)
  87946. * @returns a VertexBuffer
  87947. */
  87948. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87949. /**
  87950. * Returns all vertex buffers
  87951. * @return an object holding all vertex buffers indexed by kind
  87952. */
  87953. getVertexBuffers(): Nullable<{
  87954. [key: string]: VertexBuffer;
  87955. }>;
  87956. /**
  87957. * Gets a boolean indicating if specific vertex buffer is present
  87958. * @param kind defines the data kind (Position, normal, etc...)
  87959. * @returns true if data is present
  87960. */
  87961. isVerticesDataPresent(kind: string): boolean;
  87962. /**
  87963. * Gets a list of all attached data kinds (Position, normal, etc...)
  87964. * @returns a list of string containing all kinds
  87965. */
  87966. getVerticesDataKinds(): string[];
  87967. /**
  87968. * Update index buffer
  87969. * @param indices defines the indices to store in the index buffer
  87970. * @param offset defines the offset in the target buffer where to store the data
  87971. * @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)
  87972. */
  87973. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  87974. /**
  87975. * Creates a new index buffer
  87976. * @param indices defines the indices to store in the index buffer
  87977. * @param totalVertices defines the total number of vertices (could be null)
  87978. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87979. */
  87980. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  87981. /**
  87982. * Return the total number of indices
  87983. * @returns the total number of indices
  87984. */
  87985. getTotalIndices(): number;
  87986. /**
  87987. * Gets the index buffer array
  87988. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87989. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87990. * @returns the index buffer array
  87991. */
  87992. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87993. /**
  87994. * Gets the index buffer
  87995. * @return the index buffer
  87996. */
  87997. getIndexBuffer(): Nullable<DataBuffer>;
  87998. /** @hidden */
  87999. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  88000. /**
  88001. * Release the associated resources for a specific mesh
  88002. * @param mesh defines the source mesh
  88003. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  88004. */
  88005. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  88006. /**
  88007. * Apply current geometry to a given mesh
  88008. * @param mesh defines the mesh to apply geometry to
  88009. */
  88010. applyToMesh(mesh: Mesh): void;
  88011. private _updateExtend;
  88012. private _applyToMesh;
  88013. private notifyUpdate;
  88014. /**
  88015. * Load the geometry if it was flagged as delay loaded
  88016. * @param scene defines the hosting scene
  88017. * @param onLoaded defines a callback called when the geometry is loaded
  88018. */
  88019. load(scene: Scene, onLoaded?: () => void): void;
  88020. private _queueLoad;
  88021. /**
  88022. * Invert the geometry to move from a right handed system to a left handed one.
  88023. */
  88024. toLeftHanded(): void;
  88025. /** @hidden */
  88026. _resetPointsArrayCache(): void;
  88027. /** @hidden */
  88028. _generatePointsArray(): boolean;
  88029. /**
  88030. * Gets a value indicating if the geometry is disposed
  88031. * @returns true if the geometry was disposed
  88032. */
  88033. isDisposed(): boolean;
  88034. private _disposeVertexArrayObjects;
  88035. /**
  88036. * Free all associated resources
  88037. */
  88038. dispose(): void;
  88039. /**
  88040. * Clone the current geometry into a new geometry
  88041. * @param id defines the unique ID of the new geometry
  88042. * @returns a new geometry object
  88043. */
  88044. copy(id: string): Geometry;
  88045. /**
  88046. * Serialize the current geometry info (and not the vertices data) into a JSON object
  88047. * @return a JSON representation of the current geometry data (without the vertices data)
  88048. */
  88049. serialize(): any;
  88050. private toNumberArray;
  88051. /**
  88052. * Serialize all vertices data into a JSON oject
  88053. * @returns a JSON representation of the current geometry data
  88054. */
  88055. serializeVerticeData(): any;
  88056. /**
  88057. * Extracts a clone of a mesh geometry
  88058. * @param mesh defines the source mesh
  88059. * @param id defines the unique ID of the new geometry object
  88060. * @returns the new geometry object
  88061. */
  88062. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  88063. /**
  88064. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  88065. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88066. * Be aware Math.random() could cause collisions, but:
  88067. * "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"
  88068. * @returns a string containing a new GUID
  88069. */
  88070. static RandomId(): string;
  88071. /** @hidden */
  88072. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  88073. private static _CleanMatricesWeights;
  88074. /**
  88075. * Create a new geometry from persisted data (Using .babylon file format)
  88076. * @param parsedVertexData defines the persisted data
  88077. * @param scene defines the hosting scene
  88078. * @param rootUrl defines the root url to use to load assets (like delayed data)
  88079. * @returns the new geometry object
  88080. */
  88081. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  88082. }
  88083. }
  88084. declare module BABYLON {
  88085. /**
  88086. * Define an interface for all classes that will get and set the data on vertices
  88087. */
  88088. export interface IGetSetVerticesData {
  88089. /**
  88090. * Gets a boolean indicating if specific vertex data is present
  88091. * @param kind defines the vertex data kind to use
  88092. * @returns true is data kind is present
  88093. */
  88094. isVerticesDataPresent(kind: string): boolean;
  88095. /**
  88096. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88097. * @param kind defines the data kind (Position, normal, etc...)
  88098. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88099. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88100. * @returns a float array containing vertex data
  88101. */
  88102. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88103. /**
  88104. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88105. * @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.
  88106. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88107. * @returns the indices array or an empty array if the mesh has no geometry
  88108. */
  88109. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88110. /**
  88111. * Set specific vertex data
  88112. * @param kind defines the data kind (Position, normal, etc...)
  88113. * @param data defines the vertex data to use
  88114. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88115. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88116. */
  88117. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  88118. /**
  88119. * Update a specific associated vertex buffer
  88120. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88121. * - VertexBuffer.PositionKind
  88122. * - VertexBuffer.UVKind
  88123. * - VertexBuffer.UV2Kind
  88124. * - VertexBuffer.UV3Kind
  88125. * - VertexBuffer.UV4Kind
  88126. * - VertexBuffer.UV5Kind
  88127. * - VertexBuffer.UV6Kind
  88128. * - VertexBuffer.ColorKind
  88129. * - VertexBuffer.MatricesIndicesKind
  88130. * - VertexBuffer.MatricesIndicesExtraKind
  88131. * - VertexBuffer.MatricesWeightsKind
  88132. * - VertexBuffer.MatricesWeightsExtraKind
  88133. * @param data defines the data source
  88134. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88135. * @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)
  88136. */
  88137. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  88138. /**
  88139. * Creates a new index buffer
  88140. * @param indices defines the indices to store in the index buffer
  88141. * @param totalVertices defines the total number of vertices (could be null)
  88142. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88143. */
  88144. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  88145. }
  88146. /**
  88147. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  88148. */
  88149. export class VertexData {
  88150. /**
  88151. * Mesh side orientation : usually the external or front surface
  88152. */
  88153. static readonly FRONTSIDE: number;
  88154. /**
  88155. * Mesh side orientation : usually the internal or back surface
  88156. */
  88157. static readonly BACKSIDE: number;
  88158. /**
  88159. * Mesh side orientation : both internal and external or front and back surfaces
  88160. */
  88161. static readonly DOUBLESIDE: number;
  88162. /**
  88163. * Mesh side orientation : by default, `FRONTSIDE`
  88164. */
  88165. static readonly DEFAULTSIDE: number;
  88166. /**
  88167. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  88168. */
  88169. positions: Nullable<FloatArray>;
  88170. /**
  88171. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  88172. */
  88173. normals: Nullable<FloatArray>;
  88174. /**
  88175. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  88176. */
  88177. tangents: Nullable<FloatArray>;
  88178. /**
  88179. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88180. */
  88181. uvs: Nullable<FloatArray>;
  88182. /**
  88183. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88184. */
  88185. uvs2: Nullable<FloatArray>;
  88186. /**
  88187. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88188. */
  88189. uvs3: Nullable<FloatArray>;
  88190. /**
  88191. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88192. */
  88193. uvs4: Nullable<FloatArray>;
  88194. /**
  88195. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88196. */
  88197. uvs5: Nullable<FloatArray>;
  88198. /**
  88199. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88200. */
  88201. uvs6: Nullable<FloatArray>;
  88202. /**
  88203. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  88204. */
  88205. colors: Nullable<FloatArray>;
  88206. /**
  88207. * 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).
  88208. */
  88209. matricesIndices: Nullable<FloatArray>;
  88210. /**
  88211. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  88212. */
  88213. matricesWeights: Nullable<FloatArray>;
  88214. /**
  88215. * An array extending the number of possible indices
  88216. */
  88217. matricesIndicesExtra: Nullable<FloatArray>;
  88218. /**
  88219. * An array extending the number of possible weights when the number of indices is extended
  88220. */
  88221. matricesWeightsExtra: Nullable<FloatArray>;
  88222. /**
  88223. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  88224. */
  88225. indices: Nullable<IndicesArray>;
  88226. /**
  88227. * Uses the passed data array to set the set the values for the specified kind of data
  88228. * @param data a linear array of floating numbers
  88229. * @param kind the type of data that is being set, eg positions, colors etc
  88230. */
  88231. set(data: FloatArray, kind: string): void;
  88232. /**
  88233. * Associates the vertexData to the passed Mesh.
  88234. * Sets it as updatable or not (default `false`)
  88235. * @param mesh the mesh the vertexData is applied to
  88236. * @param updatable when used and having the value true allows new data to update the vertexData
  88237. * @returns the VertexData
  88238. */
  88239. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  88240. /**
  88241. * Associates the vertexData to the passed Geometry.
  88242. * Sets it as updatable or not (default `false`)
  88243. * @param geometry the geometry the vertexData is applied to
  88244. * @param updatable when used and having the value true allows new data to update the vertexData
  88245. * @returns VertexData
  88246. */
  88247. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  88248. /**
  88249. * Updates the associated mesh
  88250. * @param mesh the mesh to be updated
  88251. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88252. * @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
  88253. * @returns VertexData
  88254. */
  88255. updateMesh(mesh: Mesh): VertexData;
  88256. /**
  88257. * Updates the associated geometry
  88258. * @param geometry the geometry to be updated
  88259. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88260. * @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
  88261. * @returns VertexData.
  88262. */
  88263. updateGeometry(geometry: Geometry): VertexData;
  88264. private _applyTo;
  88265. private _update;
  88266. /**
  88267. * Transforms each position and each normal of the vertexData according to the passed Matrix
  88268. * @param matrix the transforming matrix
  88269. * @returns the VertexData
  88270. */
  88271. transform(matrix: Matrix): VertexData;
  88272. /**
  88273. * Merges the passed VertexData into the current one
  88274. * @param other the VertexData to be merged into the current one
  88275. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  88276. * @returns the modified VertexData
  88277. */
  88278. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  88279. private _mergeElement;
  88280. private _validate;
  88281. /**
  88282. * Serializes the VertexData
  88283. * @returns a serialized object
  88284. */
  88285. serialize(): any;
  88286. /**
  88287. * Extracts the vertexData from a mesh
  88288. * @param mesh the mesh from which to extract the VertexData
  88289. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  88290. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88291. * @returns the object VertexData associated to the passed mesh
  88292. */
  88293. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88294. /**
  88295. * Extracts the vertexData from the geometry
  88296. * @param geometry the geometry from which to extract the VertexData
  88297. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  88298. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88299. * @returns the object VertexData associated to the passed mesh
  88300. */
  88301. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88302. private static _ExtractFrom;
  88303. /**
  88304. * Creates the VertexData for a Ribbon
  88305. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  88306. * * pathArray array of paths, each of which an array of successive Vector3
  88307. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  88308. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  88309. * * 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
  88310. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88311. * * 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)
  88312. * * 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)
  88313. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  88314. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  88315. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  88316. * @returns the VertexData of the ribbon
  88317. */
  88318. static CreateRibbon(options: {
  88319. pathArray: Vector3[][];
  88320. closeArray?: boolean;
  88321. closePath?: boolean;
  88322. offset?: number;
  88323. sideOrientation?: number;
  88324. frontUVs?: Vector4;
  88325. backUVs?: Vector4;
  88326. invertUV?: boolean;
  88327. uvs?: Vector2[];
  88328. colors?: Color4[];
  88329. }): VertexData;
  88330. /**
  88331. * Creates the VertexData for a box
  88332. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88333. * * size sets the width, height and depth of the box to the value of size, optional default 1
  88334. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  88335. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  88336. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  88337. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88338. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88339. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88340. * * 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)
  88341. * * 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)
  88342. * @returns the VertexData of the box
  88343. */
  88344. static CreateBox(options: {
  88345. size?: number;
  88346. width?: number;
  88347. height?: number;
  88348. depth?: number;
  88349. faceUV?: Vector4[];
  88350. faceColors?: Color4[];
  88351. sideOrientation?: number;
  88352. frontUVs?: Vector4;
  88353. backUVs?: Vector4;
  88354. }): VertexData;
  88355. /**
  88356. * Creates the VertexData for a tiled box
  88357. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88358. * * faceTiles sets the pattern, tile size and number of tiles for a face
  88359. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88360. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88361. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88362. * @returns the VertexData of the box
  88363. */
  88364. static CreateTiledBox(options: {
  88365. pattern?: number;
  88366. width?: number;
  88367. height?: number;
  88368. depth?: number;
  88369. tileSize?: number;
  88370. tileWidth?: number;
  88371. tileHeight?: number;
  88372. alignHorizontal?: number;
  88373. alignVertical?: number;
  88374. faceUV?: Vector4[];
  88375. faceColors?: Color4[];
  88376. sideOrientation?: number;
  88377. }): VertexData;
  88378. /**
  88379. * Creates the VertexData for a tiled plane
  88380. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88381. * * pattern a limited pattern arrangement depending on the number
  88382. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  88383. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  88384. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  88385. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88386. * * 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)
  88387. * * 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)
  88388. * @returns the VertexData of the tiled plane
  88389. */
  88390. static CreateTiledPlane(options: {
  88391. pattern?: number;
  88392. tileSize?: number;
  88393. tileWidth?: number;
  88394. tileHeight?: number;
  88395. size?: number;
  88396. width?: number;
  88397. height?: number;
  88398. alignHorizontal?: number;
  88399. alignVertical?: number;
  88400. sideOrientation?: number;
  88401. frontUVs?: Vector4;
  88402. backUVs?: Vector4;
  88403. }): VertexData;
  88404. /**
  88405. * Creates the VertexData for an ellipsoid, defaults to a sphere
  88406. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88407. * * segments sets the number of horizontal strips optional, default 32
  88408. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  88409. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  88410. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  88411. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  88412. * * 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
  88413. * * 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
  88414. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88415. * * 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)
  88416. * * 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)
  88417. * @returns the VertexData of the ellipsoid
  88418. */
  88419. static CreateSphere(options: {
  88420. segments?: number;
  88421. diameter?: number;
  88422. diameterX?: number;
  88423. diameterY?: number;
  88424. diameterZ?: number;
  88425. arc?: number;
  88426. slice?: number;
  88427. sideOrientation?: number;
  88428. frontUVs?: Vector4;
  88429. backUVs?: Vector4;
  88430. }): VertexData;
  88431. /**
  88432. * Creates the VertexData for a cylinder, cone or prism
  88433. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88434. * * height sets the height (y direction) of the cylinder, optional, default 2
  88435. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  88436. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  88437. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  88438. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88439. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  88440. * * 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
  88441. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88442. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88443. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  88444. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  88445. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88446. * * 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)
  88447. * * 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)
  88448. * @returns the VertexData of the cylinder, cone or prism
  88449. */
  88450. static CreateCylinder(options: {
  88451. height?: number;
  88452. diameterTop?: number;
  88453. diameterBottom?: number;
  88454. diameter?: number;
  88455. tessellation?: number;
  88456. subdivisions?: number;
  88457. arc?: number;
  88458. faceColors?: Color4[];
  88459. faceUV?: Vector4[];
  88460. hasRings?: boolean;
  88461. enclose?: boolean;
  88462. sideOrientation?: number;
  88463. frontUVs?: Vector4;
  88464. backUVs?: Vector4;
  88465. }): VertexData;
  88466. /**
  88467. * Creates the VertexData for a torus
  88468. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88469. * * diameter the diameter of the torus, optional default 1
  88470. * * thickness the diameter of the tube forming the torus, optional default 0.5
  88471. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88472. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88473. * * 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)
  88474. * * 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)
  88475. * @returns the VertexData of the torus
  88476. */
  88477. static CreateTorus(options: {
  88478. diameter?: number;
  88479. thickness?: number;
  88480. tessellation?: number;
  88481. sideOrientation?: number;
  88482. frontUVs?: Vector4;
  88483. backUVs?: Vector4;
  88484. }): VertexData;
  88485. /**
  88486. * Creates the VertexData of the LineSystem
  88487. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  88488. * - lines an array of lines, each line being an array of successive Vector3
  88489. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  88490. * @returns the VertexData of the LineSystem
  88491. */
  88492. static CreateLineSystem(options: {
  88493. lines: Vector3[][];
  88494. colors?: Nullable<Color4[][]>;
  88495. }): VertexData;
  88496. /**
  88497. * Create the VertexData for a DashedLines
  88498. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  88499. * - points an array successive Vector3
  88500. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  88501. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  88502. * - dashNb the intended total number of dashes, optional, default 200
  88503. * @returns the VertexData for the DashedLines
  88504. */
  88505. static CreateDashedLines(options: {
  88506. points: Vector3[];
  88507. dashSize?: number;
  88508. gapSize?: number;
  88509. dashNb?: number;
  88510. }): VertexData;
  88511. /**
  88512. * Creates the VertexData for a Ground
  88513. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88514. * - width the width (x direction) of the ground, optional, default 1
  88515. * - height the height (z direction) of the ground, optional, default 1
  88516. * - subdivisions the number of subdivisions per side, optional, default 1
  88517. * @returns the VertexData of the Ground
  88518. */
  88519. static CreateGround(options: {
  88520. width?: number;
  88521. height?: number;
  88522. subdivisions?: number;
  88523. subdivisionsX?: number;
  88524. subdivisionsY?: number;
  88525. }): VertexData;
  88526. /**
  88527. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  88528. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88529. * * xmin the ground minimum X coordinate, optional, default -1
  88530. * * zmin the ground minimum Z coordinate, optional, default -1
  88531. * * xmax the ground maximum X coordinate, optional, default 1
  88532. * * zmax the ground maximum Z coordinate, optional, default 1
  88533. * * 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}
  88534. * * 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}
  88535. * @returns the VertexData of the TiledGround
  88536. */
  88537. static CreateTiledGround(options: {
  88538. xmin: number;
  88539. zmin: number;
  88540. xmax: number;
  88541. zmax: number;
  88542. subdivisions?: {
  88543. w: number;
  88544. h: number;
  88545. };
  88546. precision?: {
  88547. w: number;
  88548. h: number;
  88549. };
  88550. }): VertexData;
  88551. /**
  88552. * Creates the VertexData of the Ground designed from a heightmap
  88553. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  88554. * * width the width (x direction) of the ground
  88555. * * height the height (z direction) of the ground
  88556. * * subdivisions the number of subdivisions per side
  88557. * * minHeight the minimum altitude on the ground, optional, default 0
  88558. * * maxHeight the maximum altitude on the ground, optional default 1
  88559. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  88560. * * buffer the array holding the image color data
  88561. * * bufferWidth the width of image
  88562. * * bufferHeight the height of image
  88563. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  88564. * @returns the VertexData of the Ground designed from a heightmap
  88565. */
  88566. static CreateGroundFromHeightMap(options: {
  88567. width: number;
  88568. height: number;
  88569. subdivisions: number;
  88570. minHeight: number;
  88571. maxHeight: number;
  88572. colorFilter: Color3;
  88573. buffer: Uint8Array;
  88574. bufferWidth: number;
  88575. bufferHeight: number;
  88576. alphaFilter: number;
  88577. }): VertexData;
  88578. /**
  88579. * Creates the VertexData for a Plane
  88580. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  88581. * * size sets the width and height of the plane to the value of size, optional default 1
  88582. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  88583. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  88584. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88585. * * 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)
  88586. * * 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)
  88587. * @returns the VertexData of the box
  88588. */
  88589. static CreatePlane(options: {
  88590. size?: number;
  88591. width?: number;
  88592. height?: number;
  88593. sideOrientation?: number;
  88594. frontUVs?: Vector4;
  88595. backUVs?: Vector4;
  88596. }): VertexData;
  88597. /**
  88598. * Creates the VertexData of the Disc or regular Polygon
  88599. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  88600. * * radius the radius of the disc, optional default 0.5
  88601. * * tessellation the number of polygon sides, optional, default 64
  88602. * * 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
  88603. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88604. * * 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)
  88605. * * 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)
  88606. * @returns the VertexData of the box
  88607. */
  88608. static CreateDisc(options: {
  88609. radius?: number;
  88610. tessellation?: number;
  88611. arc?: number;
  88612. sideOrientation?: number;
  88613. frontUVs?: Vector4;
  88614. backUVs?: Vector4;
  88615. }): VertexData;
  88616. /**
  88617. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  88618. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  88619. * @param polygon a mesh built from polygonTriangulation.build()
  88620. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88621. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88622. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88623. * @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)
  88624. * @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)
  88625. * @returns the VertexData of the Polygon
  88626. */
  88627. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  88628. /**
  88629. * Creates the VertexData of the IcoSphere
  88630. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  88631. * * radius the radius of the IcoSphere, optional default 1
  88632. * * radiusX allows stretching in the x direction, optional, default radius
  88633. * * radiusY allows stretching in the y direction, optional, default radius
  88634. * * radiusZ allows stretching in the z direction, optional, default radius
  88635. * * flat when true creates a flat shaded mesh, optional, default true
  88636. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88637. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88638. * * 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)
  88639. * * 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)
  88640. * @returns the VertexData of the IcoSphere
  88641. */
  88642. static CreateIcoSphere(options: {
  88643. radius?: number;
  88644. radiusX?: number;
  88645. radiusY?: number;
  88646. radiusZ?: number;
  88647. flat?: boolean;
  88648. subdivisions?: number;
  88649. sideOrientation?: number;
  88650. frontUVs?: Vector4;
  88651. backUVs?: Vector4;
  88652. }): VertexData;
  88653. /**
  88654. * Creates the VertexData for a Polyhedron
  88655. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  88656. * * type provided types are:
  88657. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  88658. * * 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)
  88659. * * size the size of the IcoSphere, optional default 1
  88660. * * sizeX allows stretching in the x direction, optional, default size
  88661. * * sizeY allows stretching in the y direction, optional, default size
  88662. * * sizeZ allows stretching in the z direction, optional, default size
  88663. * * 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
  88664. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88665. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88666. * * flat when true creates a flat shaded mesh, optional, default true
  88667. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88668. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88669. * * 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)
  88670. * * 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)
  88671. * @returns the VertexData of the Polyhedron
  88672. */
  88673. static CreatePolyhedron(options: {
  88674. type?: number;
  88675. size?: number;
  88676. sizeX?: number;
  88677. sizeY?: number;
  88678. sizeZ?: number;
  88679. custom?: any;
  88680. faceUV?: Vector4[];
  88681. faceColors?: Color4[];
  88682. flat?: boolean;
  88683. sideOrientation?: number;
  88684. frontUVs?: Vector4;
  88685. backUVs?: Vector4;
  88686. }): VertexData;
  88687. /**
  88688. * Creates the VertexData for a TorusKnot
  88689. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  88690. * * radius the radius of the torus knot, optional, default 2
  88691. * * tube the thickness of the tube, optional, default 0.5
  88692. * * radialSegments the number of sides on each tube segments, optional, default 32
  88693. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  88694. * * p the number of windings around the z axis, optional, default 2
  88695. * * q the number of windings around the x axis, optional, default 3
  88696. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88697. * * 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)
  88698. * * 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)
  88699. * @returns the VertexData of the Torus Knot
  88700. */
  88701. static CreateTorusKnot(options: {
  88702. radius?: number;
  88703. tube?: number;
  88704. radialSegments?: number;
  88705. tubularSegments?: number;
  88706. p?: number;
  88707. q?: number;
  88708. sideOrientation?: number;
  88709. frontUVs?: Vector4;
  88710. backUVs?: Vector4;
  88711. }): VertexData;
  88712. /**
  88713. * Compute normals for given positions and indices
  88714. * @param positions an array of vertex positions, [...., x, y, z, ......]
  88715. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  88716. * @param normals an array of vertex normals, [...., x, y, z, ......]
  88717. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  88718. * * facetNormals : optional array of facet normals (vector3)
  88719. * * facetPositions : optional array of facet positions (vector3)
  88720. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  88721. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  88722. * * bInfo : optional bounding info, required for facetPartitioning computation
  88723. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  88724. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  88725. * * useRightHandedSystem: optional boolean to for right handed system computation
  88726. * * depthSort : optional boolean to enable the facet depth sort computation
  88727. * * distanceTo : optional Vector3 to compute the facet depth from this location
  88728. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  88729. */
  88730. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  88731. facetNormals?: any;
  88732. facetPositions?: any;
  88733. facetPartitioning?: any;
  88734. ratio?: number;
  88735. bInfo?: any;
  88736. bbSize?: Vector3;
  88737. subDiv?: any;
  88738. useRightHandedSystem?: boolean;
  88739. depthSort?: boolean;
  88740. distanceTo?: Vector3;
  88741. depthSortedFacets?: any;
  88742. }): void;
  88743. /** @hidden */
  88744. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  88745. /**
  88746. * Applies VertexData created from the imported parameters to the geometry
  88747. * @param parsedVertexData the parsed data from an imported file
  88748. * @param geometry the geometry to apply the VertexData to
  88749. */
  88750. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  88751. }
  88752. }
  88753. declare module BABYLON {
  88754. /**
  88755. * Defines a target to use with MorphTargetManager
  88756. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88757. */
  88758. export class MorphTarget implements IAnimatable {
  88759. /** defines the name of the target */
  88760. name: string;
  88761. /**
  88762. * Gets or sets the list of animations
  88763. */
  88764. animations: Animation[];
  88765. private _scene;
  88766. private _positions;
  88767. private _normals;
  88768. private _tangents;
  88769. private _uvs;
  88770. private _influence;
  88771. /**
  88772. * Observable raised when the influence changes
  88773. */
  88774. onInfluenceChanged: Observable<boolean>;
  88775. /** @hidden */
  88776. _onDataLayoutChanged: Observable<void>;
  88777. /**
  88778. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  88779. */
  88780. influence: number;
  88781. /**
  88782. * Gets or sets the id of the morph Target
  88783. */
  88784. id: string;
  88785. private _animationPropertiesOverride;
  88786. /**
  88787. * Gets or sets the animation properties override
  88788. */
  88789. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88790. /**
  88791. * Creates a new MorphTarget
  88792. * @param name defines the name of the target
  88793. * @param influence defines the influence to use
  88794. * @param scene defines the scene the morphtarget belongs to
  88795. */
  88796. constructor(
  88797. /** defines the name of the target */
  88798. name: string, influence?: number, scene?: Nullable<Scene>);
  88799. /**
  88800. * Gets a boolean defining if the target contains position data
  88801. */
  88802. readonly hasPositions: boolean;
  88803. /**
  88804. * Gets a boolean defining if the target contains normal data
  88805. */
  88806. readonly hasNormals: boolean;
  88807. /**
  88808. * Gets a boolean defining if the target contains tangent data
  88809. */
  88810. readonly hasTangents: boolean;
  88811. /**
  88812. * Gets a boolean defining if the target contains texture coordinates data
  88813. */
  88814. readonly hasUVs: boolean;
  88815. /**
  88816. * Affects position data to this target
  88817. * @param data defines the position data to use
  88818. */
  88819. setPositions(data: Nullable<FloatArray>): void;
  88820. /**
  88821. * Gets the position data stored in this target
  88822. * @returns a FloatArray containing the position data (or null if not present)
  88823. */
  88824. getPositions(): Nullable<FloatArray>;
  88825. /**
  88826. * Affects normal data to this target
  88827. * @param data defines the normal data to use
  88828. */
  88829. setNormals(data: Nullable<FloatArray>): void;
  88830. /**
  88831. * Gets the normal data stored in this target
  88832. * @returns a FloatArray containing the normal data (or null if not present)
  88833. */
  88834. getNormals(): Nullable<FloatArray>;
  88835. /**
  88836. * Affects tangent data to this target
  88837. * @param data defines the tangent data to use
  88838. */
  88839. setTangents(data: Nullable<FloatArray>): void;
  88840. /**
  88841. * Gets the tangent data stored in this target
  88842. * @returns a FloatArray containing the tangent data (or null if not present)
  88843. */
  88844. getTangents(): Nullable<FloatArray>;
  88845. /**
  88846. * Affects texture coordinates data to this target
  88847. * @param data defines the texture coordinates data to use
  88848. */
  88849. setUVs(data: Nullable<FloatArray>): void;
  88850. /**
  88851. * Gets the texture coordinates data stored in this target
  88852. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  88853. */
  88854. getUVs(): Nullable<FloatArray>;
  88855. /**
  88856. * Serializes the current target into a Serialization object
  88857. * @returns the serialized object
  88858. */
  88859. serialize(): any;
  88860. /**
  88861. * Returns the string "MorphTarget"
  88862. * @returns "MorphTarget"
  88863. */
  88864. getClassName(): string;
  88865. /**
  88866. * Creates a new target from serialized data
  88867. * @param serializationObject defines the serialized data to use
  88868. * @returns a new MorphTarget
  88869. */
  88870. static Parse(serializationObject: any): MorphTarget;
  88871. /**
  88872. * Creates a MorphTarget from mesh data
  88873. * @param mesh defines the source mesh
  88874. * @param name defines the name to use for the new target
  88875. * @param influence defines the influence to attach to the target
  88876. * @returns a new MorphTarget
  88877. */
  88878. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  88879. }
  88880. }
  88881. declare module BABYLON {
  88882. /**
  88883. * This class is used to deform meshes using morphing between different targets
  88884. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88885. */
  88886. export class MorphTargetManager {
  88887. private _targets;
  88888. private _targetInfluenceChangedObservers;
  88889. private _targetDataLayoutChangedObservers;
  88890. private _activeTargets;
  88891. private _scene;
  88892. private _influences;
  88893. private _supportsNormals;
  88894. private _supportsTangents;
  88895. private _supportsUVs;
  88896. private _vertexCount;
  88897. private _uniqueId;
  88898. private _tempInfluences;
  88899. /**
  88900. * Gets or sets a boolean indicating if normals must be morphed
  88901. */
  88902. enableNormalMorphing: boolean;
  88903. /**
  88904. * Gets or sets a boolean indicating if tangents must be morphed
  88905. */
  88906. enableTangentMorphing: boolean;
  88907. /**
  88908. * Gets or sets a boolean indicating if UV must be morphed
  88909. */
  88910. enableUVMorphing: boolean;
  88911. /**
  88912. * Creates a new MorphTargetManager
  88913. * @param scene defines the current scene
  88914. */
  88915. constructor(scene?: Nullable<Scene>);
  88916. /**
  88917. * Gets the unique ID of this manager
  88918. */
  88919. readonly uniqueId: number;
  88920. /**
  88921. * Gets the number of vertices handled by this manager
  88922. */
  88923. readonly vertexCount: number;
  88924. /**
  88925. * Gets a boolean indicating if this manager supports morphing of normals
  88926. */
  88927. readonly supportsNormals: boolean;
  88928. /**
  88929. * Gets a boolean indicating if this manager supports morphing of tangents
  88930. */
  88931. readonly supportsTangents: boolean;
  88932. /**
  88933. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  88934. */
  88935. readonly supportsUVs: boolean;
  88936. /**
  88937. * Gets the number of targets stored in this manager
  88938. */
  88939. readonly numTargets: number;
  88940. /**
  88941. * Gets the number of influencers (ie. the number of targets with influences > 0)
  88942. */
  88943. readonly numInfluencers: number;
  88944. /**
  88945. * Gets the list of influences (one per target)
  88946. */
  88947. readonly influences: Float32Array;
  88948. /**
  88949. * Gets the active target at specified index. An active target is a target with an influence > 0
  88950. * @param index defines the index to check
  88951. * @returns the requested target
  88952. */
  88953. getActiveTarget(index: number): MorphTarget;
  88954. /**
  88955. * Gets the target at specified index
  88956. * @param index defines the index to check
  88957. * @returns the requested target
  88958. */
  88959. getTarget(index: number): MorphTarget;
  88960. /**
  88961. * Add a new target to this manager
  88962. * @param target defines the target to add
  88963. */
  88964. addTarget(target: MorphTarget): void;
  88965. /**
  88966. * Removes a target from the manager
  88967. * @param target defines the target to remove
  88968. */
  88969. removeTarget(target: MorphTarget): void;
  88970. /**
  88971. * Serializes the current manager into a Serialization object
  88972. * @returns the serialized object
  88973. */
  88974. serialize(): any;
  88975. private _syncActiveTargets;
  88976. /**
  88977. * Syncrhonize the targets with all the meshes using this morph target manager
  88978. */
  88979. synchronize(): void;
  88980. /**
  88981. * Creates a new MorphTargetManager from serialized data
  88982. * @param serializationObject defines the serialized data
  88983. * @param scene defines the hosting scene
  88984. * @returns the new MorphTargetManager
  88985. */
  88986. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  88987. }
  88988. }
  88989. declare module BABYLON {
  88990. /**
  88991. * Class used to represent a specific level of detail of a mesh
  88992. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  88993. */
  88994. export class MeshLODLevel {
  88995. /** Defines the distance where this level should start being displayed */
  88996. distance: number;
  88997. /** Defines the mesh to use to render this level */
  88998. mesh: Nullable<Mesh>;
  88999. /**
  89000. * Creates a new LOD level
  89001. * @param distance defines the distance where this level should star being displayed
  89002. * @param mesh defines the mesh to use to render this level
  89003. */
  89004. constructor(
  89005. /** Defines the distance where this level should start being displayed */
  89006. distance: number,
  89007. /** Defines the mesh to use to render this level */
  89008. mesh: Nullable<Mesh>);
  89009. }
  89010. }
  89011. declare module BABYLON {
  89012. /**
  89013. * Mesh representing the gorund
  89014. */
  89015. export class GroundMesh extends Mesh {
  89016. /** If octree should be generated */
  89017. generateOctree: boolean;
  89018. private _heightQuads;
  89019. /** @hidden */
  89020. _subdivisionsX: number;
  89021. /** @hidden */
  89022. _subdivisionsY: number;
  89023. /** @hidden */
  89024. _width: number;
  89025. /** @hidden */
  89026. _height: number;
  89027. /** @hidden */
  89028. _minX: number;
  89029. /** @hidden */
  89030. _maxX: number;
  89031. /** @hidden */
  89032. _minZ: number;
  89033. /** @hidden */
  89034. _maxZ: number;
  89035. constructor(name: string, scene: Scene);
  89036. /**
  89037. * "GroundMesh"
  89038. * @returns "GroundMesh"
  89039. */
  89040. getClassName(): string;
  89041. /**
  89042. * The minimum of x and y subdivisions
  89043. */
  89044. readonly subdivisions: number;
  89045. /**
  89046. * X subdivisions
  89047. */
  89048. readonly subdivisionsX: number;
  89049. /**
  89050. * Y subdivisions
  89051. */
  89052. readonly subdivisionsY: number;
  89053. /**
  89054. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  89055. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  89056. * @param chunksCount the number of subdivisions for x and y
  89057. * @param octreeBlocksSize (Default: 32)
  89058. */
  89059. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  89060. /**
  89061. * Returns a height (y) value in the Worl system :
  89062. * the ground altitude at the coordinates (x, z) expressed in the World system.
  89063. * @param x x coordinate
  89064. * @param z z coordinate
  89065. * @returns the ground y position if (x, z) are outside the ground surface.
  89066. */
  89067. getHeightAtCoordinates(x: number, z: number): number;
  89068. /**
  89069. * Returns a normalized vector (Vector3) orthogonal to the ground
  89070. * at the ground coordinates (x, z) expressed in the World system.
  89071. * @param x x coordinate
  89072. * @param z z coordinate
  89073. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  89074. */
  89075. getNormalAtCoordinates(x: number, z: number): Vector3;
  89076. /**
  89077. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  89078. * at the ground coordinates (x, z) expressed in the World system.
  89079. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  89080. * @param x x coordinate
  89081. * @param z z coordinate
  89082. * @param ref vector to store the result
  89083. * @returns the GroundMesh.
  89084. */
  89085. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  89086. /**
  89087. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  89088. * if the ground has been updated.
  89089. * This can be used in the render loop.
  89090. * @returns the GroundMesh.
  89091. */
  89092. updateCoordinateHeights(): GroundMesh;
  89093. private _getFacetAt;
  89094. private _initHeightQuads;
  89095. private _computeHeightQuads;
  89096. /**
  89097. * Serializes this ground mesh
  89098. * @param serializationObject object to write serialization to
  89099. */
  89100. serialize(serializationObject: any): void;
  89101. /**
  89102. * Parses a serialized ground mesh
  89103. * @param parsedMesh the serialized mesh
  89104. * @param scene the scene to create the ground mesh in
  89105. * @returns the created ground mesh
  89106. */
  89107. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  89108. }
  89109. }
  89110. declare module BABYLON {
  89111. /**
  89112. * Interface for Physics-Joint data
  89113. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89114. */
  89115. export interface PhysicsJointData {
  89116. /**
  89117. * The main pivot of the joint
  89118. */
  89119. mainPivot?: Vector3;
  89120. /**
  89121. * The connected pivot of the joint
  89122. */
  89123. connectedPivot?: Vector3;
  89124. /**
  89125. * The main axis of the joint
  89126. */
  89127. mainAxis?: Vector3;
  89128. /**
  89129. * The connected axis of the joint
  89130. */
  89131. connectedAxis?: Vector3;
  89132. /**
  89133. * The collision of the joint
  89134. */
  89135. collision?: boolean;
  89136. /**
  89137. * Native Oimo/Cannon/Energy data
  89138. */
  89139. nativeParams?: any;
  89140. }
  89141. /**
  89142. * This is a holder class for the physics joint created by the physics plugin
  89143. * It holds a set of functions to control the underlying joint
  89144. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89145. */
  89146. export class PhysicsJoint {
  89147. /**
  89148. * The type of the physics joint
  89149. */
  89150. type: number;
  89151. /**
  89152. * The data for the physics joint
  89153. */
  89154. jointData: PhysicsJointData;
  89155. private _physicsJoint;
  89156. protected _physicsPlugin: IPhysicsEnginePlugin;
  89157. /**
  89158. * Initializes the physics joint
  89159. * @param type The type of the physics joint
  89160. * @param jointData The data for the physics joint
  89161. */
  89162. constructor(
  89163. /**
  89164. * The type of the physics joint
  89165. */
  89166. type: number,
  89167. /**
  89168. * The data for the physics joint
  89169. */
  89170. jointData: PhysicsJointData);
  89171. /**
  89172. * Gets the physics joint
  89173. */
  89174. /**
  89175. * Sets the physics joint
  89176. */
  89177. physicsJoint: any;
  89178. /**
  89179. * Sets the physics plugin
  89180. */
  89181. physicsPlugin: IPhysicsEnginePlugin;
  89182. /**
  89183. * Execute a function that is physics-plugin specific.
  89184. * @param {Function} func the function that will be executed.
  89185. * It accepts two parameters: the physics world and the physics joint
  89186. */
  89187. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  89188. /**
  89189. * Distance-Joint type
  89190. */
  89191. static DistanceJoint: number;
  89192. /**
  89193. * Hinge-Joint type
  89194. */
  89195. static HingeJoint: number;
  89196. /**
  89197. * Ball-and-Socket joint type
  89198. */
  89199. static BallAndSocketJoint: number;
  89200. /**
  89201. * Wheel-Joint type
  89202. */
  89203. static WheelJoint: number;
  89204. /**
  89205. * Slider-Joint type
  89206. */
  89207. static SliderJoint: number;
  89208. /**
  89209. * Prismatic-Joint type
  89210. */
  89211. static PrismaticJoint: number;
  89212. /**
  89213. * Universal-Joint type
  89214. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  89215. */
  89216. static UniversalJoint: number;
  89217. /**
  89218. * Hinge-Joint 2 type
  89219. */
  89220. static Hinge2Joint: number;
  89221. /**
  89222. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  89223. */
  89224. static PointToPointJoint: number;
  89225. /**
  89226. * Spring-Joint type
  89227. */
  89228. static SpringJoint: number;
  89229. /**
  89230. * Lock-Joint type
  89231. */
  89232. static LockJoint: number;
  89233. }
  89234. /**
  89235. * A class representing a physics distance joint
  89236. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89237. */
  89238. export class DistanceJoint extends PhysicsJoint {
  89239. /**
  89240. *
  89241. * @param jointData The data for the Distance-Joint
  89242. */
  89243. constructor(jointData: DistanceJointData);
  89244. /**
  89245. * Update the predefined distance.
  89246. * @param maxDistance The maximum preferred distance
  89247. * @param minDistance The minimum preferred distance
  89248. */
  89249. updateDistance(maxDistance: number, minDistance?: number): void;
  89250. }
  89251. /**
  89252. * Represents a Motor-Enabled Joint
  89253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89254. */
  89255. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  89256. /**
  89257. * Initializes the Motor-Enabled Joint
  89258. * @param type The type of the joint
  89259. * @param jointData The physica joint data for the joint
  89260. */
  89261. constructor(type: number, jointData: PhysicsJointData);
  89262. /**
  89263. * Set the motor values.
  89264. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89265. * @param force the force to apply
  89266. * @param maxForce max force for this motor.
  89267. */
  89268. setMotor(force?: number, maxForce?: number): void;
  89269. /**
  89270. * Set the motor's limits.
  89271. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89272. * @param upperLimit The upper limit of the motor
  89273. * @param lowerLimit The lower limit of the motor
  89274. */
  89275. setLimit(upperLimit: number, lowerLimit?: number): void;
  89276. }
  89277. /**
  89278. * This class represents a single physics Hinge-Joint
  89279. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89280. */
  89281. export class HingeJoint extends MotorEnabledJoint {
  89282. /**
  89283. * Initializes the Hinge-Joint
  89284. * @param jointData The joint data for the Hinge-Joint
  89285. */
  89286. constructor(jointData: PhysicsJointData);
  89287. /**
  89288. * Set the motor values.
  89289. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89290. * @param {number} force the force to apply
  89291. * @param {number} maxForce max force for this motor.
  89292. */
  89293. setMotor(force?: number, maxForce?: number): void;
  89294. /**
  89295. * Set the motor's limits.
  89296. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89297. * @param upperLimit The upper limit of the motor
  89298. * @param lowerLimit The lower limit of the motor
  89299. */
  89300. setLimit(upperLimit: number, lowerLimit?: number): void;
  89301. }
  89302. /**
  89303. * This class represents a dual hinge physics joint (same as wheel joint)
  89304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89305. */
  89306. export class Hinge2Joint extends MotorEnabledJoint {
  89307. /**
  89308. * Initializes the Hinge2-Joint
  89309. * @param jointData The joint data for the Hinge2-Joint
  89310. */
  89311. constructor(jointData: PhysicsJointData);
  89312. /**
  89313. * Set the motor values.
  89314. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89315. * @param {number} targetSpeed the speed the motor is to reach
  89316. * @param {number} maxForce max force for this motor.
  89317. * @param {motorIndex} the motor's index, 0 or 1.
  89318. */
  89319. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  89320. /**
  89321. * Set the motor limits.
  89322. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89323. * @param {number} upperLimit the upper limit
  89324. * @param {number} lowerLimit lower limit
  89325. * @param {motorIndex} the motor's index, 0 or 1.
  89326. */
  89327. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89328. }
  89329. /**
  89330. * Interface for a motor enabled joint
  89331. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89332. */
  89333. export interface IMotorEnabledJoint {
  89334. /**
  89335. * Physics joint
  89336. */
  89337. physicsJoint: any;
  89338. /**
  89339. * Sets the motor of the motor-enabled joint
  89340. * @param force The force of the motor
  89341. * @param maxForce The maximum force of the motor
  89342. * @param motorIndex The index of the motor
  89343. */
  89344. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  89345. /**
  89346. * Sets the limit of the motor
  89347. * @param upperLimit The upper limit of the motor
  89348. * @param lowerLimit The lower limit of the motor
  89349. * @param motorIndex The index of the motor
  89350. */
  89351. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89352. }
  89353. /**
  89354. * Joint data for a Distance-Joint
  89355. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89356. */
  89357. export interface DistanceJointData extends PhysicsJointData {
  89358. /**
  89359. * Max distance the 2 joint objects can be apart
  89360. */
  89361. maxDistance: number;
  89362. }
  89363. /**
  89364. * Joint data from a spring joint
  89365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89366. */
  89367. export interface SpringJointData extends PhysicsJointData {
  89368. /**
  89369. * Length of the spring
  89370. */
  89371. length: number;
  89372. /**
  89373. * Stiffness of the spring
  89374. */
  89375. stiffness: number;
  89376. /**
  89377. * Damping of the spring
  89378. */
  89379. damping: number;
  89380. /** this callback will be called when applying the force to the impostors. */
  89381. forceApplicationCallback: () => void;
  89382. }
  89383. }
  89384. declare module BABYLON {
  89385. /**
  89386. * Holds the data for the raycast result
  89387. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89388. */
  89389. export class PhysicsRaycastResult {
  89390. private _hasHit;
  89391. private _hitDistance;
  89392. private _hitNormalWorld;
  89393. private _hitPointWorld;
  89394. private _rayFromWorld;
  89395. private _rayToWorld;
  89396. /**
  89397. * Gets if there was a hit
  89398. */
  89399. readonly hasHit: boolean;
  89400. /**
  89401. * Gets the distance from the hit
  89402. */
  89403. readonly hitDistance: number;
  89404. /**
  89405. * Gets the hit normal/direction in the world
  89406. */
  89407. readonly hitNormalWorld: Vector3;
  89408. /**
  89409. * Gets the hit point in the world
  89410. */
  89411. readonly hitPointWorld: Vector3;
  89412. /**
  89413. * Gets the ray "start point" of the ray in the world
  89414. */
  89415. readonly rayFromWorld: Vector3;
  89416. /**
  89417. * Gets the ray "end point" of the ray in the world
  89418. */
  89419. readonly rayToWorld: Vector3;
  89420. /**
  89421. * Sets the hit data (normal & point in world space)
  89422. * @param hitNormalWorld defines the normal in world space
  89423. * @param hitPointWorld defines the point in world space
  89424. */
  89425. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  89426. /**
  89427. * Sets the distance from the start point to the hit point
  89428. * @param distance
  89429. */
  89430. setHitDistance(distance: number): void;
  89431. /**
  89432. * Calculates the distance manually
  89433. */
  89434. calculateHitDistance(): void;
  89435. /**
  89436. * Resets all the values to default
  89437. * @param from The from point on world space
  89438. * @param to The to point on world space
  89439. */
  89440. reset(from?: Vector3, to?: Vector3): void;
  89441. }
  89442. /**
  89443. * Interface for the size containing width and height
  89444. */
  89445. interface IXYZ {
  89446. /**
  89447. * X
  89448. */
  89449. x: number;
  89450. /**
  89451. * Y
  89452. */
  89453. y: number;
  89454. /**
  89455. * Z
  89456. */
  89457. z: number;
  89458. }
  89459. }
  89460. declare module BABYLON {
  89461. /**
  89462. * Interface used to describe a physics joint
  89463. */
  89464. export interface PhysicsImpostorJoint {
  89465. /** Defines the main impostor to which the joint is linked */
  89466. mainImpostor: PhysicsImpostor;
  89467. /** Defines the impostor that is connected to the main impostor using this joint */
  89468. connectedImpostor: PhysicsImpostor;
  89469. /** Defines the joint itself */
  89470. joint: PhysicsJoint;
  89471. }
  89472. /** @hidden */
  89473. export interface IPhysicsEnginePlugin {
  89474. world: any;
  89475. name: string;
  89476. setGravity(gravity: Vector3): void;
  89477. setTimeStep(timeStep: number): void;
  89478. getTimeStep(): number;
  89479. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  89480. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89481. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89482. generatePhysicsBody(impostor: PhysicsImpostor): void;
  89483. removePhysicsBody(impostor: PhysicsImpostor): void;
  89484. generateJoint(joint: PhysicsImpostorJoint): void;
  89485. removeJoint(joint: PhysicsImpostorJoint): void;
  89486. isSupported(): boolean;
  89487. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  89488. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  89489. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89490. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89491. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89492. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89493. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  89494. getBodyMass(impostor: PhysicsImpostor): number;
  89495. getBodyFriction(impostor: PhysicsImpostor): number;
  89496. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  89497. getBodyRestitution(impostor: PhysicsImpostor): number;
  89498. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  89499. getBodyPressure?(impostor: PhysicsImpostor): number;
  89500. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  89501. getBodyStiffness?(impostor: PhysicsImpostor): number;
  89502. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  89503. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  89504. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  89505. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  89506. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  89507. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89508. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89509. sleepBody(impostor: PhysicsImpostor): void;
  89510. wakeUpBody(impostor: PhysicsImpostor): void;
  89511. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89512. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  89513. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  89514. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89515. getRadius(impostor: PhysicsImpostor): number;
  89516. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  89517. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  89518. dispose(): void;
  89519. }
  89520. /**
  89521. * Interface used to define a physics engine
  89522. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  89523. */
  89524. export interface IPhysicsEngine {
  89525. /**
  89526. * Gets the gravity vector used by the simulation
  89527. */
  89528. gravity: Vector3;
  89529. /**
  89530. * Sets the gravity vector used by the simulation
  89531. * @param gravity defines the gravity vector to use
  89532. */
  89533. setGravity(gravity: Vector3): void;
  89534. /**
  89535. * Set the time step of the physics engine.
  89536. * Default is 1/60.
  89537. * To slow it down, enter 1/600 for example.
  89538. * To speed it up, 1/30
  89539. * @param newTimeStep the new timestep to apply to this world.
  89540. */
  89541. setTimeStep(newTimeStep: number): void;
  89542. /**
  89543. * Get the time step of the physics engine.
  89544. * @returns the current time step
  89545. */
  89546. getTimeStep(): number;
  89547. /**
  89548. * Release all resources
  89549. */
  89550. dispose(): void;
  89551. /**
  89552. * Gets the name of the current physics plugin
  89553. * @returns the name of the plugin
  89554. */
  89555. getPhysicsPluginName(): string;
  89556. /**
  89557. * Adding a new impostor for the impostor tracking.
  89558. * This will be done by the impostor itself.
  89559. * @param impostor the impostor to add
  89560. */
  89561. addImpostor(impostor: PhysicsImpostor): void;
  89562. /**
  89563. * Remove an impostor from the engine.
  89564. * This impostor and its mesh will not longer be updated by the physics engine.
  89565. * @param impostor the impostor to remove
  89566. */
  89567. removeImpostor(impostor: PhysicsImpostor): void;
  89568. /**
  89569. * Add a joint to the physics engine
  89570. * @param mainImpostor defines the main impostor to which the joint is added.
  89571. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  89572. * @param joint defines the joint that will connect both impostors.
  89573. */
  89574. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89575. /**
  89576. * Removes a joint from the simulation
  89577. * @param mainImpostor defines the impostor used with the joint
  89578. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  89579. * @param joint defines the joint to remove
  89580. */
  89581. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89582. /**
  89583. * Gets the current plugin used to run the simulation
  89584. * @returns current plugin
  89585. */
  89586. getPhysicsPlugin(): IPhysicsEnginePlugin;
  89587. /**
  89588. * Gets the list of physic impostors
  89589. * @returns an array of PhysicsImpostor
  89590. */
  89591. getImpostors(): Array<PhysicsImpostor>;
  89592. /**
  89593. * Gets the impostor for a physics enabled object
  89594. * @param object defines the object impersonated by the impostor
  89595. * @returns the PhysicsImpostor or null if not found
  89596. */
  89597. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89598. /**
  89599. * Gets the impostor for a physics body object
  89600. * @param body defines physics body used by the impostor
  89601. * @returns the PhysicsImpostor or null if not found
  89602. */
  89603. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  89604. /**
  89605. * Does a raycast in the physics world
  89606. * @param from when should the ray start?
  89607. * @param to when should the ray end?
  89608. * @returns PhysicsRaycastResult
  89609. */
  89610. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89611. /**
  89612. * Called by the scene. No need to call it.
  89613. * @param delta defines the timespam between frames
  89614. */
  89615. _step(delta: number): void;
  89616. }
  89617. }
  89618. declare module BABYLON {
  89619. /**
  89620. * The interface for the physics imposter parameters
  89621. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89622. */
  89623. export interface PhysicsImpostorParameters {
  89624. /**
  89625. * The mass of the physics imposter
  89626. */
  89627. mass: number;
  89628. /**
  89629. * The friction of the physics imposter
  89630. */
  89631. friction?: number;
  89632. /**
  89633. * The coefficient of restitution of the physics imposter
  89634. */
  89635. restitution?: number;
  89636. /**
  89637. * The native options of the physics imposter
  89638. */
  89639. nativeOptions?: any;
  89640. /**
  89641. * Specifies if the parent should be ignored
  89642. */
  89643. ignoreParent?: boolean;
  89644. /**
  89645. * Specifies if bi-directional transformations should be disabled
  89646. */
  89647. disableBidirectionalTransformation?: boolean;
  89648. /**
  89649. * The pressure inside the physics imposter, soft object only
  89650. */
  89651. pressure?: number;
  89652. /**
  89653. * The stiffness the physics imposter, soft object only
  89654. */
  89655. stiffness?: number;
  89656. /**
  89657. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  89658. */
  89659. velocityIterations?: number;
  89660. /**
  89661. * The number of iterations used in maintaining consistent vertex positions, soft object only
  89662. */
  89663. positionIterations?: number;
  89664. /**
  89665. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  89666. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  89667. * Add to fix multiple points
  89668. */
  89669. fixedPoints?: number;
  89670. /**
  89671. * The collision margin around a soft object
  89672. */
  89673. margin?: number;
  89674. /**
  89675. * The collision margin around a soft object
  89676. */
  89677. damping?: number;
  89678. /**
  89679. * The path for a rope based on an extrusion
  89680. */
  89681. path?: any;
  89682. /**
  89683. * The shape of an extrusion used for a rope based on an extrusion
  89684. */
  89685. shape?: any;
  89686. }
  89687. /**
  89688. * Interface for a physics-enabled object
  89689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89690. */
  89691. export interface IPhysicsEnabledObject {
  89692. /**
  89693. * The position of the physics-enabled object
  89694. */
  89695. position: Vector3;
  89696. /**
  89697. * The rotation of the physics-enabled object
  89698. */
  89699. rotationQuaternion: Nullable<Quaternion>;
  89700. /**
  89701. * The scale of the physics-enabled object
  89702. */
  89703. scaling: Vector3;
  89704. /**
  89705. * The rotation of the physics-enabled object
  89706. */
  89707. rotation?: Vector3;
  89708. /**
  89709. * The parent of the physics-enabled object
  89710. */
  89711. parent?: any;
  89712. /**
  89713. * The bounding info of the physics-enabled object
  89714. * @returns The bounding info of the physics-enabled object
  89715. */
  89716. getBoundingInfo(): BoundingInfo;
  89717. /**
  89718. * Computes the world matrix
  89719. * @param force Specifies if the world matrix should be computed by force
  89720. * @returns A world matrix
  89721. */
  89722. computeWorldMatrix(force: boolean): Matrix;
  89723. /**
  89724. * Gets the world matrix
  89725. * @returns A world matrix
  89726. */
  89727. getWorldMatrix?(): Matrix;
  89728. /**
  89729. * Gets the child meshes
  89730. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  89731. * @returns An array of abstract meshes
  89732. */
  89733. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  89734. /**
  89735. * Gets the vertex data
  89736. * @param kind The type of vertex data
  89737. * @returns A nullable array of numbers, or a float32 array
  89738. */
  89739. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  89740. /**
  89741. * Gets the indices from the mesh
  89742. * @returns A nullable array of index arrays
  89743. */
  89744. getIndices?(): Nullable<IndicesArray>;
  89745. /**
  89746. * Gets the scene from the mesh
  89747. * @returns the indices array or null
  89748. */
  89749. getScene?(): Scene;
  89750. /**
  89751. * Gets the absolute position from the mesh
  89752. * @returns the absolute position
  89753. */
  89754. getAbsolutePosition(): Vector3;
  89755. /**
  89756. * Gets the absolute pivot point from the mesh
  89757. * @returns the absolute pivot point
  89758. */
  89759. getAbsolutePivotPoint(): Vector3;
  89760. /**
  89761. * Rotates the mesh
  89762. * @param axis The axis of rotation
  89763. * @param amount The amount of rotation
  89764. * @param space The space of the rotation
  89765. * @returns The rotation transform node
  89766. */
  89767. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  89768. /**
  89769. * Translates the mesh
  89770. * @param axis The axis of translation
  89771. * @param distance The distance of translation
  89772. * @param space The space of the translation
  89773. * @returns The transform node
  89774. */
  89775. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  89776. /**
  89777. * Sets the absolute position of the mesh
  89778. * @param absolutePosition The absolute position of the mesh
  89779. * @returns The transform node
  89780. */
  89781. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89782. /**
  89783. * Gets the class name of the mesh
  89784. * @returns The class name
  89785. */
  89786. getClassName(): string;
  89787. }
  89788. /**
  89789. * Represents a physics imposter
  89790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89791. */
  89792. export class PhysicsImpostor {
  89793. /**
  89794. * The physics-enabled object used as the physics imposter
  89795. */
  89796. object: IPhysicsEnabledObject;
  89797. /**
  89798. * The type of the physics imposter
  89799. */
  89800. type: number;
  89801. private _options;
  89802. private _scene?;
  89803. /**
  89804. * The default object size of the imposter
  89805. */
  89806. static DEFAULT_OBJECT_SIZE: Vector3;
  89807. /**
  89808. * The identity quaternion of the imposter
  89809. */
  89810. static IDENTITY_QUATERNION: Quaternion;
  89811. /** @hidden */
  89812. _pluginData: any;
  89813. private _physicsEngine;
  89814. private _physicsBody;
  89815. private _bodyUpdateRequired;
  89816. private _onBeforePhysicsStepCallbacks;
  89817. private _onAfterPhysicsStepCallbacks;
  89818. /** @hidden */
  89819. _onPhysicsCollideCallbacks: Array<{
  89820. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  89821. otherImpostors: Array<PhysicsImpostor>;
  89822. }>;
  89823. private _deltaPosition;
  89824. private _deltaRotation;
  89825. private _deltaRotationConjugated;
  89826. /** @hidden */
  89827. _isFromLine: boolean;
  89828. private _parent;
  89829. private _isDisposed;
  89830. private static _tmpVecs;
  89831. private static _tmpQuat;
  89832. /**
  89833. * Specifies if the physics imposter is disposed
  89834. */
  89835. readonly isDisposed: boolean;
  89836. /**
  89837. * Gets the mass of the physics imposter
  89838. */
  89839. mass: number;
  89840. /**
  89841. * Gets the coefficient of friction
  89842. */
  89843. /**
  89844. * Sets the coefficient of friction
  89845. */
  89846. friction: number;
  89847. /**
  89848. * Gets the coefficient of restitution
  89849. */
  89850. /**
  89851. * Sets the coefficient of restitution
  89852. */
  89853. restitution: number;
  89854. /**
  89855. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  89856. */
  89857. /**
  89858. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  89859. */
  89860. pressure: number;
  89861. /**
  89862. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89863. */
  89864. /**
  89865. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89866. */
  89867. stiffness: number;
  89868. /**
  89869. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89870. */
  89871. /**
  89872. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89873. */
  89874. velocityIterations: number;
  89875. /**
  89876. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89877. */
  89878. /**
  89879. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89880. */
  89881. positionIterations: number;
  89882. /**
  89883. * The unique id of the physics imposter
  89884. * set by the physics engine when adding this impostor to the array
  89885. */
  89886. uniqueId: number;
  89887. /**
  89888. * @hidden
  89889. */
  89890. soft: boolean;
  89891. /**
  89892. * @hidden
  89893. */
  89894. segments: number;
  89895. private _joints;
  89896. /**
  89897. * Initializes the physics imposter
  89898. * @param object The physics-enabled object used as the physics imposter
  89899. * @param type The type of the physics imposter
  89900. * @param _options The options for the physics imposter
  89901. * @param _scene The Babylon scene
  89902. */
  89903. constructor(
  89904. /**
  89905. * The physics-enabled object used as the physics imposter
  89906. */
  89907. object: IPhysicsEnabledObject,
  89908. /**
  89909. * The type of the physics imposter
  89910. */
  89911. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  89912. /**
  89913. * This function will completly initialize this impostor.
  89914. * It will create a new body - but only if this mesh has no parent.
  89915. * If it has, this impostor will not be used other than to define the impostor
  89916. * of the child mesh.
  89917. * @hidden
  89918. */
  89919. _init(): void;
  89920. private _getPhysicsParent;
  89921. /**
  89922. * Should a new body be generated.
  89923. * @returns boolean specifying if body initialization is required
  89924. */
  89925. isBodyInitRequired(): boolean;
  89926. /**
  89927. * Sets the updated scaling
  89928. * @param updated Specifies if the scaling is updated
  89929. */
  89930. setScalingUpdated(): void;
  89931. /**
  89932. * Force a regeneration of this or the parent's impostor's body.
  89933. * Use under cautious - This will remove all joints already implemented.
  89934. */
  89935. forceUpdate(): void;
  89936. /**
  89937. * Gets the body that holds this impostor. Either its own, or its parent.
  89938. */
  89939. /**
  89940. * Set the physics body. Used mainly by the physics engine/plugin
  89941. */
  89942. physicsBody: any;
  89943. /**
  89944. * Get the parent of the physics imposter
  89945. * @returns Physics imposter or null
  89946. */
  89947. /**
  89948. * Sets the parent of the physics imposter
  89949. */
  89950. parent: Nullable<PhysicsImpostor>;
  89951. /**
  89952. * Resets the update flags
  89953. */
  89954. resetUpdateFlags(): void;
  89955. /**
  89956. * Gets the object extend size
  89957. * @returns the object extend size
  89958. */
  89959. getObjectExtendSize(): Vector3;
  89960. /**
  89961. * Gets the object center
  89962. * @returns The object center
  89963. */
  89964. getObjectCenter(): Vector3;
  89965. /**
  89966. * Get a specific parametes from the options parameter
  89967. * @param paramName The object parameter name
  89968. * @returns The object parameter
  89969. */
  89970. getParam(paramName: string): any;
  89971. /**
  89972. * Sets a specific parameter in the options given to the physics plugin
  89973. * @param paramName The parameter name
  89974. * @param value The value of the parameter
  89975. */
  89976. setParam(paramName: string, value: number): void;
  89977. /**
  89978. * Specifically change the body's mass option. Won't recreate the physics body object
  89979. * @param mass The mass of the physics imposter
  89980. */
  89981. setMass(mass: number): void;
  89982. /**
  89983. * Gets the linear velocity
  89984. * @returns linear velocity or null
  89985. */
  89986. getLinearVelocity(): Nullable<Vector3>;
  89987. /**
  89988. * Sets the linear velocity
  89989. * @param velocity linear velocity or null
  89990. */
  89991. setLinearVelocity(velocity: Nullable<Vector3>): void;
  89992. /**
  89993. * Gets the angular velocity
  89994. * @returns angular velocity or null
  89995. */
  89996. getAngularVelocity(): Nullable<Vector3>;
  89997. /**
  89998. * Sets the angular velocity
  89999. * @param velocity The velocity or null
  90000. */
  90001. setAngularVelocity(velocity: Nullable<Vector3>): void;
  90002. /**
  90003. * Execute a function with the physics plugin native code
  90004. * Provide a function the will have two variables - the world object and the physics body object
  90005. * @param func The function to execute with the physics plugin native code
  90006. */
  90007. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  90008. /**
  90009. * Register a function that will be executed before the physics world is stepping forward
  90010. * @param func The function to execute before the physics world is stepped forward
  90011. */
  90012. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90013. /**
  90014. * Unregister a function that will be executed before the physics world is stepping forward
  90015. * @param func The function to execute before the physics world is stepped forward
  90016. */
  90017. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90018. /**
  90019. * Register a function that will be executed after the physics step
  90020. * @param func The function to execute after physics step
  90021. */
  90022. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90023. /**
  90024. * Unregisters a function that will be executed after the physics step
  90025. * @param func The function to execute after physics step
  90026. */
  90027. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90028. /**
  90029. * register a function that will be executed when this impostor collides against a different body
  90030. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  90031. * @param func Callback that is executed on collision
  90032. */
  90033. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  90034. /**
  90035. * Unregisters the physics imposter on contact
  90036. * @param collideAgainst The physics object to collide against
  90037. * @param func Callback to execute on collision
  90038. */
  90039. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  90040. private _tmpQuat;
  90041. private _tmpQuat2;
  90042. /**
  90043. * Get the parent rotation
  90044. * @returns The parent rotation
  90045. */
  90046. getParentsRotation(): Quaternion;
  90047. /**
  90048. * this function is executed by the physics engine.
  90049. */
  90050. beforeStep: () => void;
  90051. /**
  90052. * this function is executed by the physics engine
  90053. */
  90054. afterStep: () => void;
  90055. /**
  90056. * Legacy collision detection event support
  90057. */
  90058. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  90059. /**
  90060. * event and body object due to cannon's event-based architecture.
  90061. */
  90062. onCollide: (e: {
  90063. body: any;
  90064. }) => void;
  90065. /**
  90066. * Apply a force
  90067. * @param force The force to apply
  90068. * @param contactPoint The contact point for the force
  90069. * @returns The physics imposter
  90070. */
  90071. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90072. /**
  90073. * Apply an impulse
  90074. * @param force The impulse force
  90075. * @param contactPoint The contact point for the impulse force
  90076. * @returns The physics imposter
  90077. */
  90078. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90079. /**
  90080. * A help function to create a joint
  90081. * @param otherImpostor A physics imposter used to create a joint
  90082. * @param jointType The type of joint
  90083. * @param jointData The data for the joint
  90084. * @returns The physics imposter
  90085. */
  90086. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  90087. /**
  90088. * Add a joint to this impostor with a different impostor
  90089. * @param otherImpostor A physics imposter used to add a joint
  90090. * @param joint The joint to add
  90091. * @returns The physics imposter
  90092. */
  90093. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  90094. /**
  90095. * Add an anchor to a cloth impostor
  90096. * @param otherImpostor rigid impostor to anchor to
  90097. * @param width ratio across width from 0 to 1
  90098. * @param height ratio up height from 0 to 1
  90099. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  90100. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  90101. * @returns impostor the soft imposter
  90102. */
  90103. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90104. /**
  90105. * Add a hook to a rope impostor
  90106. * @param otherImpostor rigid impostor to anchor to
  90107. * @param length ratio across rope from 0 to 1
  90108. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  90109. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  90110. * @returns impostor the rope imposter
  90111. */
  90112. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90113. /**
  90114. * Will keep this body still, in a sleep mode.
  90115. * @returns the physics imposter
  90116. */
  90117. sleep(): PhysicsImpostor;
  90118. /**
  90119. * Wake the body up.
  90120. * @returns The physics imposter
  90121. */
  90122. wakeUp(): PhysicsImpostor;
  90123. /**
  90124. * Clones the physics imposter
  90125. * @param newObject The physics imposter clones to this physics-enabled object
  90126. * @returns A nullable physics imposter
  90127. */
  90128. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90129. /**
  90130. * Disposes the physics imposter
  90131. */
  90132. dispose(): void;
  90133. /**
  90134. * Sets the delta position
  90135. * @param position The delta position amount
  90136. */
  90137. setDeltaPosition(position: Vector3): void;
  90138. /**
  90139. * Sets the delta rotation
  90140. * @param rotation The delta rotation amount
  90141. */
  90142. setDeltaRotation(rotation: Quaternion): void;
  90143. /**
  90144. * Gets the box size of the physics imposter and stores the result in the input parameter
  90145. * @param result Stores the box size
  90146. * @returns The physics imposter
  90147. */
  90148. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  90149. /**
  90150. * Gets the radius of the physics imposter
  90151. * @returns Radius of the physics imposter
  90152. */
  90153. getRadius(): number;
  90154. /**
  90155. * Sync a bone with this impostor
  90156. * @param bone The bone to sync to the impostor.
  90157. * @param boneMesh The mesh that the bone is influencing.
  90158. * @param jointPivot The pivot of the joint / bone in local space.
  90159. * @param distToJoint Optional distance from the impostor to the joint.
  90160. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90161. */
  90162. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  90163. /**
  90164. * Sync impostor to a bone
  90165. * @param bone The bone that the impostor will be synced to.
  90166. * @param boneMesh The mesh that the bone is influencing.
  90167. * @param jointPivot The pivot of the joint / bone in local space.
  90168. * @param distToJoint Optional distance from the impostor to the joint.
  90169. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90170. * @param boneAxis Optional vector3 axis the bone is aligned with
  90171. */
  90172. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  90173. /**
  90174. * No-Imposter type
  90175. */
  90176. static NoImpostor: number;
  90177. /**
  90178. * Sphere-Imposter type
  90179. */
  90180. static SphereImpostor: number;
  90181. /**
  90182. * Box-Imposter type
  90183. */
  90184. static BoxImpostor: number;
  90185. /**
  90186. * Plane-Imposter type
  90187. */
  90188. static PlaneImpostor: number;
  90189. /**
  90190. * Mesh-imposter type
  90191. */
  90192. static MeshImpostor: number;
  90193. /**
  90194. * Capsule-Impostor type (Ammo.js plugin only)
  90195. */
  90196. static CapsuleImpostor: number;
  90197. /**
  90198. * Cylinder-Imposter type
  90199. */
  90200. static CylinderImpostor: number;
  90201. /**
  90202. * Particle-Imposter type
  90203. */
  90204. static ParticleImpostor: number;
  90205. /**
  90206. * Heightmap-Imposter type
  90207. */
  90208. static HeightmapImpostor: number;
  90209. /**
  90210. * ConvexHull-Impostor type (Ammo.js plugin only)
  90211. */
  90212. static ConvexHullImpostor: number;
  90213. /**
  90214. * Rope-Imposter type
  90215. */
  90216. static RopeImpostor: number;
  90217. /**
  90218. * Cloth-Imposter type
  90219. */
  90220. static ClothImpostor: number;
  90221. /**
  90222. * Softbody-Imposter type
  90223. */
  90224. static SoftbodyImpostor: number;
  90225. }
  90226. }
  90227. declare module BABYLON {
  90228. /**
  90229. * @hidden
  90230. **/
  90231. export class _CreationDataStorage {
  90232. closePath?: boolean;
  90233. closeArray?: boolean;
  90234. idx: number[];
  90235. dashSize: number;
  90236. gapSize: number;
  90237. path3D: Path3D;
  90238. pathArray: Vector3[][];
  90239. arc: number;
  90240. radius: number;
  90241. cap: number;
  90242. tessellation: number;
  90243. }
  90244. /**
  90245. * @hidden
  90246. **/
  90247. class _InstanceDataStorage {
  90248. visibleInstances: any;
  90249. batchCache: _InstancesBatch;
  90250. instancesBufferSize: number;
  90251. instancesBuffer: Nullable<Buffer>;
  90252. instancesData: Float32Array;
  90253. overridenInstanceCount: number;
  90254. isFrozen: boolean;
  90255. previousBatch: Nullable<_InstancesBatch>;
  90256. hardwareInstancedRendering: boolean;
  90257. sideOrientation: number;
  90258. }
  90259. /**
  90260. * @hidden
  90261. **/
  90262. export class _InstancesBatch {
  90263. mustReturn: boolean;
  90264. visibleInstances: Nullable<InstancedMesh[]>[];
  90265. renderSelf: boolean[];
  90266. hardwareInstancedRendering: boolean[];
  90267. }
  90268. /**
  90269. * Class used to represent renderable models
  90270. */
  90271. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  90272. /**
  90273. * Mesh side orientation : usually the external or front surface
  90274. */
  90275. static readonly FRONTSIDE: number;
  90276. /**
  90277. * Mesh side orientation : usually the internal or back surface
  90278. */
  90279. static readonly BACKSIDE: number;
  90280. /**
  90281. * Mesh side orientation : both internal and external or front and back surfaces
  90282. */
  90283. static readonly DOUBLESIDE: number;
  90284. /**
  90285. * Mesh side orientation : by default, `FRONTSIDE`
  90286. */
  90287. static readonly DEFAULTSIDE: number;
  90288. /**
  90289. * Mesh cap setting : no cap
  90290. */
  90291. static readonly NO_CAP: number;
  90292. /**
  90293. * Mesh cap setting : one cap at the beginning of the mesh
  90294. */
  90295. static readonly CAP_START: number;
  90296. /**
  90297. * Mesh cap setting : one cap at the end of the mesh
  90298. */
  90299. static readonly CAP_END: number;
  90300. /**
  90301. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  90302. */
  90303. static readonly CAP_ALL: number;
  90304. /**
  90305. * Mesh pattern setting : no flip or rotate
  90306. */
  90307. static readonly NO_FLIP: number;
  90308. /**
  90309. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  90310. */
  90311. static readonly FLIP_TILE: number;
  90312. /**
  90313. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  90314. */
  90315. static readonly ROTATE_TILE: number;
  90316. /**
  90317. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  90318. */
  90319. static readonly FLIP_ROW: number;
  90320. /**
  90321. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  90322. */
  90323. static readonly ROTATE_ROW: number;
  90324. /**
  90325. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  90326. */
  90327. static readonly FLIP_N_ROTATE_TILE: number;
  90328. /**
  90329. * Mesh pattern setting : rotate pattern and rotate
  90330. */
  90331. static readonly FLIP_N_ROTATE_ROW: number;
  90332. /**
  90333. * Mesh tile positioning : part tiles same on left/right or top/bottom
  90334. */
  90335. static readonly CENTER: number;
  90336. /**
  90337. * Mesh tile positioning : part tiles on left
  90338. */
  90339. static readonly LEFT: number;
  90340. /**
  90341. * Mesh tile positioning : part tiles on right
  90342. */
  90343. static readonly RIGHT: number;
  90344. /**
  90345. * Mesh tile positioning : part tiles on top
  90346. */
  90347. static readonly TOP: number;
  90348. /**
  90349. * Mesh tile positioning : part tiles on bottom
  90350. */
  90351. static readonly BOTTOM: number;
  90352. /**
  90353. * Gets the default side orientation.
  90354. * @param orientation the orientation to value to attempt to get
  90355. * @returns the default orientation
  90356. * @hidden
  90357. */
  90358. static _GetDefaultSideOrientation(orientation?: number): number;
  90359. private _internalMeshDataInfo;
  90360. /**
  90361. * An event triggered before rendering the mesh
  90362. */
  90363. readonly onBeforeRenderObservable: Observable<Mesh>;
  90364. /**
  90365. * An event triggered before binding the mesh
  90366. */
  90367. readonly onBeforeBindObservable: Observable<Mesh>;
  90368. /**
  90369. * An event triggered after rendering the mesh
  90370. */
  90371. readonly onAfterRenderObservable: Observable<Mesh>;
  90372. /**
  90373. * An event triggered before drawing the mesh
  90374. */
  90375. readonly onBeforeDrawObservable: Observable<Mesh>;
  90376. private _onBeforeDrawObserver;
  90377. /**
  90378. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  90379. */
  90380. onBeforeDraw: () => void;
  90381. readonly hasInstances: boolean;
  90382. /**
  90383. * Gets the delay loading state of the mesh (when delay loading is turned on)
  90384. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  90385. */
  90386. delayLoadState: number;
  90387. /**
  90388. * Gets the list of instances created from this mesh
  90389. * it is not supposed to be modified manually.
  90390. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  90391. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90392. */
  90393. instances: InstancedMesh[];
  90394. /**
  90395. * Gets the file containing delay loading data for this mesh
  90396. */
  90397. delayLoadingFile: string;
  90398. /** @hidden */
  90399. _binaryInfo: any;
  90400. /**
  90401. * User defined function used to change how LOD level selection is done
  90402. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90403. */
  90404. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  90405. /**
  90406. * Gets or sets the morph target manager
  90407. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90408. */
  90409. morphTargetManager: Nullable<MorphTargetManager>;
  90410. /** @hidden */
  90411. _creationDataStorage: Nullable<_CreationDataStorage>;
  90412. /** @hidden */
  90413. _geometry: Nullable<Geometry>;
  90414. /** @hidden */
  90415. _delayInfo: Array<string>;
  90416. /** @hidden */
  90417. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  90418. /** @hidden */
  90419. _instanceDataStorage: _InstanceDataStorage;
  90420. private _effectiveMaterial;
  90421. /** @hidden */
  90422. _shouldGenerateFlatShading: boolean;
  90423. /** @hidden */
  90424. _originalBuilderSideOrientation: number;
  90425. /**
  90426. * Use this property to change the original side orientation defined at construction time
  90427. */
  90428. overrideMaterialSideOrientation: Nullable<number>;
  90429. /**
  90430. * Gets the source mesh (the one used to clone this one from)
  90431. */
  90432. readonly source: Nullable<Mesh>;
  90433. /**
  90434. * Gets or sets a boolean indicating that this mesh does not use index buffer
  90435. */
  90436. isUnIndexed: boolean;
  90437. /**
  90438. * @constructor
  90439. * @param name The value used by scene.getMeshByName() to do a lookup.
  90440. * @param scene The scene to add this mesh to.
  90441. * @param parent The parent of this mesh, if it has one
  90442. * @param source An optional Mesh from which geometry is shared, cloned.
  90443. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90444. * When false, achieved by calling a clone(), also passing False.
  90445. * This will make creation of children, recursive.
  90446. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  90447. */
  90448. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  90449. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  90450. /**
  90451. * Gets the class name
  90452. * @returns the string "Mesh".
  90453. */
  90454. getClassName(): string;
  90455. /** @hidden */
  90456. readonly _isMesh: boolean;
  90457. /**
  90458. * Returns a description of this mesh
  90459. * @param fullDetails define if full details about this mesh must be used
  90460. * @returns a descriptive string representing this mesh
  90461. */
  90462. toString(fullDetails?: boolean): string;
  90463. /** @hidden */
  90464. _unBindEffect(): void;
  90465. /**
  90466. * Gets a boolean indicating if this mesh has LOD
  90467. */
  90468. readonly hasLODLevels: boolean;
  90469. /**
  90470. * Gets the list of MeshLODLevel associated with the current mesh
  90471. * @returns an array of MeshLODLevel
  90472. */
  90473. getLODLevels(): MeshLODLevel[];
  90474. private _sortLODLevels;
  90475. /**
  90476. * Add a mesh as LOD level triggered at the given distance.
  90477. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90478. * @param distance The distance from the center of the object to show this level
  90479. * @param mesh The mesh to be added as LOD level (can be null)
  90480. * @return This mesh (for chaining)
  90481. */
  90482. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  90483. /**
  90484. * Returns the LOD level mesh at the passed distance or null if not found.
  90485. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90486. * @param distance The distance from the center of the object to show this level
  90487. * @returns a Mesh or `null`
  90488. */
  90489. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  90490. /**
  90491. * Remove a mesh from the LOD array
  90492. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90493. * @param mesh defines the mesh to be removed
  90494. * @return This mesh (for chaining)
  90495. */
  90496. removeLODLevel(mesh: Mesh): Mesh;
  90497. /**
  90498. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  90499. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90500. * @param camera defines the camera to use to compute distance
  90501. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  90502. * @return This mesh (for chaining)
  90503. */
  90504. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  90505. /**
  90506. * Gets the mesh internal Geometry object
  90507. */
  90508. readonly geometry: Nullable<Geometry>;
  90509. /**
  90510. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  90511. * @returns the total number of vertices
  90512. */
  90513. getTotalVertices(): number;
  90514. /**
  90515. * Returns the content of an associated vertex buffer
  90516. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90517. * - VertexBuffer.PositionKind
  90518. * - VertexBuffer.UVKind
  90519. * - VertexBuffer.UV2Kind
  90520. * - VertexBuffer.UV3Kind
  90521. * - VertexBuffer.UV4Kind
  90522. * - VertexBuffer.UV5Kind
  90523. * - VertexBuffer.UV6Kind
  90524. * - VertexBuffer.ColorKind
  90525. * - VertexBuffer.MatricesIndicesKind
  90526. * - VertexBuffer.MatricesIndicesExtraKind
  90527. * - VertexBuffer.MatricesWeightsKind
  90528. * - VertexBuffer.MatricesWeightsExtraKind
  90529. * @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
  90530. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  90531. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  90532. */
  90533. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90534. /**
  90535. * Returns the mesh VertexBuffer object from the requested `kind`
  90536. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90537. * - VertexBuffer.PositionKind
  90538. * - VertexBuffer.NormalKind
  90539. * - VertexBuffer.UVKind
  90540. * - VertexBuffer.UV2Kind
  90541. * - VertexBuffer.UV3Kind
  90542. * - VertexBuffer.UV4Kind
  90543. * - VertexBuffer.UV5Kind
  90544. * - VertexBuffer.UV6Kind
  90545. * - VertexBuffer.ColorKind
  90546. * - VertexBuffer.MatricesIndicesKind
  90547. * - VertexBuffer.MatricesIndicesExtraKind
  90548. * - VertexBuffer.MatricesWeightsKind
  90549. * - VertexBuffer.MatricesWeightsExtraKind
  90550. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  90551. */
  90552. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90553. /**
  90554. * Tests if a specific vertex buffer is associated with this mesh
  90555. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90556. * - VertexBuffer.PositionKind
  90557. * - VertexBuffer.NormalKind
  90558. * - VertexBuffer.UVKind
  90559. * - VertexBuffer.UV2Kind
  90560. * - VertexBuffer.UV3Kind
  90561. * - VertexBuffer.UV4Kind
  90562. * - VertexBuffer.UV5Kind
  90563. * - VertexBuffer.UV6Kind
  90564. * - VertexBuffer.ColorKind
  90565. * - VertexBuffer.MatricesIndicesKind
  90566. * - VertexBuffer.MatricesIndicesExtraKind
  90567. * - VertexBuffer.MatricesWeightsKind
  90568. * - VertexBuffer.MatricesWeightsExtraKind
  90569. * @returns a boolean
  90570. */
  90571. isVerticesDataPresent(kind: string): boolean;
  90572. /**
  90573. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  90574. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90575. * - VertexBuffer.PositionKind
  90576. * - VertexBuffer.UVKind
  90577. * - VertexBuffer.UV2Kind
  90578. * - VertexBuffer.UV3Kind
  90579. * - VertexBuffer.UV4Kind
  90580. * - VertexBuffer.UV5Kind
  90581. * - VertexBuffer.UV6Kind
  90582. * - VertexBuffer.ColorKind
  90583. * - VertexBuffer.MatricesIndicesKind
  90584. * - VertexBuffer.MatricesIndicesExtraKind
  90585. * - VertexBuffer.MatricesWeightsKind
  90586. * - VertexBuffer.MatricesWeightsExtraKind
  90587. * @returns a boolean
  90588. */
  90589. isVertexBufferUpdatable(kind: string): boolean;
  90590. /**
  90591. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  90592. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90593. * - VertexBuffer.PositionKind
  90594. * - VertexBuffer.NormalKind
  90595. * - VertexBuffer.UVKind
  90596. * - VertexBuffer.UV2Kind
  90597. * - VertexBuffer.UV3Kind
  90598. * - VertexBuffer.UV4Kind
  90599. * - VertexBuffer.UV5Kind
  90600. * - VertexBuffer.UV6Kind
  90601. * - VertexBuffer.ColorKind
  90602. * - VertexBuffer.MatricesIndicesKind
  90603. * - VertexBuffer.MatricesIndicesExtraKind
  90604. * - VertexBuffer.MatricesWeightsKind
  90605. * - VertexBuffer.MatricesWeightsExtraKind
  90606. * @returns an array of strings
  90607. */
  90608. getVerticesDataKinds(): string[];
  90609. /**
  90610. * Returns a positive integer : the total number of indices in this mesh geometry.
  90611. * @returns the numner of indices or zero if the mesh has no geometry.
  90612. */
  90613. getTotalIndices(): number;
  90614. /**
  90615. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90616. * @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.
  90617. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90618. * @returns the indices array or an empty array if the mesh has no geometry
  90619. */
  90620. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90621. readonly isBlocked: boolean;
  90622. /**
  90623. * Determine if the current mesh is ready to be rendered
  90624. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90625. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  90626. * @returns true if all associated assets are ready (material, textures, shaders)
  90627. */
  90628. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  90629. /**
  90630. * 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.
  90631. */
  90632. readonly areNormalsFrozen: boolean;
  90633. /**
  90634. * 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.
  90635. * @returns the current mesh
  90636. */
  90637. freezeNormals(): Mesh;
  90638. /**
  90639. * 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
  90640. * @returns the current mesh
  90641. */
  90642. unfreezeNormals(): Mesh;
  90643. /**
  90644. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  90645. */
  90646. overridenInstanceCount: number;
  90647. /** @hidden */
  90648. _preActivate(): Mesh;
  90649. /** @hidden */
  90650. _preActivateForIntermediateRendering(renderId: number): Mesh;
  90651. /** @hidden */
  90652. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  90653. /**
  90654. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90655. * This means the mesh underlying bounding box and sphere are recomputed.
  90656. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90657. * @returns the current mesh
  90658. */
  90659. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  90660. /** @hidden */
  90661. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  90662. /**
  90663. * This function will subdivide the mesh into multiple submeshes
  90664. * @param count defines the expected number of submeshes
  90665. */
  90666. subdivide(count: number): void;
  90667. /**
  90668. * Copy a FloatArray into a specific associated vertex buffer
  90669. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90670. * - VertexBuffer.PositionKind
  90671. * - VertexBuffer.UVKind
  90672. * - VertexBuffer.UV2Kind
  90673. * - VertexBuffer.UV3Kind
  90674. * - VertexBuffer.UV4Kind
  90675. * - VertexBuffer.UV5Kind
  90676. * - VertexBuffer.UV6Kind
  90677. * - VertexBuffer.ColorKind
  90678. * - VertexBuffer.MatricesIndicesKind
  90679. * - VertexBuffer.MatricesIndicesExtraKind
  90680. * - VertexBuffer.MatricesWeightsKind
  90681. * - VertexBuffer.MatricesWeightsExtraKind
  90682. * @param data defines the data source
  90683. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90684. * @param stride defines the data stride size (can be null)
  90685. * @returns the current mesh
  90686. */
  90687. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90688. /**
  90689. * Flags an associated vertex buffer as updatable
  90690. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  90691. * - VertexBuffer.PositionKind
  90692. * - VertexBuffer.UVKind
  90693. * - VertexBuffer.UV2Kind
  90694. * - VertexBuffer.UV3Kind
  90695. * - VertexBuffer.UV4Kind
  90696. * - VertexBuffer.UV5Kind
  90697. * - VertexBuffer.UV6Kind
  90698. * - VertexBuffer.ColorKind
  90699. * - VertexBuffer.MatricesIndicesKind
  90700. * - VertexBuffer.MatricesIndicesExtraKind
  90701. * - VertexBuffer.MatricesWeightsKind
  90702. * - VertexBuffer.MatricesWeightsExtraKind
  90703. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90704. */
  90705. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  90706. /**
  90707. * Sets the mesh global Vertex Buffer
  90708. * @param buffer defines the buffer to use
  90709. * @returns the current mesh
  90710. */
  90711. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  90712. /**
  90713. * Update a specific associated vertex buffer
  90714. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90715. * - VertexBuffer.PositionKind
  90716. * - VertexBuffer.UVKind
  90717. * - VertexBuffer.UV2Kind
  90718. * - VertexBuffer.UV3Kind
  90719. * - VertexBuffer.UV4Kind
  90720. * - VertexBuffer.UV5Kind
  90721. * - VertexBuffer.UV6Kind
  90722. * - VertexBuffer.ColorKind
  90723. * - VertexBuffer.MatricesIndicesKind
  90724. * - VertexBuffer.MatricesIndicesExtraKind
  90725. * - VertexBuffer.MatricesWeightsKind
  90726. * - VertexBuffer.MatricesWeightsExtraKind
  90727. * @param data defines the data source
  90728. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90729. * @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)
  90730. * @returns the current mesh
  90731. */
  90732. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90733. /**
  90734. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  90735. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  90736. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  90737. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  90738. * @returns the current mesh
  90739. */
  90740. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  90741. /**
  90742. * Creates a un-shared specific occurence of the geometry for the mesh.
  90743. * @returns the current mesh
  90744. */
  90745. makeGeometryUnique(): Mesh;
  90746. /**
  90747. * Set the index buffer of this mesh
  90748. * @param indices defines the source data
  90749. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  90750. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  90751. * @returns the current mesh
  90752. */
  90753. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  90754. /**
  90755. * Update the current index buffer
  90756. * @param indices defines the source data
  90757. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90758. * @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)
  90759. * @returns the current mesh
  90760. */
  90761. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90762. /**
  90763. * Invert the geometry to move from a right handed system to a left handed one.
  90764. * @returns the current mesh
  90765. */
  90766. toLeftHanded(): Mesh;
  90767. /** @hidden */
  90768. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90769. /** @hidden */
  90770. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90771. /**
  90772. * Registers for this mesh a javascript function called just before the rendering process
  90773. * @param func defines the function to call before rendering this mesh
  90774. * @returns the current mesh
  90775. */
  90776. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90777. /**
  90778. * Disposes a previously registered javascript function called before the rendering
  90779. * @param func defines the function to remove
  90780. * @returns the current mesh
  90781. */
  90782. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90783. /**
  90784. * Registers for this mesh a javascript function called just after the rendering is complete
  90785. * @param func defines the function to call after rendering this mesh
  90786. * @returns the current mesh
  90787. */
  90788. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90789. /**
  90790. * Disposes a previously registered javascript function called after the rendering.
  90791. * @param func defines the function to remove
  90792. * @returns the current mesh
  90793. */
  90794. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90795. /** @hidden */
  90796. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  90797. /** @hidden */
  90798. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  90799. /** @hidden */
  90800. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  90801. /** @hidden */
  90802. _rebuild(): void;
  90803. /** @hidden */
  90804. _freeze(): void;
  90805. /** @hidden */
  90806. _unFreeze(): void;
  90807. /**
  90808. * 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
  90809. * @param subMesh defines the subMesh to render
  90810. * @param enableAlphaMode defines if alpha mode can be changed
  90811. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  90812. * @returns the current mesh
  90813. */
  90814. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  90815. private _onBeforeDraw;
  90816. /**
  90817. * Renormalize the mesh and patch it up if there are no weights
  90818. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  90819. * However in the case of zero weights then we set just a single influence to 1.
  90820. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  90821. */
  90822. cleanMatrixWeights(): void;
  90823. private normalizeSkinFourWeights;
  90824. private normalizeSkinWeightsAndExtra;
  90825. /**
  90826. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  90827. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  90828. * the user know there was an issue with importing the mesh
  90829. * @returns a validation object with skinned, valid and report string
  90830. */
  90831. validateSkinning(): {
  90832. skinned: boolean;
  90833. valid: boolean;
  90834. report: string;
  90835. };
  90836. /** @hidden */
  90837. _checkDelayState(): Mesh;
  90838. private _queueLoad;
  90839. /**
  90840. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90841. * A mesh is in the frustum if its bounding box intersects the frustum
  90842. * @param frustumPlanes defines the frustum to test
  90843. * @returns true if the mesh is in the frustum planes
  90844. */
  90845. isInFrustum(frustumPlanes: Plane[]): boolean;
  90846. /**
  90847. * Sets the mesh material by the material or multiMaterial `id` property
  90848. * @param id is a string identifying the material or the multiMaterial
  90849. * @returns the current mesh
  90850. */
  90851. setMaterialByID(id: string): Mesh;
  90852. /**
  90853. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  90854. * @returns an array of IAnimatable
  90855. */
  90856. getAnimatables(): IAnimatable[];
  90857. /**
  90858. * Modifies the mesh geometry according to the passed transformation matrix.
  90859. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  90860. * The mesh normals are modified using the same transformation.
  90861. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90862. * @param transform defines the transform matrix to use
  90863. * @see http://doc.babylonjs.com/resources/baking_transformations
  90864. * @returns the current mesh
  90865. */
  90866. bakeTransformIntoVertices(transform: Matrix): Mesh;
  90867. /**
  90868. * Modifies the mesh geometry according to its own current World Matrix.
  90869. * The mesh World Matrix is then reset.
  90870. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  90871. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90872. * @see http://doc.babylonjs.com/resources/baking_transformations
  90873. * @returns the current mesh
  90874. */
  90875. bakeCurrentTransformIntoVertices(): Mesh;
  90876. /** @hidden */
  90877. readonly _positions: Nullable<Vector3[]>;
  90878. /** @hidden */
  90879. _resetPointsArrayCache(): Mesh;
  90880. /** @hidden */
  90881. _generatePointsArray(): boolean;
  90882. /**
  90883. * Returns a new Mesh object generated from the current mesh properties.
  90884. * This method must not get confused with createInstance()
  90885. * @param name is a string, the name given to the new mesh
  90886. * @param newParent can be any Node object (default `null`)
  90887. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  90888. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  90889. * @returns a new mesh
  90890. */
  90891. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  90892. /**
  90893. * Releases resources associated with this mesh.
  90894. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90895. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90896. */
  90897. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90898. /**
  90899. * Modifies the mesh geometry according to a displacement map.
  90900. * 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.
  90901. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90902. * @param url is a string, the URL from the image file is to be downloaded.
  90903. * @param minHeight is the lower limit of the displacement.
  90904. * @param maxHeight is the upper limit of the displacement.
  90905. * @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.
  90906. * @param uvOffset is an optional vector2 used to offset UV.
  90907. * @param uvScale is an optional vector2 used to scale UV.
  90908. * @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.
  90909. * @returns the Mesh.
  90910. */
  90911. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90912. /**
  90913. * Modifies the mesh geometry according to a displacementMap buffer.
  90914. * 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.
  90915. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90916. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  90917. * @param heightMapWidth is the width of the buffer image.
  90918. * @param heightMapHeight is the height of the buffer image.
  90919. * @param minHeight is the lower limit of the displacement.
  90920. * @param maxHeight is the upper limit of the displacement.
  90921. * @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.
  90922. * @param uvOffset is an optional vector2 used to offset UV.
  90923. * @param uvScale is an optional vector2 used to scale UV.
  90924. * @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.
  90925. * @returns the Mesh.
  90926. */
  90927. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90928. /**
  90929. * Modify the mesh to get a flat shading rendering.
  90930. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  90931. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  90932. * @returns current mesh
  90933. */
  90934. convertToFlatShadedMesh(): Mesh;
  90935. /**
  90936. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  90937. * In other words, more vertices, no more indices and a single bigger VBO.
  90938. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  90939. * @returns current mesh
  90940. */
  90941. convertToUnIndexedMesh(): Mesh;
  90942. /**
  90943. * Inverses facet orientations.
  90944. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90945. * @param flipNormals will also inverts the normals
  90946. * @returns current mesh
  90947. */
  90948. flipFaces(flipNormals?: boolean): Mesh;
  90949. /**
  90950. * Increase the number of facets and hence vertices in a mesh
  90951. * Vertex normals are interpolated from existing vertex normals
  90952. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90953. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  90954. */
  90955. increaseVertices(numberPerEdge: number): void;
  90956. /**
  90957. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  90958. * This will undo any application of covertToFlatShadedMesh
  90959. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90960. */
  90961. forceSharedVertices(): void;
  90962. /** @hidden */
  90963. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  90964. /** @hidden */
  90965. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  90966. /**
  90967. * Creates a new InstancedMesh object from the mesh model.
  90968. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90969. * @param name defines the name of the new instance
  90970. * @returns a new InstancedMesh
  90971. */
  90972. createInstance(name: string): InstancedMesh;
  90973. /**
  90974. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  90975. * After this call, all the mesh instances have the same submeshes than the current mesh.
  90976. * @returns the current mesh
  90977. */
  90978. synchronizeInstances(): Mesh;
  90979. /**
  90980. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  90981. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  90982. * This should be used together with the simplification to avoid disappearing triangles.
  90983. * @param successCallback an optional success callback to be called after the optimization finished.
  90984. * @returns the current mesh
  90985. */
  90986. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  90987. /**
  90988. * Serialize current mesh
  90989. * @param serializationObject defines the object which will receive the serialization data
  90990. */
  90991. serialize(serializationObject: any): void;
  90992. /** @hidden */
  90993. _syncGeometryWithMorphTargetManager(): void;
  90994. /** @hidden */
  90995. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  90996. /**
  90997. * Returns a new Mesh object parsed from the source provided.
  90998. * @param parsedMesh is the source
  90999. * @param scene defines the hosting scene
  91000. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  91001. * @returns a new Mesh
  91002. */
  91003. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  91004. /**
  91005. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  91006. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91007. * @param name defines the name of the mesh to create
  91008. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  91009. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  91010. * @param closePath creates a seam between the first and the last points of each path of the path array
  91011. * @param offset is taken in account only if the `pathArray` is containing a single path
  91012. * @param scene defines the hosting scene
  91013. * @param updatable defines if the mesh must be flagged as updatable
  91014. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91015. * @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)
  91016. * @returns a new Mesh
  91017. */
  91018. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91019. /**
  91020. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  91021. * @param name defines the name of the mesh to create
  91022. * @param radius sets the radius size (float) of the polygon (default 0.5)
  91023. * @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
  91024. * @param scene defines the hosting scene
  91025. * @param updatable defines if the mesh must be flagged as updatable
  91026. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91027. * @returns a new Mesh
  91028. */
  91029. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91030. /**
  91031. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  91032. * @param name defines the name of the mesh to create
  91033. * @param size sets the size (float) of each box side (default 1)
  91034. * @param scene defines the hosting scene
  91035. * @param updatable defines if the mesh must be flagged as updatable
  91036. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91037. * @returns a new Mesh
  91038. */
  91039. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91040. /**
  91041. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  91042. * @param name defines the name of the mesh to create
  91043. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91044. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91045. * @param scene defines the hosting scene
  91046. * @param updatable defines if the mesh must be flagged as updatable
  91047. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91048. * @returns a new Mesh
  91049. */
  91050. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91051. /**
  91052. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  91053. * @param name defines the name of the mesh to create
  91054. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91055. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91056. * @param scene defines the hosting scene
  91057. * @returns a new Mesh
  91058. */
  91059. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  91060. /**
  91061. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  91062. * @param name defines the name of the mesh to create
  91063. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  91064. * @param diameterTop set the top cap diameter (floats, default 1)
  91065. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  91066. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  91067. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  91068. * @param scene defines the hosting scene
  91069. * @param updatable defines if the mesh must be flagged as updatable
  91070. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91071. * @returns a new Mesh
  91072. */
  91073. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  91074. /**
  91075. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  91076. * @param name defines the name of the mesh to create
  91077. * @param diameter sets the diameter size (float) of the torus (default 1)
  91078. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  91079. * @param tessellation sets the number of torus sides (postive integer, default 16)
  91080. * @param scene defines the hosting scene
  91081. * @param updatable defines if the mesh must be flagged as updatable
  91082. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91083. * @returns a new Mesh
  91084. */
  91085. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91086. /**
  91087. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  91088. * @param name defines the name of the mesh to create
  91089. * @param radius sets the global radius size (float) of the torus knot (default 2)
  91090. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  91091. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  91092. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  91093. * @param p the number of windings on X axis (positive integers, default 2)
  91094. * @param q the number of windings on Y axis (positive integers, default 3)
  91095. * @param scene defines the hosting scene
  91096. * @param updatable defines if the mesh must be flagged as updatable
  91097. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91098. * @returns a new Mesh
  91099. */
  91100. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91101. /**
  91102. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  91103. * @param name defines the name of the mesh to create
  91104. * @param points is an array successive Vector3
  91105. * @param scene defines the hosting scene
  91106. * @param updatable defines if the mesh must be flagged as updatable
  91107. * @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).
  91108. * @returns a new Mesh
  91109. */
  91110. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  91111. /**
  91112. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  91113. * @param name defines the name of the mesh to create
  91114. * @param points is an array successive Vector3
  91115. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  91116. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  91117. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  91118. * @param scene defines the hosting scene
  91119. * @param updatable defines if the mesh must be flagged as updatable
  91120. * @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)
  91121. * @returns a new Mesh
  91122. */
  91123. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  91124. /**
  91125. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  91126. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  91127. * 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.
  91128. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91129. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91130. * Remember you can only change the shape positions, not their number when updating a polygon.
  91131. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  91132. * @param name defines the name of the mesh to create
  91133. * @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
  91134. * @param scene defines the hosting scene
  91135. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91136. * @param updatable defines if the mesh must be flagged as updatable
  91137. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91138. * @param earcutInjection can be used to inject your own earcut reference
  91139. * @returns a new Mesh
  91140. */
  91141. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91142. /**
  91143. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  91144. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  91145. * @param name defines the name of the mesh to create
  91146. * @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
  91147. * @param depth defines the height of extrusion
  91148. * @param scene defines the hosting scene
  91149. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91150. * @param updatable defines if the mesh must be flagged as updatable
  91151. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91152. * @param earcutInjection can be used to inject your own earcut reference
  91153. * @returns a new Mesh
  91154. */
  91155. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91156. /**
  91157. * Creates an extruded shape mesh.
  91158. * 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
  91159. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91160. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91161. * @param name defines the name of the mesh to create
  91162. * @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
  91163. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91164. * @param scale is the value to scale the shape
  91165. * @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
  91166. * @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
  91167. * @param scene defines the hosting scene
  91168. * @param updatable defines if the mesh must be flagged as updatable
  91169. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91170. * @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)
  91171. * @returns a new Mesh
  91172. */
  91173. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91174. /**
  91175. * Creates an custom extruded shape mesh.
  91176. * The custom extrusion is a parametric shape.
  91177. * It has no predefined shape. Its final shape will depend on the input parameters.
  91178. * Please consider using the same method from the MeshBuilder class instead
  91179. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91180. * @param name defines the name of the mesh to create
  91181. * @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
  91182. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91183. * @param scaleFunction is a custom Javascript function called on each path point
  91184. * @param rotationFunction is a custom Javascript function called on each path point
  91185. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  91186. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  91187. * @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
  91188. * @param scene defines the hosting scene
  91189. * @param updatable defines if the mesh must be flagged as updatable
  91190. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91191. * @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)
  91192. * @returns a new Mesh
  91193. */
  91194. 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;
  91195. /**
  91196. * Creates lathe mesh.
  91197. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  91198. * Please consider using the same method from the MeshBuilder class instead
  91199. * @param name defines the name of the mesh to create
  91200. * @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
  91201. * @param radius is the radius value of the lathe
  91202. * @param tessellation is the side number of the lathe.
  91203. * @param scene defines the hosting scene
  91204. * @param updatable defines if the mesh must be flagged as updatable
  91205. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91206. * @returns a new Mesh
  91207. */
  91208. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91209. /**
  91210. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  91211. * @param name defines the name of the mesh to create
  91212. * @param size sets the size (float) of both sides of the plane at once (default 1)
  91213. * @param scene defines the hosting scene
  91214. * @param updatable defines if the mesh must be flagged as updatable
  91215. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91216. * @returns a new Mesh
  91217. */
  91218. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91219. /**
  91220. * Creates a ground mesh.
  91221. * Please consider using the same method from the MeshBuilder class instead
  91222. * @param name defines the name of the mesh to create
  91223. * @param width set the width of the ground
  91224. * @param height set the height of the ground
  91225. * @param subdivisions sets the number of subdivisions per side
  91226. * @param scene defines the hosting scene
  91227. * @param updatable defines if the mesh must be flagged as updatable
  91228. * @returns a new Mesh
  91229. */
  91230. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  91231. /**
  91232. * Creates a tiled ground mesh.
  91233. * Please consider using the same method from the MeshBuilder class instead
  91234. * @param name defines the name of the mesh to create
  91235. * @param xmin set the ground minimum X coordinate
  91236. * @param zmin set the ground minimum Y coordinate
  91237. * @param xmax set the ground maximum X coordinate
  91238. * @param zmax set the ground maximum Z coordinate
  91239. * @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
  91240. * @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
  91241. * @param scene defines the hosting scene
  91242. * @param updatable defines if the mesh must be flagged as updatable
  91243. * @returns a new Mesh
  91244. */
  91245. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  91246. w: number;
  91247. h: number;
  91248. }, precision: {
  91249. w: number;
  91250. h: number;
  91251. }, scene: Scene, updatable?: boolean): Mesh;
  91252. /**
  91253. * Creates a ground mesh from a height map.
  91254. * Please consider using the same method from the MeshBuilder class instead
  91255. * @see http://doc.babylonjs.com/babylon101/height_map
  91256. * @param name defines the name of the mesh to create
  91257. * @param url sets the URL of the height map image resource
  91258. * @param width set the ground width size
  91259. * @param height set the ground height size
  91260. * @param subdivisions sets the number of subdivision per side
  91261. * @param minHeight is the minimum altitude on the ground
  91262. * @param maxHeight is the maximum altitude on the ground
  91263. * @param scene defines the hosting scene
  91264. * @param updatable defines if the mesh must be flagged as updatable
  91265. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  91266. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  91267. * @returns a new Mesh
  91268. */
  91269. 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;
  91270. /**
  91271. * Creates a tube mesh.
  91272. * The tube is a parametric shape.
  91273. * It has no predefined shape. Its final shape will depend on the input parameters.
  91274. * Please consider using the same method from the MeshBuilder class instead
  91275. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91276. * @param name defines the name of the mesh to create
  91277. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  91278. * @param radius sets the tube radius size
  91279. * @param tessellation is the number of sides on the tubular surface
  91280. * @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
  91281. * @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
  91282. * @param scene defines the hosting scene
  91283. * @param updatable defines if the mesh must be flagged as updatable
  91284. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91285. * @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)
  91286. * @returns a new Mesh
  91287. */
  91288. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  91289. (i: number, distance: number): number;
  91290. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91291. /**
  91292. * Creates a polyhedron mesh.
  91293. * Please consider using the same method from the MeshBuilder class instead.
  91294. * * 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
  91295. * * The parameter `size` (positive float, default 1) sets the polygon size
  91296. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  91297. * * 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`
  91298. * * 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
  91299. * * 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)`)
  91300. * * 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
  91301. * * 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
  91302. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91303. * * 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
  91304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91305. * @param name defines the name of the mesh to create
  91306. * @param options defines the options used to create the mesh
  91307. * @param scene defines the hosting scene
  91308. * @returns a new Mesh
  91309. */
  91310. static CreatePolyhedron(name: string, options: {
  91311. type?: number;
  91312. size?: number;
  91313. sizeX?: number;
  91314. sizeY?: number;
  91315. sizeZ?: number;
  91316. custom?: any;
  91317. faceUV?: Vector4[];
  91318. faceColors?: Color4[];
  91319. updatable?: boolean;
  91320. sideOrientation?: number;
  91321. }, scene: Scene): Mesh;
  91322. /**
  91323. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  91324. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  91325. * * 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`)
  91326. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  91327. * * 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
  91328. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91329. * * 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
  91330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91331. * @param name defines the name of the mesh
  91332. * @param options defines the options used to create the mesh
  91333. * @param scene defines the hosting scene
  91334. * @returns a new Mesh
  91335. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  91336. */
  91337. static CreateIcoSphere(name: string, options: {
  91338. radius?: number;
  91339. flat?: boolean;
  91340. subdivisions?: number;
  91341. sideOrientation?: number;
  91342. updatable?: boolean;
  91343. }, scene: Scene): Mesh;
  91344. /**
  91345. * Creates a decal mesh.
  91346. * Please consider using the same method from the MeshBuilder class instead.
  91347. * A decal is a mesh usually applied as a model onto the surface of another mesh
  91348. * @param name defines the name of the mesh
  91349. * @param sourceMesh defines the mesh receiving the decal
  91350. * @param position sets the position of the decal in world coordinates
  91351. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  91352. * @param size sets the decal scaling
  91353. * @param angle sets the angle to rotate the decal
  91354. * @returns a new Mesh
  91355. */
  91356. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  91357. /**
  91358. * Prepare internal position array for software CPU skinning
  91359. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  91360. */
  91361. setPositionsForCPUSkinning(): Float32Array;
  91362. /**
  91363. * Prepare internal normal array for software CPU skinning
  91364. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  91365. */
  91366. setNormalsForCPUSkinning(): Float32Array;
  91367. /**
  91368. * Updates the vertex buffer by applying transformation from the bones
  91369. * @param skeleton defines the skeleton to apply to current mesh
  91370. * @returns the current mesh
  91371. */
  91372. applySkeleton(skeleton: Skeleton): Mesh;
  91373. /**
  91374. * 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
  91375. * @param meshes defines the list of meshes to scan
  91376. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  91377. */
  91378. static MinMax(meshes: AbstractMesh[]): {
  91379. min: Vector3;
  91380. max: Vector3;
  91381. };
  91382. /**
  91383. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  91384. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  91385. * @returns a vector3
  91386. */
  91387. static Center(meshesOrMinMaxVector: {
  91388. min: Vector3;
  91389. max: Vector3;
  91390. } | AbstractMesh[]): Vector3;
  91391. /**
  91392. * Merge the array of meshes into a single mesh for performance reasons.
  91393. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  91394. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  91395. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  91396. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  91397. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  91398. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  91399. * @returns a new mesh
  91400. */
  91401. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  91402. /** @hidden */
  91403. addInstance(instance: InstancedMesh): void;
  91404. /** @hidden */
  91405. removeInstance(instance: InstancedMesh): void;
  91406. }
  91407. }
  91408. declare module BABYLON {
  91409. /**
  91410. * This is the base class of all the camera used in the application.
  91411. * @see http://doc.babylonjs.com/features/cameras
  91412. */
  91413. export class Camera extends Node {
  91414. /** @hidden */
  91415. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  91416. /**
  91417. * This is the default projection mode used by the cameras.
  91418. * It helps recreating a feeling of perspective and better appreciate depth.
  91419. * This is the best way to simulate real life cameras.
  91420. */
  91421. static readonly PERSPECTIVE_CAMERA: number;
  91422. /**
  91423. * This helps creating camera with an orthographic mode.
  91424. * 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.
  91425. */
  91426. static readonly ORTHOGRAPHIC_CAMERA: number;
  91427. /**
  91428. * This is the default FOV mode for perspective cameras.
  91429. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  91430. */
  91431. static readonly FOVMODE_VERTICAL_FIXED: number;
  91432. /**
  91433. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  91434. */
  91435. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  91436. /**
  91437. * This specifies ther is no need for a camera rig.
  91438. * Basically only one eye is rendered corresponding to the camera.
  91439. */
  91440. static readonly RIG_MODE_NONE: number;
  91441. /**
  91442. * Simulates a camera Rig with one blue eye and one red eye.
  91443. * This can be use with 3d blue and red glasses.
  91444. */
  91445. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  91446. /**
  91447. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  91448. */
  91449. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  91450. /**
  91451. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  91452. */
  91453. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  91454. /**
  91455. * Defines that both eyes of the camera will be rendered over under each other.
  91456. */
  91457. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  91458. /**
  91459. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  91460. */
  91461. static readonly RIG_MODE_VR: number;
  91462. /**
  91463. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  91464. */
  91465. static readonly RIG_MODE_WEBVR: number;
  91466. /**
  91467. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  91468. */
  91469. static readonly RIG_MODE_CUSTOM: number;
  91470. /**
  91471. * Defines if by default attaching controls should prevent the default javascript event to continue.
  91472. */
  91473. static ForceAttachControlToAlwaysPreventDefault: boolean;
  91474. /**
  91475. * Define the input manager associated with the camera.
  91476. */
  91477. inputs: CameraInputsManager<Camera>;
  91478. /** @hidden */
  91479. _position: Vector3;
  91480. /**
  91481. * Define the current local position of the camera in the scene
  91482. */
  91483. position: Vector3;
  91484. /**
  91485. * The vector the camera should consider as up.
  91486. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  91487. */
  91488. upVector: Vector3;
  91489. /**
  91490. * Define the current limit on the left side for an orthographic camera
  91491. * In scene unit
  91492. */
  91493. orthoLeft: Nullable<number>;
  91494. /**
  91495. * Define the current limit on the right side for an orthographic camera
  91496. * In scene unit
  91497. */
  91498. orthoRight: Nullable<number>;
  91499. /**
  91500. * Define the current limit on the bottom side for an orthographic camera
  91501. * In scene unit
  91502. */
  91503. orthoBottom: Nullable<number>;
  91504. /**
  91505. * Define the current limit on the top side for an orthographic camera
  91506. * In scene unit
  91507. */
  91508. orthoTop: Nullable<number>;
  91509. /**
  91510. * Field Of View is set in Radians. (default is 0.8)
  91511. */
  91512. fov: number;
  91513. /**
  91514. * Define the minimum distance the camera can see from.
  91515. * This is important to note that the depth buffer are not infinite and the closer it starts
  91516. * the more your scene might encounter depth fighting issue.
  91517. */
  91518. minZ: number;
  91519. /**
  91520. * Define the maximum distance the camera can see to.
  91521. * This is important to note that the depth buffer are not infinite and the further it end
  91522. * the more your scene might encounter depth fighting issue.
  91523. */
  91524. maxZ: number;
  91525. /**
  91526. * Define the default inertia of the camera.
  91527. * This helps giving a smooth feeling to the camera movement.
  91528. */
  91529. inertia: number;
  91530. /**
  91531. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  91532. */
  91533. mode: number;
  91534. /**
  91535. * Define wether the camera is intermediate.
  91536. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  91537. */
  91538. isIntermediate: boolean;
  91539. /**
  91540. * Define the viewport of the camera.
  91541. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  91542. */
  91543. viewport: Viewport;
  91544. /**
  91545. * Restricts the camera to viewing objects with the same layerMask.
  91546. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  91547. */
  91548. layerMask: number;
  91549. /**
  91550. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  91551. */
  91552. fovMode: number;
  91553. /**
  91554. * Rig mode of the camera.
  91555. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  91556. * This is normally controlled byt the camera themselves as internal use.
  91557. */
  91558. cameraRigMode: number;
  91559. /**
  91560. * Defines the distance between both "eyes" in case of a RIG
  91561. */
  91562. interaxialDistance: number;
  91563. /**
  91564. * Defines if stereoscopic rendering is done side by side or over under.
  91565. */
  91566. isStereoscopicSideBySide: boolean;
  91567. /**
  91568. * 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
  91569. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  91570. * else in the scene. (Eg. security camera)
  91571. *
  91572. * 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)
  91573. */
  91574. customRenderTargets: RenderTargetTexture[];
  91575. /**
  91576. * When set, the camera will render to this render target instead of the default canvas
  91577. *
  91578. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  91579. */
  91580. outputRenderTarget: Nullable<RenderTargetTexture>;
  91581. /**
  91582. * Observable triggered when the camera view matrix has changed.
  91583. */
  91584. onViewMatrixChangedObservable: Observable<Camera>;
  91585. /**
  91586. * Observable triggered when the camera Projection matrix has changed.
  91587. */
  91588. onProjectionMatrixChangedObservable: Observable<Camera>;
  91589. /**
  91590. * Observable triggered when the inputs have been processed.
  91591. */
  91592. onAfterCheckInputsObservable: Observable<Camera>;
  91593. /**
  91594. * Observable triggered when reset has been called and applied to the camera.
  91595. */
  91596. onRestoreStateObservable: Observable<Camera>;
  91597. /** @hidden */
  91598. _cameraRigParams: any;
  91599. /** @hidden */
  91600. _rigCameras: Camera[];
  91601. /** @hidden */
  91602. _rigPostProcess: Nullable<PostProcess>;
  91603. protected _webvrViewMatrix: Matrix;
  91604. /** @hidden */
  91605. _skipRendering: boolean;
  91606. /** @hidden */
  91607. _projectionMatrix: Matrix;
  91608. /** @hidden */
  91609. _postProcesses: Nullable<PostProcess>[];
  91610. /** @hidden */
  91611. _activeMeshes: SmartArray<AbstractMesh>;
  91612. protected _globalPosition: Vector3;
  91613. /** @hidden */
  91614. _computedViewMatrix: Matrix;
  91615. private _doNotComputeProjectionMatrix;
  91616. private _transformMatrix;
  91617. private _frustumPlanes;
  91618. private _refreshFrustumPlanes;
  91619. private _storedFov;
  91620. private _stateStored;
  91621. /**
  91622. * Instantiates a new camera object.
  91623. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  91624. * @see http://doc.babylonjs.com/features/cameras
  91625. * @param name Defines the name of the camera in the scene
  91626. * @param position Defines the position of the camera
  91627. * @param scene Defines the scene the camera belongs too
  91628. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  91629. */
  91630. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91631. /**
  91632. * Store current camera state (fov, position, etc..)
  91633. * @returns the camera
  91634. */
  91635. storeState(): Camera;
  91636. /**
  91637. * Restores the camera state values if it has been stored. You must call storeState() first
  91638. */
  91639. protected _restoreStateValues(): boolean;
  91640. /**
  91641. * Restored camera state. You must call storeState() first.
  91642. * @returns true if restored and false otherwise
  91643. */
  91644. restoreState(): boolean;
  91645. /**
  91646. * Gets the class name of the camera.
  91647. * @returns the class name
  91648. */
  91649. getClassName(): string;
  91650. /** @hidden */
  91651. readonly _isCamera: boolean;
  91652. /**
  91653. * Gets a string representation of the camera useful for debug purpose.
  91654. * @param fullDetails Defines that a more verboe level of logging is required
  91655. * @returns the string representation
  91656. */
  91657. toString(fullDetails?: boolean): string;
  91658. /**
  91659. * Gets the current world space position of the camera.
  91660. */
  91661. readonly globalPosition: Vector3;
  91662. /**
  91663. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  91664. * @returns the active meshe list
  91665. */
  91666. getActiveMeshes(): SmartArray<AbstractMesh>;
  91667. /**
  91668. * Check wether a mesh is part of the current active mesh list of the camera
  91669. * @param mesh Defines the mesh to check
  91670. * @returns true if active, false otherwise
  91671. */
  91672. isActiveMesh(mesh: Mesh): boolean;
  91673. /**
  91674. * Is this camera ready to be used/rendered
  91675. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  91676. * @return true if the camera is ready
  91677. */
  91678. isReady(completeCheck?: boolean): boolean;
  91679. /** @hidden */
  91680. _initCache(): void;
  91681. /** @hidden */
  91682. _updateCache(ignoreParentClass?: boolean): void;
  91683. /** @hidden */
  91684. _isSynchronized(): boolean;
  91685. /** @hidden */
  91686. _isSynchronizedViewMatrix(): boolean;
  91687. /** @hidden */
  91688. _isSynchronizedProjectionMatrix(): boolean;
  91689. /**
  91690. * Attach the input controls to a specific dom element to get the input from.
  91691. * @param element Defines the element the controls should be listened from
  91692. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91693. */
  91694. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91695. /**
  91696. * Detach the current controls from the specified dom element.
  91697. * @param element Defines the element to stop listening the inputs from
  91698. */
  91699. detachControl(element: HTMLElement): void;
  91700. /**
  91701. * Update the camera state according to the different inputs gathered during the frame.
  91702. */
  91703. update(): void;
  91704. /** @hidden */
  91705. _checkInputs(): void;
  91706. /** @hidden */
  91707. readonly rigCameras: Camera[];
  91708. /**
  91709. * Gets the post process used by the rig cameras
  91710. */
  91711. readonly rigPostProcess: Nullable<PostProcess>;
  91712. /**
  91713. * Internal, gets the first post proces.
  91714. * @returns the first post process to be run on this camera.
  91715. */
  91716. _getFirstPostProcess(): Nullable<PostProcess>;
  91717. private _cascadePostProcessesToRigCams;
  91718. /**
  91719. * Attach a post process to the camera.
  91720. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91721. * @param postProcess The post process to attach to the camera
  91722. * @param insertAt The position of the post process in case several of them are in use in the scene
  91723. * @returns the position the post process has been inserted at
  91724. */
  91725. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  91726. /**
  91727. * Detach a post process to the camera.
  91728. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91729. * @param postProcess The post process to detach from the camera
  91730. */
  91731. detachPostProcess(postProcess: PostProcess): void;
  91732. /**
  91733. * Gets the current world matrix of the camera
  91734. */
  91735. getWorldMatrix(): Matrix;
  91736. /** @hidden */
  91737. _getViewMatrix(): Matrix;
  91738. /**
  91739. * Gets the current view matrix of the camera.
  91740. * @param force forces the camera to recompute the matrix without looking at the cached state
  91741. * @returns the view matrix
  91742. */
  91743. getViewMatrix(force?: boolean): Matrix;
  91744. /**
  91745. * Freeze the projection matrix.
  91746. * It will prevent the cache check of the camera projection compute and can speed up perf
  91747. * if no parameter of the camera are meant to change
  91748. * @param projection Defines manually a projection if necessary
  91749. */
  91750. freezeProjectionMatrix(projection?: Matrix): void;
  91751. /**
  91752. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  91753. */
  91754. unfreezeProjectionMatrix(): void;
  91755. /**
  91756. * Gets the current projection matrix of the camera.
  91757. * @param force forces the camera to recompute the matrix without looking at the cached state
  91758. * @returns the projection matrix
  91759. */
  91760. getProjectionMatrix(force?: boolean): Matrix;
  91761. /**
  91762. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  91763. * @returns a Matrix
  91764. */
  91765. getTransformationMatrix(): Matrix;
  91766. private _updateFrustumPlanes;
  91767. /**
  91768. * Checks if a cullable object (mesh...) is in the camera frustum
  91769. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  91770. * @param target The object to check
  91771. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  91772. * @returns true if the object is in frustum otherwise false
  91773. */
  91774. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  91775. /**
  91776. * Checks if a cullable object (mesh...) is in the camera frustum
  91777. * Unlike isInFrustum this cheks the full bounding box
  91778. * @param target The object to check
  91779. * @returns true if the object is in frustum otherwise false
  91780. */
  91781. isCompletelyInFrustum(target: ICullable): boolean;
  91782. /**
  91783. * Gets a ray in the forward direction from the camera.
  91784. * @param length Defines the length of the ray to create
  91785. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  91786. * @param origin Defines the start point of the ray which defaults to the camera position
  91787. * @returns the forward ray
  91788. */
  91789. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  91790. /**
  91791. * Releases resources associated with this node.
  91792. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91793. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91794. */
  91795. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91796. /** @hidden */
  91797. _isLeftCamera: boolean;
  91798. /**
  91799. * Gets the left camera of a rig setup in case of Rigged Camera
  91800. */
  91801. readonly isLeftCamera: boolean;
  91802. /** @hidden */
  91803. _isRightCamera: boolean;
  91804. /**
  91805. * Gets the right camera of a rig setup in case of Rigged Camera
  91806. */
  91807. readonly isRightCamera: boolean;
  91808. /**
  91809. * Gets the left camera of a rig setup in case of Rigged Camera
  91810. */
  91811. readonly leftCamera: Nullable<FreeCamera>;
  91812. /**
  91813. * Gets the right camera of a rig setup in case of Rigged Camera
  91814. */
  91815. readonly rightCamera: Nullable<FreeCamera>;
  91816. /**
  91817. * Gets the left camera target of a rig setup in case of Rigged Camera
  91818. * @returns the target position
  91819. */
  91820. getLeftTarget(): Nullable<Vector3>;
  91821. /**
  91822. * Gets the right camera target of a rig setup in case of Rigged Camera
  91823. * @returns the target position
  91824. */
  91825. getRightTarget(): Nullable<Vector3>;
  91826. /**
  91827. * @hidden
  91828. */
  91829. setCameraRigMode(mode: number, rigParams: any): void;
  91830. /** @hidden */
  91831. static _setStereoscopicRigMode(camera: Camera): void;
  91832. /** @hidden */
  91833. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  91834. /** @hidden */
  91835. static _setVRRigMode(camera: Camera, rigParams: any): void;
  91836. /** @hidden */
  91837. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  91838. /** @hidden */
  91839. _getVRProjectionMatrix(): Matrix;
  91840. protected _updateCameraRotationMatrix(): void;
  91841. protected _updateWebVRCameraRotationMatrix(): void;
  91842. /**
  91843. * This function MUST be overwritten by the different WebVR cameras available.
  91844. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91845. * @hidden
  91846. */
  91847. _getWebVRProjectionMatrix(): Matrix;
  91848. /**
  91849. * This function MUST be overwritten by the different WebVR cameras available.
  91850. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91851. * @hidden
  91852. */
  91853. _getWebVRViewMatrix(): Matrix;
  91854. /** @hidden */
  91855. setCameraRigParameter(name: string, value: any): void;
  91856. /**
  91857. * needs to be overridden by children so sub has required properties to be copied
  91858. * @hidden
  91859. */
  91860. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  91861. /**
  91862. * May need to be overridden by children
  91863. * @hidden
  91864. */
  91865. _updateRigCameras(): void;
  91866. /** @hidden */
  91867. _setupInputs(): void;
  91868. /**
  91869. * Serialiaze the camera setup to a json represention
  91870. * @returns the JSON representation
  91871. */
  91872. serialize(): any;
  91873. /**
  91874. * Clones the current camera.
  91875. * @param name The cloned camera name
  91876. * @returns the cloned camera
  91877. */
  91878. clone(name: string): Camera;
  91879. /**
  91880. * Gets the direction of the camera relative to a given local axis.
  91881. * @param localAxis Defines the reference axis to provide a relative direction.
  91882. * @return the direction
  91883. */
  91884. getDirection(localAxis: Vector3): Vector3;
  91885. /**
  91886. * Returns the current camera absolute rotation
  91887. */
  91888. readonly absoluteRotation: Quaternion;
  91889. /**
  91890. * Gets the direction of the camera relative to a given local axis into a passed vector.
  91891. * @param localAxis Defines the reference axis to provide a relative direction.
  91892. * @param result Defines the vector to store the result in
  91893. */
  91894. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  91895. /**
  91896. * Gets a camera constructor for a given camera type
  91897. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  91898. * @param name The name of the camera the result will be able to instantiate
  91899. * @param scene The scene the result will construct the camera in
  91900. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  91901. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  91902. * @returns a factory method to construc the camera
  91903. */
  91904. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  91905. /**
  91906. * Compute the world matrix of the camera.
  91907. * @returns the camera workd matrix
  91908. */
  91909. computeWorldMatrix(): Matrix;
  91910. /**
  91911. * Parse a JSON and creates the camera from the parsed information
  91912. * @param parsedCamera The JSON to parse
  91913. * @param scene The scene to instantiate the camera in
  91914. * @returns the newly constructed camera
  91915. */
  91916. static Parse(parsedCamera: any, scene: Scene): Camera;
  91917. }
  91918. }
  91919. declare module BABYLON {
  91920. /**
  91921. * Class containing static functions to help procedurally build meshes
  91922. */
  91923. export class DiscBuilder {
  91924. /**
  91925. * Creates a plane polygonal mesh. By default, this is a disc
  91926. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  91927. * * 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
  91928. * * 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
  91929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91930. * * 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
  91931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91932. * @param name defines the name of the mesh
  91933. * @param options defines the options used to create the mesh
  91934. * @param scene defines the hosting scene
  91935. * @returns the plane polygonal mesh
  91936. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  91937. */
  91938. static CreateDisc(name: string, options: {
  91939. radius?: number;
  91940. tessellation?: number;
  91941. arc?: number;
  91942. updatable?: boolean;
  91943. sideOrientation?: number;
  91944. frontUVs?: Vector4;
  91945. backUVs?: Vector4;
  91946. }, scene?: Nullable<Scene>): Mesh;
  91947. }
  91948. }
  91949. declare module BABYLON {
  91950. /**
  91951. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  91952. *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.
  91953. * The SPS is also a particle system. It provides some methods to manage the particles.
  91954. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  91955. *
  91956. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  91957. */
  91958. export class SolidParticleSystem implements IDisposable {
  91959. /**
  91960. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  91961. * Example : var p = SPS.particles[i];
  91962. */
  91963. particles: SolidParticle[];
  91964. /**
  91965. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  91966. */
  91967. nbParticles: number;
  91968. /**
  91969. * If the particles must ever face the camera (default false). Useful for planar particles.
  91970. */
  91971. billboard: boolean;
  91972. /**
  91973. * Recompute normals when adding a shape
  91974. */
  91975. recomputeNormals: boolean;
  91976. /**
  91977. * This a counter ofr your own usage. It's not set by any SPS functions.
  91978. */
  91979. counter: number;
  91980. /**
  91981. * The SPS name. This name is also given to the underlying mesh.
  91982. */
  91983. name: string;
  91984. /**
  91985. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  91986. */
  91987. mesh: Mesh;
  91988. /**
  91989. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  91990. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  91991. */
  91992. vars: any;
  91993. /**
  91994. * This array is populated when the SPS is set as 'pickable'.
  91995. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  91996. * Each element of this array is an object `{idx: int, faceId: int}`.
  91997. * `idx` is the picked particle index in the `SPS.particles` array
  91998. * `faceId` is the picked face index counted within this particle.
  91999. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  92000. */
  92001. pickedParticles: {
  92002. idx: number;
  92003. faceId: number;
  92004. }[];
  92005. /**
  92006. * This array is populated when `enableDepthSort` is set to true.
  92007. * Each element of this array is an instance of the class DepthSortedParticle.
  92008. */
  92009. depthSortedParticles: DepthSortedParticle[];
  92010. /**
  92011. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  92012. * @hidden
  92013. */
  92014. _bSphereOnly: boolean;
  92015. /**
  92016. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  92017. * @hidden
  92018. */
  92019. _bSphereRadiusFactor: number;
  92020. private _scene;
  92021. private _positions;
  92022. private _indices;
  92023. private _normals;
  92024. private _colors;
  92025. private _uvs;
  92026. private _indices32;
  92027. private _positions32;
  92028. private _normals32;
  92029. private _fixedNormal32;
  92030. private _colors32;
  92031. private _uvs32;
  92032. private _index;
  92033. private _updatable;
  92034. private _pickable;
  92035. private _isVisibilityBoxLocked;
  92036. private _alwaysVisible;
  92037. private _depthSort;
  92038. private _expandable;
  92039. private _shapeCounter;
  92040. private _copy;
  92041. private _color;
  92042. private _computeParticleColor;
  92043. private _computeParticleTexture;
  92044. private _computeParticleRotation;
  92045. private _computeParticleVertex;
  92046. private _computeBoundingBox;
  92047. private _depthSortParticles;
  92048. private _camera;
  92049. private _mustUnrotateFixedNormals;
  92050. private _particlesIntersect;
  92051. private _needs32Bits;
  92052. /**
  92053. * Creates a SPS (Solid Particle System) object.
  92054. * @param name (String) is the SPS name, this will be the underlying mesh name.
  92055. * @param scene (Scene) is the scene in which the SPS is added.
  92056. * @param options defines the options of the sps e.g.
  92057. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  92058. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  92059. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  92060. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  92061. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  92062. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  92063. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  92064. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  92065. */
  92066. constructor(name: string, scene: Scene, options?: {
  92067. updatable?: boolean;
  92068. isPickable?: boolean;
  92069. enableDepthSort?: boolean;
  92070. particleIntersection?: boolean;
  92071. boundingSphereOnly?: boolean;
  92072. bSphereRadiusFactor?: number;
  92073. expandable?: boolean;
  92074. });
  92075. /**
  92076. * Builds the SPS underlying mesh. Returns a standard Mesh.
  92077. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  92078. * @returns the created mesh
  92079. */
  92080. buildMesh(): Mesh;
  92081. /**
  92082. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  92083. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  92084. * Thus the particles generated from `digest()` have their property `position` set yet.
  92085. * @param mesh ( Mesh ) is the mesh to be digested
  92086. * @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
  92087. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  92088. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  92089. * @returns the current SPS
  92090. */
  92091. digest(mesh: Mesh, options?: {
  92092. facetNb?: number;
  92093. number?: number;
  92094. delta?: number;
  92095. }): SolidParticleSystem;
  92096. private _unrotateFixedNormals;
  92097. private _resetCopy;
  92098. private _meshBuilder;
  92099. private _posToShape;
  92100. private _uvsToShapeUV;
  92101. private _addParticle;
  92102. /**
  92103. * Adds some particles to the SPS from the model shape. Returns the shape id.
  92104. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  92105. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  92106. * @param nb (positive integer) the number of particles to be created from this model
  92107. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  92108. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  92109. * @returns the number of shapes in the system
  92110. */
  92111. addShape(mesh: Mesh, nb: number, options?: {
  92112. positionFunction?: any;
  92113. vertexFunction?: any;
  92114. }): number;
  92115. private _rebuildParticle;
  92116. /**
  92117. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  92118. * @returns the SPS.
  92119. */
  92120. rebuildMesh(): SolidParticleSystem;
  92121. /**
  92122. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  92123. * This method calls `updateParticle()` for each particle of the SPS.
  92124. * For an animated SPS, it is usually called within the render loop.
  92125. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  92126. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  92127. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  92128. * @returns the SPS.
  92129. */
  92130. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  92131. /**
  92132. * Disposes the SPS.
  92133. */
  92134. dispose(): void;
  92135. /**
  92136. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  92137. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92138. * @returns the SPS.
  92139. */
  92140. refreshVisibleSize(): SolidParticleSystem;
  92141. /**
  92142. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  92143. * @param size the size (float) of the visibility box
  92144. * note : this doesn't lock the SPS mesh bounding box.
  92145. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92146. */
  92147. setVisibilityBox(size: number): void;
  92148. /**
  92149. * Gets whether the SPS as always visible or not
  92150. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92151. */
  92152. /**
  92153. * Sets the SPS as always visible or not
  92154. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92155. */
  92156. isAlwaysVisible: boolean;
  92157. /**
  92158. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92159. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92160. */
  92161. /**
  92162. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92163. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92164. */
  92165. isVisibilityBoxLocked: boolean;
  92166. /**
  92167. * Tells to `setParticles()` to compute the particle rotations or not.
  92168. * Default value : true. The SPS is faster when it's set to false.
  92169. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92170. */
  92171. /**
  92172. * Gets if `setParticles()` computes the particle rotations or not.
  92173. * Default value : true. The SPS is faster when it's set to false.
  92174. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92175. */
  92176. computeParticleRotation: boolean;
  92177. /**
  92178. * Tells to `setParticles()` to compute the particle colors or not.
  92179. * Default value : true. The SPS is faster when it's set to false.
  92180. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92181. */
  92182. /**
  92183. * Gets if `setParticles()` computes the particle colors or not.
  92184. * Default value : true. The SPS is faster when it's set to false.
  92185. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92186. */
  92187. computeParticleColor: boolean;
  92188. /**
  92189. * Gets if `setParticles()` computes the particle textures or not.
  92190. * Default value : true. The SPS is faster when it's set to false.
  92191. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  92192. */
  92193. computeParticleTexture: boolean;
  92194. /**
  92195. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  92196. * Default value : false. The SPS is faster when it's set to false.
  92197. * Note : the particle custom vertex positions aren't stored values.
  92198. */
  92199. /**
  92200. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  92201. * Default value : false. The SPS is faster when it's set to false.
  92202. * Note : the particle custom vertex positions aren't stored values.
  92203. */
  92204. computeParticleVertex: boolean;
  92205. /**
  92206. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  92207. */
  92208. /**
  92209. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  92210. */
  92211. computeBoundingBox: boolean;
  92212. /**
  92213. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  92214. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92215. * Default : `true`
  92216. */
  92217. /**
  92218. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  92219. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92220. * Default : `true`
  92221. */
  92222. depthSortParticles: boolean;
  92223. /**
  92224. * Gets if the SPS is created as expandable at construction time.
  92225. * Default : `false`
  92226. */
  92227. readonly expandable: boolean;
  92228. /**
  92229. * This function does nothing. It may be overwritten to set all the particle first values.
  92230. * The SPS doesn't call this function, you may have to call it by your own.
  92231. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92232. */
  92233. initParticles(): void;
  92234. /**
  92235. * This function does nothing. It may be overwritten to recycle a particle.
  92236. * The SPS doesn't call this function, you may have to call it by your own.
  92237. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92238. * @param particle The particle to recycle
  92239. * @returns the recycled particle
  92240. */
  92241. recycleParticle(particle: SolidParticle): SolidParticle;
  92242. /**
  92243. * Updates a particle : this function should be overwritten by the user.
  92244. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  92245. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92246. * @example : just set a particle position or velocity and recycle conditions
  92247. * @param particle The particle to update
  92248. * @returns the updated particle
  92249. */
  92250. updateParticle(particle: SolidParticle): SolidParticle;
  92251. /**
  92252. * Updates a vertex of a particle : it can be overwritten by the user.
  92253. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  92254. * @param particle the current particle
  92255. * @param vertex the current index of the current particle
  92256. * @param pt the index of the current vertex in the particle shape
  92257. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  92258. * @example : just set a vertex particle position
  92259. * @returns the updated vertex
  92260. */
  92261. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  92262. /**
  92263. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  92264. * This does nothing and may be overwritten by the user.
  92265. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92266. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92267. * @param update the boolean update value actually passed to setParticles()
  92268. */
  92269. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92270. /**
  92271. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  92272. * This will be passed three parameters.
  92273. * This does nothing and may be overwritten by the user.
  92274. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92275. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92276. * @param update the boolean update value actually passed to setParticles()
  92277. */
  92278. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92279. }
  92280. }
  92281. declare module BABYLON {
  92282. /**
  92283. * Represents one particle of a solid particle system.
  92284. */
  92285. export class SolidParticle {
  92286. /**
  92287. * particle global index
  92288. */
  92289. idx: number;
  92290. /**
  92291. * The color of the particle
  92292. */
  92293. color: Nullable<Color4>;
  92294. /**
  92295. * The world space position of the particle.
  92296. */
  92297. position: Vector3;
  92298. /**
  92299. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  92300. */
  92301. rotation: Vector3;
  92302. /**
  92303. * The world space rotation quaternion of the particle.
  92304. */
  92305. rotationQuaternion: Nullable<Quaternion>;
  92306. /**
  92307. * The scaling of the particle.
  92308. */
  92309. scaling: Vector3;
  92310. /**
  92311. * The uvs of the particle.
  92312. */
  92313. uvs: Vector4;
  92314. /**
  92315. * The current speed of the particle.
  92316. */
  92317. velocity: Vector3;
  92318. /**
  92319. * The pivot point in the particle local space.
  92320. */
  92321. pivot: Vector3;
  92322. /**
  92323. * Must the particle be translated from its pivot point in its local space ?
  92324. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  92325. * Default : false
  92326. */
  92327. translateFromPivot: boolean;
  92328. /**
  92329. * Is the particle active or not ?
  92330. */
  92331. alive: boolean;
  92332. /**
  92333. * Is the particle visible or not ?
  92334. */
  92335. isVisible: boolean;
  92336. /**
  92337. * Index of this particle in the global "positions" array (Internal use)
  92338. * @hidden
  92339. */
  92340. _pos: number;
  92341. /**
  92342. * @hidden Index of this particle in the global "indices" array (Internal use)
  92343. */
  92344. _ind: number;
  92345. /**
  92346. * @hidden ModelShape of this particle (Internal use)
  92347. */
  92348. _model: ModelShape;
  92349. /**
  92350. * ModelShape id of this particle
  92351. */
  92352. shapeId: number;
  92353. /**
  92354. * Index of the particle in its shape id
  92355. */
  92356. idxInShape: number;
  92357. /**
  92358. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  92359. */
  92360. _modelBoundingInfo: BoundingInfo;
  92361. /**
  92362. * @hidden Particle BoundingInfo object (Internal use)
  92363. */
  92364. _boundingInfo: BoundingInfo;
  92365. /**
  92366. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  92367. */
  92368. _sps: SolidParticleSystem;
  92369. /**
  92370. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  92371. */
  92372. _stillInvisible: boolean;
  92373. /**
  92374. * @hidden Last computed particle rotation matrix
  92375. */
  92376. _rotationMatrix: number[];
  92377. /**
  92378. * Parent particle Id, if any.
  92379. * Default null.
  92380. */
  92381. parentId: Nullable<number>;
  92382. /**
  92383. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  92384. * The possible values are :
  92385. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92386. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92387. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92388. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92389. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92390. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  92391. * */
  92392. cullingStrategy: number;
  92393. /**
  92394. * @hidden Internal global position in the SPS.
  92395. */
  92396. _globalPosition: Vector3;
  92397. /**
  92398. * Creates a Solid Particle object.
  92399. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  92400. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  92401. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  92402. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  92403. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  92404. * @param shapeId (integer) is the model shape identifier in the SPS.
  92405. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  92406. * @param sps defines the sps it is associated to
  92407. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  92408. */
  92409. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  92410. /**
  92411. * Legacy support, changed scale to scaling
  92412. */
  92413. /**
  92414. * Legacy support, changed scale to scaling
  92415. */
  92416. scale: Vector3;
  92417. /**
  92418. * Legacy support, changed quaternion to rotationQuaternion
  92419. */
  92420. /**
  92421. * Legacy support, changed quaternion to rotationQuaternion
  92422. */
  92423. quaternion: Nullable<Quaternion>;
  92424. /**
  92425. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  92426. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  92427. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  92428. * @returns true if it intersects
  92429. */
  92430. intersectsMesh(target: Mesh | SolidParticle): boolean;
  92431. /**
  92432. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  92433. * A particle is in the frustum if its bounding box intersects the frustum
  92434. * @param frustumPlanes defines the frustum to test
  92435. * @returns true if the particle is in the frustum planes
  92436. */
  92437. isInFrustum(frustumPlanes: Plane[]): boolean;
  92438. /**
  92439. * get the rotation matrix of the particle
  92440. * @hidden
  92441. */
  92442. getRotationMatrix(m: Matrix): void;
  92443. }
  92444. /**
  92445. * Represents the shape of the model used by one particle of a solid particle system.
  92446. * SPS internal tool, don't use it manually.
  92447. */
  92448. export class ModelShape {
  92449. /**
  92450. * The shape id
  92451. * @hidden
  92452. */
  92453. shapeID: number;
  92454. /**
  92455. * flat array of model positions (internal use)
  92456. * @hidden
  92457. */
  92458. _shape: Vector3[];
  92459. /**
  92460. * flat array of model UVs (internal use)
  92461. * @hidden
  92462. */
  92463. _shapeUV: number[];
  92464. /**
  92465. * length of the shape in the model indices array (internal use)
  92466. * @hidden
  92467. */
  92468. _indicesLength: number;
  92469. /**
  92470. * Custom position function (internal use)
  92471. * @hidden
  92472. */
  92473. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  92474. /**
  92475. * Custom vertex function (internal use)
  92476. * @hidden
  92477. */
  92478. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  92479. /**
  92480. * 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.
  92481. * SPS internal tool, don't use it manually.
  92482. * @hidden
  92483. */
  92484. 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>);
  92485. }
  92486. /**
  92487. * Represents a Depth Sorted Particle in the solid particle system.
  92488. */
  92489. export class DepthSortedParticle {
  92490. /**
  92491. * Index of the particle in the "indices" array
  92492. */
  92493. ind: number;
  92494. /**
  92495. * Length of the particle shape in the "indices" array
  92496. */
  92497. indicesLength: number;
  92498. /**
  92499. * Squared distance from the particle to the camera
  92500. */
  92501. sqDistance: number;
  92502. }
  92503. }
  92504. declare module BABYLON {
  92505. /**
  92506. * @hidden
  92507. */
  92508. export class _MeshCollisionData {
  92509. _checkCollisions: boolean;
  92510. _collisionMask: number;
  92511. _collisionGroup: number;
  92512. _collider: Nullable<Collider>;
  92513. _oldPositionForCollisions: Vector3;
  92514. _diffPositionForCollisions: Vector3;
  92515. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  92516. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  92517. }
  92518. }
  92519. declare module BABYLON {
  92520. /** @hidden */
  92521. class _FacetDataStorage {
  92522. facetPositions: Vector3[];
  92523. facetNormals: Vector3[];
  92524. facetPartitioning: number[][];
  92525. facetNb: number;
  92526. partitioningSubdivisions: number;
  92527. partitioningBBoxRatio: number;
  92528. facetDataEnabled: boolean;
  92529. facetParameters: any;
  92530. bbSize: Vector3;
  92531. subDiv: {
  92532. max: number;
  92533. X: number;
  92534. Y: number;
  92535. Z: number;
  92536. };
  92537. facetDepthSort: boolean;
  92538. facetDepthSortEnabled: boolean;
  92539. depthSortedIndices: IndicesArray;
  92540. depthSortedFacets: {
  92541. ind: number;
  92542. sqDistance: number;
  92543. }[];
  92544. facetDepthSortFunction: (f1: {
  92545. ind: number;
  92546. sqDistance: number;
  92547. }, f2: {
  92548. ind: number;
  92549. sqDistance: number;
  92550. }) => number;
  92551. facetDepthSortFrom: Vector3;
  92552. facetDepthSortOrigin: Vector3;
  92553. invertedMatrix: Matrix;
  92554. }
  92555. /**
  92556. * @hidden
  92557. **/
  92558. class _InternalAbstractMeshDataInfo {
  92559. _hasVertexAlpha: boolean;
  92560. _useVertexColors: boolean;
  92561. _numBoneInfluencers: number;
  92562. _applyFog: boolean;
  92563. _receiveShadows: boolean;
  92564. _facetData: _FacetDataStorage;
  92565. _visibility: number;
  92566. _skeleton: Nullable<Skeleton>;
  92567. _layerMask: number;
  92568. _computeBonesUsingShaders: boolean;
  92569. _isActive: boolean;
  92570. _onlyForInstances: boolean;
  92571. _isActiveIntermediate: boolean;
  92572. _onlyForInstancesIntermediate: boolean;
  92573. }
  92574. /**
  92575. * Class used to store all common mesh properties
  92576. */
  92577. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  92578. /** No occlusion */
  92579. static OCCLUSION_TYPE_NONE: number;
  92580. /** Occlusion set to optimisitic */
  92581. static OCCLUSION_TYPE_OPTIMISTIC: number;
  92582. /** Occlusion set to strict */
  92583. static OCCLUSION_TYPE_STRICT: number;
  92584. /** Use an accurante occlusion algorithm */
  92585. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  92586. /** Use a conservative occlusion algorithm */
  92587. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  92588. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  92589. * Test order :
  92590. * Is the bounding sphere outside the frustum ?
  92591. * If not, are the bounding box vertices outside the frustum ?
  92592. * It not, then the cullable object is in the frustum.
  92593. */
  92594. static readonly CULLINGSTRATEGY_STANDARD: number;
  92595. /** Culling strategy : Bounding Sphere Only.
  92596. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  92597. * It's also less accurate than the standard because some not visible objects can still be selected.
  92598. * Test : is the bounding sphere outside the frustum ?
  92599. * If not, then the cullable object is in the frustum.
  92600. */
  92601. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  92602. /** Culling strategy : Optimistic Inclusion.
  92603. * This in an inclusion test first, then the standard exclusion test.
  92604. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  92605. * 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.
  92606. * Anyway, it's as accurate as the standard strategy.
  92607. * Test :
  92608. * Is the cullable object bounding sphere center in the frustum ?
  92609. * If not, apply the default culling strategy.
  92610. */
  92611. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  92612. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  92613. * This in an inclusion test first, then the bounding sphere only exclusion test.
  92614. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  92615. * 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.
  92616. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  92617. * Test :
  92618. * Is the cullable object bounding sphere center in the frustum ?
  92619. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  92620. */
  92621. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  92622. /**
  92623. * No billboard
  92624. */
  92625. static readonly BILLBOARDMODE_NONE: number;
  92626. /** Billboard on X axis */
  92627. static readonly BILLBOARDMODE_X: number;
  92628. /** Billboard on Y axis */
  92629. static readonly BILLBOARDMODE_Y: number;
  92630. /** Billboard on Z axis */
  92631. static readonly BILLBOARDMODE_Z: number;
  92632. /** Billboard on all axes */
  92633. static readonly BILLBOARDMODE_ALL: number;
  92634. /** Billboard on using position instead of orientation */
  92635. static readonly BILLBOARDMODE_USE_POSITION: number;
  92636. /** @hidden */
  92637. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  92638. /**
  92639. * The culling strategy to use to check whether the mesh must be rendered or not.
  92640. * This value can be changed at any time and will be used on the next render mesh selection.
  92641. * The possible values are :
  92642. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92643. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92644. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92645. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92646. * Please read each static variable documentation to get details about the culling process.
  92647. * */
  92648. cullingStrategy: number;
  92649. /**
  92650. * Gets the number of facets in the mesh
  92651. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92652. */
  92653. readonly facetNb: number;
  92654. /**
  92655. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  92656. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92657. */
  92658. partitioningSubdivisions: number;
  92659. /**
  92660. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  92661. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  92662. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92663. */
  92664. partitioningBBoxRatio: number;
  92665. /**
  92666. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  92667. * Works only for updatable meshes.
  92668. * Doesn't work with multi-materials
  92669. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92670. */
  92671. mustDepthSortFacets: boolean;
  92672. /**
  92673. * The location (Vector3) where the facet depth sort must be computed from.
  92674. * By default, the active camera position.
  92675. * Used only when facet depth sort is enabled
  92676. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92677. */
  92678. facetDepthSortFrom: Vector3;
  92679. /**
  92680. * gets a boolean indicating if facetData is enabled
  92681. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92682. */
  92683. readonly isFacetDataEnabled: boolean;
  92684. /** @hidden */
  92685. _updateNonUniformScalingState(value: boolean): boolean;
  92686. /**
  92687. * An event triggered when this mesh collides with another one
  92688. */
  92689. onCollideObservable: Observable<AbstractMesh>;
  92690. /** Set a function to call when this mesh collides with another one */
  92691. onCollide: () => void;
  92692. /**
  92693. * An event triggered when the collision's position changes
  92694. */
  92695. onCollisionPositionChangeObservable: Observable<Vector3>;
  92696. /** Set a function to call when the collision's position changes */
  92697. onCollisionPositionChange: () => void;
  92698. /**
  92699. * An event triggered when material is changed
  92700. */
  92701. onMaterialChangedObservable: Observable<AbstractMesh>;
  92702. /**
  92703. * Gets or sets the orientation for POV movement & rotation
  92704. */
  92705. definedFacingForward: boolean;
  92706. /** @hidden */
  92707. _occlusionQuery: Nullable<WebGLQuery>;
  92708. /** @hidden */
  92709. _renderingGroup: Nullable<RenderingGroup>;
  92710. /**
  92711. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92712. */
  92713. /**
  92714. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92715. */
  92716. visibility: number;
  92717. /** Gets or sets the alpha index used to sort transparent meshes
  92718. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  92719. */
  92720. alphaIndex: number;
  92721. /**
  92722. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  92723. */
  92724. isVisible: boolean;
  92725. /**
  92726. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  92727. */
  92728. isPickable: boolean;
  92729. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  92730. showSubMeshesBoundingBox: boolean;
  92731. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  92732. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  92733. */
  92734. isBlocker: boolean;
  92735. /**
  92736. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  92737. */
  92738. enablePointerMoveEvents: boolean;
  92739. /**
  92740. * Specifies the rendering group id for this mesh (0 by default)
  92741. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  92742. */
  92743. renderingGroupId: number;
  92744. private _material;
  92745. /** Gets or sets current material */
  92746. material: Nullable<Material>;
  92747. /**
  92748. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  92749. * @see http://doc.babylonjs.com/babylon101/shadows
  92750. */
  92751. receiveShadows: boolean;
  92752. /** Defines color to use when rendering outline */
  92753. outlineColor: Color3;
  92754. /** Define width to use when rendering outline */
  92755. outlineWidth: number;
  92756. /** Defines color to use when rendering overlay */
  92757. overlayColor: Color3;
  92758. /** Defines alpha to use when rendering overlay */
  92759. overlayAlpha: number;
  92760. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  92761. hasVertexAlpha: boolean;
  92762. /** 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) */
  92763. useVertexColors: boolean;
  92764. /**
  92765. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  92766. */
  92767. computeBonesUsingShaders: boolean;
  92768. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  92769. numBoneInfluencers: number;
  92770. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  92771. applyFog: boolean;
  92772. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  92773. useOctreeForRenderingSelection: boolean;
  92774. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  92775. useOctreeForPicking: boolean;
  92776. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  92777. useOctreeForCollisions: boolean;
  92778. /**
  92779. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  92780. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  92781. */
  92782. layerMask: number;
  92783. /**
  92784. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  92785. */
  92786. alwaysSelectAsActiveMesh: boolean;
  92787. /**
  92788. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  92789. */
  92790. doNotSyncBoundingInfo: boolean;
  92791. /**
  92792. * Gets or sets the current action manager
  92793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92794. */
  92795. actionManager: Nullable<AbstractActionManager>;
  92796. private _meshCollisionData;
  92797. /**
  92798. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  92799. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92800. */
  92801. ellipsoid: Vector3;
  92802. /**
  92803. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  92804. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92805. */
  92806. ellipsoidOffset: Vector3;
  92807. /**
  92808. * Gets or sets a collision mask used to mask collisions (default is -1).
  92809. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92810. */
  92811. collisionMask: number;
  92812. /**
  92813. * Gets or sets the current collision group mask (-1 by default).
  92814. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92815. */
  92816. collisionGroup: number;
  92817. /**
  92818. * Defines edge width used when edgesRenderer is enabled
  92819. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92820. */
  92821. edgesWidth: number;
  92822. /**
  92823. * Defines edge color used when edgesRenderer is enabled
  92824. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92825. */
  92826. edgesColor: Color4;
  92827. /** @hidden */
  92828. _edgesRenderer: Nullable<IEdgesRenderer>;
  92829. /** @hidden */
  92830. _masterMesh: Nullable<AbstractMesh>;
  92831. /** @hidden */
  92832. _boundingInfo: Nullable<BoundingInfo>;
  92833. /** @hidden */
  92834. _renderId: number;
  92835. /**
  92836. * Gets or sets the list of subMeshes
  92837. * @see http://doc.babylonjs.com/how_to/multi_materials
  92838. */
  92839. subMeshes: SubMesh[];
  92840. /** @hidden */
  92841. _intersectionsInProgress: AbstractMesh[];
  92842. /** @hidden */
  92843. _unIndexed: boolean;
  92844. /** @hidden */
  92845. _lightSources: Light[];
  92846. /** Gets the list of lights affecting that mesh */
  92847. readonly lightSources: Light[];
  92848. /** @hidden */
  92849. readonly _positions: Nullable<Vector3[]>;
  92850. /** @hidden */
  92851. _waitingData: {
  92852. lods: Nullable<any>;
  92853. actions: Nullable<any>;
  92854. freezeWorldMatrix: Nullable<boolean>;
  92855. };
  92856. /** @hidden */
  92857. _bonesTransformMatrices: Nullable<Float32Array>;
  92858. /** @hidden */
  92859. _transformMatrixTexture: Nullable<RawTexture>;
  92860. /**
  92861. * Gets or sets a skeleton to apply skining transformations
  92862. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92863. */
  92864. skeleton: Nullable<Skeleton>;
  92865. /**
  92866. * An event triggered when the mesh is rebuilt.
  92867. */
  92868. onRebuildObservable: Observable<AbstractMesh>;
  92869. /**
  92870. * Creates a new AbstractMesh
  92871. * @param name defines the name of the mesh
  92872. * @param scene defines the hosting scene
  92873. */
  92874. constructor(name: string, scene?: Nullable<Scene>);
  92875. /**
  92876. * Returns the string "AbstractMesh"
  92877. * @returns "AbstractMesh"
  92878. */
  92879. getClassName(): string;
  92880. /**
  92881. * Gets a string representation of the current mesh
  92882. * @param fullDetails defines a boolean indicating if full details must be included
  92883. * @returns a string representation of the current mesh
  92884. */
  92885. toString(fullDetails?: boolean): string;
  92886. /**
  92887. * @hidden
  92888. */
  92889. protected _getEffectiveParent(): Nullable<Node>;
  92890. /** @hidden */
  92891. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92892. /** @hidden */
  92893. _rebuild(): void;
  92894. /** @hidden */
  92895. _resyncLightSources(): void;
  92896. /** @hidden */
  92897. _resyncLighSource(light: Light): void;
  92898. /** @hidden */
  92899. _unBindEffect(): void;
  92900. /** @hidden */
  92901. _removeLightSource(light: Light, dispose: boolean): void;
  92902. private _markSubMeshesAsDirty;
  92903. /** @hidden */
  92904. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  92905. /** @hidden */
  92906. _markSubMeshesAsAttributesDirty(): void;
  92907. /** @hidden */
  92908. _markSubMeshesAsMiscDirty(): void;
  92909. /**
  92910. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  92911. */
  92912. scaling: Vector3;
  92913. /**
  92914. * Returns true if the mesh is blocked. Implemented by child classes
  92915. */
  92916. readonly isBlocked: boolean;
  92917. /**
  92918. * Returns the mesh itself by default. Implemented by child classes
  92919. * @param camera defines the camera to use to pick the right LOD level
  92920. * @returns the currentAbstractMesh
  92921. */
  92922. getLOD(camera: Camera): Nullable<AbstractMesh>;
  92923. /**
  92924. * Returns 0 by default. Implemented by child classes
  92925. * @returns an integer
  92926. */
  92927. getTotalVertices(): number;
  92928. /**
  92929. * Returns a positive integer : the total number of indices in this mesh geometry.
  92930. * @returns the numner of indices or zero if the mesh has no geometry.
  92931. */
  92932. getTotalIndices(): number;
  92933. /**
  92934. * Returns null by default. Implemented by child classes
  92935. * @returns null
  92936. */
  92937. getIndices(): Nullable<IndicesArray>;
  92938. /**
  92939. * Returns the array of the requested vertex data kind. Implemented by child classes
  92940. * @param kind defines the vertex data kind to use
  92941. * @returns null
  92942. */
  92943. getVerticesData(kind: string): Nullable<FloatArray>;
  92944. /**
  92945. * Sets the vertex data of the mesh geometry for the requested `kind`.
  92946. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  92947. * Note that a new underlying VertexBuffer object is created each call.
  92948. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  92949. * @param kind defines vertex data kind:
  92950. * * VertexBuffer.PositionKind
  92951. * * VertexBuffer.UVKind
  92952. * * VertexBuffer.UV2Kind
  92953. * * VertexBuffer.UV3Kind
  92954. * * VertexBuffer.UV4Kind
  92955. * * VertexBuffer.UV5Kind
  92956. * * VertexBuffer.UV6Kind
  92957. * * VertexBuffer.ColorKind
  92958. * * VertexBuffer.MatricesIndicesKind
  92959. * * VertexBuffer.MatricesIndicesExtraKind
  92960. * * VertexBuffer.MatricesWeightsKind
  92961. * * VertexBuffer.MatricesWeightsExtraKind
  92962. * @param data defines the data source
  92963. * @param updatable defines if the data must be flagged as updatable (or static)
  92964. * @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
  92965. * @returns the current mesh
  92966. */
  92967. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92968. /**
  92969. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  92970. * If the mesh has no geometry, it is simply returned as it is.
  92971. * @param kind defines vertex data kind:
  92972. * * VertexBuffer.PositionKind
  92973. * * VertexBuffer.UVKind
  92974. * * VertexBuffer.UV2Kind
  92975. * * VertexBuffer.UV3Kind
  92976. * * VertexBuffer.UV4Kind
  92977. * * VertexBuffer.UV5Kind
  92978. * * VertexBuffer.UV6Kind
  92979. * * VertexBuffer.ColorKind
  92980. * * VertexBuffer.MatricesIndicesKind
  92981. * * VertexBuffer.MatricesIndicesExtraKind
  92982. * * VertexBuffer.MatricesWeightsKind
  92983. * * VertexBuffer.MatricesWeightsExtraKind
  92984. * @param data defines the data source
  92985. * @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
  92986. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  92987. * @returns the current mesh
  92988. */
  92989. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92990. /**
  92991. * Sets the mesh indices,
  92992. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  92993. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  92994. * @param totalVertices Defines the total number of vertices
  92995. * @returns the current mesh
  92996. */
  92997. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  92998. /**
  92999. * Gets a boolean indicating if specific vertex data is present
  93000. * @param kind defines the vertex data kind to use
  93001. * @returns true is data kind is present
  93002. */
  93003. isVerticesDataPresent(kind: string): boolean;
  93004. /**
  93005. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  93006. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  93007. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  93008. * @returns a BoundingInfo
  93009. */
  93010. getBoundingInfo(): BoundingInfo;
  93011. /**
  93012. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93013. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93014. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93015. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93016. * @returns the current mesh
  93017. */
  93018. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  93019. /**
  93020. * Overwrite the current bounding info
  93021. * @param boundingInfo defines the new bounding info
  93022. * @returns the current mesh
  93023. */
  93024. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  93025. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  93026. readonly useBones: boolean;
  93027. /** @hidden */
  93028. _preActivate(): void;
  93029. /** @hidden */
  93030. _preActivateForIntermediateRendering(renderId: number): void;
  93031. /** @hidden */
  93032. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93033. /** @hidden */
  93034. _postActivate(): void;
  93035. /** @hidden */
  93036. _freeze(): void;
  93037. /** @hidden */
  93038. _unFreeze(): void;
  93039. /**
  93040. * Gets the current world matrix
  93041. * @returns a Matrix
  93042. */
  93043. getWorldMatrix(): Matrix;
  93044. /** @hidden */
  93045. _getWorldMatrixDeterminant(): number;
  93046. /**
  93047. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  93048. */
  93049. readonly isAnInstance: boolean;
  93050. /**
  93051. * Gets a boolean indicating if this mesh has instances
  93052. */
  93053. readonly hasInstances: boolean;
  93054. /**
  93055. * Perform relative position change from the point of view of behind the front of the mesh.
  93056. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93057. * Supports definition of mesh facing forward or backward
  93058. * @param amountRight defines the distance on the right axis
  93059. * @param amountUp defines the distance on the up axis
  93060. * @param amountForward defines the distance on the forward axis
  93061. * @returns the current mesh
  93062. */
  93063. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  93064. /**
  93065. * Calculate relative position change from the point of view of behind the front of the mesh.
  93066. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93067. * Supports definition of mesh facing forward or backward
  93068. * @param amountRight defines the distance on the right axis
  93069. * @param amountUp defines the distance on the up axis
  93070. * @param amountForward defines the distance on the forward axis
  93071. * @returns the new displacement vector
  93072. */
  93073. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  93074. /**
  93075. * Perform relative rotation change from the point of view of behind the front of the mesh.
  93076. * Supports definition of mesh facing forward or backward
  93077. * @param flipBack defines the flip
  93078. * @param twirlClockwise defines the twirl
  93079. * @param tiltRight defines the tilt
  93080. * @returns the current mesh
  93081. */
  93082. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  93083. /**
  93084. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  93085. * Supports definition of mesh facing forward or backward.
  93086. * @param flipBack defines the flip
  93087. * @param twirlClockwise defines the twirl
  93088. * @param tiltRight defines the tilt
  93089. * @returns the new rotation vector
  93090. */
  93091. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  93092. /**
  93093. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93094. * This means the mesh underlying bounding box and sphere are recomputed.
  93095. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93096. * @returns the current mesh
  93097. */
  93098. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  93099. /** @hidden */
  93100. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  93101. /** @hidden */
  93102. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  93103. /** @hidden */
  93104. _updateBoundingInfo(): AbstractMesh;
  93105. /** @hidden */
  93106. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  93107. /** @hidden */
  93108. protected _afterComputeWorldMatrix(): void;
  93109. /** @hidden */
  93110. readonly _effectiveMesh: AbstractMesh;
  93111. /**
  93112. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93113. * A mesh is in the frustum if its bounding box intersects the frustum
  93114. * @param frustumPlanes defines the frustum to test
  93115. * @returns true if the mesh is in the frustum planes
  93116. */
  93117. isInFrustum(frustumPlanes: Plane[]): boolean;
  93118. /**
  93119. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  93120. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  93121. * @param frustumPlanes defines the frustum to test
  93122. * @returns true if the mesh is completely in the frustum planes
  93123. */
  93124. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93125. /**
  93126. * True if the mesh intersects another mesh or a SolidParticle object
  93127. * @param mesh defines a target mesh or SolidParticle to test
  93128. * @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)
  93129. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  93130. * @returns true if there is an intersection
  93131. */
  93132. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  93133. /**
  93134. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  93135. * @param point defines the point to test
  93136. * @returns true if there is an intersection
  93137. */
  93138. intersectsPoint(point: Vector3): boolean;
  93139. /**
  93140. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  93141. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93142. */
  93143. checkCollisions: boolean;
  93144. /**
  93145. * Gets Collider object used to compute collisions (not physics)
  93146. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93147. */
  93148. readonly collider: Nullable<Collider>;
  93149. /**
  93150. * Move the mesh using collision engine
  93151. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93152. * @param displacement defines the requested displacement vector
  93153. * @returns the current mesh
  93154. */
  93155. moveWithCollisions(displacement: Vector3): AbstractMesh;
  93156. private _onCollisionPositionChange;
  93157. /** @hidden */
  93158. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  93159. /** @hidden */
  93160. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  93161. /** @hidden */
  93162. _checkCollision(collider: Collider): AbstractMesh;
  93163. /** @hidden */
  93164. _generatePointsArray(): boolean;
  93165. /**
  93166. * Checks if the passed Ray intersects with the mesh
  93167. * @param ray defines the ray to use
  93168. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  93169. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93170. * @returns the picking info
  93171. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93172. */
  93173. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  93174. /**
  93175. * Clones the current mesh
  93176. * @param name defines the mesh name
  93177. * @param newParent defines the new mesh parent
  93178. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  93179. * @returns the new mesh
  93180. */
  93181. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  93182. /**
  93183. * Disposes all the submeshes of the current meshnp
  93184. * @returns the current mesh
  93185. */
  93186. releaseSubMeshes(): AbstractMesh;
  93187. /**
  93188. * Releases resources associated with this abstract mesh.
  93189. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93190. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93191. */
  93192. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93193. /**
  93194. * Adds the passed mesh as a child to the current mesh
  93195. * @param mesh defines the child mesh
  93196. * @returns the current mesh
  93197. */
  93198. addChild(mesh: AbstractMesh): AbstractMesh;
  93199. /**
  93200. * Removes the passed mesh from the current mesh children list
  93201. * @param mesh defines the child mesh
  93202. * @returns the current mesh
  93203. */
  93204. removeChild(mesh: AbstractMesh): AbstractMesh;
  93205. /** @hidden */
  93206. private _initFacetData;
  93207. /**
  93208. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  93209. * This method can be called within the render loop.
  93210. * 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
  93211. * @returns the current mesh
  93212. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93213. */
  93214. updateFacetData(): AbstractMesh;
  93215. /**
  93216. * Returns the facetLocalNormals array.
  93217. * The normals are expressed in the mesh local spac
  93218. * @returns an array of Vector3
  93219. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93220. */
  93221. getFacetLocalNormals(): Vector3[];
  93222. /**
  93223. * Returns the facetLocalPositions array.
  93224. * The facet positions are expressed in the mesh local space
  93225. * @returns an array of Vector3
  93226. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93227. */
  93228. getFacetLocalPositions(): Vector3[];
  93229. /**
  93230. * Returns the facetLocalPartioning array
  93231. * @returns an array of array of numbers
  93232. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93233. */
  93234. getFacetLocalPartitioning(): number[][];
  93235. /**
  93236. * Returns the i-th facet position in the world system.
  93237. * This method allocates a new Vector3 per call
  93238. * @param i defines the facet index
  93239. * @returns a new Vector3
  93240. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93241. */
  93242. getFacetPosition(i: number): Vector3;
  93243. /**
  93244. * Sets the reference Vector3 with the i-th facet position in the world system
  93245. * @param i defines the facet index
  93246. * @param ref defines the target vector
  93247. * @returns the current mesh
  93248. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93249. */
  93250. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  93251. /**
  93252. * Returns the i-th facet normal in the world system.
  93253. * This method allocates a new Vector3 per call
  93254. * @param i defines the facet index
  93255. * @returns a new Vector3
  93256. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93257. */
  93258. getFacetNormal(i: number): Vector3;
  93259. /**
  93260. * Sets the reference Vector3 with the i-th facet normal in the world system
  93261. * @param i defines the facet index
  93262. * @param ref defines the target vector
  93263. * @returns the current mesh
  93264. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93265. */
  93266. getFacetNormalToRef(i: number, ref: Vector3): this;
  93267. /**
  93268. * 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)
  93269. * @param x defines x coordinate
  93270. * @param y defines y coordinate
  93271. * @param z defines z coordinate
  93272. * @returns the array of facet indexes
  93273. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93274. */
  93275. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  93276. /**
  93277. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  93278. * @param projected sets as the (x,y,z) world projection on the facet
  93279. * @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
  93280. * @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
  93281. * @param x defines x coordinate
  93282. * @param y defines y coordinate
  93283. * @param z defines z coordinate
  93284. * @returns the face index if found (or null instead)
  93285. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93286. */
  93287. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93288. /**
  93289. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  93290. * @param projected sets as the (x,y,z) local projection on the facet
  93291. * @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
  93292. * @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
  93293. * @param x defines x coordinate
  93294. * @param y defines y coordinate
  93295. * @param z defines z coordinate
  93296. * @returns the face index if found (or null instead)
  93297. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93298. */
  93299. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93300. /**
  93301. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  93302. * @returns the parameters
  93303. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93304. */
  93305. getFacetDataParameters(): any;
  93306. /**
  93307. * Disables the feature FacetData and frees the related memory
  93308. * @returns the current mesh
  93309. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93310. */
  93311. disableFacetData(): AbstractMesh;
  93312. /**
  93313. * Updates the AbstractMesh indices array
  93314. * @param indices defines the data source
  93315. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93316. * @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)
  93317. * @returns the current mesh
  93318. */
  93319. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93320. /**
  93321. * Creates new normals data for the mesh
  93322. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  93323. * @returns the current mesh
  93324. */
  93325. createNormals(updatable: boolean): AbstractMesh;
  93326. /**
  93327. * Align the mesh with a normal
  93328. * @param normal defines the normal to use
  93329. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  93330. * @returns the current mesh
  93331. */
  93332. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  93333. /** @hidden */
  93334. _checkOcclusionQuery(): boolean;
  93335. /**
  93336. * Disables the mesh edge rendering mode
  93337. * @returns the currentAbstractMesh
  93338. */
  93339. disableEdgesRendering(): AbstractMesh;
  93340. /**
  93341. * Enables the edge rendering mode on the mesh.
  93342. * This mode makes the mesh edges visible
  93343. * @param epsilon defines the maximal distance between two angles to detect a face
  93344. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93345. * @returns the currentAbstractMesh
  93346. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93347. */
  93348. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93349. }
  93350. }
  93351. declare module BABYLON {
  93352. /**
  93353. * Interface used to define ActionEvent
  93354. */
  93355. export interface IActionEvent {
  93356. /** The mesh or sprite that triggered the action */
  93357. source: any;
  93358. /** The X mouse cursor position at the time of the event */
  93359. pointerX: number;
  93360. /** The Y mouse cursor position at the time of the event */
  93361. pointerY: number;
  93362. /** The mesh that is currently pointed at (can be null) */
  93363. meshUnderPointer: Nullable<AbstractMesh>;
  93364. /** the original (browser) event that triggered the ActionEvent */
  93365. sourceEvent?: any;
  93366. /** additional data for the event */
  93367. additionalData?: any;
  93368. }
  93369. /**
  93370. * ActionEvent is the event being sent when an action is triggered.
  93371. */
  93372. export class ActionEvent implements IActionEvent {
  93373. /** The mesh or sprite that triggered the action */
  93374. source: any;
  93375. /** The X mouse cursor position at the time of the event */
  93376. pointerX: number;
  93377. /** The Y mouse cursor position at the time of the event */
  93378. pointerY: number;
  93379. /** The mesh that is currently pointed at (can be null) */
  93380. meshUnderPointer: Nullable<AbstractMesh>;
  93381. /** the original (browser) event that triggered the ActionEvent */
  93382. sourceEvent?: any;
  93383. /** additional data for the event */
  93384. additionalData?: any;
  93385. /**
  93386. * Creates a new ActionEvent
  93387. * @param source The mesh or sprite that triggered the action
  93388. * @param pointerX The X mouse cursor position at the time of the event
  93389. * @param pointerY The Y mouse cursor position at the time of the event
  93390. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  93391. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  93392. * @param additionalData additional data for the event
  93393. */
  93394. constructor(
  93395. /** The mesh or sprite that triggered the action */
  93396. source: any,
  93397. /** The X mouse cursor position at the time of the event */
  93398. pointerX: number,
  93399. /** The Y mouse cursor position at the time of the event */
  93400. pointerY: number,
  93401. /** The mesh that is currently pointed at (can be null) */
  93402. meshUnderPointer: Nullable<AbstractMesh>,
  93403. /** the original (browser) event that triggered the ActionEvent */
  93404. sourceEvent?: any,
  93405. /** additional data for the event */
  93406. additionalData?: any);
  93407. /**
  93408. * Helper function to auto-create an ActionEvent from a source mesh.
  93409. * @param source The source mesh that triggered the event
  93410. * @param evt The original (browser) event
  93411. * @param additionalData additional data for the event
  93412. * @returns the new ActionEvent
  93413. */
  93414. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  93415. /**
  93416. * Helper function to auto-create an ActionEvent from a source sprite
  93417. * @param source The source sprite that triggered the event
  93418. * @param scene Scene associated with the sprite
  93419. * @param evt The original (browser) event
  93420. * @param additionalData additional data for the event
  93421. * @returns the new ActionEvent
  93422. */
  93423. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  93424. /**
  93425. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  93426. * @param scene the scene where the event occurred
  93427. * @param evt The original (browser) event
  93428. * @returns the new ActionEvent
  93429. */
  93430. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  93431. /**
  93432. * Helper function to auto-create an ActionEvent from a primitive
  93433. * @param prim defines the target primitive
  93434. * @param pointerPos defines the pointer position
  93435. * @param evt The original (browser) event
  93436. * @param additionalData additional data for the event
  93437. * @returns the new ActionEvent
  93438. */
  93439. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  93440. }
  93441. }
  93442. declare module BABYLON {
  93443. /**
  93444. * Abstract class used to decouple action Manager from scene and meshes.
  93445. * Do not instantiate.
  93446. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93447. */
  93448. export abstract class AbstractActionManager implements IDisposable {
  93449. /** Gets the list of active triggers */
  93450. static Triggers: {
  93451. [key: string]: number;
  93452. };
  93453. /** Gets the cursor to use when hovering items */
  93454. hoverCursor: string;
  93455. /** Gets the list of actions */
  93456. actions: IAction[];
  93457. /**
  93458. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  93459. */
  93460. isRecursive: boolean;
  93461. /**
  93462. * Releases all associated resources
  93463. */
  93464. abstract dispose(): void;
  93465. /**
  93466. * Does this action manager has pointer triggers
  93467. */
  93468. abstract readonly hasPointerTriggers: boolean;
  93469. /**
  93470. * Does this action manager has pick triggers
  93471. */
  93472. abstract readonly hasPickTriggers: boolean;
  93473. /**
  93474. * Process a specific trigger
  93475. * @param trigger defines the trigger to process
  93476. * @param evt defines the event details to be processed
  93477. */
  93478. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  93479. /**
  93480. * Does this action manager handles actions of any of the given triggers
  93481. * @param triggers defines the triggers to be tested
  93482. * @return a boolean indicating whether one (or more) of the triggers is handled
  93483. */
  93484. abstract hasSpecificTriggers(triggers: number[]): boolean;
  93485. /**
  93486. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  93487. * speed.
  93488. * @param triggerA defines the trigger to be tested
  93489. * @param triggerB defines the trigger to be tested
  93490. * @return a boolean indicating whether one (or more) of the triggers is handled
  93491. */
  93492. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  93493. /**
  93494. * Does this action manager handles actions of a given trigger
  93495. * @param trigger defines the trigger to be tested
  93496. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  93497. * @return whether the trigger is handled
  93498. */
  93499. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  93500. /**
  93501. * Serialize this manager to a JSON object
  93502. * @param name defines the property name to store this manager
  93503. * @returns a JSON representation of this manager
  93504. */
  93505. abstract serialize(name: string): any;
  93506. /**
  93507. * Registers an action to this action manager
  93508. * @param action defines the action to be registered
  93509. * @return the action amended (prepared) after registration
  93510. */
  93511. abstract registerAction(action: IAction): Nullable<IAction>;
  93512. /**
  93513. * Unregisters an action to this action manager
  93514. * @param action defines the action to be unregistered
  93515. * @return a boolean indicating whether the action has been unregistered
  93516. */
  93517. abstract unregisterAction(action: IAction): Boolean;
  93518. /**
  93519. * Does exist one action manager with at least one trigger
  93520. **/
  93521. static readonly HasTriggers: boolean;
  93522. /**
  93523. * Does exist one action manager with at least one pick trigger
  93524. **/
  93525. static readonly HasPickTriggers: boolean;
  93526. /**
  93527. * Does exist one action manager that handles actions of a given trigger
  93528. * @param trigger defines the trigger to be tested
  93529. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  93530. **/
  93531. static HasSpecificTrigger(trigger: number): boolean;
  93532. }
  93533. }
  93534. declare module BABYLON {
  93535. /**
  93536. * Defines how a node can be built from a string name.
  93537. */
  93538. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  93539. /**
  93540. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  93541. */
  93542. export class Node implements IBehaviorAware<Node> {
  93543. /** @hidden */
  93544. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  93545. private static _NodeConstructors;
  93546. /**
  93547. * Add a new node constructor
  93548. * @param type defines the type name of the node to construct
  93549. * @param constructorFunc defines the constructor function
  93550. */
  93551. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  93552. /**
  93553. * Returns a node constructor based on type name
  93554. * @param type defines the type name
  93555. * @param name defines the new node name
  93556. * @param scene defines the hosting scene
  93557. * @param options defines optional options to transmit to constructors
  93558. * @returns the new constructor or null
  93559. */
  93560. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  93561. /**
  93562. * Gets or sets the name of the node
  93563. */
  93564. name: string;
  93565. /**
  93566. * Gets or sets the id of the node
  93567. */
  93568. id: string;
  93569. /**
  93570. * Gets or sets the unique id of the node
  93571. */
  93572. uniqueId: number;
  93573. /**
  93574. * Gets or sets a string used to store user defined state for the node
  93575. */
  93576. state: string;
  93577. /**
  93578. * Gets or sets an object used to store user defined information for the node
  93579. */
  93580. metadata: any;
  93581. /**
  93582. * For internal use only. Please do not use.
  93583. */
  93584. reservedDataStore: any;
  93585. /**
  93586. * List of inspectable custom properties (used by the Inspector)
  93587. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93588. */
  93589. inspectableCustomProperties: IInspectable[];
  93590. private _doNotSerialize;
  93591. /**
  93592. * Gets or sets a boolean used to define if the node must be serialized
  93593. */
  93594. doNotSerialize: boolean;
  93595. /** @hidden */
  93596. _isDisposed: boolean;
  93597. /**
  93598. * Gets a list of Animations associated with the node
  93599. */
  93600. animations: Animation[];
  93601. protected _ranges: {
  93602. [name: string]: Nullable<AnimationRange>;
  93603. };
  93604. /**
  93605. * Callback raised when the node is ready to be used
  93606. */
  93607. onReady: Nullable<(node: Node) => void>;
  93608. private _isEnabled;
  93609. private _isParentEnabled;
  93610. private _isReady;
  93611. /** @hidden */
  93612. _currentRenderId: number;
  93613. private _parentUpdateId;
  93614. /** @hidden */
  93615. _childUpdateId: number;
  93616. /** @hidden */
  93617. _waitingParentId: Nullable<string>;
  93618. /** @hidden */
  93619. _scene: Scene;
  93620. /** @hidden */
  93621. _cache: any;
  93622. private _parentNode;
  93623. private _children;
  93624. /** @hidden */
  93625. _worldMatrix: Matrix;
  93626. /** @hidden */
  93627. _worldMatrixDeterminant: number;
  93628. /** @hidden */
  93629. _worldMatrixDeterminantIsDirty: boolean;
  93630. /** @hidden */
  93631. private _sceneRootNodesIndex;
  93632. /**
  93633. * Gets a boolean indicating if the node has been disposed
  93634. * @returns true if the node was disposed
  93635. */
  93636. isDisposed(): boolean;
  93637. /**
  93638. * Gets or sets the parent of the node (without keeping the current position in the scene)
  93639. * @see https://doc.babylonjs.com/how_to/parenting
  93640. */
  93641. parent: Nullable<Node>;
  93642. private addToSceneRootNodes;
  93643. private removeFromSceneRootNodes;
  93644. private _animationPropertiesOverride;
  93645. /**
  93646. * Gets or sets the animation properties override
  93647. */
  93648. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  93649. /**
  93650. * Gets a string idenfifying the name of the class
  93651. * @returns "Node" string
  93652. */
  93653. getClassName(): string;
  93654. /** @hidden */
  93655. readonly _isNode: boolean;
  93656. /**
  93657. * An event triggered when the mesh is disposed
  93658. */
  93659. onDisposeObservable: Observable<Node>;
  93660. private _onDisposeObserver;
  93661. /**
  93662. * Sets a callback that will be raised when the node will be disposed
  93663. */
  93664. onDispose: () => void;
  93665. /**
  93666. * Creates a new Node
  93667. * @param name the name and id to be given to this node
  93668. * @param scene the scene this node will be added to
  93669. * @param addToRootNodes the node will be added to scene.rootNodes
  93670. */
  93671. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  93672. /**
  93673. * Gets the scene of the node
  93674. * @returns a scene
  93675. */
  93676. getScene(): Scene;
  93677. /**
  93678. * Gets the engine of the node
  93679. * @returns a Engine
  93680. */
  93681. getEngine(): Engine;
  93682. private _behaviors;
  93683. /**
  93684. * Attach a behavior to the node
  93685. * @see http://doc.babylonjs.com/features/behaviour
  93686. * @param behavior defines the behavior to attach
  93687. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  93688. * @returns the current Node
  93689. */
  93690. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  93691. /**
  93692. * Remove an attached behavior
  93693. * @see http://doc.babylonjs.com/features/behaviour
  93694. * @param behavior defines the behavior to attach
  93695. * @returns the current Node
  93696. */
  93697. removeBehavior(behavior: Behavior<Node>): Node;
  93698. /**
  93699. * Gets the list of attached behaviors
  93700. * @see http://doc.babylonjs.com/features/behaviour
  93701. */
  93702. readonly behaviors: Behavior<Node>[];
  93703. /**
  93704. * Gets an attached behavior by name
  93705. * @param name defines the name of the behavior to look for
  93706. * @see http://doc.babylonjs.com/features/behaviour
  93707. * @returns null if behavior was not found else the requested behavior
  93708. */
  93709. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  93710. /**
  93711. * Returns the latest update of the World matrix
  93712. * @returns a Matrix
  93713. */
  93714. getWorldMatrix(): Matrix;
  93715. /** @hidden */
  93716. _getWorldMatrixDeterminant(): number;
  93717. /**
  93718. * Returns directly the latest state of the mesh World matrix.
  93719. * A Matrix is returned.
  93720. */
  93721. readonly worldMatrixFromCache: Matrix;
  93722. /** @hidden */
  93723. _initCache(): void;
  93724. /** @hidden */
  93725. updateCache(force?: boolean): void;
  93726. /** @hidden */
  93727. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93728. /** @hidden */
  93729. _updateCache(ignoreParentClass?: boolean): void;
  93730. /** @hidden */
  93731. _isSynchronized(): boolean;
  93732. /** @hidden */
  93733. _markSyncedWithParent(): void;
  93734. /** @hidden */
  93735. isSynchronizedWithParent(): boolean;
  93736. /** @hidden */
  93737. isSynchronized(): boolean;
  93738. /**
  93739. * Is this node ready to be used/rendered
  93740. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93741. * @return true if the node is ready
  93742. */
  93743. isReady(completeCheck?: boolean): boolean;
  93744. /**
  93745. * Is this node enabled?
  93746. * 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
  93747. * @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
  93748. * @return whether this node (and its parent) is enabled
  93749. */
  93750. isEnabled(checkAncestors?: boolean): boolean;
  93751. /** @hidden */
  93752. protected _syncParentEnabledState(): void;
  93753. /**
  93754. * Set the enabled state of this node
  93755. * @param value defines the new enabled state
  93756. */
  93757. setEnabled(value: boolean): void;
  93758. /**
  93759. * Is this node a descendant of the given node?
  93760. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  93761. * @param ancestor defines the parent node to inspect
  93762. * @returns a boolean indicating if this node is a descendant of the given node
  93763. */
  93764. isDescendantOf(ancestor: Node): boolean;
  93765. /** @hidden */
  93766. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  93767. /**
  93768. * Will return all nodes that have this node as ascendant
  93769. * @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
  93770. * @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
  93771. * @return all children nodes of all types
  93772. */
  93773. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  93774. /**
  93775. * Get all child-meshes of this node
  93776. * @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)
  93777. * @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
  93778. * @returns an array of AbstractMesh
  93779. */
  93780. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  93781. /**
  93782. * Get all direct children of this node
  93783. * @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
  93784. * @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)
  93785. * @returns an array of Node
  93786. */
  93787. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  93788. /** @hidden */
  93789. _setReady(state: boolean): void;
  93790. /**
  93791. * Get an animation by name
  93792. * @param name defines the name of the animation to look for
  93793. * @returns null if not found else the requested animation
  93794. */
  93795. getAnimationByName(name: string): Nullable<Animation>;
  93796. /**
  93797. * Creates an animation range for this node
  93798. * @param name defines the name of the range
  93799. * @param from defines the starting key
  93800. * @param to defines the end key
  93801. */
  93802. createAnimationRange(name: string, from: number, to: number): void;
  93803. /**
  93804. * Delete a specific animation range
  93805. * @param name defines the name of the range to delete
  93806. * @param deleteFrames defines if animation frames from the range must be deleted as well
  93807. */
  93808. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93809. /**
  93810. * Get an animation range by name
  93811. * @param name defines the name of the animation range to look for
  93812. * @returns null if not found else the requested animation range
  93813. */
  93814. getAnimationRange(name: string): Nullable<AnimationRange>;
  93815. /**
  93816. * Gets the list of all animation ranges defined on this node
  93817. * @returns an array
  93818. */
  93819. getAnimationRanges(): Nullable<AnimationRange>[];
  93820. /**
  93821. * Will start the animation sequence
  93822. * @param name defines the range frames for animation sequence
  93823. * @param loop defines if the animation should loop (false by default)
  93824. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  93825. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  93826. * @returns the object created for this animation. If range does not exist, it will return null
  93827. */
  93828. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93829. /**
  93830. * Serialize animation ranges into a JSON compatible object
  93831. * @returns serialization object
  93832. */
  93833. serializeAnimationRanges(): any;
  93834. /**
  93835. * Computes the world matrix of the node
  93836. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93837. * @returns the world matrix
  93838. */
  93839. computeWorldMatrix(force?: boolean): Matrix;
  93840. /**
  93841. * Releases resources associated with this node.
  93842. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93843. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93844. */
  93845. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93846. /**
  93847. * Parse animation range data from a serialization object and store them into a given node
  93848. * @param node defines where to store the animation ranges
  93849. * @param parsedNode defines the serialization object to read data from
  93850. * @param scene defines the hosting scene
  93851. */
  93852. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  93853. /**
  93854. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  93855. * @param includeDescendants Include bounding info from descendants as well (true by default)
  93856. * @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
  93857. * @returns the new bounding vectors
  93858. */
  93859. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  93860. min: Vector3;
  93861. max: Vector3;
  93862. };
  93863. }
  93864. }
  93865. declare module BABYLON {
  93866. /**
  93867. * @hidden
  93868. */
  93869. export class _IAnimationState {
  93870. key: number;
  93871. repeatCount: number;
  93872. workValue?: any;
  93873. loopMode?: number;
  93874. offsetValue?: any;
  93875. highLimitValue?: any;
  93876. }
  93877. /**
  93878. * Class used to store any kind of animation
  93879. */
  93880. export class Animation {
  93881. /**Name of the animation */
  93882. name: string;
  93883. /**Property to animate */
  93884. targetProperty: string;
  93885. /**The frames per second of the animation */
  93886. framePerSecond: number;
  93887. /**The data type of the animation */
  93888. dataType: number;
  93889. /**The loop mode of the animation */
  93890. loopMode?: number | undefined;
  93891. /**Specifies if blending should be enabled */
  93892. enableBlending?: boolean | undefined;
  93893. /**
  93894. * Use matrix interpolation instead of using direct key value when animating matrices
  93895. */
  93896. static AllowMatricesInterpolation: boolean;
  93897. /**
  93898. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  93899. */
  93900. static AllowMatrixDecomposeForInterpolation: boolean;
  93901. /**
  93902. * Stores the key frames of the animation
  93903. */
  93904. private _keys;
  93905. /**
  93906. * Stores the easing function of the animation
  93907. */
  93908. private _easingFunction;
  93909. /**
  93910. * @hidden Internal use only
  93911. */
  93912. _runtimeAnimations: RuntimeAnimation[];
  93913. /**
  93914. * The set of event that will be linked to this animation
  93915. */
  93916. private _events;
  93917. /**
  93918. * Stores an array of target property paths
  93919. */
  93920. targetPropertyPath: string[];
  93921. /**
  93922. * Stores the blending speed of the animation
  93923. */
  93924. blendingSpeed: number;
  93925. /**
  93926. * Stores the animation ranges for the animation
  93927. */
  93928. private _ranges;
  93929. /**
  93930. * @hidden Internal use
  93931. */
  93932. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  93933. /**
  93934. * Sets up an animation
  93935. * @param property The property to animate
  93936. * @param animationType The animation type to apply
  93937. * @param framePerSecond The frames per second of the animation
  93938. * @param easingFunction The easing function used in the animation
  93939. * @returns The created animation
  93940. */
  93941. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  93942. /**
  93943. * Create and start an animation on a node
  93944. * @param name defines the name of the global animation that will be run on all nodes
  93945. * @param node defines the root node where the animation will take place
  93946. * @param targetProperty defines property to animate
  93947. * @param framePerSecond defines the number of frame per second yo use
  93948. * @param totalFrame defines the number of frames in total
  93949. * @param from defines the initial value
  93950. * @param to defines the final value
  93951. * @param loopMode defines which loop mode you want to use (off by default)
  93952. * @param easingFunction defines the easing function to use (linear by default)
  93953. * @param onAnimationEnd defines the callback to call when animation end
  93954. * @returns the animatable created for this animation
  93955. */
  93956. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93957. /**
  93958. * Create and start an animation on a node and its descendants
  93959. * @param name defines the name of the global animation that will be run on all nodes
  93960. * @param node defines the root node where the animation will take place
  93961. * @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
  93962. * @param targetProperty defines property to animate
  93963. * @param framePerSecond defines the number of frame per second to use
  93964. * @param totalFrame defines the number of frames in total
  93965. * @param from defines the initial value
  93966. * @param to defines the final value
  93967. * @param loopMode defines which loop mode you want to use (off by default)
  93968. * @param easingFunction defines the easing function to use (linear by default)
  93969. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93970. * @returns the list of animatables created for all nodes
  93971. * @example https://www.babylonjs-playground.com/#MH0VLI
  93972. */
  93973. 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[]>;
  93974. /**
  93975. * Creates a new animation, merges it with the existing animations and starts it
  93976. * @param name Name of the animation
  93977. * @param node Node which contains the scene that begins the animations
  93978. * @param targetProperty Specifies which property to animate
  93979. * @param framePerSecond The frames per second of the animation
  93980. * @param totalFrame The total number of frames
  93981. * @param from The frame at the beginning of the animation
  93982. * @param to The frame at the end of the animation
  93983. * @param loopMode Specifies the loop mode of the animation
  93984. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  93985. * @param onAnimationEnd Callback to run once the animation is complete
  93986. * @returns Nullable animation
  93987. */
  93988. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93989. /**
  93990. * Transition property of an host to the target Value
  93991. * @param property The property to transition
  93992. * @param targetValue The target Value of the property
  93993. * @param host The object where the property to animate belongs
  93994. * @param scene Scene used to run the animation
  93995. * @param frameRate Framerate (in frame/s) to use
  93996. * @param transition The transition type we want to use
  93997. * @param duration The duration of the animation, in milliseconds
  93998. * @param onAnimationEnd Callback trigger at the end of the animation
  93999. * @returns Nullable animation
  94000. */
  94001. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  94002. /**
  94003. * Return the array of runtime animations currently using this animation
  94004. */
  94005. readonly runtimeAnimations: RuntimeAnimation[];
  94006. /**
  94007. * Specifies if any of the runtime animations are currently running
  94008. */
  94009. readonly hasRunningRuntimeAnimations: boolean;
  94010. /**
  94011. * Initializes the animation
  94012. * @param name Name of the animation
  94013. * @param targetProperty Property to animate
  94014. * @param framePerSecond The frames per second of the animation
  94015. * @param dataType The data type of the animation
  94016. * @param loopMode The loop mode of the animation
  94017. * @param enableBlending Specifies if blending should be enabled
  94018. */
  94019. constructor(
  94020. /**Name of the animation */
  94021. name: string,
  94022. /**Property to animate */
  94023. targetProperty: string,
  94024. /**The frames per second of the animation */
  94025. framePerSecond: number,
  94026. /**The data type of the animation */
  94027. dataType: number,
  94028. /**The loop mode of the animation */
  94029. loopMode?: number | undefined,
  94030. /**Specifies if blending should be enabled */
  94031. enableBlending?: boolean | undefined);
  94032. /**
  94033. * Converts the animation to a string
  94034. * @param fullDetails support for multiple levels of logging within scene loading
  94035. * @returns String form of the animation
  94036. */
  94037. toString(fullDetails?: boolean): string;
  94038. /**
  94039. * Add an event to this animation
  94040. * @param event Event to add
  94041. */
  94042. addEvent(event: AnimationEvent): void;
  94043. /**
  94044. * Remove all events found at the given frame
  94045. * @param frame The frame to remove events from
  94046. */
  94047. removeEvents(frame: number): void;
  94048. /**
  94049. * Retrieves all the events from the animation
  94050. * @returns Events from the animation
  94051. */
  94052. getEvents(): AnimationEvent[];
  94053. /**
  94054. * Creates an animation range
  94055. * @param name Name of the animation range
  94056. * @param from Starting frame of the animation range
  94057. * @param to Ending frame of the animation
  94058. */
  94059. createRange(name: string, from: number, to: number): void;
  94060. /**
  94061. * Deletes an animation range by name
  94062. * @param name Name of the animation range to delete
  94063. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  94064. */
  94065. deleteRange(name: string, deleteFrames?: boolean): void;
  94066. /**
  94067. * Gets the animation range by name, or null if not defined
  94068. * @param name Name of the animation range
  94069. * @returns Nullable animation range
  94070. */
  94071. getRange(name: string): Nullable<AnimationRange>;
  94072. /**
  94073. * Gets the key frames from the animation
  94074. * @returns The key frames of the animation
  94075. */
  94076. getKeys(): Array<IAnimationKey>;
  94077. /**
  94078. * Gets the highest frame rate of the animation
  94079. * @returns Highest frame rate of the animation
  94080. */
  94081. getHighestFrame(): number;
  94082. /**
  94083. * Gets the easing function of the animation
  94084. * @returns Easing function of the animation
  94085. */
  94086. getEasingFunction(): IEasingFunction;
  94087. /**
  94088. * Sets the easing function of the animation
  94089. * @param easingFunction A custom mathematical formula for animation
  94090. */
  94091. setEasingFunction(easingFunction: EasingFunction): void;
  94092. /**
  94093. * Interpolates a scalar linearly
  94094. * @param startValue Start value of the animation curve
  94095. * @param endValue End value of the animation curve
  94096. * @param gradient Scalar amount to interpolate
  94097. * @returns Interpolated scalar value
  94098. */
  94099. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  94100. /**
  94101. * Interpolates a scalar cubically
  94102. * @param startValue Start value of the animation curve
  94103. * @param outTangent End tangent of the animation
  94104. * @param endValue End value of the animation curve
  94105. * @param inTangent Start tangent of the animation curve
  94106. * @param gradient Scalar amount to interpolate
  94107. * @returns Interpolated scalar value
  94108. */
  94109. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  94110. /**
  94111. * Interpolates a quaternion using a spherical linear interpolation
  94112. * @param startValue Start value of the animation curve
  94113. * @param endValue End value of the animation curve
  94114. * @param gradient Scalar amount to interpolate
  94115. * @returns Interpolated quaternion value
  94116. */
  94117. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  94118. /**
  94119. * Interpolates a quaternion cubically
  94120. * @param startValue Start value of the animation curve
  94121. * @param outTangent End tangent of the animation curve
  94122. * @param endValue End value of the animation curve
  94123. * @param inTangent Start tangent of the animation curve
  94124. * @param gradient Scalar amount to interpolate
  94125. * @returns Interpolated quaternion value
  94126. */
  94127. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  94128. /**
  94129. * Interpolates a Vector3 linearl
  94130. * @param startValue Start value of the animation curve
  94131. * @param endValue End value of the animation curve
  94132. * @param gradient Scalar amount to interpolate
  94133. * @returns Interpolated scalar value
  94134. */
  94135. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  94136. /**
  94137. * Interpolates a Vector3 cubically
  94138. * @param startValue Start value of the animation curve
  94139. * @param outTangent End tangent of the animation
  94140. * @param endValue End value of the animation curve
  94141. * @param inTangent Start tangent of the animation curve
  94142. * @param gradient Scalar amount to interpolate
  94143. * @returns InterpolatedVector3 value
  94144. */
  94145. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  94146. /**
  94147. * Interpolates a Vector2 linearly
  94148. * @param startValue Start value of the animation curve
  94149. * @param endValue End value of the animation curve
  94150. * @param gradient Scalar amount to interpolate
  94151. * @returns Interpolated Vector2 value
  94152. */
  94153. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  94154. /**
  94155. * Interpolates a Vector2 cubically
  94156. * @param startValue Start value of the animation curve
  94157. * @param outTangent End tangent of the animation
  94158. * @param endValue End value of the animation curve
  94159. * @param inTangent Start tangent of the animation curve
  94160. * @param gradient Scalar amount to interpolate
  94161. * @returns Interpolated Vector2 value
  94162. */
  94163. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  94164. /**
  94165. * Interpolates a size linearly
  94166. * @param startValue Start value of the animation curve
  94167. * @param endValue End value of the animation curve
  94168. * @param gradient Scalar amount to interpolate
  94169. * @returns Interpolated Size value
  94170. */
  94171. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  94172. /**
  94173. * Interpolates a Color3 linearly
  94174. * @param startValue Start value of the animation curve
  94175. * @param endValue End value of the animation curve
  94176. * @param gradient Scalar amount to interpolate
  94177. * @returns Interpolated Color3 value
  94178. */
  94179. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  94180. /**
  94181. * @hidden Internal use only
  94182. */
  94183. _getKeyValue(value: any): any;
  94184. /**
  94185. * @hidden Internal use only
  94186. */
  94187. _interpolate(currentFrame: number, state: _IAnimationState): any;
  94188. /**
  94189. * Defines the function to use to interpolate matrices
  94190. * @param startValue defines the start matrix
  94191. * @param endValue defines the end matrix
  94192. * @param gradient defines the gradient between both matrices
  94193. * @param result defines an optional target matrix where to store the interpolation
  94194. * @returns the interpolated matrix
  94195. */
  94196. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  94197. /**
  94198. * Makes a copy of the animation
  94199. * @returns Cloned animation
  94200. */
  94201. clone(): Animation;
  94202. /**
  94203. * Sets the key frames of the animation
  94204. * @param values The animation key frames to set
  94205. */
  94206. setKeys(values: Array<IAnimationKey>): void;
  94207. /**
  94208. * Serializes the animation to an object
  94209. * @returns Serialized object
  94210. */
  94211. serialize(): any;
  94212. /**
  94213. * Float animation type
  94214. */
  94215. private static _ANIMATIONTYPE_FLOAT;
  94216. /**
  94217. * Vector3 animation type
  94218. */
  94219. private static _ANIMATIONTYPE_VECTOR3;
  94220. /**
  94221. * Quaternion animation type
  94222. */
  94223. private static _ANIMATIONTYPE_QUATERNION;
  94224. /**
  94225. * Matrix animation type
  94226. */
  94227. private static _ANIMATIONTYPE_MATRIX;
  94228. /**
  94229. * Color3 animation type
  94230. */
  94231. private static _ANIMATIONTYPE_COLOR3;
  94232. /**
  94233. * Vector2 animation type
  94234. */
  94235. private static _ANIMATIONTYPE_VECTOR2;
  94236. /**
  94237. * Size animation type
  94238. */
  94239. private static _ANIMATIONTYPE_SIZE;
  94240. /**
  94241. * Relative Loop Mode
  94242. */
  94243. private static _ANIMATIONLOOPMODE_RELATIVE;
  94244. /**
  94245. * Cycle Loop Mode
  94246. */
  94247. private static _ANIMATIONLOOPMODE_CYCLE;
  94248. /**
  94249. * Constant Loop Mode
  94250. */
  94251. private static _ANIMATIONLOOPMODE_CONSTANT;
  94252. /**
  94253. * Get the float animation type
  94254. */
  94255. static readonly ANIMATIONTYPE_FLOAT: number;
  94256. /**
  94257. * Get the Vector3 animation type
  94258. */
  94259. static readonly ANIMATIONTYPE_VECTOR3: number;
  94260. /**
  94261. * Get the Vector2 animation type
  94262. */
  94263. static readonly ANIMATIONTYPE_VECTOR2: number;
  94264. /**
  94265. * Get the Size animation type
  94266. */
  94267. static readonly ANIMATIONTYPE_SIZE: number;
  94268. /**
  94269. * Get the Quaternion animation type
  94270. */
  94271. static readonly ANIMATIONTYPE_QUATERNION: number;
  94272. /**
  94273. * Get the Matrix animation type
  94274. */
  94275. static readonly ANIMATIONTYPE_MATRIX: number;
  94276. /**
  94277. * Get the Color3 animation type
  94278. */
  94279. static readonly ANIMATIONTYPE_COLOR3: number;
  94280. /**
  94281. * Get the Relative Loop Mode
  94282. */
  94283. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  94284. /**
  94285. * Get the Cycle Loop Mode
  94286. */
  94287. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  94288. /**
  94289. * Get the Constant Loop Mode
  94290. */
  94291. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  94292. /** @hidden */
  94293. static _UniversalLerp(left: any, right: any, amount: number): any;
  94294. /**
  94295. * Parses an animation object and creates an animation
  94296. * @param parsedAnimation Parsed animation object
  94297. * @returns Animation object
  94298. */
  94299. static Parse(parsedAnimation: any): Animation;
  94300. /**
  94301. * Appends the serialized animations from the source animations
  94302. * @param source Source containing the animations
  94303. * @param destination Target to store the animations
  94304. */
  94305. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94306. }
  94307. }
  94308. declare module BABYLON {
  94309. /**
  94310. * Interface containing an array of animations
  94311. */
  94312. export interface IAnimatable {
  94313. /**
  94314. * Array of animations
  94315. */
  94316. animations: Nullable<Array<Animation>>;
  94317. }
  94318. }
  94319. declare module BABYLON {
  94320. /**
  94321. * This represents all the required information to add a fresnel effect on a material:
  94322. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94323. */
  94324. export class FresnelParameters {
  94325. private _isEnabled;
  94326. /**
  94327. * Define if the fresnel effect is enable or not.
  94328. */
  94329. isEnabled: boolean;
  94330. /**
  94331. * Define the color used on edges (grazing angle)
  94332. */
  94333. leftColor: Color3;
  94334. /**
  94335. * Define the color used on center
  94336. */
  94337. rightColor: Color3;
  94338. /**
  94339. * Define bias applied to computed fresnel term
  94340. */
  94341. bias: number;
  94342. /**
  94343. * Defined the power exponent applied to fresnel term
  94344. */
  94345. power: number;
  94346. /**
  94347. * Clones the current fresnel and its valuues
  94348. * @returns a clone fresnel configuration
  94349. */
  94350. clone(): FresnelParameters;
  94351. /**
  94352. * Serializes the current fresnel parameters to a JSON representation.
  94353. * @return the JSON serialization
  94354. */
  94355. serialize(): any;
  94356. /**
  94357. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94358. * @param parsedFresnelParameters Define the JSON representation
  94359. * @returns the parsed parameters
  94360. */
  94361. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94362. }
  94363. }
  94364. declare module BABYLON {
  94365. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  94366. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94367. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94368. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94369. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94370. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94371. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94372. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94373. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94374. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94375. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94376. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94377. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94378. /**
  94379. * Decorator used to define property that can be serialized as reference to a camera
  94380. * @param sourceName defines the name of the property to decorate
  94381. */
  94382. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94383. /**
  94384. * Class used to help serialization objects
  94385. */
  94386. export class SerializationHelper {
  94387. /** @hidden */
  94388. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  94389. /** @hidden */
  94390. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  94391. /** @hidden */
  94392. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  94393. /** @hidden */
  94394. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  94395. /**
  94396. * Appends the serialized animations from the source animations
  94397. * @param source Source containing the animations
  94398. * @param destination Target to store the animations
  94399. */
  94400. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94401. /**
  94402. * Static function used to serialized a specific entity
  94403. * @param entity defines the entity to serialize
  94404. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  94405. * @returns a JSON compatible object representing the serialization of the entity
  94406. */
  94407. static Serialize<T>(entity: T, serializationObject?: any): any;
  94408. /**
  94409. * Creates a new entity from a serialization data object
  94410. * @param creationFunction defines a function used to instanciated the new entity
  94411. * @param source defines the source serialization data
  94412. * @param scene defines the hosting scene
  94413. * @param rootUrl defines the root url for resources
  94414. * @returns a new entity
  94415. */
  94416. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  94417. /**
  94418. * Clones an object
  94419. * @param creationFunction defines the function used to instanciate the new object
  94420. * @param source defines the source object
  94421. * @returns the cloned object
  94422. */
  94423. static Clone<T>(creationFunction: () => T, source: T): T;
  94424. /**
  94425. * Instanciates a new object based on a source one (some data will be shared between both object)
  94426. * @param creationFunction defines the function used to instanciate the new object
  94427. * @param source defines the source object
  94428. * @returns the new object
  94429. */
  94430. static Instanciate<T>(creationFunction: () => T, source: T): T;
  94431. }
  94432. }
  94433. declare module BABYLON {
  94434. /**
  94435. * Class used to manipulate GUIDs
  94436. */
  94437. export class GUID {
  94438. /**
  94439. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94440. * Be aware Math.random() could cause collisions, but:
  94441. * "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"
  94442. * @returns a pseudo random id
  94443. */
  94444. static RandomId(): string;
  94445. }
  94446. }
  94447. declare module BABYLON {
  94448. /**
  94449. * Base class of all the textures in babylon.
  94450. * It groups all the common properties the materials, post process, lights... might need
  94451. * in order to make a correct use of the texture.
  94452. */
  94453. export class BaseTexture implements IAnimatable {
  94454. /**
  94455. * Default anisotropic filtering level for the application.
  94456. * It is set to 4 as a good tradeoff between perf and quality.
  94457. */
  94458. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  94459. /**
  94460. * Gets or sets the unique id of the texture
  94461. */
  94462. uniqueId: number;
  94463. /**
  94464. * Define the name of the texture.
  94465. */
  94466. name: string;
  94467. /**
  94468. * Gets or sets an object used to store user defined information.
  94469. */
  94470. metadata: any;
  94471. /**
  94472. * For internal use only. Please do not use.
  94473. */
  94474. reservedDataStore: any;
  94475. private _hasAlpha;
  94476. /**
  94477. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  94478. */
  94479. hasAlpha: boolean;
  94480. /**
  94481. * Defines if the alpha value should be determined via the rgb values.
  94482. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  94483. */
  94484. getAlphaFromRGB: boolean;
  94485. /**
  94486. * Intensity or strength of the texture.
  94487. * It is commonly used by materials to fine tune the intensity of the texture
  94488. */
  94489. level: number;
  94490. /**
  94491. * Define the UV chanel to use starting from 0 and defaulting to 0.
  94492. * This is part of the texture as textures usually maps to one uv set.
  94493. */
  94494. coordinatesIndex: number;
  94495. private _coordinatesMode;
  94496. /**
  94497. * How a texture is mapped.
  94498. *
  94499. * | Value | Type | Description |
  94500. * | ----- | ----------------------------------- | ----------- |
  94501. * | 0 | EXPLICIT_MODE | |
  94502. * | 1 | SPHERICAL_MODE | |
  94503. * | 2 | PLANAR_MODE | |
  94504. * | 3 | CUBIC_MODE | |
  94505. * | 4 | PROJECTION_MODE | |
  94506. * | 5 | SKYBOX_MODE | |
  94507. * | 6 | INVCUBIC_MODE | |
  94508. * | 7 | EQUIRECTANGULAR_MODE | |
  94509. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  94510. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  94511. */
  94512. coordinatesMode: number;
  94513. /**
  94514. * | Value | Type | Description |
  94515. * | ----- | ------------------ | ----------- |
  94516. * | 0 | CLAMP_ADDRESSMODE | |
  94517. * | 1 | WRAP_ADDRESSMODE | |
  94518. * | 2 | MIRROR_ADDRESSMODE | |
  94519. */
  94520. wrapU: number;
  94521. /**
  94522. * | Value | Type | Description |
  94523. * | ----- | ------------------ | ----------- |
  94524. * | 0 | CLAMP_ADDRESSMODE | |
  94525. * | 1 | WRAP_ADDRESSMODE | |
  94526. * | 2 | MIRROR_ADDRESSMODE | |
  94527. */
  94528. wrapV: number;
  94529. /**
  94530. * | Value | Type | Description |
  94531. * | ----- | ------------------ | ----------- |
  94532. * | 0 | CLAMP_ADDRESSMODE | |
  94533. * | 1 | WRAP_ADDRESSMODE | |
  94534. * | 2 | MIRROR_ADDRESSMODE | |
  94535. */
  94536. wrapR: number;
  94537. /**
  94538. * With compliant hardware and browser (supporting anisotropic filtering)
  94539. * this defines the level of anisotropic filtering in the texture.
  94540. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  94541. */
  94542. anisotropicFilteringLevel: number;
  94543. /**
  94544. * Define if the texture is a cube texture or if false a 2d texture.
  94545. */
  94546. isCube: boolean;
  94547. /**
  94548. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  94549. */
  94550. is3D: boolean;
  94551. /**
  94552. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  94553. * HDR texture are usually stored in linear space.
  94554. * This only impacts the PBR and Background materials
  94555. */
  94556. gammaSpace: boolean;
  94557. /**
  94558. * Gets or sets whether or not the texture contains RGBD data.
  94559. */
  94560. isRGBD: boolean;
  94561. /**
  94562. * Is Z inverted in the texture (useful in a cube texture).
  94563. */
  94564. invertZ: boolean;
  94565. /**
  94566. * Are mip maps generated for this texture or not.
  94567. */
  94568. readonly noMipmap: boolean;
  94569. /**
  94570. * @hidden
  94571. */
  94572. lodLevelInAlpha: boolean;
  94573. /**
  94574. * With prefiltered texture, defined the offset used during the prefiltering steps.
  94575. */
  94576. lodGenerationOffset: number;
  94577. /**
  94578. * With prefiltered texture, defined the scale used during the prefiltering steps.
  94579. */
  94580. lodGenerationScale: number;
  94581. /**
  94582. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  94583. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  94584. * average roughness values.
  94585. */
  94586. linearSpecularLOD: boolean;
  94587. /**
  94588. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  94589. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  94590. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  94591. */
  94592. irradianceTexture: Nullable<BaseTexture>;
  94593. /**
  94594. * Define if the texture is a render target.
  94595. */
  94596. isRenderTarget: boolean;
  94597. /**
  94598. * Define the unique id of the texture in the scene.
  94599. */
  94600. readonly uid: string;
  94601. /**
  94602. * Return a string representation of the texture.
  94603. * @returns the texture as a string
  94604. */
  94605. toString(): string;
  94606. /**
  94607. * Get the class name of the texture.
  94608. * @returns "BaseTexture"
  94609. */
  94610. getClassName(): string;
  94611. /**
  94612. * Define the list of animation attached to the texture.
  94613. */
  94614. animations: Animation[];
  94615. /**
  94616. * An event triggered when the texture is disposed.
  94617. */
  94618. onDisposeObservable: Observable<BaseTexture>;
  94619. private _onDisposeObserver;
  94620. /**
  94621. * Callback triggered when the texture has been disposed.
  94622. * Kept for back compatibility, you can use the onDisposeObservable instead.
  94623. */
  94624. onDispose: () => void;
  94625. /**
  94626. * Define the current state of the loading sequence when in delayed load mode.
  94627. */
  94628. delayLoadState: number;
  94629. private _scene;
  94630. /** @hidden */
  94631. _texture: Nullable<InternalTexture>;
  94632. private _uid;
  94633. /**
  94634. * Define if the texture is preventinga material to render or not.
  94635. * If not and the texture is not ready, the engine will use a default black texture instead.
  94636. */
  94637. readonly isBlocking: boolean;
  94638. /**
  94639. * Instantiates a new BaseTexture.
  94640. * Base class of all the textures in babylon.
  94641. * It groups all the common properties the materials, post process, lights... might need
  94642. * in order to make a correct use of the texture.
  94643. * @param scene Define the scene the texture blongs to
  94644. */
  94645. constructor(scene: Nullable<Scene>);
  94646. /**
  94647. * Get the scene the texture belongs to.
  94648. * @returns the scene or null if undefined
  94649. */
  94650. getScene(): Nullable<Scene>;
  94651. /**
  94652. * Get the texture transform matrix used to offset tile the texture for istance.
  94653. * @returns the transformation matrix
  94654. */
  94655. getTextureMatrix(): Matrix;
  94656. /**
  94657. * Get the texture reflection matrix used to rotate/transform the reflection.
  94658. * @returns the reflection matrix
  94659. */
  94660. getReflectionTextureMatrix(): Matrix;
  94661. /**
  94662. * Get the underlying lower level texture from Babylon.
  94663. * @returns the insternal texture
  94664. */
  94665. getInternalTexture(): Nullable<InternalTexture>;
  94666. /**
  94667. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  94668. * @returns true if ready or not blocking
  94669. */
  94670. isReadyOrNotBlocking(): boolean;
  94671. /**
  94672. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  94673. * @returns true if fully ready
  94674. */
  94675. isReady(): boolean;
  94676. private _cachedSize;
  94677. /**
  94678. * Get the size of the texture.
  94679. * @returns the texture size.
  94680. */
  94681. getSize(): ISize;
  94682. /**
  94683. * Get the base size of the texture.
  94684. * It can be different from the size if the texture has been resized for POT for instance
  94685. * @returns the base size
  94686. */
  94687. getBaseSize(): ISize;
  94688. /**
  94689. * Update the sampling mode of the texture.
  94690. * Default is Trilinear mode.
  94691. *
  94692. * | Value | Type | Description |
  94693. * | ----- | ------------------ | ----------- |
  94694. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  94695. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  94696. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  94697. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  94698. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  94699. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  94700. * | 7 | NEAREST_LINEAR | |
  94701. * | 8 | NEAREST_NEAREST | |
  94702. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  94703. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  94704. * | 11 | LINEAR_LINEAR | |
  94705. * | 12 | LINEAR_NEAREST | |
  94706. *
  94707. * > _mag_: magnification filter (close to the viewer)
  94708. * > _min_: minification filter (far from the viewer)
  94709. * > _mip_: filter used between mip map levels
  94710. *@param samplingMode Define the new sampling mode of the texture
  94711. */
  94712. updateSamplingMode(samplingMode: number): void;
  94713. /**
  94714. * Scales the texture if is `canRescale()`
  94715. * @param ratio the resize factor we want to use to rescale
  94716. */
  94717. scale(ratio: number): void;
  94718. /**
  94719. * Get if the texture can rescale.
  94720. */
  94721. readonly canRescale: boolean;
  94722. /** @hidden */
  94723. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  94724. /** @hidden */
  94725. _rebuild(): void;
  94726. /**
  94727. * Triggers the load sequence in delayed load mode.
  94728. */
  94729. delayLoad(): void;
  94730. /**
  94731. * Clones the texture.
  94732. * @returns the cloned texture
  94733. */
  94734. clone(): Nullable<BaseTexture>;
  94735. /**
  94736. * Get the texture underlying type (INT, FLOAT...)
  94737. */
  94738. readonly textureType: number;
  94739. /**
  94740. * Get the texture underlying format (RGB, RGBA...)
  94741. */
  94742. readonly textureFormat: number;
  94743. /**
  94744. * Indicates that textures need to be re-calculated for all materials
  94745. */
  94746. protected _markAllSubMeshesAsTexturesDirty(): void;
  94747. /**
  94748. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  94749. * This will returns an RGBA array buffer containing either in values (0-255) or
  94750. * float values (0-1) depending of the underlying buffer type.
  94751. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  94752. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  94753. * @param buffer defines a user defined buffer to fill with data (can be null)
  94754. * @returns The Array buffer containing the pixels data.
  94755. */
  94756. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  94757. /**
  94758. * Release and destroy the underlying lower level texture aka internalTexture.
  94759. */
  94760. releaseInternalTexture(): void;
  94761. /** @hidden */
  94762. readonly _lodTextureHigh: Nullable<BaseTexture>;
  94763. /** @hidden */
  94764. readonly _lodTextureMid: Nullable<BaseTexture>;
  94765. /** @hidden */
  94766. readonly _lodTextureLow: Nullable<BaseTexture>;
  94767. /**
  94768. * Dispose the texture and release its associated resources.
  94769. */
  94770. dispose(): void;
  94771. /**
  94772. * Serialize the texture into a JSON representation that can be parsed later on.
  94773. * @returns the JSON representation of the texture
  94774. */
  94775. serialize(): any;
  94776. /**
  94777. * Helper function to be called back once a list of texture contains only ready textures.
  94778. * @param textures Define the list of textures to wait for
  94779. * @param callback Define the callback triggered once the entire list will be ready
  94780. */
  94781. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  94782. }
  94783. }
  94784. declare module BABYLON {
  94785. /**
  94786. * Options to be used when creating an effect.
  94787. */
  94788. export interface IEffectCreationOptions {
  94789. /**
  94790. * Atrributes that will be used in the shader.
  94791. */
  94792. attributes: string[];
  94793. /**
  94794. * Uniform varible names that will be set in the shader.
  94795. */
  94796. uniformsNames: string[];
  94797. /**
  94798. * Uniform buffer varible names that will be set in the shader.
  94799. */
  94800. uniformBuffersNames: string[];
  94801. /**
  94802. * Sampler texture variable names that will be set in the shader.
  94803. */
  94804. samplers: string[];
  94805. /**
  94806. * Define statements that will be set in the shader.
  94807. */
  94808. defines: any;
  94809. /**
  94810. * Possible fallbacks for this effect to improve performance when needed.
  94811. */
  94812. fallbacks: Nullable<IEffectFallbacks>;
  94813. /**
  94814. * Callback that will be called when the shader is compiled.
  94815. */
  94816. onCompiled: Nullable<(effect: Effect) => void>;
  94817. /**
  94818. * Callback that will be called if an error occurs during shader compilation.
  94819. */
  94820. onError: Nullable<(effect: Effect, errors: string) => void>;
  94821. /**
  94822. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94823. */
  94824. indexParameters?: any;
  94825. /**
  94826. * Max number of lights that can be used in the shader.
  94827. */
  94828. maxSimultaneousLights?: number;
  94829. /**
  94830. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94831. */
  94832. transformFeedbackVaryings?: Nullable<string[]>;
  94833. }
  94834. /**
  94835. * Effect containing vertex and fragment shader that can be executed on an object.
  94836. */
  94837. export class Effect implements IDisposable {
  94838. /**
  94839. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94840. */
  94841. static ShadersRepository: string;
  94842. /**
  94843. * Name of the effect.
  94844. */
  94845. name: any;
  94846. /**
  94847. * String container all the define statements that should be set on the shader.
  94848. */
  94849. defines: string;
  94850. /**
  94851. * Callback that will be called when the shader is compiled.
  94852. */
  94853. onCompiled: Nullable<(effect: Effect) => void>;
  94854. /**
  94855. * Callback that will be called if an error occurs during shader compilation.
  94856. */
  94857. onError: Nullable<(effect: Effect, errors: string) => void>;
  94858. /**
  94859. * Callback that will be called when effect is bound.
  94860. */
  94861. onBind: Nullable<(effect: Effect) => void>;
  94862. /**
  94863. * Unique ID of the effect.
  94864. */
  94865. uniqueId: number;
  94866. /**
  94867. * Observable that will be called when the shader is compiled.
  94868. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94869. */
  94870. onCompileObservable: Observable<Effect>;
  94871. /**
  94872. * Observable that will be called if an error occurs during shader compilation.
  94873. */
  94874. onErrorObservable: Observable<Effect>;
  94875. /** @hidden */
  94876. _onBindObservable: Nullable<Observable<Effect>>;
  94877. /**
  94878. * Observable that will be called when effect is bound.
  94879. */
  94880. readonly onBindObservable: Observable<Effect>;
  94881. /** @hidden */
  94882. _bonesComputationForcedToCPU: boolean;
  94883. private static _uniqueIdSeed;
  94884. private _engine;
  94885. private _uniformBuffersNames;
  94886. private _uniformsNames;
  94887. private _samplerList;
  94888. private _samplers;
  94889. private _isReady;
  94890. private _compilationError;
  94891. private _allFallbacksProcessed;
  94892. private _attributesNames;
  94893. private _attributes;
  94894. private _uniforms;
  94895. /**
  94896. * Key for the effect.
  94897. * @hidden
  94898. */
  94899. _key: string;
  94900. private _indexParameters;
  94901. private _fallbacks;
  94902. private _vertexSourceCode;
  94903. private _fragmentSourceCode;
  94904. private _vertexSourceCodeOverride;
  94905. private _fragmentSourceCodeOverride;
  94906. private _transformFeedbackVaryings;
  94907. /**
  94908. * Compiled shader to webGL program.
  94909. * @hidden
  94910. */
  94911. _pipelineContext: Nullable<IPipelineContext>;
  94912. private _valueCache;
  94913. private static _baseCache;
  94914. /**
  94915. * Instantiates an effect.
  94916. * An effect can be used to create/manage/execute vertex and fragment shaders.
  94917. * @param baseName Name of the effect.
  94918. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  94919. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  94920. * @param samplers List of sampler variables that will be passed to the shader.
  94921. * @param engine Engine to be used to render the effect
  94922. * @param defines Define statements to be added to the shader.
  94923. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  94924. * @param onCompiled Callback that will be called when the shader is compiled.
  94925. * @param onError Callback that will be called if an error occurs during shader compilation.
  94926. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94927. */
  94928. 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);
  94929. private _useFinalCode;
  94930. /**
  94931. * Unique key for this effect
  94932. */
  94933. readonly key: string;
  94934. /**
  94935. * If the effect has been compiled and prepared.
  94936. * @returns if the effect is compiled and prepared.
  94937. */
  94938. isReady(): boolean;
  94939. private _isReadyInternal;
  94940. /**
  94941. * The engine the effect was initialized with.
  94942. * @returns the engine.
  94943. */
  94944. getEngine(): Engine;
  94945. /**
  94946. * The pipeline context for this effect
  94947. * @returns the associated pipeline context
  94948. */
  94949. getPipelineContext(): Nullable<IPipelineContext>;
  94950. /**
  94951. * The set of names of attribute variables for the shader.
  94952. * @returns An array of attribute names.
  94953. */
  94954. getAttributesNames(): string[];
  94955. /**
  94956. * Returns the attribute at the given index.
  94957. * @param index The index of the attribute.
  94958. * @returns The location of the attribute.
  94959. */
  94960. getAttributeLocation(index: number): number;
  94961. /**
  94962. * Returns the attribute based on the name of the variable.
  94963. * @param name of the attribute to look up.
  94964. * @returns the attribute location.
  94965. */
  94966. getAttributeLocationByName(name: string): number;
  94967. /**
  94968. * The number of attributes.
  94969. * @returns the numnber of attributes.
  94970. */
  94971. getAttributesCount(): number;
  94972. /**
  94973. * Gets the index of a uniform variable.
  94974. * @param uniformName of the uniform to look up.
  94975. * @returns the index.
  94976. */
  94977. getUniformIndex(uniformName: string): number;
  94978. /**
  94979. * Returns the attribute based on the name of the variable.
  94980. * @param uniformName of the uniform to look up.
  94981. * @returns the location of the uniform.
  94982. */
  94983. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  94984. /**
  94985. * Returns an array of sampler variable names
  94986. * @returns The array of sampler variable neames.
  94987. */
  94988. getSamplers(): string[];
  94989. /**
  94990. * The error from the last compilation.
  94991. * @returns the error string.
  94992. */
  94993. getCompilationError(): string;
  94994. /**
  94995. * Gets a boolean indicating that all fallbacks were used during compilation
  94996. * @returns true if all fallbacks were used
  94997. */
  94998. allFallbacksProcessed(): boolean;
  94999. /**
  95000. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  95001. * @param func The callback to be used.
  95002. */
  95003. executeWhenCompiled(func: (effect: Effect) => void): void;
  95004. private _checkIsReady;
  95005. private _loadShader;
  95006. /**
  95007. * Recompiles the webGL program
  95008. * @param vertexSourceCode The source code for the vertex shader.
  95009. * @param fragmentSourceCode The source code for the fragment shader.
  95010. * @param onCompiled Callback called when completed.
  95011. * @param onError Callback called on error.
  95012. * @hidden
  95013. */
  95014. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  95015. /**
  95016. * Prepares the effect
  95017. * @hidden
  95018. */
  95019. _prepareEffect(): void;
  95020. private _processCompilationErrors;
  95021. /**
  95022. * Checks if the effect is supported. (Must be called after compilation)
  95023. */
  95024. readonly isSupported: boolean;
  95025. /**
  95026. * Binds a texture to the engine to be used as output of the shader.
  95027. * @param channel Name of the output variable.
  95028. * @param texture Texture to bind.
  95029. * @hidden
  95030. */
  95031. _bindTexture(channel: string, texture: InternalTexture): void;
  95032. /**
  95033. * Sets a texture on the engine to be used in the shader.
  95034. * @param channel Name of the sampler variable.
  95035. * @param texture Texture to set.
  95036. */
  95037. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  95038. /**
  95039. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  95040. * @param channel Name of the sampler variable.
  95041. * @param texture Texture to set.
  95042. */
  95043. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  95044. /**
  95045. * Sets an array of textures on the engine to be used in the shader.
  95046. * @param channel Name of the variable.
  95047. * @param textures Textures to set.
  95048. */
  95049. setTextureArray(channel: string, textures: BaseTexture[]): void;
  95050. /**
  95051. * 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)
  95052. * @param channel Name of the sampler variable.
  95053. * @param postProcess Post process to get the input texture from.
  95054. */
  95055. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  95056. /**
  95057. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  95058. * 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)
  95059. * @param channel Name of the sampler variable.
  95060. * @param postProcess Post process to get the output texture from.
  95061. */
  95062. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  95063. /** @hidden */
  95064. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  95065. /** @hidden */
  95066. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  95067. /** @hidden */
  95068. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  95069. /** @hidden */
  95070. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  95071. /**
  95072. * Binds a buffer to a uniform.
  95073. * @param buffer Buffer to bind.
  95074. * @param name Name of the uniform variable to bind to.
  95075. */
  95076. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  95077. /**
  95078. * Binds block to a uniform.
  95079. * @param blockName Name of the block to bind.
  95080. * @param index Index to bind.
  95081. */
  95082. bindUniformBlock(blockName: string, index: number): void;
  95083. /**
  95084. * Sets an interger value on a uniform variable.
  95085. * @param uniformName Name of the variable.
  95086. * @param value Value to be set.
  95087. * @returns this effect.
  95088. */
  95089. setInt(uniformName: string, value: number): Effect;
  95090. /**
  95091. * Sets an int array on a uniform variable.
  95092. * @param uniformName Name of the variable.
  95093. * @param array array to be set.
  95094. * @returns this effect.
  95095. */
  95096. setIntArray(uniformName: string, array: Int32Array): Effect;
  95097. /**
  95098. * 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)
  95099. * @param uniformName Name of the variable.
  95100. * @param array array to be set.
  95101. * @returns this effect.
  95102. */
  95103. setIntArray2(uniformName: string, array: Int32Array): Effect;
  95104. /**
  95105. * 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)
  95106. * @param uniformName Name of the variable.
  95107. * @param array array to be set.
  95108. * @returns this effect.
  95109. */
  95110. setIntArray3(uniformName: string, array: Int32Array): Effect;
  95111. /**
  95112. * 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)
  95113. * @param uniformName Name of the variable.
  95114. * @param array array to be set.
  95115. * @returns this effect.
  95116. */
  95117. setIntArray4(uniformName: string, array: Int32Array): Effect;
  95118. /**
  95119. * Sets an float array on a uniform variable.
  95120. * @param uniformName Name of the variable.
  95121. * @param array array to be set.
  95122. * @returns this effect.
  95123. */
  95124. setFloatArray(uniformName: string, array: Float32Array): Effect;
  95125. /**
  95126. * 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)
  95127. * @param uniformName Name of the variable.
  95128. * @param array array to be set.
  95129. * @returns this effect.
  95130. */
  95131. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  95132. /**
  95133. * 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)
  95134. * @param uniformName Name of the variable.
  95135. * @param array array to be set.
  95136. * @returns this effect.
  95137. */
  95138. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  95139. /**
  95140. * 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)
  95141. * @param uniformName Name of the variable.
  95142. * @param array array to be set.
  95143. * @returns this effect.
  95144. */
  95145. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  95146. /**
  95147. * Sets an array on a uniform variable.
  95148. * @param uniformName Name of the variable.
  95149. * @param array array to be set.
  95150. * @returns this effect.
  95151. */
  95152. setArray(uniformName: string, array: number[]): Effect;
  95153. /**
  95154. * 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)
  95155. * @param uniformName Name of the variable.
  95156. * @param array array to be set.
  95157. * @returns this effect.
  95158. */
  95159. setArray2(uniformName: string, array: number[]): Effect;
  95160. /**
  95161. * 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)
  95162. * @param uniformName Name of the variable.
  95163. * @param array array to be set.
  95164. * @returns this effect.
  95165. */
  95166. setArray3(uniformName: string, array: number[]): Effect;
  95167. /**
  95168. * 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)
  95169. * @param uniformName Name of the variable.
  95170. * @param array array to be set.
  95171. * @returns this effect.
  95172. */
  95173. setArray4(uniformName: string, array: number[]): Effect;
  95174. /**
  95175. * Sets matrices on a uniform variable.
  95176. * @param uniformName Name of the variable.
  95177. * @param matrices matrices to be set.
  95178. * @returns this effect.
  95179. */
  95180. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  95181. /**
  95182. * Sets matrix on a uniform variable.
  95183. * @param uniformName Name of the variable.
  95184. * @param matrix matrix to be set.
  95185. * @returns this effect.
  95186. */
  95187. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  95188. /**
  95189. * 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)
  95190. * @param uniformName Name of the variable.
  95191. * @param matrix matrix to be set.
  95192. * @returns this effect.
  95193. */
  95194. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  95195. /**
  95196. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  95197. * @param uniformName Name of the variable.
  95198. * @param matrix matrix to be set.
  95199. * @returns this effect.
  95200. */
  95201. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  95202. /**
  95203. * Sets a float on a uniform variable.
  95204. * @param uniformName Name of the variable.
  95205. * @param value value to be set.
  95206. * @returns this effect.
  95207. */
  95208. setFloat(uniformName: string, value: number): Effect;
  95209. /**
  95210. * Sets a boolean on a uniform variable.
  95211. * @param uniformName Name of the variable.
  95212. * @param bool value to be set.
  95213. * @returns this effect.
  95214. */
  95215. setBool(uniformName: string, bool: boolean): Effect;
  95216. /**
  95217. * Sets a Vector2 on a uniform variable.
  95218. * @param uniformName Name of the variable.
  95219. * @param vector2 vector2 to be set.
  95220. * @returns this effect.
  95221. */
  95222. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  95223. /**
  95224. * Sets a float2 on a uniform variable.
  95225. * @param uniformName Name of the variable.
  95226. * @param x First float in float2.
  95227. * @param y Second float in float2.
  95228. * @returns this effect.
  95229. */
  95230. setFloat2(uniformName: string, x: number, y: number): Effect;
  95231. /**
  95232. * Sets a Vector3 on a uniform variable.
  95233. * @param uniformName Name of the variable.
  95234. * @param vector3 Value to be set.
  95235. * @returns this effect.
  95236. */
  95237. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  95238. /**
  95239. * Sets a float3 on a uniform variable.
  95240. * @param uniformName Name of the variable.
  95241. * @param x First float in float3.
  95242. * @param y Second float in float3.
  95243. * @param z Third float in float3.
  95244. * @returns this effect.
  95245. */
  95246. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  95247. /**
  95248. * Sets a Vector4 on a uniform variable.
  95249. * @param uniformName Name of the variable.
  95250. * @param vector4 Value to be set.
  95251. * @returns this effect.
  95252. */
  95253. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  95254. /**
  95255. * Sets a float4 on a uniform variable.
  95256. * @param uniformName Name of the variable.
  95257. * @param x First float in float4.
  95258. * @param y Second float in float4.
  95259. * @param z Third float in float4.
  95260. * @param w Fourth float in float4.
  95261. * @returns this effect.
  95262. */
  95263. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  95264. /**
  95265. * Sets a Color3 on a uniform variable.
  95266. * @param uniformName Name of the variable.
  95267. * @param color3 Value to be set.
  95268. * @returns this effect.
  95269. */
  95270. setColor3(uniformName: string, color3: IColor3Like): Effect;
  95271. /**
  95272. * Sets a Color4 on a uniform variable.
  95273. * @param uniformName Name of the variable.
  95274. * @param color3 Value to be set.
  95275. * @param alpha Alpha value to be set.
  95276. * @returns this effect.
  95277. */
  95278. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  95279. /**
  95280. * Sets a Color4 on a uniform variable
  95281. * @param uniformName defines the name of the variable
  95282. * @param color4 defines the value to be set
  95283. * @returns this effect.
  95284. */
  95285. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  95286. /** Release all associated resources */
  95287. dispose(): void;
  95288. /**
  95289. * This function will add a new shader to the shader store
  95290. * @param name the name of the shader
  95291. * @param pixelShader optional pixel shader content
  95292. * @param vertexShader optional vertex shader content
  95293. */
  95294. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  95295. /**
  95296. * Store of each shader (The can be looked up using effect.key)
  95297. */
  95298. static ShadersStore: {
  95299. [key: string]: string;
  95300. };
  95301. /**
  95302. * Store of each included file for a shader (The can be looked up using effect.key)
  95303. */
  95304. static IncludesShadersStore: {
  95305. [key: string]: string;
  95306. };
  95307. /**
  95308. * Resets the cache of effects.
  95309. */
  95310. static ResetCache(): void;
  95311. }
  95312. }
  95313. declare module BABYLON {
  95314. /**
  95315. * Class used to describe the capabilities of the engine relatively to the current browser
  95316. */
  95317. export class EngineCapabilities {
  95318. /** Maximum textures units per fragment shader */
  95319. maxTexturesImageUnits: number;
  95320. /** Maximum texture units per vertex shader */
  95321. maxVertexTextureImageUnits: number;
  95322. /** Maximum textures units in the entire pipeline */
  95323. maxCombinedTexturesImageUnits: number;
  95324. /** Maximum texture size */
  95325. maxTextureSize: number;
  95326. /** Maximum cube texture size */
  95327. maxCubemapTextureSize: number;
  95328. /** Maximum render texture size */
  95329. maxRenderTextureSize: number;
  95330. /** Maximum number of vertex attributes */
  95331. maxVertexAttribs: number;
  95332. /** Maximum number of varyings */
  95333. maxVaryingVectors: number;
  95334. /** Maximum number of uniforms per vertex shader */
  95335. maxVertexUniformVectors: number;
  95336. /** Maximum number of uniforms per fragment shader */
  95337. maxFragmentUniformVectors: number;
  95338. /** Defines if standard derivates (dx/dy) are supported */
  95339. standardDerivatives: boolean;
  95340. /** Defines if s3tc texture compression is supported */
  95341. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95342. /** Defines if pvrtc texture compression is supported */
  95343. pvrtc: any;
  95344. /** Defines if etc1 texture compression is supported */
  95345. etc1: any;
  95346. /** Defines if etc2 texture compression is supported */
  95347. etc2: any;
  95348. /** Defines if astc texture compression is supported */
  95349. astc: any;
  95350. /** Defines if float textures are supported */
  95351. textureFloat: boolean;
  95352. /** Defines if vertex array objects are supported */
  95353. vertexArrayObject: boolean;
  95354. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95355. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95356. /** Gets the maximum level of anisotropy supported */
  95357. maxAnisotropy: number;
  95358. /** Defines if instancing is supported */
  95359. instancedArrays: boolean;
  95360. /** Defines if 32 bits indices are supported */
  95361. uintIndices: boolean;
  95362. /** Defines if high precision shaders are supported */
  95363. highPrecisionShaderSupported: boolean;
  95364. /** Defines if depth reading in the fragment shader is supported */
  95365. fragmentDepthSupported: boolean;
  95366. /** Defines if float texture linear filtering is supported*/
  95367. textureFloatLinearFiltering: boolean;
  95368. /** Defines if rendering to float textures is supported */
  95369. textureFloatRender: boolean;
  95370. /** Defines if half float textures are supported*/
  95371. textureHalfFloat: boolean;
  95372. /** Defines if half float texture linear filtering is supported*/
  95373. textureHalfFloatLinearFiltering: boolean;
  95374. /** Defines if rendering to half float textures is supported */
  95375. textureHalfFloatRender: boolean;
  95376. /** Defines if textureLOD shader command is supported */
  95377. textureLOD: boolean;
  95378. /** Defines if draw buffers extension is supported */
  95379. drawBuffersExtension: boolean;
  95380. /** Defines if depth textures are supported */
  95381. depthTextureExtension: boolean;
  95382. /** Defines if float color buffer are supported */
  95383. colorBufferFloat: boolean;
  95384. /** Gets disjoint timer query extension (null if not supported) */
  95385. timerQuery: EXT_disjoint_timer_query;
  95386. /** Defines if timestamp can be used with timer query */
  95387. canUseTimestampForTimerQuery: boolean;
  95388. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95389. multiview: any;
  95390. /** Function used to let the system compiles shaders in background */
  95391. parallelShaderCompile: {
  95392. COMPLETION_STATUS_KHR: number;
  95393. };
  95394. /** Max number of texture samples for MSAA */
  95395. maxMSAASamples: number;
  95396. /** Defines if the blend min max extension is supported */
  95397. blendMinMax: boolean;
  95398. }
  95399. }
  95400. declare module BABYLON {
  95401. /**
  95402. * @hidden
  95403. **/
  95404. export class DepthCullingState {
  95405. private _isDepthTestDirty;
  95406. private _isDepthMaskDirty;
  95407. private _isDepthFuncDirty;
  95408. private _isCullFaceDirty;
  95409. private _isCullDirty;
  95410. private _isZOffsetDirty;
  95411. private _isFrontFaceDirty;
  95412. private _depthTest;
  95413. private _depthMask;
  95414. private _depthFunc;
  95415. private _cull;
  95416. private _cullFace;
  95417. private _zOffset;
  95418. private _frontFace;
  95419. /**
  95420. * Initializes the state.
  95421. */
  95422. constructor();
  95423. readonly isDirty: boolean;
  95424. zOffset: number;
  95425. cullFace: Nullable<number>;
  95426. cull: Nullable<boolean>;
  95427. depthFunc: Nullable<number>;
  95428. depthMask: boolean;
  95429. depthTest: boolean;
  95430. frontFace: Nullable<number>;
  95431. reset(): void;
  95432. apply(gl: WebGLRenderingContext): void;
  95433. }
  95434. }
  95435. declare module BABYLON {
  95436. /**
  95437. * @hidden
  95438. **/
  95439. export class StencilState {
  95440. /** 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 */
  95441. static readonly ALWAYS: number;
  95442. /** Passed to stencilOperation to specify that stencil value must be kept */
  95443. static readonly KEEP: number;
  95444. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95445. static readonly REPLACE: number;
  95446. private _isStencilTestDirty;
  95447. private _isStencilMaskDirty;
  95448. private _isStencilFuncDirty;
  95449. private _isStencilOpDirty;
  95450. private _stencilTest;
  95451. private _stencilMask;
  95452. private _stencilFunc;
  95453. private _stencilFuncRef;
  95454. private _stencilFuncMask;
  95455. private _stencilOpStencilFail;
  95456. private _stencilOpDepthFail;
  95457. private _stencilOpStencilDepthPass;
  95458. readonly isDirty: boolean;
  95459. stencilFunc: number;
  95460. stencilFuncRef: number;
  95461. stencilFuncMask: number;
  95462. stencilOpStencilFail: number;
  95463. stencilOpDepthFail: number;
  95464. stencilOpStencilDepthPass: number;
  95465. stencilMask: number;
  95466. stencilTest: boolean;
  95467. constructor();
  95468. reset(): void;
  95469. apply(gl: WebGLRenderingContext): void;
  95470. }
  95471. }
  95472. declare module BABYLON {
  95473. /**
  95474. * @hidden
  95475. **/
  95476. export class AlphaState {
  95477. private _isAlphaBlendDirty;
  95478. private _isBlendFunctionParametersDirty;
  95479. private _isBlendEquationParametersDirty;
  95480. private _isBlendConstantsDirty;
  95481. private _alphaBlend;
  95482. private _blendFunctionParameters;
  95483. private _blendEquationParameters;
  95484. private _blendConstants;
  95485. /**
  95486. * Initializes the state.
  95487. */
  95488. constructor();
  95489. readonly isDirty: boolean;
  95490. alphaBlend: boolean;
  95491. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  95492. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  95493. setAlphaEquationParameters(rgb: number, alpha: number): void;
  95494. reset(): void;
  95495. apply(gl: WebGLRenderingContext): void;
  95496. }
  95497. }
  95498. declare module BABYLON {
  95499. /** @hidden */
  95500. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95501. attributeProcessor(attribute: string): string;
  95502. varyingProcessor(varying: string, isFragment: boolean): string;
  95503. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95504. }
  95505. }
  95506. declare module BABYLON {
  95507. /**
  95508. * Interface for attribute information associated with buffer instanciation
  95509. */
  95510. export class InstancingAttributeInfo {
  95511. /**
  95512. * Index/offset of the attribute in the vertex shader
  95513. */
  95514. index: number;
  95515. /**
  95516. * size of the attribute, 1, 2, 3 or 4
  95517. */
  95518. attributeSize: number;
  95519. /**
  95520. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95521. * default is FLOAT
  95522. */
  95523. attribyteType: number;
  95524. /**
  95525. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95526. */
  95527. normalized: boolean;
  95528. /**
  95529. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95530. */
  95531. offset: number;
  95532. /**
  95533. * Name of the GLSL attribute, for debugging purpose only
  95534. */
  95535. attributeName: string;
  95536. }
  95537. }
  95538. declare module BABYLON {
  95539. interface ThinEngine {
  95540. /**
  95541. * Update a video texture
  95542. * @param texture defines the texture to update
  95543. * @param video defines the video element to use
  95544. * @param invertY defines if data must be stored with Y axis inverted
  95545. */
  95546. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95547. }
  95548. }
  95549. declare module BABYLON {
  95550. /**
  95551. * Settings for finer control over video usage
  95552. */
  95553. export interface VideoTextureSettings {
  95554. /**
  95555. * Applies `autoplay` to video, if specified
  95556. */
  95557. autoPlay?: boolean;
  95558. /**
  95559. * Applies `loop` to video, if specified
  95560. */
  95561. loop?: boolean;
  95562. /**
  95563. * Automatically updates internal texture from video at every frame in the render loop
  95564. */
  95565. autoUpdateTexture: boolean;
  95566. /**
  95567. * Image src displayed during the video loading or until the user interacts with the video.
  95568. */
  95569. poster?: string;
  95570. }
  95571. /**
  95572. * If you want to display a video in your scene, this is the special texture for that.
  95573. * This special texture works similar to other textures, with the exception of a few parameters.
  95574. * @see https://doc.babylonjs.com/how_to/video_texture
  95575. */
  95576. export class VideoTexture extends Texture {
  95577. /**
  95578. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95579. */
  95580. readonly autoUpdateTexture: boolean;
  95581. /**
  95582. * The video instance used by the texture internally
  95583. */
  95584. readonly video: HTMLVideoElement;
  95585. private _onUserActionRequestedObservable;
  95586. /**
  95587. * Event triggerd when a dom action is required by the user to play the video.
  95588. * This happens due to recent changes in browser policies preventing video to auto start.
  95589. */
  95590. readonly onUserActionRequestedObservable: Observable<Texture>;
  95591. private _generateMipMaps;
  95592. private _engine;
  95593. private _stillImageCaptured;
  95594. private _displayingPosterTexture;
  95595. private _settings;
  95596. private _createInternalTextureOnEvent;
  95597. private _frameId;
  95598. /**
  95599. * Creates a video texture.
  95600. * If you want to display a video in your scene, this is the special texture for that.
  95601. * This special texture works similar to other textures, with the exception of a few parameters.
  95602. * @see https://doc.babylonjs.com/how_to/video_texture
  95603. * @param name optional name, will detect from video source, if not defined
  95604. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95605. * @param scene is obviously the current scene.
  95606. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95607. * @param invertY is false by default but can be used to invert video on Y axis
  95608. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95609. * @param settings allows finer control over video usage
  95610. */
  95611. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95612. private _getName;
  95613. private _getVideo;
  95614. private _createInternalTexture;
  95615. private reset;
  95616. /**
  95617. * @hidden Internal method to initiate `update`.
  95618. */
  95619. _rebuild(): void;
  95620. /**
  95621. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95622. */
  95623. update(): void;
  95624. /**
  95625. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95626. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95627. */
  95628. updateTexture(isVisible: boolean): void;
  95629. protected _updateInternalTexture: () => void;
  95630. /**
  95631. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95632. * @param url New url.
  95633. */
  95634. updateURL(url: string): void;
  95635. /**
  95636. * Dispose the texture and release its associated resources.
  95637. */
  95638. dispose(): void;
  95639. /**
  95640. * Creates a video texture straight from a stream.
  95641. * @param scene Define the scene the texture should be created in
  95642. * @param stream Define the stream the texture should be created from
  95643. * @returns The created video texture as a promise
  95644. */
  95645. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95646. /**
  95647. * Creates a video texture straight from your WebCam video feed.
  95648. * @param scene Define the scene the texture should be created in
  95649. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95650. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95651. * @returns The created video texture as a promise
  95652. */
  95653. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95654. minWidth: number;
  95655. maxWidth: number;
  95656. minHeight: number;
  95657. maxHeight: number;
  95658. deviceId: string;
  95659. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95660. /**
  95661. * Creates a video texture straight from your WebCam video feed.
  95662. * @param scene Define the scene the texture should be created in
  95663. * @param onReady Define a callback to triggered once the texture will be ready
  95664. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95665. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95666. */
  95667. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95668. minWidth: number;
  95669. maxWidth: number;
  95670. minHeight: number;
  95671. maxHeight: number;
  95672. deviceId: string;
  95673. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95674. }
  95675. }
  95676. declare module BABYLON {
  95677. /**
  95678. * Defines the interface used by objects working like Scene
  95679. * @hidden
  95680. */
  95681. interface ISceneLike {
  95682. _addPendingData(data: any): void;
  95683. _removePendingData(data: any): void;
  95684. offlineProvider: IOfflineProvider;
  95685. }
  95686. /** Interface defining initialization parameters for Engine class */
  95687. export interface EngineOptions extends WebGLContextAttributes {
  95688. /**
  95689. * Defines if the engine should no exceed a specified device ratio
  95690. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95691. */
  95692. limitDeviceRatio?: number;
  95693. /**
  95694. * Defines if webvr should be enabled automatically
  95695. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95696. */
  95697. autoEnableWebVR?: boolean;
  95698. /**
  95699. * Defines if webgl2 should be turned off even if supported
  95700. * @see http://doc.babylonjs.com/features/webgl2
  95701. */
  95702. disableWebGL2Support?: boolean;
  95703. /**
  95704. * Defines if webaudio should be initialized as well
  95705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95706. */
  95707. audioEngine?: boolean;
  95708. /**
  95709. * Defines if animations should run using a deterministic lock step
  95710. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95711. */
  95712. deterministicLockstep?: boolean;
  95713. /** Defines the maximum steps to use with deterministic lock step mode */
  95714. lockstepMaxSteps?: number;
  95715. /**
  95716. * Defines that engine should ignore context lost events
  95717. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95718. */
  95719. doNotHandleContextLost?: boolean;
  95720. /**
  95721. * Defines that engine should ignore modifying touch action attribute and style
  95722. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95723. */
  95724. doNotHandleTouchAction?: boolean;
  95725. /**
  95726. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95727. */
  95728. useHighPrecisionFloats?: boolean;
  95729. }
  95730. /**
  95731. * The base engine class (root of all engines)
  95732. */
  95733. export class ThinEngine {
  95734. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95735. static ExceptionList: ({
  95736. key: string;
  95737. capture: string;
  95738. captureConstraint: number;
  95739. targets: string[];
  95740. } | {
  95741. key: string;
  95742. capture: null;
  95743. captureConstraint: null;
  95744. targets: string[];
  95745. })[];
  95746. /** @hidden */
  95747. static _TextureLoaders: IInternalTextureLoader[];
  95748. /**
  95749. * Returns the current npm package of the sdk
  95750. */
  95751. static readonly NpmPackage: string;
  95752. /**
  95753. * Returns the current version of the framework
  95754. */
  95755. static readonly Version: string;
  95756. /**
  95757. * Returns a string describing the current engine
  95758. */
  95759. readonly description: string;
  95760. /**
  95761. * Gets or sets the epsilon value used by collision engine
  95762. */
  95763. static CollisionsEpsilon: number;
  95764. /**
  95765. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95766. */
  95767. static ShadersRepository: string;
  95768. /** @hidden */
  95769. _shaderProcessor: IShaderProcessor;
  95770. /**
  95771. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95772. */
  95773. forcePOTTextures: boolean;
  95774. /**
  95775. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95776. */
  95777. isFullscreen: boolean;
  95778. /**
  95779. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95780. */
  95781. cullBackFaces: boolean;
  95782. /**
  95783. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95784. */
  95785. renderEvenInBackground: boolean;
  95786. /**
  95787. * Gets or sets a boolean indicating that cache can be kept between frames
  95788. */
  95789. preventCacheWipeBetweenFrames: boolean;
  95790. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95791. validateShaderPrograms: boolean;
  95792. /**
  95793. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95794. */
  95795. disableUniformBuffers: boolean;
  95796. /** @hidden */
  95797. _uniformBuffers: UniformBuffer[];
  95798. /**
  95799. * Gets a boolean indicating that the engine supports uniform buffers
  95800. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95801. */
  95802. readonly supportsUniformBuffers: boolean;
  95803. /** @hidden */
  95804. _gl: WebGLRenderingContext;
  95805. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  95806. protected _windowIsBackground: boolean;
  95807. protected _webGLVersion: number;
  95808. protected _highPrecisionShadersAllowed: boolean;
  95809. /** @hidden */
  95810. readonly _shouldUseHighPrecisionShader: boolean;
  95811. /**
  95812. * Gets a boolean indicating that only power of 2 textures are supported
  95813. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  95814. */
  95815. readonly needPOTTextures: boolean;
  95816. /** @hidden */
  95817. _badOS: boolean;
  95818. /** @hidden */
  95819. _badDesktopOS: boolean;
  95820. private _hardwareScalingLevel;
  95821. /** @hidden */
  95822. _caps: EngineCapabilities;
  95823. private _isStencilEnable;
  95824. protected _colorWrite: boolean;
  95825. private _glVersion;
  95826. private _glRenderer;
  95827. private _glVendor;
  95828. /** @hidden */
  95829. _videoTextureSupported: boolean;
  95830. protected _renderingQueueLaunched: boolean;
  95831. protected _activeRenderLoops: (() => void)[];
  95832. /**
  95833. * Observable signaled when a context lost event is raised
  95834. */
  95835. onContextLostObservable: Observable<ThinEngine>;
  95836. /**
  95837. * Observable signaled when a context restored event is raised
  95838. */
  95839. onContextRestoredObservable: Observable<ThinEngine>;
  95840. private _onContextLost;
  95841. private _onContextRestored;
  95842. protected _contextWasLost: boolean;
  95843. /** @hidden */
  95844. _doNotHandleContextLost: boolean;
  95845. /**
  95846. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  95847. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  95848. */
  95849. doNotHandleContextLost: boolean;
  95850. /**
  95851. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  95852. */
  95853. disableVertexArrayObjects: boolean;
  95854. /** @hidden */
  95855. protected _depthCullingState: DepthCullingState;
  95856. /** @hidden */
  95857. protected _stencilState: StencilState;
  95858. /** @hidden */
  95859. protected _alphaState: AlphaState;
  95860. /** @hidden */
  95861. _internalTexturesCache: InternalTexture[];
  95862. /** @hidden */
  95863. protected _activeChannel: number;
  95864. private _currentTextureChannel;
  95865. /** @hidden */
  95866. protected _boundTexturesCache: {
  95867. [key: string]: Nullable<InternalTexture>;
  95868. };
  95869. /** @hidden */
  95870. protected _currentEffect: Nullable<Effect>;
  95871. /** @hidden */
  95872. protected _currentProgram: Nullable<WebGLProgram>;
  95873. private _compiledEffects;
  95874. private _vertexAttribArraysEnabled;
  95875. /** @hidden */
  95876. protected _cachedViewport: Nullable<IViewportLike>;
  95877. private _cachedVertexArrayObject;
  95878. /** @hidden */
  95879. protected _cachedVertexBuffers: any;
  95880. /** @hidden */
  95881. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  95882. /** @hidden */
  95883. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  95884. /** @hidden */
  95885. _currentRenderTarget: Nullable<InternalTexture>;
  95886. private _uintIndicesCurrentlySet;
  95887. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  95888. /** @hidden */
  95889. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  95890. private _currentBufferPointers;
  95891. private _currentInstanceLocations;
  95892. private _currentInstanceBuffers;
  95893. private _textureUnits;
  95894. /** @hidden */
  95895. _workingCanvas: Nullable<HTMLCanvasElement>;
  95896. /** @hidden */
  95897. _workingContext: Nullable<CanvasRenderingContext2D>;
  95898. /** @hidden */
  95899. _bindedRenderFunction: any;
  95900. private _vaoRecordInProgress;
  95901. private _mustWipeVertexAttributes;
  95902. private _emptyTexture;
  95903. private _emptyCubeTexture;
  95904. private _emptyTexture3D;
  95905. /** @hidden */
  95906. _frameHandler: number;
  95907. private _nextFreeTextureSlots;
  95908. private _maxSimultaneousTextures;
  95909. private _activeRequests;
  95910. protected _texturesSupported: string[];
  95911. /** @hidden */
  95912. _textureFormatInUse: Nullable<string>;
  95913. protected readonly _supportsHardwareTextureRescaling: boolean;
  95914. /**
  95915. * Gets the list of texture formats supported
  95916. */
  95917. readonly texturesSupported: Array<string>;
  95918. /**
  95919. * Gets the list of texture formats in use
  95920. */
  95921. readonly textureFormatInUse: Nullable<string>;
  95922. /**
  95923. * Gets the current viewport
  95924. */
  95925. readonly currentViewport: Nullable<IViewportLike>;
  95926. /**
  95927. * Gets the default empty texture
  95928. */
  95929. readonly emptyTexture: InternalTexture;
  95930. /**
  95931. * Gets the default empty 3D texture
  95932. */
  95933. readonly emptyTexture3D: InternalTexture;
  95934. /**
  95935. * Gets the default empty cube texture
  95936. */
  95937. readonly emptyCubeTexture: InternalTexture;
  95938. /**
  95939. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  95940. */
  95941. readonly premultipliedAlpha: boolean;
  95942. /**
  95943. * Observable event triggered before each texture is initialized
  95944. */
  95945. onBeforeTextureInitObservable: Observable<Texture>;
  95946. /**
  95947. * Creates a new engine
  95948. * @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
  95949. * @param antialias defines enable antialiasing (default: false)
  95950. * @param options defines further options to be sent to the getContext() function
  95951. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  95952. */
  95953. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  95954. private _rebuildInternalTextures;
  95955. private _rebuildEffects;
  95956. /**
  95957. * Gets a boolean indicating if all created effects are ready
  95958. * @returns true if all effects are ready
  95959. */
  95960. areAllEffectsReady(): boolean;
  95961. protected _rebuildBuffers(): void;
  95962. private _initGLContext;
  95963. /**
  95964. * Gets version of the current webGL context
  95965. */
  95966. readonly webGLVersion: number;
  95967. /**
  95968. * Gets a string idenfifying the name of the class
  95969. * @returns "Engine" string
  95970. */
  95971. getClassName(): string;
  95972. /**
  95973. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  95974. */
  95975. readonly isStencilEnable: boolean;
  95976. /** @hidden */
  95977. _prepareWorkingCanvas(): void;
  95978. /**
  95979. * Reset the texture cache to empty state
  95980. */
  95981. resetTextureCache(): void;
  95982. /**
  95983. * Gets an object containing information about the current webGL context
  95984. * @returns an object containing the vender, the renderer and the version of the current webGL context
  95985. */
  95986. getGlInfo(): {
  95987. vendor: string;
  95988. renderer: string;
  95989. version: string;
  95990. };
  95991. /**
  95992. * Defines the hardware scaling level.
  95993. * By default the hardware scaling level is computed from the window device ratio.
  95994. * 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.
  95995. * @param level defines the level to use
  95996. */
  95997. setHardwareScalingLevel(level: number): void;
  95998. /**
  95999. * Gets the current hardware scaling level.
  96000. * By default the hardware scaling level is computed from the window device ratio.
  96001. * 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.
  96002. * @returns a number indicating the current hardware scaling level
  96003. */
  96004. getHardwareScalingLevel(): number;
  96005. /**
  96006. * Gets the list of loaded textures
  96007. * @returns an array containing all loaded textures
  96008. */
  96009. getLoadedTexturesCache(): InternalTexture[];
  96010. /**
  96011. * Gets the object containing all engine capabilities
  96012. * @returns the EngineCapabilities object
  96013. */
  96014. getCaps(): EngineCapabilities;
  96015. /**
  96016. * stop executing a render loop function and remove it from the execution array
  96017. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96018. */
  96019. stopRenderLoop(renderFunction?: () => void): void;
  96020. /** @hidden */
  96021. _renderLoop(): void;
  96022. /**
  96023. * Gets the HTML canvas attached with the current webGL context
  96024. * @returns a HTML canvas
  96025. */
  96026. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96027. /**
  96028. * Gets host window
  96029. * @returns the host window object
  96030. */
  96031. getHostWindow(): Window;
  96032. /**
  96033. * Gets the current render width
  96034. * @param useScreen defines if screen size must be used (or the current render target if any)
  96035. * @returns a number defining the current render width
  96036. */
  96037. getRenderWidth(useScreen?: boolean): number;
  96038. /**
  96039. * Gets the current render height
  96040. * @param useScreen defines if screen size must be used (or the current render target if any)
  96041. * @returns a number defining the current render height
  96042. */
  96043. getRenderHeight(useScreen?: boolean): number;
  96044. /**
  96045. * Can be used to override the current requestAnimationFrame requester.
  96046. * @hidden
  96047. */
  96048. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96049. /**
  96050. * Register and execute a render loop. The engine can have more than one render function
  96051. * @param renderFunction defines the function to continuously execute
  96052. */
  96053. runRenderLoop(renderFunction: () => void): void;
  96054. /**
  96055. * Clear the current render buffer or the current render target (if any is set up)
  96056. * @param color defines the color to use
  96057. * @param backBuffer defines if the back buffer must be cleared
  96058. * @param depth defines if the depth buffer must be cleared
  96059. * @param stencil defines if the stencil buffer must be cleared
  96060. */
  96061. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96062. private _viewportCached;
  96063. /** @hidden */
  96064. _viewport(x: number, y: number, width: number, height: number): void;
  96065. /**
  96066. * Set the WebGL's viewport
  96067. * @param viewport defines the viewport element to be used
  96068. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96069. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96070. */
  96071. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96072. /**
  96073. * Begin a new frame
  96074. */
  96075. beginFrame(): void;
  96076. /**
  96077. * Enf the current frame
  96078. */
  96079. endFrame(): void;
  96080. /**
  96081. * Resize the view according to the canvas' size
  96082. */
  96083. resize(): void;
  96084. /**
  96085. * Force a specific size of the canvas
  96086. * @param width defines the new canvas' width
  96087. * @param height defines the new canvas' height
  96088. */
  96089. setSize(width: number, height: number): void;
  96090. /**
  96091. * Binds the frame buffer to the specified texture.
  96092. * @param texture The texture to render to or null for the default canvas
  96093. * @param faceIndex The face of the texture to render to in case of cube texture
  96094. * @param requiredWidth The width of the target to render to
  96095. * @param requiredHeight The height of the target to render to
  96096. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96097. * @param depthStencilTexture The depth stencil texture to use to render
  96098. * @param lodLevel defines le lod level to bind to the frame buffer
  96099. */
  96100. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96101. /** @hidden */
  96102. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96103. /**
  96104. * Unbind the current render target texture from the webGL context
  96105. * @param texture defines the render target texture to unbind
  96106. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96107. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96108. */
  96109. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96110. /**
  96111. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96112. */
  96113. flushFramebuffer(): void;
  96114. /**
  96115. * Unbind the current render target and bind the default framebuffer
  96116. */
  96117. restoreDefaultFramebuffer(): void;
  96118. private _resetVertexBufferBinding;
  96119. /**
  96120. * Creates a vertex buffer
  96121. * @param data the data for the vertex buffer
  96122. * @returns the new WebGL static buffer
  96123. */
  96124. createVertexBuffer(data: DataArray): DataBuffer;
  96125. private _createVertexBuffer;
  96126. /**
  96127. * Creates a dynamic vertex buffer
  96128. * @param data the data for the dynamic vertex buffer
  96129. * @returns the new WebGL dynamic buffer
  96130. */
  96131. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96132. /**
  96133. * Updates a dynamic vertex buffer.
  96134. * @param vertexBuffer the vertex buffer to update
  96135. * @param data the data used to update the vertex buffer
  96136. * @param byteOffset the byte offset of the data
  96137. * @param byteLength the byte length of the data
  96138. */
  96139. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96140. protected _resetIndexBufferBinding(): void;
  96141. /**
  96142. * Creates a new index buffer
  96143. * @param indices defines the content of the index buffer
  96144. * @param updatable defines if the index buffer must be updatable
  96145. * @returns a new webGL buffer
  96146. */
  96147. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96148. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96149. /**
  96150. * Bind a webGL buffer to the webGL context
  96151. * @param buffer defines the buffer to bind
  96152. */
  96153. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96154. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  96155. private bindBuffer;
  96156. /**
  96157. * update the bound buffer with the given data
  96158. * @param data defines the data to update
  96159. */
  96160. updateArrayBuffer(data: Float32Array): void;
  96161. private _vertexAttribPointer;
  96162. private _bindIndexBufferWithCache;
  96163. private _bindVertexBuffersAttributes;
  96164. /**
  96165. * Records a vertex array object
  96166. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96167. * @param vertexBuffers defines the list of vertex buffers to store
  96168. * @param indexBuffer defines the index buffer to store
  96169. * @param effect defines the effect to store
  96170. * @returns the new vertex array object
  96171. */
  96172. recordVertexArrayObject(vertexBuffers: {
  96173. [key: string]: VertexBuffer;
  96174. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96175. /**
  96176. * Bind a specific vertex array object
  96177. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96178. * @param vertexArrayObject defines the vertex array object to bind
  96179. * @param indexBuffer defines the index buffer to bind
  96180. */
  96181. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96182. /**
  96183. * Bind webGl buffers directly to the webGL context
  96184. * @param vertexBuffer defines the vertex buffer to bind
  96185. * @param indexBuffer defines the index buffer to bind
  96186. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96187. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96188. * @param effect defines the effect associated with the vertex buffer
  96189. */
  96190. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96191. private _unbindVertexArrayObject;
  96192. /**
  96193. * Bind a list of vertex buffers to the webGL context
  96194. * @param vertexBuffers defines the list of vertex buffers to bind
  96195. * @param indexBuffer defines the index buffer to bind
  96196. * @param effect defines the effect associated with the vertex buffers
  96197. */
  96198. bindBuffers(vertexBuffers: {
  96199. [key: string]: Nullable<VertexBuffer>;
  96200. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96201. /**
  96202. * Unbind all instance attributes
  96203. */
  96204. unbindInstanceAttributes(): void;
  96205. /**
  96206. * Release and free the memory of a vertex array object
  96207. * @param vao defines the vertex array object to delete
  96208. */
  96209. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96210. /** @hidden */
  96211. _releaseBuffer(buffer: DataBuffer): boolean;
  96212. protected _deleteBuffer(buffer: DataBuffer): void;
  96213. /**
  96214. * Creates a webGL buffer to use with instanciation
  96215. * @param capacity defines the size of the buffer
  96216. * @returns the webGL buffer
  96217. */
  96218. createInstancesBuffer(capacity: number): DataBuffer;
  96219. /**
  96220. * Delete a webGL buffer used with instanciation
  96221. * @param buffer defines the webGL buffer to delete
  96222. */
  96223. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96224. /**
  96225. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96226. * @param instancesBuffer defines the webGL buffer to update and bind
  96227. * @param data defines the data to store in the buffer
  96228. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96229. */
  96230. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96231. /**
  96232. * Apply all cached states (depth, culling, stencil and alpha)
  96233. */
  96234. applyStates(): void;
  96235. /**
  96236. * Send a draw order
  96237. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96238. * @param indexStart defines the starting index
  96239. * @param indexCount defines the number of index to draw
  96240. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96241. */
  96242. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96243. /**
  96244. * Draw a list of points
  96245. * @param verticesStart defines the index of first vertex to draw
  96246. * @param verticesCount defines the count of vertices to draw
  96247. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96248. */
  96249. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96250. /**
  96251. * Draw a list of unindexed primitives
  96252. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96253. * @param verticesStart defines the index of first vertex to draw
  96254. * @param verticesCount defines the count of vertices to draw
  96255. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96256. */
  96257. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96258. /**
  96259. * Draw a list of indexed primitives
  96260. * @param fillMode defines the primitive to use
  96261. * @param indexStart defines the starting index
  96262. * @param indexCount defines the number of index to draw
  96263. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96264. */
  96265. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96266. /**
  96267. * Draw a list of unindexed primitives
  96268. * @param fillMode defines the primitive to use
  96269. * @param verticesStart defines the index of first vertex to draw
  96270. * @param verticesCount defines the count of vertices to draw
  96271. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96272. */
  96273. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96274. private _drawMode;
  96275. /** @hidden */
  96276. protected _reportDrawCall(): void;
  96277. /** @hidden */
  96278. _releaseEffect(effect: Effect): void;
  96279. /** @hidden */
  96280. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96281. /**
  96282. * Create a new effect (used to store vertex/fragment shaders)
  96283. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96284. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  96285. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96286. * @param samplers defines an array of string used to represent textures
  96287. * @param defines defines the string containing the defines to use to compile the shaders
  96288. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96289. * @param onCompiled defines a function to call when the effect creation is successful
  96290. * @param onError defines a function to call when the effect creation has failed
  96291. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96292. * @returns the new Effect
  96293. */
  96294. 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;
  96295. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96296. private _compileShader;
  96297. private _compileRawShader;
  96298. /**
  96299. * Directly creates a webGL program
  96300. * @param pipelineContext defines the pipeline context to attach to
  96301. * @param vertexCode defines the vertex shader code to use
  96302. * @param fragmentCode defines the fragment shader code to use
  96303. * @param context defines the webGL context to use (if not set, the current one will be used)
  96304. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96305. * @returns the new webGL program
  96306. */
  96307. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96308. /**
  96309. * Creates a webGL program
  96310. * @param pipelineContext defines the pipeline context to attach to
  96311. * @param vertexCode defines the vertex shader code to use
  96312. * @param fragmentCode defines the fragment shader code to use
  96313. * @param defines defines the string containing the defines to use to compile the shaders
  96314. * @param context defines the webGL context to use (if not set, the current one will be used)
  96315. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96316. * @returns the new webGL program
  96317. */
  96318. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96319. /**
  96320. * Creates a new pipeline context
  96321. * @returns the new pipeline
  96322. */
  96323. createPipelineContext(): IPipelineContext;
  96324. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96325. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  96326. /** @hidden */
  96327. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96328. /** @hidden */
  96329. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96330. /** @hidden */
  96331. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96332. /**
  96333. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96334. * @param pipelineContext defines the pipeline context to use
  96335. * @param uniformsNames defines the list of uniform names
  96336. * @returns an array of webGL uniform locations
  96337. */
  96338. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96339. /**
  96340. * Gets the lsit of active attributes for a given webGL program
  96341. * @param pipelineContext defines the pipeline context to use
  96342. * @param attributesNames defines the list of attribute names to get
  96343. * @returns an array of indices indicating the offset of each attribute
  96344. */
  96345. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96346. /**
  96347. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96348. * @param effect defines the effect to activate
  96349. */
  96350. enableEffect(effect: Nullable<Effect>): void;
  96351. /**
  96352. * Set the value of an uniform to an array of int32
  96353. * @param uniform defines the webGL uniform location where to store the value
  96354. * @param array defines the array of int32 to store
  96355. */
  96356. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96357. /**
  96358. * Set the value of an uniform to an array of int32 (stored as vec2)
  96359. * @param uniform defines the webGL uniform location where to store the value
  96360. * @param array defines the array of int32 to store
  96361. */
  96362. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96363. /**
  96364. * Set the value of an uniform to an array of int32 (stored as vec3)
  96365. * @param uniform defines the webGL uniform location where to store the value
  96366. * @param array defines the array of int32 to store
  96367. */
  96368. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96369. /**
  96370. * Set the value of an uniform to an array of int32 (stored as vec4)
  96371. * @param uniform defines the webGL uniform location where to store the value
  96372. * @param array defines the array of int32 to store
  96373. */
  96374. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96375. /**
  96376. * Set the value of an uniform to an array of float32
  96377. * @param uniform defines the webGL uniform location where to store the value
  96378. * @param array defines the array of float32 to store
  96379. */
  96380. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96381. /**
  96382. * Set the value of an uniform to an array of float32 (stored as vec2)
  96383. * @param uniform defines the webGL uniform location where to store the value
  96384. * @param array defines the array of float32 to store
  96385. */
  96386. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96387. /**
  96388. * Set the value of an uniform to an array of float32 (stored as vec3)
  96389. * @param uniform defines the webGL uniform location where to store the value
  96390. * @param array defines the array of float32 to store
  96391. */
  96392. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96393. /**
  96394. * Set the value of an uniform to an array of float32 (stored as vec4)
  96395. * @param uniform defines the webGL uniform location where to store the value
  96396. * @param array defines the array of float32 to store
  96397. */
  96398. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96399. /**
  96400. * Set the value of an uniform to an array of number
  96401. * @param uniform defines the webGL uniform location where to store the value
  96402. * @param array defines the array of number to store
  96403. */
  96404. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96405. /**
  96406. * Set the value of an uniform to an array of number (stored as vec2)
  96407. * @param uniform defines the webGL uniform location where to store the value
  96408. * @param array defines the array of number to store
  96409. */
  96410. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96411. /**
  96412. * Set the value of an uniform to an array of number (stored as vec3)
  96413. * @param uniform defines the webGL uniform location where to store the value
  96414. * @param array defines the array of number to store
  96415. */
  96416. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96417. /**
  96418. * Set the value of an uniform to an array of number (stored as vec4)
  96419. * @param uniform defines the webGL uniform location where to store the value
  96420. * @param array defines the array of number to store
  96421. */
  96422. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96423. /**
  96424. * Set the value of an uniform to an array of float32 (stored as matrices)
  96425. * @param uniform defines the webGL uniform location where to store the value
  96426. * @param matrices defines the array of float32 to store
  96427. */
  96428. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96429. /**
  96430. * Set the value of an uniform to a matrix (3x3)
  96431. * @param uniform defines the webGL uniform location where to store the value
  96432. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96433. */
  96434. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96435. /**
  96436. * Set the value of an uniform to a matrix (2x2)
  96437. * @param uniform defines the webGL uniform location where to store the value
  96438. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96439. */
  96440. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96441. /**
  96442. * Set the value of an uniform to a number (int)
  96443. * @param uniform defines the webGL uniform location where to store the value
  96444. * @param value defines the int number to store
  96445. */
  96446. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96447. /**
  96448. * Set the value of an uniform to a number (float)
  96449. * @param uniform defines the webGL uniform location where to store the value
  96450. * @param value defines the float number to store
  96451. */
  96452. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96453. /**
  96454. * Set the value of an uniform to a vec2
  96455. * @param uniform defines the webGL uniform location where to store the value
  96456. * @param x defines the 1st component of the value
  96457. * @param y defines the 2nd component of the value
  96458. */
  96459. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96460. /**
  96461. * Set the value of an uniform to a vec3
  96462. * @param uniform defines the webGL uniform location where to store the value
  96463. * @param x defines the 1st component of the value
  96464. * @param y defines the 2nd component of the value
  96465. * @param z defines the 3rd component of the value
  96466. */
  96467. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96468. /**
  96469. * Set the value of an uniform to a boolean
  96470. * @param uniform defines the webGL uniform location where to store the value
  96471. * @param bool defines the boolean to store
  96472. */
  96473. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96474. /**
  96475. * Set the value of an uniform to a vec4
  96476. * @param uniform defines the webGL uniform location where to store the value
  96477. * @param x defines the 1st component of the value
  96478. * @param y defines the 2nd component of the value
  96479. * @param z defines the 3rd component of the value
  96480. * @param w defines the 4th component of the value
  96481. */
  96482. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96483. /**
  96484. * Sets a Color4 on a uniform variable
  96485. * @param uniform defines the uniform location
  96486. * @param color4 defines the value to be set
  96487. */
  96488. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96489. /**
  96490. * Gets the depth culling state manager
  96491. */
  96492. readonly depthCullingState: DepthCullingState;
  96493. /**
  96494. * Gets the alpha state manager
  96495. */
  96496. readonly alphaState: AlphaState;
  96497. /**
  96498. * Gets the stencil state manager
  96499. */
  96500. readonly stencilState: StencilState;
  96501. /**
  96502. * Clears the list of texture accessible through engine.
  96503. * This can help preventing texture load conflict due to name collision.
  96504. */
  96505. clearInternalTexturesCache(): void;
  96506. /**
  96507. * Force the entire cache to be cleared
  96508. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96509. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96510. */
  96511. wipeCaches(bruteForce?: boolean): void;
  96512. /** @hidden */
  96513. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96514. min: number;
  96515. mag: number;
  96516. };
  96517. /** @hidden */
  96518. _createTexture(): WebGLTexture;
  96519. /**
  96520. * Usually called from Texture.ts.
  96521. * Passed information to create a WebGLTexture
  96522. * @param urlArg defines a value which contains one of the following:
  96523. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96524. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96525. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96526. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96527. * @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)
  96528. * @param scene needed for loading to the correct scene
  96529. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96530. * @param onLoad optional callback to be called upon successful completion
  96531. * @param onError optional callback to be called upon failure
  96532. * @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
  96533. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96534. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96535. * @param forcedExtension defines the extension to use to pick the right loader
  96536. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96537. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96538. */
  96539. 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;
  96540. /**
  96541. * @hidden
  96542. */
  96543. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  96544. /**
  96545. * Creates a raw texture
  96546. * @param data defines the data to store in the texture
  96547. * @param width defines the width of the texture
  96548. * @param height defines the height of the texture
  96549. * @param format defines the format of the data
  96550. * @param generateMipMaps defines if the engine should generate the mip levels
  96551. * @param invertY defines if data must be stored with Y axis inverted
  96552. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96553. * @param compression defines the compression used (null by default)
  96554. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  96555. * @returns the raw texture inside an InternalTexture
  96556. */
  96557. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  96558. /**
  96559. * Creates a new raw cube texture
  96560. * @param data defines the array of data to use to create each face
  96561. * @param size defines the size of the textures
  96562. * @param format defines the format of the data
  96563. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  96564. * @param generateMipMaps defines if the engine should generate the mip levels
  96565. * @param invertY defines if data must be stored with Y axis inverted
  96566. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96567. * @param compression defines the compression used (null by default)
  96568. * @returns the cube texture as an InternalTexture
  96569. */
  96570. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  96571. /**
  96572. * Creates a new raw 3D texture
  96573. * @param data defines the data used to create the texture
  96574. * @param width defines the width of the texture
  96575. * @param height defines the height of the texture
  96576. * @param depth defines the depth of the texture
  96577. * @param format defines the format of the texture
  96578. * @param generateMipMaps defines if the engine must generate mip levels
  96579. * @param invertY defines if data must be stored with Y axis inverted
  96580. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96581. * @param compression defines the compressed used (can be null)
  96582. * @param textureType defines the compressed used (can be null)
  96583. * @returns a new raw 3D texture (stored in an InternalTexture)
  96584. */
  96585. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  96586. private _unpackFlipYCached;
  96587. /**
  96588. * In case you are sharing the context with other applications, it might
  96589. * be interested to not cache the unpack flip y state to ensure a consistent
  96590. * value would be set.
  96591. */
  96592. enableUnpackFlipYCached: boolean;
  96593. /** @hidden */
  96594. _unpackFlipY(value: boolean): void;
  96595. /** @hidden */
  96596. _getUnpackAlignement(): number;
  96597. /**
  96598. * Update the sampling mode of a given texture
  96599. * @param samplingMode defines the required sampling mode
  96600. * @param texture defines the texture to update
  96601. */
  96602. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96603. /**
  96604. * Updates a depth texture Comparison Mode and Function.
  96605. * If the comparison Function is equal to 0, the mode will be set to none.
  96606. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96607. * @param texture The texture to set the comparison function for
  96608. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96609. */
  96610. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96611. /** @hidden */
  96612. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96613. width: number;
  96614. height: number;
  96615. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96616. /**
  96617. * Creates a depth stencil texture.
  96618. * This is only available in WebGL 2 or with the depth texture extension available.
  96619. * @param size The size of face edge in the texture.
  96620. * @param options The options defining the texture.
  96621. * @returns The texture
  96622. */
  96623. createDepthStencilTexture(size: number | {
  96624. width: number;
  96625. height: number;
  96626. }, options: DepthTextureCreationOptions): InternalTexture;
  96627. /**
  96628. * Creates a depth stencil texture.
  96629. * This is only available in WebGL 2 or with the depth texture extension available.
  96630. * @param size The size of face edge in the texture.
  96631. * @param options The options defining the texture.
  96632. * @returns The texture
  96633. */
  96634. private _createDepthStencilTexture;
  96635. /** @hidden */
  96636. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96637. /** @hidden */
  96638. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96639. /** @hidden */
  96640. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96641. /** @hidden */
  96642. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96643. /**
  96644. * @hidden
  96645. */
  96646. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96647. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  96648. private _prepareWebGLTexture;
  96649. /** @hidden */
  96650. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96651. /** @hidden */
  96652. _releaseFramebufferObjects(texture: InternalTexture): void;
  96653. /** @hidden */
  96654. _releaseTexture(texture: InternalTexture): void;
  96655. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  96656. protected _setProgram(program: WebGLProgram): void;
  96657. protected _boundUniforms: {
  96658. [key: number]: WebGLUniformLocation;
  96659. };
  96660. /**
  96661. * Binds an effect to the webGL context
  96662. * @param effect defines the effect to bind
  96663. */
  96664. bindSamplers(effect: Effect): void;
  96665. private _activateCurrentTexture;
  96666. /** @hidden */
  96667. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96668. /** @hidden */
  96669. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96670. /**
  96671. * Unbind all textures from the webGL context
  96672. */
  96673. unbindAllTextures(): void;
  96674. /**
  96675. * Sets a texture to the according uniform.
  96676. * @param channel The texture channel
  96677. * @param uniform The uniform to set
  96678. * @param texture The texture to apply
  96679. */
  96680. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96681. private _bindSamplerUniformToChannel;
  96682. private _getTextureWrapMode;
  96683. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  96684. /**
  96685. * Sets an array of texture to the webGL context
  96686. * @param channel defines the channel where the texture array must be set
  96687. * @param uniform defines the associated uniform location
  96688. * @param textures defines the array of textures to bind
  96689. */
  96690. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96691. /** @hidden */
  96692. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96693. private _setTextureParameterFloat;
  96694. private _setTextureParameterInteger;
  96695. /**
  96696. * Unbind all vertex attributes from the webGL context
  96697. */
  96698. unbindAllAttributes(): void;
  96699. /**
  96700. * 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
  96701. */
  96702. releaseEffects(): void;
  96703. /**
  96704. * Dispose and release all associated resources
  96705. */
  96706. dispose(): void;
  96707. /**
  96708. * Attach a new callback raised when context lost event is fired
  96709. * @param callback defines the callback to call
  96710. */
  96711. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96712. /**
  96713. * Attach a new callback raised when context restored event is fired
  96714. * @param callback defines the callback to call
  96715. */
  96716. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96717. /**
  96718. * Get the current error code of the webGL context
  96719. * @returns the error code
  96720. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96721. */
  96722. getError(): number;
  96723. private _canRenderToFloatFramebuffer;
  96724. private _canRenderToHalfFloatFramebuffer;
  96725. private _canRenderToFramebuffer;
  96726. /** @hidden */
  96727. _getWebGLTextureType(type: number): number;
  96728. /** @hidden */
  96729. _getInternalFormat(format: number): number;
  96730. /** @hidden */
  96731. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96732. /** @hidden */
  96733. _getRGBAMultiSampleBufferFormat(type: number): number;
  96734. /** @hidden */
  96735. _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;
  96736. /**
  96737. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96738. * @returns true if the engine can be created
  96739. * @ignorenaming
  96740. */
  96741. static isSupported(): boolean;
  96742. /**
  96743. * Find the next highest power of two.
  96744. * @param x Number to start search from.
  96745. * @return Next highest power of two.
  96746. */
  96747. static CeilingPOT(x: number): number;
  96748. /**
  96749. * Find the next lowest power of two.
  96750. * @param x Number to start search from.
  96751. * @return Next lowest power of two.
  96752. */
  96753. static FloorPOT(x: number): number;
  96754. /**
  96755. * Find the nearest power of two.
  96756. * @param x Number to start search from.
  96757. * @return Next nearest power of two.
  96758. */
  96759. static NearestPOT(x: number): number;
  96760. /**
  96761. * Get the closest exponent of two
  96762. * @param value defines the value to approximate
  96763. * @param max defines the maximum value to return
  96764. * @param mode defines how to define the closest value
  96765. * @returns closest exponent of two of the given value
  96766. */
  96767. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  96768. /**
  96769. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  96770. * @param func - the function to be called
  96771. * @param requester - the object that will request the next frame. Falls back to window.
  96772. * @returns frame number
  96773. */
  96774. static QueueNewFrame(func: () => void, requester?: any): number;
  96775. }
  96776. }
  96777. declare module BABYLON {
  96778. /**
  96779. * Class representing spherical harmonics coefficients to the 3rd degree
  96780. */
  96781. export class SphericalHarmonics {
  96782. /**
  96783. * Defines whether or not the harmonics have been prescaled for rendering.
  96784. */
  96785. preScaled: boolean;
  96786. /**
  96787. * The l0,0 coefficients of the spherical harmonics
  96788. */
  96789. l00: Vector3;
  96790. /**
  96791. * The l1,-1 coefficients of the spherical harmonics
  96792. */
  96793. l1_1: Vector3;
  96794. /**
  96795. * The l1,0 coefficients of the spherical harmonics
  96796. */
  96797. l10: Vector3;
  96798. /**
  96799. * The l1,1 coefficients of the spherical harmonics
  96800. */
  96801. l11: Vector3;
  96802. /**
  96803. * The l2,-2 coefficients of the spherical harmonics
  96804. */
  96805. l2_2: Vector3;
  96806. /**
  96807. * The l2,-1 coefficients of the spherical harmonics
  96808. */
  96809. l2_1: Vector3;
  96810. /**
  96811. * The l2,0 coefficients of the spherical harmonics
  96812. */
  96813. l20: Vector3;
  96814. /**
  96815. * The l2,1 coefficients of the spherical harmonics
  96816. */
  96817. l21: Vector3;
  96818. /**
  96819. * The l2,2 coefficients of the spherical harmonics
  96820. */
  96821. l22: Vector3;
  96822. /**
  96823. * Adds a light to the spherical harmonics
  96824. * @param direction the direction of the light
  96825. * @param color the color of the light
  96826. * @param deltaSolidAngle the delta solid angle of the light
  96827. */
  96828. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  96829. /**
  96830. * Scales the spherical harmonics by the given amount
  96831. * @param scale the amount to scale
  96832. */
  96833. scaleInPlace(scale: number): void;
  96834. /**
  96835. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  96836. *
  96837. * ```
  96838. * E_lm = A_l * L_lm
  96839. * ```
  96840. *
  96841. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  96842. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  96843. * the scaling factors are given in equation 9.
  96844. */
  96845. convertIncidentRadianceToIrradiance(): void;
  96846. /**
  96847. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  96848. *
  96849. * ```
  96850. * L = (1/pi) * E * rho
  96851. * ```
  96852. *
  96853. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  96854. */
  96855. convertIrradianceToLambertianRadiance(): void;
  96856. /**
  96857. * Integrates the reconstruction coefficients directly in to the SH preventing further
  96858. * required operations at run time.
  96859. *
  96860. * This is simply done by scaling back the SH with Ylm constants parameter.
  96861. * The trigonometric part being applied by the shader at run time.
  96862. */
  96863. preScaleForRendering(): void;
  96864. /**
  96865. * Constructs a spherical harmonics from an array.
  96866. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  96867. * @returns the spherical harmonics
  96868. */
  96869. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  96870. /**
  96871. * Gets the spherical harmonics from polynomial
  96872. * @param polynomial the spherical polynomial
  96873. * @returns the spherical harmonics
  96874. */
  96875. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  96876. }
  96877. /**
  96878. * Class representing spherical polynomial coefficients to the 3rd degree
  96879. */
  96880. export class SphericalPolynomial {
  96881. private _harmonics;
  96882. /**
  96883. * The spherical harmonics used to create the polynomials.
  96884. */
  96885. readonly preScaledHarmonics: SphericalHarmonics;
  96886. /**
  96887. * The x coefficients of the spherical polynomial
  96888. */
  96889. x: Vector3;
  96890. /**
  96891. * The y coefficients of the spherical polynomial
  96892. */
  96893. y: Vector3;
  96894. /**
  96895. * The z coefficients of the spherical polynomial
  96896. */
  96897. z: Vector3;
  96898. /**
  96899. * The xx coefficients of the spherical polynomial
  96900. */
  96901. xx: Vector3;
  96902. /**
  96903. * The yy coefficients of the spherical polynomial
  96904. */
  96905. yy: Vector3;
  96906. /**
  96907. * The zz coefficients of the spherical polynomial
  96908. */
  96909. zz: Vector3;
  96910. /**
  96911. * The xy coefficients of the spherical polynomial
  96912. */
  96913. xy: Vector3;
  96914. /**
  96915. * The yz coefficients of the spherical polynomial
  96916. */
  96917. yz: Vector3;
  96918. /**
  96919. * The zx coefficients of the spherical polynomial
  96920. */
  96921. zx: Vector3;
  96922. /**
  96923. * Adds an ambient color to the spherical polynomial
  96924. * @param color the color to add
  96925. */
  96926. addAmbient(color: Color3): void;
  96927. /**
  96928. * Scales the spherical polynomial by the given amount
  96929. * @param scale the amount to scale
  96930. */
  96931. scaleInPlace(scale: number): void;
  96932. /**
  96933. * Gets the spherical polynomial from harmonics
  96934. * @param harmonics the spherical harmonics
  96935. * @returns the spherical polynomial
  96936. */
  96937. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  96938. /**
  96939. * Constructs a spherical polynomial from an array.
  96940. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  96941. * @returns the spherical polynomial
  96942. */
  96943. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  96944. }
  96945. }
  96946. declare module BABYLON {
  96947. /**
  96948. * Defines the source of the internal texture
  96949. */
  96950. export enum InternalTextureSource {
  96951. /**
  96952. * The source of the texture data is unknown
  96953. */
  96954. Unknown = 0,
  96955. /**
  96956. * Texture data comes from an URL
  96957. */
  96958. Url = 1,
  96959. /**
  96960. * Texture data is only used for temporary storage
  96961. */
  96962. Temp = 2,
  96963. /**
  96964. * Texture data comes from raw data (ArrayBuffer)
  96965. */
  96966. Raw = 3,
  96967. /**
  96968. * Texture content is dynamic (video or dynamic texture)
  96969. */
  96970. Dynamic = 4,
  96971. /**
  96972. * Texture content is generated by rendering to it
  96973. */
  96974. RenderTarget = 5,
  96975. /**
  96976. * Texture content is part of a multi render target process
  96977. */
  96978. MultiRenderTarget = 6,
  96979. /**
  96980. * Texture data comes from a cube data file
  96981. */
  96982. Cube = 7,
  96983. /**
  96984. * Texture data comes from a raw cube data
  96985. */
  96986. CubeRaw = 8,
  96987. /**
  96988. * Texture data come from a prefiltered cube data file
  96989. */
  96990. CubePrefiltered = 9,
  96991. /**
  96992. * Texture content is raw 3D data
  96993. */
  96994. Raw3D = 10,
  96995. /**
  96996. * Texture content is a depth texture
  96997. */
  96998. Depth = 11,
  96999. /**
  97000. * Texture data comes from a raw cube data encoded with RGBD
  97001. */
  97002. CubeRawRGBD = 12
  97003. }
  97004. /**
  97005. * Class used to store data associated with WebGL texture data for the engine
  97006. * This class should not be used directly
  97007. */
  97008. export class InternalTexture {
  97009. /** @hidden */
  97010. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  97011. /**
  97012. * Defines if the texture is ready
  97013. */
  97014. isReady: boolean;
  97015. /**
  97016. * Defines if the texture is a cube texture
  97017. */
  97018. isCube: boolean;
  97019. /**
  97020. * Defines if the texture contains 3D data
  97021. */
  97022. is3D: boolean;
  97023. /**
  97024. * Defines if the texture contains multiview data
  97025. */
  97026. isMultiview: boolean;
  97027. /**
  97028. * Gets the URL used to load this texture
  97029. */
  97030. url: string;
  97031. /**
  97032. * Gets the sampling mode of the texture
  97033. */
  97034. samplingMode: number;
  97035. /**
  97036. * Gets a boolean indicating if the texture needs mipmaps generation
  97037. */
  97038. generateMipMaps: boolean;
  97039. /**
  97040. * Gets the number of samples used by the texture (WebGL2+ only)
  97041. */
  97042. samples: number;
  97043. /**
  97044. * Gets the type of the texture (int, float...)
  97045. */
  97046. type: number;
  97047. /**
  97048. * Gets the format of the texture (RGB, RGBA...)
  97049. */
  97050. format: number;
  97051. /**
  97052. * Observable called when the texture is loaded
  97053. */
  97054. onLoadedObservable: Observable<InternalTexture>;
  97055. /**
  97056. * Gets the width of the texture
  97057. */
  97058. width: number;
  97059. /**
  97060. * Gets the height of the texture
  97061. */
  97062. height: number;
  97063. /**
  97064. * Gets the depth of the texture
  97065. */
  97066. depth: number;
  97067. /**
  97068. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  97069. */
  97070. baseWidth: number;
  97071. /**
  97072. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  97073. */
  97074. baseHeight: number;
  97075. /**
  97076. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  97077. */
  97078. baseDepth: number;
  97079. /**
  97080. * Gets a boolean indicating if the texture is inverted on Y axis
  97081. */
  97082. invertY: boolean;
  97083. /** @hidden */
  97084. _invertVScale: boolean;
  97085. /** @hidden */
  97086. _associatedChannel: number;
  97087. /** @hidden */
  97088. _source: InternalTextureSource;
  97089. /** @hidden */
  97090. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  97091. /** @hidden */
  97092. _bufferView: Nullable<ArrayBufferView>;
  97093. /** @hidden */
  97094. _bufferViewArray: Nullable<ArrayBufferView[]>;
  97095. /** @hidden */
  97096. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  97097. /** @hidden */
  97098. _size: number;
  97099. /** @hidden */
  97100. _extension: string;
  97101. /** @hidden */
  97102. _files: Nullable<string[]>;
  97103. /** @hidden */
  97104. _workingCanvas: Nullable<HTMLCanvasElement>;
  97105. /** @hidden */
  97106. _workingContext: Nullable<CanvasRenderingContext2D>;
  97107. /** @hidden */
  97108. _framebuffer: Nullable<WebGLFramebuffer>;
  97109. /** @hidden */
  97110. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  97111. /** @hidden */
  97112. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  97113. /** @hidden */
  97114. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  97115. /** @hidden */
  97116. _attachments: Nullable<number[]>;
  97117. /** @hidden */
  97118. _cachedCoordinatesMode: Nullable<number>;
  97119. /** @hidden */
  97120. _cachedWrapU: Nullable<number>;
  97121. /** @hidden */
  97122. _cachedWrapV: Nullable<number>;
  97123. /** @hidden */
  97124. _cachedWrapR: Nullable<number>;
  97125. /** @hidden */
  97126. _cachedAnisotropicFilteringLevel: Nullable<number>;
  97127. /** @hidden */
  97128. _isDisabled: boolean;
  97129. /** @hidden */
  97130. _compression: Nullable<string>;
  97131. /** @hidden */
  97132. _generateStencilBuffer: boolean;
  97133. /** @hidden */
  97134. _generateDepthBuffer: boolean;
  97135. /** @hidden */
  97136. _comparisonFunction: number;
  97137. /** @hidden */
  97138. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  97139. /** @hidden */
  97140. _lodGenerationScale: number;
  97141. /** @hidden */
  97142. _lodGenerationOffset: number;
  97143. /** @hidden */
  97144. _colorTextureArray: Nullable<WebGLTexture>;
  97145. /** @hidden */
  97146. _depthStencilTextureArray: Nullable<WebGLTexture>;
  97147. /** @hidden */
  97148. _lodTextureHigh: Nullable<BaseTexture>;
  97149. /** @hidden */
  97150. _lodTextureMid: Nullable<BaseTexture>;
  97151. /** @hidden */
  97152. _lodTextureLow: Nullable<BaseTexture>;
  97153. /** @hidden */
  97154. _isRGBD: boolean;
  97155. /** @hidden */
  97156. _linearSpecularLOD: boolean;
  97157. /** @hidden */
  97158. _irradianceTexture: Nullable<BaseTexture>;
  97159. /** @hidden */
  97160. _webGLTexture: Nullable<WebGLTexture>;
  97161. /** @hidden */
  97162. _references: number;
  97163. private _engine;
  97164. /**
  97165. * Gets the Engine the texture belongs to.
  97166. * @returns The babylon engine
  97167. */
  97168. getEngine(): ThinEngine;
  97169. /**
  97170. * Gets the data source type of the texture
  97171. */
  97172. readonly source: InternalTextureSource;
  97173. /**
  97174. * Creates a new InternalTexture
  97175. * @param engine defines the engine to use
  97176. * @param source defines the type of data that will be used
  97177. * @param delayAllocation if the texture allocation should be delayed (default: false)
  97178. */
  97179. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  97180. /**
  97181. * Increments the number of references (ie. the number of Texture that point to it)
  97182. */
  97183. incrementReferences(): void;
  97184. /**
  97185. * Change the size of the texture (not the size of the content)
  97186. * @param width defines the new width
  97187. * @param height defines the new height
  97188. * @param depth defines the new depth (1 by default)
  97189. */
  97190. updateSize(width: int, height: int, depth?: int): void;
  97191. /** @hidden */
  97192. _rebuild(): void;
  97193. /** @hidden */
  97194. _swapAndDie(target: InternalTexture): void;
  97195. /**
  97196. * Dispose the current allocated resources
  97197. */
  97198. dispose(): void;
  97199. }
  97200. }
  97201. declare module BABYLON {
  97202. /**
  97203. * Class used to work with sound analyzer using fast fourier transform (FFT)
  97204. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97205. */
  97206. export class Analyser {
  97207. /**
  97208. * Gets or sets the smoothing
  97209. * @ignorenaming
  97210. */
  97211. SMOOTHING: number;
  97212. /**
  97213. * Gets or sets the FFT table size
  97214. * @ignorenaming
  97215. */
  97216. FFT_SIZE: number;
  97217. /**
  97218. * Gets or sets the bar graph amplitude
  97219. * @ignorenaming
  97220. */
  97221. BARGRAPHAMPLITUDE: number;
  97222. /**
  97223. * Gets or sets the position of the debug canvas
  97224. * @ignorenaming
  97225. */
  97226. DEBUGCANVASPOS: {
  97227. x: number;
  97228. y: number;
  97229. };
  97230. /**
  97231. * Gets or sets the debug canvas size
  97232. * @ignorenaming
  97233. */
  97234. DEBUGCANVASSIZE: {
  97235. width: number;
  97236. height: number;
  97237. };
  97238. private _byteFreqs;
  97239. private _byteTime;
  97240. private _floatFreqs;
  97241. private _webAudioAnalyser;
  97242. private _debugCanvas;
  97243. private _debugCanvasContext;
  97244. private _scene;
  97245. private _registerFunc;
  97246. private _audioEngine;
  97247. /**
  97248. * Creates a new analyser
  97249. * @param scene defines hosting scene
  97250. */
  97251. constructor(scene: Scene);
  97252. /**
  97253. * Get the number of data values you will have to play with for the visualization
  97254. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  97255. * @returns a number
  97256. */
  97257. getFrequencyBinCount(): number;
  97258. /**
  97259. * Gets the current frequency data as a byte array
  97260. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97261. * @returns a Uint8Array
  97262. */
  97263. getByteFrequencyData(): Uint8Array;
  97264. /**
  97265. * Gets the current waveform as a byte array
  97266. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  97267. * @returns a Uint8Array
  97268. */
  97269. getByteTimeDomainData(): Uint8Array;
  97270. /**
  97271. * Gets the current frequency data as a float array
  97272. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97273. * @returns a Float32Array
  97274. */
  97275. getFloatFrequencyData(): Float32Array;
  97276. /**
  97277. * Renders the debug canvas
  97278. */
  97279. drawDebugCanvas(): void;
  97280. /**
  97281. * Stops rendering the debug canvas and removes it
  97282. */
  97283. stopDebugCanvas(): void;
  97284. /**
  97285. * Connects two audio nodes
  97286. * @param inputAudioNode defines first node to connect
  97287. * @param outputAudioNode defines second node to connect
  97288. */
  97289. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  97290. /**
  97291. * Releases all associated resources
  97292. */
  97293. dispose(): void;
  97294. }
  97295. }
  97296. declare module BABYLON {
  97297. /**
  97298. * This represents an audio engine and it is responsible
  97299. * to play, synchronize and analyse sounds throughout the application.
  97300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97301. */
  97302. export interface IAudioEngine extends IDisposable {
  97303. /**
  97304. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97305. */
  97306. readonly canUseWebAudio: boolean;
  97307. /**
  97308. * Gets the current AudioContext if available.
  97309. */
  97310. readonly audioContext: Nullable<AudioContext>;
  97311. /**
  97312. * The master gain node defines the global audio volume of your audio engine.
  97313. */
  97314. readonly masterGain: GainNode;
  97315. /**
  97316. * Gets whether or not mp3 are supported by your browser.
  97317. */
  97318. readonly isMP3supported: boolean;
  97319. /**
  97320. * Gets whether or not ogg are supported by your browser.
  97321. */
  97322. readonly isOGGsupported: boolean;
  97323. /**
  97324. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97325. * @ignoreNaming
  97326. */
  97327. WarnedWebAudioUnsupported: boolean;
  97328. /**
  97329. * Defines if the audio engine relies on a custom unlocked button.
  97330. * In this case, the embedded button will not be displayed.
  97331. */
  97332. useCustomUnlockedButton: boolean;
  97333. /**
  97334. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  97335. */
  97336. readonly unlocked: boolean;
  97337. /**
  97338. * Event raised when audio has been unlocked on the browser.
  97339. */
  97340. onAudioUnlockedObservable: Observable<AudioEngine>;
  97341. /**
  97342. * Event raised when audio has been locked on the browser.
  97343. */
  97344. onAudioLockedObservable: Observable<AudioEngine>;
  97345. /**
  97346. * Flags the audio engine in Locked state.
  97347. * This happens due to new browser policies preventing audio to autoplay.
  97348. */
  97349. lock(): void;
  97350. /**
  97351. * Unlocks the audio engine once a user action has been done on the dom.
  97352. * This is helpful to resume play once browser policies have been satisfied.
  97353. */
  97354. unlock(): void;
  97355. }
  97356. /**
  97357. * This represents the default audio engine used in babylon.
  97358. * It is responsible to play, synchronize and analyse sounds throughout the application.
  97359. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97360. */
  97361. export class AudioEngine implements IAudioEngine {
  97362. private _audioContext;
  97363. private _audioContextInitialized;
  97364. private _muteButton;
  97365. private _hostElement;
  97366. /**
  97367. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97368. */
  97369. canUseWebAudio: boolean;
  97370. /**
  97371. * The master gain node defines the global audio volume of your audio engine.
  97372. */
  97373. masterGain: GainNode;
  97374. /**
  97375. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97376. * @ignoreNaming
  97377. */
  97378. WarnedWebAudioUnsupported: boolean;
  97379. /**
  97380. * Gets whether or not mp3 are supported by your browser.
  97381. */
  97382. isMP3supported: boolean;
  97383. /**
  97384. * Gets whether or not ogg are supported by your browser.
  97385. */
  97386. isOGGsupported: boolean;
  97387. /**
  97388. * Gets whether audio has been unlocked on the device.
  97389. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  97390. * a user interaction has happened.
  97391. */
  97392. unlocked: boolean;
  97393. /**
  97394. * Defines if the audio engine relies on a custom unlocked button.
  97395. * In this case, the embedded button will not be displayed.
  97396. */
  97397. useCustomUnlockedButton: boolean;
  97398. /**
  97399. * Event raised when audio has been unlocked on the browser.
  97400. */
  97401. onAudioUnlockedObservable: Observable<AudioEngine>;
  97402. /**
  97403. * Event raised when audio has been locked on the browser.
  97404. */
  97405. onAudioLockedObservable: Observable<AudioEngine>;
  97406. /**
  97407. * Gets the current AudioContext if available.
  97408. */
  97409. readonly audioContext: Nullable<AudioContext>;
  97410. private _connectedAnalyser;
  97411. /**
  97412. * Instantiates a new audio engine.
  97413. *
  97414. * There should be only one per page as some browsers restrict the number
  97415. * of audio contexts you can create.
  97416. * @param hostElement defines the host element where to display the mute icon if necessary
  97417. */
  97418. constructor(hostElement?: Nullable<HTMLElement>);
  97419. /**
  97420. * Flags the audio engine in Locked state.
  97421. * This happens due to new browser policies preventing audio to autoplay.
  97422. */
  97423. lock(): void;
  97424. /**
  97425. * Unlocks the audio engine once a user action has been done on the dom.
  97426. * This is helpful to resume play once browser policies have been satisfied.
  97427. */
  97428. unlock(): void;
  97429. private _resumeAudioContext;
  97430. private _initializeAudioContext;
  97431. private _tryToRun;
  97432. private _triggerRunningState;
  97433. private _triggerSuspendedState;
  97434. private _displayMuteButton;
  97435. private _moveButtonToTopLeft;
  97436. private _onResize;
  97437. private _hideMuteButton;
  97438. /**
  97439. * Destroy and release the resources associated with the audio ccontext.
  97440. */
  97441. dispose(): void;
  97442. /**
  97443. * Gets the global volume sets on the master gain.
  97444. * @returns the global volume if set or -1 otherwise
  97445. */
  97446. getGlobalVolume(): number;
  97447. /**
  97448. * Sets the global volume of your experience (sets on the master gain).
  97449. * @param newVolume Defines the new global volume of the application
  97450. */
  97451. setGlobalVolume(newVolume: number): void;
  97452. /**
  97453. * Connect the audio engine to an audio analyser allowing some amazing
  97454. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97456. * @param analyser The analyser to connect to the engine
  97457. */
  97458. connectToAnalyser(analyser: Analyser): void;
  97459. }
  97460. }
  97461. declare module BABYLON {
  97462. /**
  97463. * Interface used to present a loading screen while loading a scene
  97464. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97465. */
  97466. export interface ILoadingScreen {
  97467. /**
  97468. * Function called to display the loading screen
  97469. */
  97470. displayLoadingUI: () => void;
  97471. /**
  97472. * Function called to hide the loading screen
  97473. */
  97474. hideLoadingUI: () => void;
  97475. /**
  97476. * Gets or sets the color to use for the background
  97477. */
  97478. loadingUIBackgroundColor: string;
  97479. /**
  97480. * Gets or sets the text to display while loading
  97481. */
  97482. loadingUIText: string;
  97483. }
  97484. /**
  97485. * Class used for the default loading screen
  97486. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97487. */
  97488. export class DefaultLoadingScreen implements ILoadingScreen {
  97489. private _renderingCanvas;
  97490. private _loadingText;
  97491. private _loadingDivBackgroundColor;
  97492. private _loadingDiv;
  97493. private _loadingTextDiv;
  97494. /** Gets or sets the logo url to use for the default loading screen */
  97495. static DefaultLogoUrl: string;
  97496. /** Gets or sets the spinner url to use for the default loading screen */
  97497. static DefaultSpinnerUrl: string;
  97498. /**
  97499. * Creates a new default loading screen
  97500. * @param _renderingCanvas defines the canvas used to render the scene
  97501. * @param _loadingText defines the default text to display
  97502. * @param _loadingDivBackgroundColor defines the default background color
  97503. */
  97504. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  97505. /**
  97506. * Function called to display the loading screen
  97507. */
  97508. displayLoadingUI(): void;
  97509. /**
  97510. * Function called to hide the loading screen
  97511. */
  97512. hideLoadingUI(): void;
  97513. /**
  97514. * Gets or sets the text to display while loading
  97515. */
  97516. loadingUIText: string;
  97517. /**
  97518. * Gets or sets the color to use for the background
  97519. */
  97520. loadingUIBackgroundColor: string;
  97521. private _resizeLoadingUI;
  97522. }
  97523. }
  97524. declare module BABYLON {
  97525. /**
  97526. * Interface for any object that can request an animation frame
  97527. */
  97528. export interface ICustomAnimationFrameRequester {
  97529. /**
  97530. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  97531. */
  97532. renderFunction?: Function;
  97533. /**
  97534. * Called to request the next frame to render to
  97535. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  97536. */
  97537. requestAnimationFrame: Function;
  97538. /**
  97539. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  97540. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  97541. */
  97542. requestID?: number;
  97543. }
  97544. }
  97545. declare module BABYLON {
  97546. /**
  97547. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  97548. */
  97549. export class PerformanceMonitor {
  97550. private _enabled;
  97551. private _rollingFrameTime;
  97552. private _lastFrameTimeMs;
  97553. /**
  97554. * constructor
  97555. * @param frameSampleSize The number of samples required to saturate the sliding window
  97556. */
  97557. constructor(frameSampleSize?: number);
  97558. /**
  97559. * Samples current frame
  97560. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  97561. */
  97562. sampleFrame(timeMs?: number): void;
  97563. /**
  97564. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97565. */
  97566. readonly averageFrameTime: number;
  97567. /**
  97568. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97569. */
  97570. readonly averageFrameTimeVariance: number;
  97571. /**
  97572. * Returns the frame time of the most recent frame
  97573. */
  97574. readonly instantaneousFrameTime: number;
  97575. /**
  97576. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  97577. */
  97578. readonly averageFPS: number;
  97579. /**
  97580. * Returns the average framerate in frames per second using the most recent frame time
  97581. */
  97582. readonly instantaneousFPS: number;
  97583. /**
  97584. * Returns true if enough samples have been taken to completely fill the sliding window
  97585. */
  97586. readonly isSaturated: boolean;
  97587. /**
  97588. * Enables contributions to the sliding window sample set
  97589. */
  97590. enable(): void;
  97591. /**
  97592. * Disables contributions to the sliding window sample set
  97593. * Samples will not be interpolated over the disabled period
  97594. */
  97595. disable(): void;
  97596. /**
  97597. * Returns true if sampling is enabled
  97598. */
  97599. readonly isEnabled: boolean;
  97600. /**
  97601. * Resets performance monitor
  97602. */
  97603. reset(): void;
  97604. }
  97605. /**
  97606. * RollingAverage
  97607. *
  97608. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  97609. */
  97610. export class RollingAverage {
  97611. /**
  97612. * Current average
  97613. */
  97614. average: number;
  97615. /**
  97616. * Current variance
  97617. */
  97618. variance: number;
  97619. protected _samples: Array<number>;
  97620. protected _sampleCount: number;
  97621. protected _pos: number;
  97622. protected _m2: number;
  97623. /**
  97624. * constructor
  97625. * @param length The number of samples required to saturate the sliding window
  97626. */
  97627. constructor(length: number);
  97628. /**
  97629. * Adds a sample to the sample set
  97630. * @param v The sample value
  97631. */
  97632. add(v: number): void;
  97633. /**
  97634. * Returns previously added values or null if outside of history or outside the sliding window domain
  97635. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  97636. * @return Value previously recorded with add() or null if outside of range
  97637. */
  97638. history(i: number): number;
  97639. /**
  97640. * Returns true if enough samples have been taken to completely fill the sliding window
  97641. * @return true if sample-set saturated
  97642. */
  97643. isSaturated(): boolean;
  97644. /**
  97645. * Resets the rolling average (equivalent to 0 samples taken so far)
  97646. */
  97647. reset(): void;
  97648. /**
  97649. * Wraps a value around the sample range boundaries
  97650. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  97651. * @return Wrapped position in sample range
  97652. */
  97653. protected _wrapPosition(i: number): number;
  97654. }
  97655. }
  97656. declare module BABYLON {
  97657. /**
  97658. * This class is used to track a performance counter which is number based.
  97659. * The user has access to many properties which give statistics of different nature.
  97660. *
  97661. * The implementer can track two kinds of Performance Counter: time and count.
  97662. * 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.
  97663. * 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.
  97664. */
  97665. export class PerfCounter {
  97666. /**
  97667. * Gets or sets a global boolean to turn on and off all the counters
  97668. */
  97669. static Enabled: boolean;
  97670. /**
  97671. * Returns the smallest value ever
  97672. */
  97673. readonly min: number;
  97674. /**
  97675. * Returns the biggest value ever
  97676. */
  97677. readonly max: number;
  97678. /**
  97679. * Returns the average value since the performance counter is running
  97680. */
  97681. readonly average: number;
  97682. /**
  97683. * Returns the average value of the last second the counter was monitored
  97684. */
  97685. readonly lastSecAverage: number;
  97686. /**
  97687. * Returns the current value
  97688. */
  97689. readonly current: number;
  97690. /**
  97691. * Gets the accumulated total
  97692. */
  97693. readonly total: number;
  97694. /**
  97695. * Gets the total value count
  97696. */
  97697. readonly count: number;
  97698. /**
  97699. * Creates a new counter
  97700. */
  97701. constructor();
  97702. /**
  97703. * Call this method to start monitoring a new frame.
  97704. * 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.
  97705. */
  97706. fetchNewFrame(): void;
  97707. /**
  97708. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  97709. * @param newCount the count value to add to the monitored count
  97710. * @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.
  97711. */
  97712. addCount(newCount: number, fetchResult: boolean): void;
  97713. /**
  97714. * Start monitoring this performance counter
  97715. */
  97716. beginMonitoring(): void;
  97717. /**
  97718. * Compute the time lapsed since the previous beginMonitoring() call.
  97719. * @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
  97720. */
  97721. endMonitoring(newFrame?: boolean): void;
  97722. private _fetchResult;
  97723. private _startMonitoringTime;
  97724. private _min;
  97725. private _max;
  97726. private _average;
  97727. private _current;
  97728. private _totalValueCount;
  97729. private _totalAccumulated;
  97730. private _lastSecAverage;
  97731. private _lastSecAccumulated;
  97732. private _lastSecTime;
  97733. private _lastSecValueCount;
  97734. }
  97735. }
  97736. declare module BABYLON {
  97737. /**
  97738. * Defines the interface used by display changed events
  97739. */
  97740. export interface IDisplayChangedEventArgs {
  97741. /** Gets the vrDisplay object (if any) */
  97742. vrDisplay: Nullable<any>;
  97743. /** Gets a boolean indicating if webVR is supported */
  97744. vrSupported: boolean;
  97745. }
  97746. /**
  97747. * Defines the interface used by objects containing a viewport (like a camera)
  97748. */
  97749. interface IViewportOwnerLike {
  97750. /**
  97751. * Gets or sets the viewport
  97752. */
  97753. viewport: IViewportLike;
  97754. }
  97755. /**
  97756. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  97757. */
  97758. export class Engine extends ThinEngine {
  97759. /** Defines that alpha blending is disabled */
  97760. static readonly ALPHA_DISABLE: number;
  97761. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  97762. static readonly ALPHA_ADD: number;
  97763. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  97764. static readonly ALPHA_COMBINE: number;
  97765. /** Defines that alpha blending to DEST - SRC * DEST */
  97766. static readonly ALPHA_SUBTRACT: number;
  97767. /** Defines that alpha blending to SRC * DEST */
  97768. static readonly ALPHA_MULTIPLY: number;
  97769. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  97770. static readonly ALPHA_MAXIMIZED: number;
  97771. /** Defines that alpha blending to SRC + DEST */
  97772. static readonly ALPHA_ONEONE: number;
  97773. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  97774. static readonly ALPHA_PREMULTIPLIED: number;
  97775. /**
  97776. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  97777. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  97778. */
  97779. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  97780. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  97781. static readonly ALPHA_INTERPOLATE: number;
  97782. /**
  97783. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  97784. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  97785. */
  97786. static readonly ALPHA_SCREENMODE: number;
  97787. /** Defines that the ressource is not delayed*/
  97788. static readonly DELAYLOADSTATE_NONE: number;
  97789. /** Defines that the ressource was successfully delay loaded */
  97790. static readonly DELAYLOADSTATE_LOADED: number;
  97791. /** Defines that the ressource is currently delay loading */
  97792. static readonly DELAYLOADSTATE_LOADING: number;
  97793. /** Defines that the ressource is delayed and has not started loading */
  97794. static readonly DELAYLOADSTATE_NOTLOADED: number;
  97795. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  97796. static readonly NEVER: number;
  97797. /** 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 */
  97798. static readonly ALWAYS: number;
  97799. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  97800. static readonly LESS: number;
  97801. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  97802. static readonly EQUAL: number;
  97803. /** 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 */
  97804. static readonly LEQUAL: number;
  97805. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  97806. static readonly GREATER: number;
  97807. /** 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 */
  97808. static readonly GEQUAL: number;
  97809. /** 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 */
  97810. static readonly NOTEQUAL: number;
  97811. /** Passed to stencilOperation to specify that stencil value must be kept */
  97812. static readonly KEEP: number;
  97813. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97814. static readonly REPLACE: number;
  97815. /** Passed to stencilOperation to specify that stencil value must be incremented */
  97816. static readonly INCR: number;
  97817. /** Passed to stencilOperation to specify that stencil value must be decremented */
  97818. static readonly DECR: number;
  97819. /** Passed to stencilOperation to specify that stencil value must be inverted */
  97820. static readonly INVERT: number;
  97821. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  97822. static readonly INCR_WRAP: number;
  97823. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  97824. static readonly DECR_WRAP: number;
  97825. /** Texture is not repeating outside of 0..1 UVs */
  97826. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  97827. /** Texture is repeating outside of 0..1 UVs */
  97828. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  97829. /** Texture is repeating and mirrored */
  97830. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  97831. /** ALPHA */
  97832. static readonly TEXTUREFORMAT_ALPHA: number;
  97833. /** LUMINANCE */
  97834. static readonly TEXTUREFORMAT_LUMINANCE: number;
  97835. /** LUMINANCE_ALPHA */
  97836. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  97837. /** RGB */
  97838. static readonly TEXTUREFORMAT_RGB: number;
  97839. /** RGBA */
  97840. static readonly TEXTUREFORMAT_RGBA: number;
  97841. /** RED */
  97842. static readonly TEXTUREFORMAT_RED: number;
  97843. /** RED (2nd reference) */
  97844. static readonly TEXTUREFORMAT_R: number;
  97845. /** RG */
  97846. static readonly TEXTUREFORMAT_RG: number;
  97847. /** RED_INTEGER */
  97848. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  97849. /** RED_INTEGER (2nd reference) */
  97850. static readonly TEXTUREFORMAT_R_INTEGER: number;
  97851. /** RG_INTEGER */
  97852. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  97853. /** RGB_INTEGER */
  97854. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  97855. /** RGBA_INTEGER */
  97856. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  97857. /** UNSIGNED_BYTE */
  97858. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  97859. /** UNSIGNED_BYTE (2nd reference) */
  97860. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  97861. /** FLOAT */
  97862. static readonly TEXTURETYPE_FLOAT: number;
  97863. /** HALF_FLOAT */
  97864. static readonly TEXTURETYPE_HALF_FLOAT: number;
  97865. /** BYTE */
  97866. static readonly TEXTURETYPE_BYTE: number;
  97867. /** SHORT */
  97868. static readonly TEXTURETYPE_SHORT: number;
  97869. /** UNSIGNED_SHORT */
  97870. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  97871. /** INT */
  97872. static readonly TEXTURETYPE_INT: number;
  97873. /** UNSIGNED_INT */
  97874. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  97875. /** UNSIGNED_SHORT_4_4_4_4 */
  97876. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  97877. /** UNSIGNED_SHORT_5_5_5_1 */
  97878. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  97879. /** UNSIGNED_SHORT_5_6_5 */
  97880. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  97881. /** UNSIGNED_INT_2_10_10_10_REV */
  97882. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  97883. /** UNSIGNED_INT_24_8 */
  97884. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  97885. /** UNSIGNED_INT_10F_11F_11F_REV */
  97886. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  97887. /** UNSIGNED_INT_5_9_9_9_REV */
  97888. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  97889. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  97890. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  97891. /** nearest is mag = nearest and min = nearest and mip = linear */
  97892. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  97893. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97894. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  97895. /** Trilinear is mag = linear and min = linear and mip = linear */
  97896. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  97897. /** nearest is mag = nearest and min = nearest and mip = linear */
  97898. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  97899. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97900. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  97901. /** Trilinear is mag = linear and min = linear and mip = linear */
  97902. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  97903. /** mag = nearest and min = nearest and mip = nearest */
  97904. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  97905. /** mag = nearest and min = linear and mip = nearest */
  97906. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  97907. /** mag = nearest and min = linear and mip = linear */
  97908. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  97909. /** mag = nearest and min = linear and mip = none */
  97910. static readonly TEXTURE_NEAREST_LINEAR: number;
  97911. /** mag = nearest and min = nearest and mip = none */
  97912. static readonly TEXTURE_NEAREST_NEAREST: number;
  97913. /** mag = linear and min = nearest and mip = nearest */
  97914. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  97915. /** mag = linear and min = nearest and mip = linear */
  97916. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  97917. /** mag = linear and min = linear and mip = none */
  97918. static readonly TEXTURE_LINEAR_LINEAR: number;
  97919. /** mag = linear and min = nearest and mip = none */
  97920. static readonly TEXTURE_LINEAR_NEAREST: number;
  97921. /** Explicit coordinates mode */
  97922. static readonly TEXTURE_EXPLICIT_MODE: number;
  97923. /** Spherical coordinates mode */
  97924. static readonly TEXTURE_SPHERICAL_MODE: number;
  97925. /** Planar coordinates mode */
  97926. static readonly TEXTURE_PLANAR_MODE: number;
  97927. /** Cubic coordinates mode */
  97928. static readonly TEXTURE_CUBIC_MODE: number;
  97929. /** Projection coordinates mode */
  97930. static readonly TEXTURE_PROJECTION_MODE: number;
  97931. /** Skybox coordinates mode */
  97932. static readonly TEXTURE_SKYBOX_MODE: number;
  97933. /** Inverse Cubic coordinates mode */
  97934. static readonly TEXTURE_INVCUBIC_MODE: number;
  97935. /** Equirectangular coordinates mode */
  97936. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  97937. /** Equirectangular Fixed coordinates mode */
  97938. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  97939. /** Equirectangular Fixed Mirrored coordinates mode */
  97940. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  97941. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  97942. static readonly SCALEMODE_FLOOR: number;
  97943. /** Defines that texture rescaling will look for the nearest power of 2 size */
  97944. static readonly SCALEMODE_NEAREST: number;
  97945. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  97946. static readonly SCALEMODE_CEILING: number;
  97947. /**
  97948. * Returns the current npm package of the sdk
  97949. */
  97950. static readonly NpmPackage: string;
  97951. /**
  97952. * Returns the current version of the framework
  97953. */
  97954. static readonly Version: string;
  97955. /** Gets the list of created engines */
  97956. static readonly Instances: Engine[];
  97957. /**
  97958. * Gets the latest created engine
  97959. */
  97960. static readonly LastCreatedEngine: Nullable<Engine>;
  97961. /**
  97962. * Gets the latest created scene
  97963. */
  97964. static readonly LastCreatedScene: Nullable<Scene>;
  97965. /**
  97966. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  97967. * @param flag defines which part of the materials must be marked as dirty
  97968. * @param predicate defines a predicate used to filter which materials should be affected
  97969. */
  97970. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  97971. /**
  97972. * Method called to create the default loading screen.
  97973. * This can be overriden in your own app.
  97974. * @param canvas The rendering canvas element
  97975. * @returns The loading screen
  97976. */
  97977. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  97978. /**
  97979. * Method called to create the default rescale post process on each engine.
  97980. */
  97981. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  97982. /**
  97983. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  97984. **/
  97985. enableOfflineSupport: boolean;
  97986. /**
  97987. * 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)
  97988. **/
  97989. disableManifestCheck: boolean;
  97990. /**
  97991. * Gets the list of created scenes
  97992. */
  97993. scenes: Scene[];
  97994. /**
  97995. * Event raised when a new scene is created
  97996. */
  97997. onNewSceneAddedObservable: Observable<Scene>;
  97998. /**
  97999. * Gets the list of created postprocesses
  98000. */
  98001. postProcesses: PostProcess[];
  98002. /**
  98003. * Gets a boolean indicating if the pointer is currently locked
  98004. */
  98005. isPointerLock: boolean;
  98006. /**
  98007. * Observable event triggered each time the rendering canvas is resized
  98008. */
  98009. onResizeObservable: Observable<Engine>;
  98010. /**
  98011. * Observable event triggered each time the canvas loses focus
  98012. */
  98013. onCanvasBlurObservable: Observable<Engine>;
  98014. /**
  98015. * Observable event triggered each time the canvas gains focus
  98016. */
  98017. onCanvasFocusObservable: Observable<Engine>;
  98018. /**
  98019. * Observable event triggered each time the canvas receives pointerout event
  98020. */
  98021. onCanvasPointerOutObservable: Observable<PointerEvent>;
  98022. /**
  98023. * Observable raised when the engine begins a new frame
  98024. */
  98025. onBeginFrameObservable: Observable<Engine>;
  98026. /**
  98027. * If set, will be used to request the next animation frame for the render loop
  98028. */
  98029. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  98030. /**
  98031. * Observable raised when the engine ends the current frame
  98032. */
  98033. onEndFrameObservable: Observable<Engine>;
  98034. /**
  98035. * Observable raised when the engine is about to compile a shader
  98036. */
  98037. onBeforeShaderCompilationObservable: Observable<Engine>;
  98038. /**
  98039. * Observable raised when the engine has jsut compiled a shader
  98040. */
  98041. onAfterShaderCompilationObservable: Observable<Engine>;
  98042. /**
  98043. * Gets the audio engine
  98044. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98045. * @ignorenaming
  98046. */
  98047. static audioEngine: IAudioEngine;
  98048. /**
  98049. * Default AudioEngine factory responsible of creating the Audio Engine.
  98050. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  98051. */
  98052. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  98053. /**
  98054. * Default offline support factory responsible of creating a tool used to store data locally.
  98055. * By default, this will create a Database object if the workload has been embedded.
  98056. */
  98057. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  98058. private _loadingScreen;
  98059. private _pointerLockRequested;
  98060. private _dummyFramebuffer;
  98061. private _rescalePostProcess;
  98062. /** @hidden */
  98063. protected _alphaMode: number;
  98064. /** @hidden */
  98065. protected _alphaEquation: number;
  98066. private _deterministicLockstep;
  98067. private _lockstepMaxSteps;
  98068. protected readonly _supportsHardwareTextureRescaling: boolean;
  98069. private _fps;
  98070. private _deltaTime;
  98071. /** @hidden */
  98072. _drawCalls: PerfCounter;
  98073. /**
  98074. * Turn this value on if you want to pause FPS computation when in background
  98075. */
  98076. disablePerformanceMonitorInBackground: boolean;
  98077. private _performanceMonitor;
  98078. /**
  98079. * Gets the performance monitor attached to this engine
  98080. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  98081. */
  98082. readonly performanceMonitor: PerformanceMonitor;
  98083. private _onFocus;
  98084. private _onBlur;
  98085. private _onCanvasPointerOut;
  98086. private _onCanvasBlur;
  98087. private _onCanvasFocus;
  98088. private _onFullscreenChange;
  98089. private _onPointerLockChange;
  98090. /**
  98091. * Creates a new engine
  98092. * @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
  98093. * @param antialias defines enable antialiasing (default: false)
  98094. * @param options defines further options to be sent to the getContext() function
  98095. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  98096. */
  98097. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  98098. /**
  98099. * Gets current aspect ratio
  98100. * @param viewportOwner defines the camera to use to get the aspect ratio
  98101. * @param useScreen defines if screen size must be used (or the current render target if any)
  98102. * @returns a number defining the aspect ratio
  98103. */
  98104. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  98105. /**
  98106. * Gets current screen aspect ratio
  98107. * @returns a number defining the aspect ratio
  98108. */
  98109. getScreenAspectRatio(): number;
  98110. /**
  98111. * Gets host document
  98112. * @returns the host document object
  98113. */
  98114. getHostDocument(): Document;
  98115. /**
  98116. * Gets the client rect of the HTML canvas attached with the current webGL context
  98117. * @returns a client rectanglee
  98118. */
  98119. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  98120. /**
  98121. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  98122. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98123. * @returns true if engine is in deterministic lock step mode
  98124. */
  98125. isDeterministicLockStep(): boolean;
  98126. /**
  98127. * Gets the max steps when engine is running in deterministic lock step
  98128. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98129. * @returns the max steps
  98130. */
  98131. getLockstepMaxSteps(): number;
  98132. /**
  98133. * Force the mipmap generation for the given render target texture
  98134. * @param texture defines the render target texture to use
  98135. */
  98136. generateMipMapsForCubemap(texture: InternalTexture): void;
  98137. /** States */
  98138. /**
  98139. * Set various states to the webGL context
  98140. * @param culling defines backface culling state
  98141. * @param zOffset defines the value to apply to zOffset (0 by default)
  98142. * @param force defines if states must be applied even if cache is up to date
  98143. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  98144. */
  98145. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98146. /**
  98147. * Set the z offset to apply to current rendering
  98148. * @param value defines the offset to apply
  98149. */
  98150. setZOffset(value: number): void;
  98151. /**
  98152. * Gets the current value of the zOffset
  98153. * @returns the current zOffset state
  98154. */
  98155. getZOffset(): number;
  98156. /**
  98157. * Enable or disable depth buffering
  98158. * @param enable defines the state to set
  98159. */
  98160. setDepthBuffer(enable: boolean): void;
  98161. /**
  98162. * Gets a boolean indicating if depth writing is enabled
  98163. * @returns the current depth writing state
  98164. */
  98165. getDepthWrite(): boolean;
  98166. /**
  98167. * Enable or disable depth writing
  98168. * @param enable defines the state to set
  98169. */
  98170. setDepthWrite(enable: boolean): void;
  98171. /**
  98172. * Enable or disable color writing
  98173. * @param enable defines the state to set
  98174. */
  98175. setColorWrite(enable: boolean): void;
  98176. /**
  98177. * Gets a boolean indicating if color writing is enabled
  98178. * @returns the current color writing state
  98179. */
  98180. getColorWrite(): boolean;
  98181. /**
  98182. * Sets alpha constants used by some alpha blending modes
  98183. * @param r defines the red component
  98184. * @param g defines the green component
  98185. * @param b defines the blue component
  98186. * @param a defines the alpha component
  98187. */
  98188. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  98189. /**
  98190. * Sets the current alpha mode
  98191. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  98192. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  98193. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98194. */
  98195. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98196. /**
  98197. * Gets the current alpha mode
  98198. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98199. * @returns the current alpha mode
  98200. */
  98201. getAlphaMode(): number;
  98202. /**
  98203. * Sets the current alpha equation
  98204. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  98205. */
  98206. setAlphaEquation(equation: number): void;
  98207. /**
  98208. * Gets the current alpha equation.
  98209. * @returns the current alpha equation
  98210. */
  98211. getAlphaEquation(): number;
  98212. /**
  98213. * Gets a boolean indicating if stencil buffer is enabled
  98214. * @returns the current stencil buffer state
  98215. */
  98216. getStencilBuffer(): boolean;
  98217. /**
  98218. * Enable or disable the stencil buffer
  98219. * @param enable defines if the stencil buffer must be enabled or disabled
  98220. */
  98221. setStencilBuffer(enable: boolean): void;
  98222. /**
  98223. * Gets the current stencil mask
  98224. * @returns a number defining the new stencil mask to use
  98225. */
  98226. getStencilMask(): number;
  98227. /**
  98228. * Sets the current stencil mask
  98229. * @param mask defines the new stencil mask to use
  98230. */
  98231. setStencilMask(mask: number): void;
  98232. /**
  98233. * Gets the current stencil function
  98234. * @returns a number defining the stencil function to use
  98235. */
  98236. getStencilFunction(): number;
  98237. /**
  98238. * Gets the current stencil reference value
  98239. * @returns a number defining the stencil reference value to use
  98240. */
  98241. getStencilFunctionReference(): number;
  98242. /**
  98243. * Gets the current stencil mask
  98244. * @returns a number defining the stencil mask to use
  98245. */
  98246. getStencilFunctionMask(): number;
  98247. /**
  98248. * Sets the current stencil function
  98249. * @param stencilFunc defines the new stencil function to use
  98250. */
  98251. setStencilFunction(stencilFunc: number): void;
  98252. /**
  98253. * Sets the current stencil reference
  98254. * @param reference defines the new stencil reference to use
  98255. */
  98256. setStencilFunctionReference(reference: number): void;
  98257. /**
  98258. * Sets the current stencil mask
  98259. * @param mask defines the new stencil mask to use
  98260. */
  98261. setStencilFunctionMask(mask: number): void;
  98262. /**
  98263. * Gets the current stencil operation when stencil fails
  98264. * @returns a number defining stencil operation to use when stencil fails
  98265. */
  98266. getStencilOperationFail(): number;
  98267. /**
  98268. * Gets the current stencil operation when depth fails
  98269. * @returns a number defining stencil operation to use when depth fails
  98270. */
  98271. getStencilOperationDepthFail(): number;
  98272. /**
  98273. * Gets the current stencil operation when stencil passes
  98274. * @returns a number defining stencil operation to use when stencil passes
  98275. */
  98276. getStencilOperationPass(): number;
  98277. /**
  98278. * Sets the stencil operation to use when stencil fails
  98279. * @param operation defines the stencil operation to use when stencil fails
  98280. */
  98281. setStencilOperationFail(operation: number): void;
  98282. /**
  98283. * Sets the stencil operation to use when depth fails
  98284. * @param operation defines the stencil operation to use when depth fails
  98285. */
  98286. setStencilOperationDepthFail(operation: number): void;
  98287. /**
  98288. * Sets the stencil operation to use when stencil passes
  98289. * @param operation defines the stencil operation to use when stencil passes
  98290. */
  98291. setStencilOperationPass(operation: number): void;
  98292. /**
  98293. * Sets a boolean indicating if the dithering state is enabled or disabled
  98294. * @param value defines the dithering state
  98295. */
  98296. setDitheringState(value: boolean): void;
  98297. /**
  98298. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  98299. * @param value defines the rasterizer state
  98300. */
  98301. setRasterizerState(value: boolean): void;
  98302. /**
  98303. * Gets the current depth function
  98304. * @returns a number defining the depth function
  98305. */
  98306. getDepthFunction(): Nullable<number>;
  98307. /**
  98308. * Sets the current depth function
  98309. * @param depthFunc defines the function to use
  98310. */
  98311. setDepthFunction(depthFunc: number): void;
  98312. /**
  98313. * Sets the current depth function to GREATER
  98314. */
  98315. setDepthFunctionToGreater(): void;
  98316. /**
  98317. * Sets the current depth function to GEQUAL
  98318. */
  98319. setDepthFunctionToGreaterOrEqual(): void;
  98320. /**
  98321. * Sets the current depth function to LESS
  98322. */
  98323. setDepthFunctionToLess(): void;
  98324. /**
  98325. * Sets the current depth function to LEQUAL
  98326. */
  98327. setDepthFunctionToLessOrEqual(): void;
  98328. private _cachedStencilBuffer;
  98329. private _cachedStencilFunction;
  98330. private _cachedStencilMask;
  98331. private _cachedStencilOperationPass;
  98332. private _cachedStencilOperationFail;
  98333. private _cachedStencilOperationDepthFail;
  98334. private _cachedStencilReference;
  98335. /**
  98336. * Caches the the state of the stencil buffer
  98337. */
  98338. cacheStencilState(): void;
  98339. /**
  98340. * Restores the state of the stencil buffer
  98341. */
  98342. restoreStencilState(): void;
  98343. /**
  98344. * Directly set the WebGL Viewport
  98345. * @param x defines the x coordinate of the viewport (in screen space)
  98346. * @param y defines the y coordinate of the viewport (in screen space)
  98347. * @param width defines the width of the viewport (in screen space)
  98348. * @param height defines the height of the viewport (in screen space)
  98349. * @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
  98350. */
  98351. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  98352. /**
  98353. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  98354. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98355. * @param y defines the y-coordinate of the corner of the clear rectangle
  98356. * @param width defines the width of the clear rectangle
  98357. * @param height defines the height of the clear rectangle
  98358. * @param clearColor defines the clear color
  98359. */
  98360. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  98361. /**
  98362. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  98363. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98364. * @param y defines the y-coordinate of the corner of the clear rectangle
  98365. * @param width defines the width of the clear rectangle
  98366. * @param height defines the height of the clear rectangle
  98367. */
  98368. enableScissor(x: number, y: number, width: number, height: number): void;
  98369. /**
  98370. * Disable previously set scissor test rectangle
  98371. */
  98372. disableScissor(): void;
  98373. protected _reportDrawCall(): void;
  98374. /**
  98375. * Initializes a webVR display and starts listening to display change events
  98376. * The onVRDisplayChangedObservable will be notified upon these changes
  98377. * @returns The onVRDisplayChangedObservable
  98378. */
  98379. initWebVR(): Observable<IDisplayChangedEventArgs>;
  98380. /** @hidden */
  98381. _prepareVRComponent(): void;
  98382. /** @hidden */
  98383. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  98384. /** @hidden */
  98385. _submitVRFrame(): void;
  98386. /**
  98387. * Call this function to leave webVR mode
  98388. * Will do nothing if webVR is not supported or if there is no webVR device
  98389. * @see http://doc.babylonjs.com/how_to/webvr_camera
  98390. */
  98391. disableVR(): void;
  98392. /**
  98393. * Gets a boolean indicating that the system is in VR mode and is presenting
  98394. * @returns true if VR mode is engaged
  98395. */
  98396. isVRPresenting(): boolean;
  98397. /** @hidden */
  98398. _requestVRFrame(): void;
  98399. /** @hidden */
  98400. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98401. /**
  98402. * Gets the source code of the vertex shader associated with a specific webGL program
  98403. * @param program defines the program to use
  98404. * @returns a string containing the source code of the vertex shader associated with the program
  98405. */
  98406. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  98407. /**
  98408. * Gets the source code of the fragment shader associated with a specific webGL program
  98409. * @param program defines the program to use
  98410. * @returns a string containing the source code of the fragment shader associated with the program
  98411. */
  98412. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  98413. /**
  98414. * Reads pixels from the current frame buffer. Please note that this function can be slow
  98415. * @param x defines the x coordinate of the rectangle where pixels must be read
  98416. * @param y defines the y coordinate of the rectangle where pixels must be read
  98417. * @param width defines the width of the rectangle where pixels must be read
  98418. * @param height defines the height of the rectangle where pixels must be read
  98419. * @returns a Uint8Array containing RGBA colors
  98420. */
  98421. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  98422. /**
  98423. * Sets a depth stencil texture from a render target to the according uniform.
  98424. * @param channel The texture channel
  98425. * @param uniform The uniform to set
  98426. * @param texture The render target texture containing the depth stencil texture to apply
  98427. */
  98428. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  98429. /**
  98430. * Sets a texture to the webGL context from a postprocess
  98431. * @param channel defines the channel to use
  98432. * @param postProcess defines the source postprocess
  98433. */
  98434. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  98435. /**
  98436. * Binds the output of the passed in post process to the texture channel specified
  98437. * @param channel The channel the texture should be bound to
  98438. * @param postProcess The post process which's output should be bound
  98439. */
  98440. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  98441. /** @hidden */
  98442. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  98443. protected _rebuildBuffers(): void;
  98444. _renderLoop(): void;
  98445. /**
  98446. * Toggle full screen mode
  98447. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98448. */
  98449. switchFullscreen(requestPointerLock: boolean): void;
  98450. /**
  98451. * Enters full screen mode
  98452. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98453. */
  98454. enterFullscreen(requestPointerLock: boolean): void;
  98455. /**
  98456. * Exits full screen mode
  98457. */
  98458. exitFullscreen(): void;
  98459. /**
  98460. * Enters Pointerlock mode
  98461. */
  98462. enterPointerlock(): void;
  98463. /**
  98464. * Exits Pointerlock mode
  98465. */
  98466. exitPointerlock(): void;
  98467. /**
  98468. * Begin a new frame
  98469. */
  98470. beginFrame(): void;
  98471. /**
  98472. * Enf the current frame
  98473. */
  98474. endFrame(): void;
  98475. resize(): void;
  98476. /**
  98477. * Set the compressed texture format to use, based on the formats you have, and the formats
  98478. * supported by the hardware / browser.
  98479. *
  98480. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  98481. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  98482. * to API arguments needed to compressed textures. This puts the burden on the container
  98483. * generator to house the arcane code for determining these for current & future formats.
  98484. *
  98485. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  98486. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  98487. *
  98488. * Note: The result of this call is not taken into account when a texture is base64.
  98489. *
  98490. * @param formatsAvailable defines the list of those format families you have created
  98491. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  98492. *
  98493. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  98494. * @returns The extension selected.
  98495. */
  98496. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  98497. /**
  98498. * Force a specific size of the canvas
  98499. * @param width defines the new canvas' width
  98500. * @param height defines the new canvas' height
  98501. */
  98502. setSize(width: number, height: number): void;
  98503. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98504. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98505. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98506. _releaseTexture(texture: InternalTexture): void;
  98507. /**
  98508. * @hidden
  98509. * Rescales a texture
  98510. * @param source input texutre
  98511. * @param destination destination texture
  98512. * @param scene scene to use to render the resize
  98513. * @param internalFormat format to use when resizing
  98514. * @param onComplete callback to be called when resize has completed
  98515. */
  98516. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98517. /**
  98518. * Gets the current framerate
  98519. * @returns a number representing the framerate
  98520. */
  98521. getFps(): number;
  98522. /**
  98523. * Gets the time spent between current and previous frame
  98524. * @returns a number representing the delta time in ms
  98525. */
  98526. getDeltaTime(): number;
  98527. private _measureFps;
  98528. /**
  98529. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  98530. * @param renderTarget The render target to set the frame buffer for
  98531. */
  98532. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  98533. /**
  98534. * Update a dynamic index buffer
  98535. * @param indexBuffer defines the target index buffer
  98536. * @param indices defines the data to update
  98537. * @param offset defines the offset in the target index buffer where update should start
  98538. */
  98539. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  98540. /**
  98541. * Updates the sample count of a render target texture
  98542. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  98543. * @param texture defines the texture to update
  98544. * @param samples defines the sample count to set
  98545. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  98546. */
  98547. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  98548. /** @hidden */
  98549. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  98550. dispose(): void;
  98551. private _disableTouchAction;
  98552. /**
  98553. * Display the loading screen
  98554. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98555. */
  98556. displayLoadingUI(): void;
  98557. /**
  98558. * Hide the loading screen
  98559. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98560. */
  98561. hideLoadingUI(): void;
  98562. /**
  98563. * Gets the current loading screen object
  98564. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98565. */
  98566. /**
  98567. * Sets the current loading screen object
  98568. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98569. */
  98570. loadingScreen: ILoadingScreen;
  98571. /**
  98572. * Sets the current loading screen text
  98573. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98574. */
  98575. loadingUIText: string;
  98576. /**
  98577. * Sets the current loading screen background color
  98578. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98579. */
  98580. loadingUIBackgroundColor: string;
  98581. /** Pointerlock and fullscreen */
  98582. /**
  98583. * Ask the browser to promote the current element to pointerlock mode
  98584. * @param element defines the DOM element to promote
  98585. */
  98586. static _RequestPointerlock(element: HTMLElement): void;
  98587. /**
  98588. * Asks the browser to exit pointerlock mode
  98589. */
  98590. static _ExitPointerlock(): void;
  98591. /**
  98592. * Ask the browser to promote the current element to fullscreen rendering mode
  98593. * @param element defines the DOM element to promote
  98594. */
  98595. static _RequestFullscreen(element: HTMLElement): void;
  98596. /**
  98597. * Asks the browser to exit fullscreen mode
  98598. */
  98599. static _ExitFullscreen(): void;
  98600. }
  98601. }
  98602. declare module BABYLON {
  98603. /**
  98604. * The engine store class is responsible to hold all the instances of Engine and Scene created
  98605. * during the life time of the application.
  98606. */
  98607. export class EngineStore {
  98608. /** Gets the list of created engines */
  98609. static Instances: Engine[];
  98610. /** @hidden */
  98611. static _LastCreatedScene: Nullable<Scene>;
  98612. /**
  98613. * Gets the latest created engine
  98614. */
  98615. static readonly LastCreatedEngine: Nullable<Engine>;
  98616. /**
  98617. * Gets the latest created scene
  98618. */
  98619. static readonly LastCreatedScene: Nullable<Scene>;
  98620. /**
  98621. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98622. * @ignorenaming
  98623. */
  98624. static UseFallbackTexture: boolean;
  98625. /**
  98626. * Texture content used if a texture cannot loaded
  98627. * @ignorenaming
  98628. */
  98629. static FallbackTexture: string;
  98630. }
  98631. }
  98632. declare module BABYLON {
  98633. /**
  98634. * Helper class that provides a small promise polyfill
  98635. */
  98636. export class PromisePolyfill {
  98637. /**
  98638. * Static function used to check if the polyfill is required
  98639. * If this is the case then the function will inject the polyfill to window.Promise
  98640. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  98641. */
  98642. static Apply(force?: boolean): void;
  98643. }
  98644. }
  98645. declare module BABYLON {
  98646. /**
  98647. * Interface for screenshot methods with describe argument called `size` as object with options
  98648. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  98649. */
  98650. export interface IScreenshotSize {
  98651. /**
  98652. * number in pixels for canvas height
  98653. */
  98654. height?: number;
  98655. /**
  98656. * multiplier allowing render at a higher or lower resolution
  98657. * If value is defined then height and width will be ignored and taken from camera
  98658. */
  98659. precision?: number;
  98660. /**
  98661. * number in pixels for canvas width
  98662. */
  98663. width?: number;
  98664. }
  98665. }
  98666. declare module BABYLON {
  98667. interface IColor4Like {
  98668. r: float;
  98669. g: float;
  98670. b: float;
  98671. a: float;
  98672. }
  98673. /**
  98674. * Class containing a set of static utilities functions
  98675. */
  98676. export class Tools {
  98677. /**
  98678. * Gets or sets the base URL to use to load assets
  98679. */
  98680. static BaseUrl: string;
  98681. /**
  98682. * Enable/Disable Custom HTTP Request Headers globally.
  98683. * default = false
  98684. * @see CustomRequestHeaders
  98685. */
  98686. static UseCustomRequestHeaders: boolean;
  98687. /**
  98688. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  98689. * i.e. when loading files, where the server/service expects an Authorization header
  98690. */
  98691. static CustomRequestHeaders: {
  98692. [key: string]: string;
  98693. };
  98694. /**
  98695. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  98696. */
  98697. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  98698. /**
  98699. * Default behaviour for cors in the application.
  98700. * It can be a string if the expected behavior is identical in the entire app.
  98701. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  98702. */
  98703. static CorsBehavior: string | ((url: string | string[]) => string);
  98704. /**
  98705. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98706. * @ignorenaming
  98707. */
  98708. static UseFallbackTexture: boolean;
  98709. /**
  98710. * Use this object to register external classes like custom textures or material
  98711. * to allow the laoders to instantiate them
  98712. */
  98713. static RegisteredExternalClasses: {
  98714. [key: string]: Object;
  98715. };
  98716. /**
  98717. * Texture content used if a texture cannot loaded
  98718. * @ignorenaming
  98719. */
  98720. static fallbackTexture: string;
  98721. /**
  98722. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  98723. * @param u defines the coordinate on X axis
  98724. * @param v defines the coordinate on Y axis
  98725. * @param width defines the width of the source data
  98726. * @param height defines the height of the source data
  98727. * @param pixels defines the source byte array
  98728. * @param color defines the output color
  98729. */
  98730. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  98731. /**
  98732. * Interpolates between a and b via alpha
  98733. * @param a The lower value (returned when alpha = 0)
  98734. * @param b The upper value (returned when alpha = 1)
  98735. * @param alpha The interpolation-factor
  98736. * @return The mixed value
  98737. */
  98738. static Mix(a: number, b: number, alpha: number): number;
  98739. /**
  98740. * Tries to instantiate a new object from a given class name
  98741. * @param className defines the class name to instantiate
  98742. * @returns the new object or null if the system was not able to do the instantiation
  98743. */
  98744. static Instantiate(className: string): any;
  98745. /**
  98746. * Provides a slice function that will work even on IE
  98747. * @param data defines the array to slice
  98748. * @param start defines the start of the data (optional)
  98749. * @param end defines the end of the data (optional)
  98750. * @returns the new sliced array
  98751. */
  98752. static Slice<T>(data: T, start?: number, end?: number): T;
  98753. /**
  98754. * Polyfill for setImmediate
  98755. * @param action defines the action to execute after the current execution block
  98756. */
  98757. static SetImmediate(action: () => void): void;
  98758. /**
  98759. * Function indicating if a number is an exponent of 2
  98760. * @param value defines the value to test
  98761. * @returns true if the value is an exponent of 2
  98762. */
  98763. static IsExponentOfTwo(value: number): boolean;
  98764. private static _tmpFloatArray;
  98765. /**
  98766. * Returns the nearest 32-bit single precision float representation of a Number
  98767. * @param value A Number. If the parameter is of a different type, it will get converted
  98768. * to a number or to NaN if it cannot be converted
  98769. * @returns number
  98770. */
  98771. static FloatRound(value: number): number;
  98772. /**
  98773. * Extracts the filename from a path
  98774. * @param path defines the path to use
  98775. * @returns the filename
  98776. */
  98777. static GetFilename(path: string): string;
  98778. /**
  98779. * Extracts the "folder" part of a path (everything before the filename).
  98780. * @param uri The URI to extract the info from
  98781. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  98782. * @returns The "folder" part of the path
  98783. */
  98784. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  98785. /**
  98786. * Extracts text content from a DOM element hierarchy
  98787. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  98788. */
  98789. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  98790. /**
  98791. * Convert an angle in radians to degrees
  98792. * @param angle defines the angle to convert
  98793. * @returns the angle in degrees
  98794. */
  98795. static ToDegrees(angle: number): number;
  98796. /**
  98797. * Convert an angle in degrees to radians
  98798. * @param angle defines the angle to convert
  98799. * @returns the angle in radians
  98800. */
  98801. static ToRadians(angle: number): number;
  98802. /**
  98803. * Encode a buffer to a base64 string
  98804. * @param buffer defines the buffer to encode
  98805. * @returns the encoded string
  98806. */
  98807. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  98808. /**
  98809. * Returns an array if obj is not an array
  98810. * @param obj defines the object to evaluate as an array
  98811. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  98812. * @returns either obj directly if obj is an array or a new array containing obj
  98813. */
  98814. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  98815. /**
  98816. * Gets the pointer prefix to use
  98817. * @returns "pointer" if touch is enabled. Else returns "mouse"
  98818. */
  98819. static GetPointerPrefix(): string;
  98820. /**
  98821. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  98822. * @param url define the url we are trying
  98823. * @param element define the dom element where to configure the cors policy
  98824. */
  98825. static SetCorsBehavior(url: string | string[], element: {
  98826. crossOrigin: string | null;
  98827. }): void;
  98828. /**
  98829. * Removes unwanted characters from an url
  98830. * @param url defines the url to clean
  98831. * @returns the cleaned url
  98832. */
  98833. static CleanUrl(url: string): string;
  98834. /**
  98835. * Gets or sets a function used to pre-process url before using them to load assets
  98836. */
  98837. static PreprocessUrl: (url: string) => string;
  98838. /**
  98839. * Loads an image as an HTMLImageElement.
  98840. * @param input url string, ArrayBuffer, or Blob to load
  98841. * @param onLoad callback called when the image successfully loads
  98842. * @param onError callback called when the image fails to load
  98843. * @param offlineProvider offline provider for caching
  98844. * @returns the HTMLImageElement of the loaded image
  98845. */
  98846. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  98847. /**
  98848. * Loads a file
  98849. * @param url url string, ArrayBuffer, or Blob to load
  98850. * @param onSuccess callback called when the file successfully loads
  98851. * @param onProgress callback called while file is loading (if the server supports this mode)
  98852. * @param offlineProvider defines the offline provider for caching
  98853. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  98854. * @param onError callback called when the file fails to load
  98855. * @returns a file request object
  98856. */
  98857. 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;
  98858. /**
  98859. * Loads a file from a url
  98860. * @param url the file url to load
  98861. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  98862. */
  98863. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  98864. /**
  98865. * Load a script (identified by an url). When the url returns, the
  98866. * content of this file is added into a new script element, attached to the DOM (body element)
  98867. * @param scriptUrl defines the url of the script to laod
  98868. * @param onSuccess defines the callback called when the script is loaded
  98869. * @param onError defines the callback to call if an error occurs
  98870. * @param scriptId defines the id of the script element
  98871. */
  98872. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  98873. /**
  98874. * Load an asynchronous script (identified by an url). When the url returns, the
  98875. * content of this file is added into a new script element, attached to the DOM (body element)
  98876. * @param scriptUrl defines the url of the script to laod
  98877. * @param scriptId defines the id of the script element
  98878. * @returns a promise request object
  98879. */
  98880. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  98881. /**
  98882. * Loads a file from a blob
  98883. * @param fileToLoad defines the blob to use
  98884. * @param callback defines the callback to call when data is loaded
  98885. * @param progressCallback defines the callback to call during loading process
  98886. * @returns a file request object
  98887. */
  98888. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  98889. /**
  98890. * Loads a file
  98891. * @param fileToLoad defines the file to load
  98892. * @param callback defines the callback to call when data is loaded
  98893. * @param progressCallBack defines the callback to call during loading process
  98894. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  98895. * @returns a file request object
  98896. */
  98897. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  98898. /**
  98899. * Creates a data url from a given string content
  98900. * @param content defines the content to convert
  98901. * @returns the new data url link
  98902. */
  98903. static FileAsURL(content: string): string;
  98904. /**
  98905. * Format the given number to a specific decimal format
  98906. * @param value defines the number to format
  98907. * @param decimals defines the number of decimals to use
  98908. * @returns the formatted string
  98909. */
  98910. static Format(value: number, decimals?: number): string;
  98911. /**
  98912. * Tries to copy an object by duplicating every property
  98913. * @param source defines the source object
  98914. * @param destination defines the target object
  98915. * @param doNotCopyList defines a list of properties to avoid
  98916. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98917. */
  98918. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  98919. /**
  98920. * Gets a boolean indicating if the given object has no own property
  98921. * @param obj defines the object to test
  98922. * @returns true if object has no own property
  98923. */
  98924. static IsEmpty(obj: any): boolean;
  98925. /**
  98926. * Function used to register events at window level
  98927. * @param windowElement defines the Window object to use
  98928. * @param events defines the events to register
  98929. */
  98930. static RegisterTopRootEvents(windowElement: Window, events: {
  98931. name: string;
  98932. handler: Nullable<(e: FocusEvent) => any>;
  98933. }[]): void;
  98934. /**
  98935. * Function used to unregister events from window level
  98936. * @param windowElement defines the Window object to use
  98937. * @param events defines the events to unregister
  98938. */
  98939. static UnregisterTopRootEvents(windowElement: Window, events: {
  98940. name: string;
  98941. handler: Nullable<(e: FocusEvent) => any>;
  98942. }[]): void;
  98943. /**
  98944. * @ignore
  98945. */
  98946. static _ScreenshotCanvas: HTMLCanvasElement;
  98947. /**
  98948. * Dumps the current bound framebuffer
  98949. * @param width defines the rendering width
  98950. * @param height defines the rendering height
  98951. * @param engine defines the hosting engine
  98952. * @param successCallback defines the callback triggered once the data are available
  98953. * @param mimeType defines the mime type of the result
  98954. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  98955. */
  98956. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98957. /**
  98958. * Converts the canvas data to blob.
  98959. * This acts as a polyfill for browsers not supporting the to blob function.
  98960. * @param canvas Defines the canvas to extract the data from
  98961. * @param successCallback Defines the callback triggered once the data are available
  98962. * @param mimeType Defines the mime type of the result
  98963. */
  98964. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  98965. /**
  98966. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  98967. * @param successCallback defines the callback triggered once the data are available
  98968. * @param mimeType defines the mime type of the result
  98969. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  98970. */
  98971. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98972. /**
  98973. * Downloads a blob in the browser
  98974. * @param blob defines the blob to download
  98975. * @param fileName defines the name of the downloaded file
  98976. */
  98977. static Download(blob: Blob, fileName: string): void;
  98978. /**
  98979. * Captures a screenshot of the current rendering
  98980. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98981. * @param engine defines the rendering engine
  98982. * @param camera defines the source camera
  98983. * @param size This parameter can be set to a single number or to an object with the
  98984. * following (optional) properties: precision, width, height. If a single number is passed,
  98985. * it will be used for both width and height. If an object is passed, the screenshot size
  98986. * will be derived from the parameters. The precision property is a multiplier allowing
  98987. * rendering at a higher or lower resolution
  98988. * @param successCallback defines the callback receives a single parameter which contains the
  98989. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98990. * src parameter of an <img> to display it
  98991. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98992. * Check your browser for supported MIME types
  98993. */
  98994. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  98995. /**
  98996. * Captures a screenshot of the current rendering
  98997. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98998. * @param engine defines the rendering engine
  98999. * @param camera defines the source camera
  99000. * @param size This parameter can be set to a single number or to an object with the
  99001. * following (optional) properties: precision, width, height. If a single number is passed,
  99002. * it will be used for both width and height. If an object is passed, the screenshot size
  99003. * will be derived from the parameters. The precision property is a multiplier allowing
  99004. * rendering at a higher or lower resolution
  99005. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99006. * Check your browser for supported MIME types
  99007. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99008. * to the src parameter of an <img> to display it
  99009. */
  99010. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  99011. /**
  99012. * Generates an image screenshot from the specified camera.
  99013. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99014. * @param engine The engine to use for rendering
  99015. * @param camera The camera to use for rendering
  99016. * @param size This parameter can be set to a single number or to an object with the
  99017. * following (optional) properties: precision, width, height. If a single number is passed,
  99018. * it will be used for both width and height. If an object is passed, the screenshot size
  99019. * will be derived from the parameters. The precision property is a multiplier allowing
  99020. * rendering at a higher or lower resolution
  99021. * @param successCallback The callback receives a single parameter which contains the
  99022. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99023. * src parameter of an <img> to display it
  99024. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99025. * Check your browser for supported MIME types
  99026. * @param samples Texture samples (default: 1)
  99027. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99028. * @param fileName A name for for the downloaded file.
  99029. */
  99030. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  99031. /**
  99032. * Generates an image screenshot from the specified camera.
  99033. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99034. * @param engine The engine to use for rendering
  99035. * @param camera The camera to use for rendering
  99036. * @param size This parameter can be set to a single number or to an object with the
  99037. * following (optional) properties: precision, width, height. If a single number is passed,
  99038. * it will be used for both width and height. If an object is passed, the screenshot size
  99039. * will be derived from the parameters. The precision property is a multiplier allowing
  99040. * rendering at a higher or lower resolution
  99041. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99042. * Check your browser for supported MIME types
  99043. * @param samples Texture samples (default: 1)
  99044. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99045. * @param fileName A name for for the downloaded file.
  99046. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99047. * to the src parameter of an <img> to display it
  99048. */
  99049. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  99050. /**
  99051. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99052. * Be aware Math.random() could cause collisions, but:
  99053. * "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"
  99054. * @returns a pseudo random id
  99055. */
  99056. static RandomId(): string;
  99057. /**
  99058. * Test if the given uri is a base64 string
  99059. * @param uri The uri to test
  99060. * @return True if the uri is a base64 string or false otherwise
  99061. */
  99062. static IsBase64(uri: string): boolean;
  99063. /**
  99064. * Decode the given base64 uri.
  99065. * @param uri The uri to decode
  99066. * @return The decoded base64 data.
  99067. */
  99068. static DecodeBase64(uri: string): ArrayBuffer;
  99069. /**
  99070. * Gets the absolute url.
  99071. * @param url the input url
  99072. * @return the absolute url
  99073. */
  99074. static GetAbsoluteUrl(url: string): string;
  99075. /**
  99076. * No log
  99077. */
  99078. static readonly NoneLogLevel: number;
  99079. /**
  99080. * Only message logs
  99081. */
  99082. static readonly MessageLogLevel: number;
  99083. /**
  99084. * Only warning logs
  99085. */
  99086. static readonly WarningLogLevel: number;
  99087. /**
  99088. * Only error logs
  99089. */
  99090. static readonly ErrorLogLevel: number;
  99091. /**
  99092. * All logs
  99093. */
  99094. static readonly AllLogLevel: number;
  99095. /**
  99096. * Gets a value indicating the number of loading errors
  99097. * @ignorenaming
  99098. */
  99099. static readonly errorsCount: number;
  99100. /**
  99101. * Callback called when a new log is added
  99102. */
  99103. static OnNewCacheEntry: (entry: string) => void;
  99104. /**
  99105. * Log a message to the console
  99106. * @param message defines the message to log
  99107. */
  99108. static Log(message: string): void;
  99109. /**
  99110. * Write a warning message to the console
  99111. * @param message defines the message to log
  99112. */
  99113. static Warn(message: string): void;
  99114. /**
  99115. * Write an error message to the console
  99116. * @param message defines the message to log
  99117. */
  99118. static Error(message: string): void;
  99119. /**
  99120. * Gets current log cache (list of logs)
  99121. */
  99122. static readonly LogCache: string;
  99123. /**
  99124. * Clears the log cache
  99125. */
  99126. static ClearLogCache(): void;
  99127. /**
  99128. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99129. */
  99130. static LogLevels: number;
  99131. /**
  99132. * Checks if the window object exists
  99133. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99134. */
  99135. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  99136. /**
  99137. * No performance log
  99138. */
  99139. static readonly PerformanceNoneLogLevel: number;
  99140. /**
  99141. * Use user marks to log performance
  99142. */
  99143. static readonly PerformanceUserMarkLogLevel: number;
  99144. /**
  99145. * Log performance to the console
  99146. */
  99147. static readonly PerformanceConsoleLogLevel: number;
  99148. private static _performance;
  99149. /**
  99150. * Sets the current performance log level
  99151. */
  99152. static PerformanceLogLevel: number;
  99153. private static _StartPerformanceCounterDisabled;
  99154. private static _EndPerformanceCounterDisabled;
  99155. private static _StartUserMark;
  99156. private static _EndUserMark;
  99157. private static _StartPerformanceConsole;
  99158. private static _EndPerformanceConsole;
  99159. /**
  99160. * Starts a performance counter
  99161. */
  99162. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99163. /**
  99164. * Ends a specific performance coutner
  99165. */
  99166. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99167. /**
  99168. * Gets either window.performance.now() if supported or Date.now() else
  99169. */
  99170. static readonly Now: number;
  99171. /**
  99172. * This method will return the name of the class used to create the instance of the given object.
  99173. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99174. * @param object the object to get the class name from
  99175. * @param isType defines if the object is actually a type
  99176. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99177. */
  99178. static GetClassName(object: any, isType?: boolean): string;
  99179. /**
  99180. * Gets the first element of an array satisfying a given predicate
  99181. * @param array defines the array to browse
  99182. * @param predicate defines the predicate to use
  99183. * @returns null if not found or the element
  99184. */
  99185. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  99186. /**
  99187. * This method will return the name of the full name of the class, including its owning module (if any).
  99188. * 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).
  99189. * @param object the object to get the class name from
  99190. * @param isType defines if the object is actually a type
  99191. * @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.
  99192. * @ignorenaming
  99193. */
  99194. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  99195. /**
  99196. * Returns a promise that resolves after the given amount of time.
  99197. * @param delay Number of milliseconds to delay
  99198. * @returns Promise that resolves after the given amount of time
  99199. */
  99200. static DelayAsync(delay: number): Promise<void>;
  99201. }
  99202. /**
  99203. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99204. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99205. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99206. * @param name The name of the class, case should be preserved
  99207. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99208. */
  99209. export function className(name: string, module?: string): (target: Object) => void;
  99210. /**
  99211. * An implementation of a loop for asynchronous functions.
  99212. */
  99213. export class AsyncLoop {
  99214. /**
  99215. * Defines the number of iterations for the loop
  99216. */
  99217. iterations: number;
  99218. /**
  99219. * Defines the current index of the loop.
  99220. */
  99221. index: number;
  99222. private _done;
  99223. private _fn;
  99224. private _successCallback;
  99225. /**
  99226. * Constructor.
  99227. * @param iterations the number of iterations.
  99228. * @param func the function to run each iteration
  99229. * @param successCallback the callback that will be called upon succesful execution
  99230. * @param offset starting offset.
  99231. */
  99232. constructor(
  99233. /**
  99234. * Defines the number of iterations for the loop
  99235. */
  99236. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  99237. /**
  99238. * Execute the next iteration. Must be called after the last iteration was finished.
  99239. */
  99240. executeNext(): void;
  99241. /**
  99242. * Break the loop and run the success callback.
  99243. */
  99244. breakLoop(): void;
  99245. /**
  99246. * Create and run an async loop.
  99247. * @param iterations the number of iterations.
  99248. * @param fn the function to run each iteration
  99249. * @param successCallback the callback that will be called upon succesful execution
  99250. * @param offset starting offset.
  99251. * @returns the created async loop object
  99252. */
  99253. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  99254. /**
  99255. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99256. * @param iterations total number of iterations
  99257. * @param syncedIterations number of synchronous iterations in each async iteration.
  99258. * @param fn the function to call each iteration.
  99259. * @param callback a success call back that will be called when iterating stops.
  99260. * @param breakFunction a break condition (optional)
  99261. * @param timeout timeout settings for the setTimeout function. default - 0.
  99262. * @returns the created async loop object
  99263. */
  99264. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  99265. }
  99266. }
  99267. declare module BABYLON {
  99268. /**
  99269. * This class implement a typical dictionary using a string as key and the generic type T as value.
  99270. * The underlying implementation relies on an associative array to ensure the best performances.
  99271. * The value can be anything including 'null' but except 'undefined'
  99272. */
  99273. export class StringDictionary<T> {
  99274. /**
  99275. * This will clear this dictionary and copy the content from the 'source' one.
  99276. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  99277. * @param source the dictionary to take the content from and copy to this dictionary
  99278. */
  99279. copyFrom(source: StringDictionary<T>): void;
  99280. /**
  99281. * Get a value based from its key
  99282. * @param key the given key to get the matching value from
  99283. * @return the value if found, otherwise undefined is returned
  99284. */
  99285. get(key: string): T | undefined;
  99286. /**
  99287. * Get a value from its key or add it if it doesn't exist.
  99288. * This method will ensure you that a given key/data will be present in the dictionary.
  99289. * @param key the given key to get the matching value from
  99290. * @param factory the factory that will create the value if the key is not present in the dictionary.
  99291. * The factory will only be invoked if there's no data for the given key.
  99292. * @return the value corresponding to the key.
  99293. */
  99294. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  99295. /**
  99296. * Get a value from its key if present in the dictionary otherwise add it
  99297. * @param key the key to get the value from
  99298. * @param val if there's no such key/value pair in the dictionary add it with this value
  99299. * @return the value corresponding to the key
  99300. */
  99301. getOrAdd(key: string, val: T): T;
  99302. /**
  99303. * Check if there's a given key in the dictionary
  99304. * @param key the key to check for
  99305. * @return true if the key is present, false otherwise
  99306. */
  99307. contains(key: string): boolean;
  99308. /**
  99309. * Add a new key and its corresponding value
  99310. * @param key the key to add
  99311. * @param value the value corresponding to the key
  99312. * @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
  99313. */
  99314. add(key: string, value: T): boolean;
  99315. /**
  99316. * Update a specific value associated to a key
  99317. * @param key defines the key to use
  99318. * @param value defines the value to store
  99319. * @returns true if the value was updated (or false if the key was not found)
  99320. */
  99321. set(key: string, value: T): boolean;
  99322. /**
  99323. * Get the element of the given key and remove it from the dictionary
  99324. * @param key defines the key to search
  99325. * @returns the value associated with the key or null if not found
  99326. */
  99327. getAndRemove(key: string): Nullable<T>;
  99328. /**
  99329. * Remove a key/value from the dictionary.
  99330. * @param key the key to remove
  99331. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  99332. */
  99333. remove(key: string): boolean;
  99334. /**
  99335. * Clear the whole content of the dictionary
  99336. */
  99337. clear(): void;
  99338. /**
  99339. * Gets the current count
  99340. */
  99341. readonly count: number;
  99342. /**
  99343. * Execute a callback on each key/val of the dictionary.
  99344. * Note that you can remove any element in this dictionary in the callback implementation
  99345. * @param callback the callback to execute on a given key/value pair
  99346. */
  99347. forEach(callback: (key: string, val: T) => void): void;
  99348. /**
  99349. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  99350. * If the callback returns null or undefined the method will iterate to the next key/value pair
  99351. * Note that you can remove any element in this dictionary in the callback implementation
  99352. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  99353. * @returns the first item
  99354. */
  99355. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  99356. private _count;
  99357. private _data;
  99358. }
  99359. }
  99360. declare module BABYLON {
  99361. /** @hidden */
  99362. export interface ICollisionCoordinator {
  99363. createCollider(): Collider;
  99364. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99365. init(scene: Scene): void;
  99366. }
  99367. /** @hidden */
  99368. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  99369. private _scene;
  99370. private _scaledPosition;
  99371. private _scaledVelocity;
  99372. private _finalPosition;
  99373. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99374. createCollider(): Collider;
  99375. init(scene: Scene): void;
  99376. private _collideWithWorld;
  99377. }
  99378. }
  99379. declare module BABYLON {
  99380. /**
  99381. * Class used to manage all inputs for the scene.
  99382. */
  99383. export class InputManager {
  99384. /** The distance in pixel that you have to move to prevent some events */
  99385. static DragMovementThreshold: number;
  99386. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  99387. static LongPressDelay: number;
  99388. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  99389. static DoubleClickDelay: number;
  99390. /** If you need to check double click without raising a single click at first click, enable this flag */
  99391. static ExclusiveDoubleClickMode: boolean;
  99392. private _wheelEventName;
  99393. private _onPointerMove;
  99394. private _onPointerDown;
  99395. private _onPointerUp;
  99396. private _initClickEvent;
  99397. private _initActionManager;
  99398. private _delayedSimpleClick;
  99399. private _delayedSimpleClickTimeout;
  99400. private _previousDelayedSimpleClickTimeout;
  99401. private _meshPickProceed;
  99402. private _previousButtonPressed;
  99403. private _currentPickResult;
  99404. private _previousPickResult;
  99405. private _totalPointersPressed;
  99406. private _doubleClickOccured;
  99407. private _pointerOverMesh;
  99408. private _pickedDownMesh;
  99409. private _pickedUpMesh;
  99410. private _pointerX;
  99411. private _pointerY;
  99412. private _unTranslatedPointerX;
  99413. private _unTranslatedPointerY;
  99414. private _startingPointerPosition;
  99415. private _previousStartingPointerPosition;
  99416. private _startingPointerTime;
  99417. private _previousStartingPointerTime;
  99418. private _pointerCaptures;
  99419. private _onKeyDown;
  99420. private _onKeyUp;
  99421. private _onCanvasFocusObserver;
  99422. private _onCanvasBlurObserver;
  99423. private _scene;
  99424. /**
  99425. * Creates a new InputManager
  99426. * @param scene defines the hosting scene
  99427. */
  99428. constructor(scene: Scene);
  99429. /**
  99430. * Gets the mesh that is currently under the pointer
  99431. */
  99432. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99433. /**
  99434. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  99435. */
  99436. readonly unTranslatedPointer: Vector2;
  99437. /**
  99438. * Gets or sets the current on-screen X position of the pointer
  99439. */
  99440. pointerX: number;
  99441. /**
  99442. * Gets or sets the current on-screen Y position of the pointer
  99443. */
  99444. pointerY: number;
  99445. private _updatePointerPosition;
  99446. private _processPointerMove;
  99447. private _setRayOnPointerInfo;
  99448. private _checkPrePointerObservable;
  99449. /**
  99450. * Use this method to simulate a pointer move on a mesh
  99451. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99452. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99453. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99454. */
  99455. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99456. /**
  99457. * Use this method to simulate a pointer down on a mesh
  99458. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99459. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99460. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99461. */
  99462. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99463. private _processPointerDown;
  99464. /** @hidden */
  99465. _isPointerSwiping(): boolean;
  99466. /**
  99467. * Use this method to simulate a pointer up on a mesh
  99468. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99469. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99470. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99471. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99472. */
  99473. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  99474. private _processPointerUp;
  99475. /**
  99476. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99477. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99478. * @returns true if the pointer was captured
  99479. */
  99480. isPointerCaptured(pointerId?: number): boolean;
  99481. /**
  99482. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99483. * @param attachUp defines if you want to attach events to pointerup
  99484. * @param attachDown defines if you want to attach events to pointerdown
  99485. * @param attachMove defines if you want to attach events to pointermove
  99486. */
  99487. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99488. /**
  99489. * Detaches all event handlers
  99490. */
  99491. detachControl(): void;
  99492. /**
  99493. * Force the value of meshUnderPointer
  99494. * @param mesh defines the mesh to use
  99495. */
  99496. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99497. /**
  99498. * Gets the mesh under the pointer
  99499. * @returns a Mesh or null if no mesh is under the pointer
  99500. */
  99501. getPointerOverMesh(): Nullable<AbstractMesh>;
  99502. }
  99503. }
  99504. declare module BABYLON {
  99505. /**
  99506. * Helper class used to generate session unique ID
  99507. */
  99508. export class UniqueIdGenerator {
  99509. private static _UniqueIdCounter;
  99510. /**
  99511. * Gets an unique (relatively to the current scene) Id
  99512. */
  99513. static readonly UniqueId: number;
  99514. }
  99515. }
  99516. declare module BABYLON {
  99517. /**
  99518. * This class defines the direct association between an animation and a target
  99519. */
  99520. export class TargetedAnimation {
  99521. /**
  99522. * Animation to perform
  99523. */
  99524. animation: Animation;
  99525. /**
  99526. * Target to animate
  99527. */
  99528. target: any;
  99529. /**
  99530. * Serialize the object
  99531. * @returns the JSON object representing the current entity
  99532. */
  99533. serialize(): any;
  99534. }
  99535. /**
  99536. * Use this class to create coordinated animations on multiple targets
  99537. */
  99538. export class AnimationGroup implements IDisposable {
  99539. /** The name of the animation group */
  99540. name: string;
  99541. private _scene;
  99542. private _targetedAnimations;
  99543. private _animatables;
  99544. private _from;
  99545. private _to;
  99546. private _isStarted;
  99547. private _isPaused;
  99548. private _speedRatio;
  99549. private _loopAnimation;
  99550. /**
  99551. * Gets or sets the unique id of the node
  99552. */
  99553. uniqueId: number;
  99554. /**
  99555. * This observable will notify when one animation have ended
  99556. */
  99557. onAnimationEndObservable: Observable<TargetedAnimation>;
  99558. /**
  99559. * Observer raised when one animation loops
  99560. */
  99561. onAnimationLoopObservable: Observable<TargetedAnimation>;
  99562. /**
  99563. * This observable will notify when all animations have ended.
  99564. */
  99565. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  99566. /**
  99567. * This observable will notify when all animations have paused.
  99568. */
  99569. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  99570. /**
  99571. * This observable will notify when all animations are playing.
  99572. */
  99573. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  99574. /**
  99575. * Gets the first frame
  99576. */
  99577. readonly from: number;
  99578. /**
  99579. * Gets the last frame
  99580. */
  99581. readonly to: number;
  99582. /**
  99583. * Define if the animations are started
  99584. */
  99585. readonly isStarted: boolean;
  99586. /**
  99587. * Gets a value indicating that the current group is playing
  99588. */
  99589. readonly isPlaying: boolean;
  99590. /**
  99591. * Gets or sets the speed ratio to use for all animations
  99592. */
  99593. /**
  99594. * Gets or sets the speed ratio to use for all animations
  99595. */
  99596. speedRatio: number;
  99597. /**
  99598. * Gets or sets if all animations should loop or not
  99599. */
  99600. loopAnimation: boolean;
  99601. /**
  99602. * Gets the targeted animations for this animation group
  99603. */
  99604. readonly targetedAnimations: Array<TargetedAnimation>;
  99605. /**
  99606. * returning the list of animatables controlled by this animation group.
  99607. */
  99608. readonly animatables: Array<Animatable>;
  99609. /**
  99610. * Instantiates a new Animation Group.
  99611. * This helps managing several animations at once.
  99612. * @see http://doc.babylonjs.com/how_to/group
  99613. * @param name Defines the name of the group
  99614. * @param scene Defines the scene the group belongs to
  99615. */
  99616. constructor(
  99617. /** The name of the animation group */
  99618. name: string, scene?: Nullable<Scene>);
  99619. /**
  99620. * Add an animation (with its target) in the group
  99621. * @param animation defines the animation we want to add
  99622. * @param target defines the target of the animation
  99623. * @returns the TargetedAnimation object
  99624. */
  99625. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  99626. /**
  99627. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  99628. * It can add constant keys at begin or end
  99629. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  99630. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  99631. * @returns the animation group
  99632. */
  99633. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  99634. /**
  99635. * Start all animations on given targets
  99636. * @param loop defines if animations must loop
  99637. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  99638. * @param from defines the from key (optional)
  99639. * @param to defines the to key (optional)
  99640. * @returns the current animation group
  99641. */
  99642. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  99643. /**
  99644. * Pause all animations
  99645. * @returns the animation group
  99646. */
  99647. pause(): AnimationGroup;
  99648. /**
  99649. * Play all animations to initial state
  99650. * This function will start() the animations if they were not started or will restart() them if they were paused
  99651. * @param loop defines if animations must loop
  99652. * @returns the animation group
  99653. */
  99654. play(loop?: boolean): AnimationGroup;
  99655. /**
  99656. * Reset all animations to initial state
  99657. * @returns the animation group
  99658. */
  99659. reset(): AnimationGroup;
  99660. /**
  99661. * Restart animations from key 0
  99662. * @returns the animation group
  99663. */
  99664. restart(): AnimationGroup;
  99665. /**
  99666. * Stop all animations
  99667. * @returns the animation group
  99668. */
  99669. stop(): AnimationGroup;
  99670. /**
  99671. * Set animation weight for all animatables
  99672. * @param weight defines the weight to use
  99673. * @return the animationGroup
  99674. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99675. */
  99676. setWeightForAllAnimatables(weight: number): AnimationGroup;
  99677. /**
  99678. * Synchronize and normalize all animatables with a source animatable
  99679. * @param root defines the root animatable to synchronize with
  99680. * @return the animationGroup
  99681. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99682. */
  99683. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  99684. /**
  99685. * Goes to a specific frame in this animation group
  99686. * @param frame the frame number to go to
  99687. * @return the animationGroup
  99688. */
  99689. goToFrame(frame: number): AnimationGroup;
  99690. /**
  99691. * Dispose all associated resources
  99692. */
  99693. dispose(): void;
  99694. private _checkAnimationGroupEnded;
  99695. /**
  99696. * Clone the current animation group and returns a copy
  99697. * @param newName defines the name of the new group
  99698. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  99699. * @returns the new aniamtion group
  99700. */
  99701. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  99702. /**
  99703. * Serializes the animationGroup to an object
  99704. * @returns Serialized object
  99705. */
  99706. serialize(): any;
  99707. /**
  99708. * Returns a new AnimationGroup object parsed from the source provided.
  99709. * @param parsedAnimationGroup defines the source
  99710. * @param scene defines the scene that will receive the animationGroup
  99711. * @returns a new AnimationGroup
  99712. */
  99713. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  99714. /**
  99715. * Returns the string "AnimationGroup"
  99716. * @returns "AnimationGroup"
  99717. */
  99718. getClassName(): string;
  99719. /**
  99720. * Creates a detailled string about the object
  99721. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  99722. * @returns a string representing the object
  99723. */
  99724. toString(fullDetails?: boolean): string;
  99725. }
  99726. }
  99727. declare module BABYLON {
  99728. /**
  99729. * Define an interface for all classes that will hold resources
  99730. */
  99731. export interface IDisposable {
  99732. /**
  99733. * Releases all held resources
  99734. */
  99735. dispose(): void;
  99736. }
  99737. /** Interface defining initialization parameters for Scene class */
  99738. export interface SceneOptions {
  99739. /**
  99740. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  99741. * It will improve performance when the number of geometries becomes important.
  99742. */
  99743. useGeometryUniqueIdsMap?: boolean;
  99744. /**
  99745. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  99746. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99747. */
  99748. useMaterialMeshMap?: boolean;
  99749. /**
  99750. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  99751. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99752. */
  99753. useClonedMeshhMap?: boolean;
  99754. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  99755. virtual?: boolean;
  99756. }
  99757. /**
  99758. * Represents a scene to be rendered by the engine.
  99759. * @see http://doc.babylonjs.com/features/scene
  99760. */
  99761. export class Scene extends AbstractScene implements IAnimatable {
  99762. /** The fog is deactivated */
  99763. static readonly FOGMODE_NONE: number;
  99764. /** The fog density is following an exponential function */
  99765. static readonly FOGMODE_EXP: number;
  99766. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  99767. static readonly FOGMODE_EXP2: number;
  99768. /** The fog density is following a linear function. */
  99769. static readonly FOGMODE_LINEAR: number;
  99770. /**
  99771. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  99772. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99773. */
  99774. static MinDeltaTime: number;
  99775. /**
  99776. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  99777. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99778. */
  99779. static MaxDeltaTime: number;
  99780. /**
  99781. * Factory used to create the default material.
  99782. * @param name The name of the material to create
  99783. * @param scene The scene to create the material for
  99784. * @returns The default material
  99785. */
  99786. static DefaultMaterialFactory(scene: Scene): Material;
  99787. /**
  99788. * Factory used to create the a collision coordinator.
  99789. * @returns The collision coordinator
  99790. */
  99791. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  99792. /** @hidden */
  99793. _inputManager: InputManager;
  99794. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  99795. cameraToUseForPointers: Nullable<Camera>;
  99796. /** @hidden */
  99797. readonly _isScene: boolean;
  99798. /**
  99799. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  99800. */
  99801. autoClear: boolean;
  99802. /**
  99803. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  99804. */
  99805. autoClearDepthAndStencil: boolean;
  99806. /**
  99807. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  99808. */
  99809. clearColor: Color4;
  99810. /**
  99811. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  99812. */
  99813. ambientColor: Color3;
  99814. /**
  99815. * This is use to store the default BRDF lookup for PBR materials in your scene.
  99816. * It should only be one of the following (if not the default embedded one):
  99817. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  99818. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  99819. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  99820. * The material properties need to be setup according to the type of texture in use.
  99821. */
  99822. environmentBRDFTexture: BaseTexture;
  99823. /** @hidden */
  99824. protected _environmentTexture: Nullable<BaseTexture>;
  99825. /**
  99826. * Texture used in all pbr material as the reflection texture.
  99827. * As in the majority of the scene they are the same (exception for multi room and so on),
  99828. * this is easier to reference from here than from all the materials.
  99829. */
  99830. /**
  99831. * Texture used in all pbr material as the reflection texture.
  99832. * As in the majority of the scene they are the same (exception for multi room and so on),
  99833. * this is easier to set here than in all the materials.
  99834. */
  99835. environmentTexture: Nullable<BaseTexture>;
  99836. /** @hidden */
  99837. protected _environmentIntensity: number;
  99838. /**
  99839. * Intensity of the environment in all pbr material.
  99840. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99841. * As in the majority of the scene they are the same (exception for multi room and so on),
  99842. * this is easier to reference from here than from all the materials.
  99843. */
  99844. /**
  99845. * Intensity of the environment in all pbr material.
  99846. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99847. * As in the majority of the scene they are the same (exception for multi room and so on),
  99848. * this is easier to set here than in all the materials.
  99849. */
  99850. environmentIntensity: number;
  99851. /** @hidden */
  99852. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99853. /**
  99854. * Default image processing configuration used either in the rendering
  99855. * Forward main pass or through the imageProcessingPostProcess if present.
  99856. * As in the majority of the scene they are the same (exception for multi camera),
  99857. * this is easier to reference from here than from all the materials and post process.
  99858. *
  99859. * No setter as we it is a shared configuration, you can set the values instead.
  99860. */
  99861. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  99862. private _forceWireframe;
  99863. /**
  99864. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  99865. */
  99866. forceWireframe: boolean;
  99867. private _forcePointsCloud;
  99868. /**
  99869. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  99870. */
  99871. forcePointsCloud: boolean;
  99872. /**
  99873. * Gets or sets the active clipplane 1
  99874. */
  99875. clipPlane: Nullable<Plane>;
  99876. /**
  99877. * Gets or sets the active clipplane 2
  99878. */
  99879. clipPlane2: Nullable<Plane>;
  99880. /**
  99881. * Gets or sets the active clipplane 3
  99882. */
  99883. clipPlane3: Nullable<Plane>;
  99884. /**
  99885. * Gets or sets the active clipplane 4
  99886. */
  99887. clipPlane4: Nullable<Plane>;
  99888. /**
  99889. * Gets or sets a boolean indicating if animations are enabled
  99890. */
  99891. animationsEnabled: boolean;
  99892. private _animationPropertiesOverride;
  99893. /**
  99894. * Gets or sets the animation properties override
  99895. */
  99896. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  99897. /**
  99898. * Gets or sets a boolean indicating if a constant deltatime has to be used
  99899. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  99900. */
  99901. useConstantAnimationDeltaTime: boolean;
  99902. /**
  99903. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  99904. * Please note that it requires to run a ray cast through the scene on every frame
  99905. */
  99906. constantlyUpdateMeshUnderPointer: boolean;
  99907. /**
  99908. * Defines the HTML cursor to use when hovering over interactive elements
  99909. */
  99910. hoverCursor: string;
  99911. /**
  99912. * Defines the HTML default cursor to use (empty by default)
  99913. */
  99914. defaultCursor: string;
  99915. /**
  99916. * This is used to call preventDefault() on pointer down
  99917. * in order to block unwanted artifacts like system double clicks
  99918. */
  99919. preventDefaultOnPointerDown: boolean;
  99920. /**
  99921. * This is used to call preventDefault() on pointer up
  99922. * in order to block unwanted artifacts like system double clicks
  99923. */
  99924. preventDefaultOnPointerUp: boolean;
  99925. /**
  99926. * Gets or sets user defined metadata
  99927. */
  99928. metadata: any;
  99929. /**
  99930. * For internal use only. Please do not use.
  99931. */
  99932. reservedDataStore: any;
  99933. /**
  99934. * Gets the name of the plugin used to load this scene (null by default)
  99935. */
  99936. loadingPluginName: string;
  99937. /**
  99938. * Use this array to add regular expressions used to disable offline support for specific urls
  99939. */
  99940. disableOfflineSupportExceptionRules: RegExp[];
  99941. /**
  99942. * An event triggered when the scene is disposed.
  99943. */
  99944. onDisposeObservable: Observable<Scene>;
  99945. private _onDisposeObserver;
  99946. /** Sets a function to be executed when this scene is disposed. */
  99947. onDispose: () => void;
  99948. /**
  99949. * An event triggered before rendering the scene (right after animations and physics)
  99950. */
  99951. onBeforeRenderObservable: Observable<Scene>;
  99952. private _onBeforeRenderObserver;
  99953. /** Sets a function to be executed before rendering this scene */
  99954. beforeRender: Nullable<() => void>;
  99955. /**
  99956. * An event triggered after rendering the scene
  99957. */
  99958. onAfterRenderObservable: Observable<Scene>;
  99959. /**
  99960. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  99961. */
  99962. onAfterRenderCameraObservable: Observable<Camera>;
  99963. private _onAfterRenderObserver;
  99964. /** Sets a function to be executed after rendering this scene */
  99965. afterRender: Nullable<() => void>;
  99966. /**
  99967. * An event triggered before animating the scene
  99968. */
  99969. onBeforeAnimationsObservable: Observable<Scene>;
  99970. /**
  99971. * An event triggered after animations processing
  99972. */
  99973. onAfterAnimationsObservable: Observable<Scene>;
  99974. /**
  99975. * An event triggered before draw calls are ready to be sent
  99976. */
  99977. onBeforeDrawPhaseObservable: Observable<Scene>;
  99978. /**
  99979. * An event triggered after draw calls have been sent
  99980. */
  99981. onAfterDrawPhaseObservable: Observable<Scene>;
  99982. /**
  99983. * An event triggered when the scene is ready
  99984. */
  99985. onReadyObservable: Observable<Scene>;
  99986. /**
  99987. * An event triggered before rendering a camera
  99988. */
  99989. onBeforeCameraRenderObservable: Observable<Camera>;
  99990. private _onBeforeCameraRenderObserver;
  99991. /** Sets a function to be executed before rendering a camera*/
  99992. beforeCameraRender: () => void;
  99993. /**
  99994. * An event triggered after rendering a camera
  99995. */
  99996. onAfterCameraRenderObservable: Observable<Camera>;
  99997. private _onAfterCameraRenderObserver;
  99998. /** Sets a function to be executed after rendering a camera*/
  99999. afterCameraRender: () => void;
  100000. /**
  100001. * An event triggered when active meshes evaluation is about to start
  100002. */
  100003. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  100004. /**
  100005. * An event triggered when active meshes evaluation is done
  100006. */
  100007. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  100008. /**
  100009. * An event triggered when particles rendering is about to start
  100010. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100011. */
  100012. onBeforeParticlesRenderingObservable: Observable<Scene>;
  100013. /**
  100014. * An event triggered when particles rendering is done
  100015. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100016. */
  100017. onAfterParticlesRenderingObservable: Observable<Scene>;
  100018. /**
  100019. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  100020. */
  100021. onDataLoadedObservable: Observable<Scene>;
  100022. /**
  100023. * An event triggered when a camera is created
  100024. */
  100025. onNewCameraAddedObservable: Observable<Camera>;
  100026. /**
  100027. * An event triggered when a camera is removed
  100028. */
  100029. onCameraRemovedObservable: Observable<Camera>;
  100030. /**
  100031. * An event triggered when a light is created
  100032. */
  100033. onNewLightAddedObservable: Observable<Light>;
  100034. /**
  100035. * An event triggered when a light is removed
  100036. */
  100037. onLightRemovedObservable: Observable<Light>;
  100038. /**
  100039. * An event triggered when a geometry is created
  100040. */
  100041. onNewGeometryAddedObservable: Observable<Geometry>;
  100042. /**
  100043. * An event triggered when a geometry is removed
  100044. */
  100045. onGeometryRemovedObservable: Observable<Geometry>;
  100046. /**
  100047. * An event triggered when a transform node is created
  100048. */
  100049. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  100050. /**
  100051. * An event triggered when a transform node is removed
  100052. */
  100053. onTransformNodeRemovedObservable: Observable<TransformNode>;
  100054. /**
  100055. * An event triggered when a mesh is created
  100056. */
  100057. onNewMeshAddedObservable: Observable<AbstractMesh>;
  100058. /**
  100059. * An event triggered when a mesh is removed
  100060. */
  100061. onMeshRemovedObservable: Observable<AbstractMesh>;
  100062. /**
  100063. * An event triggered when a skeleton is created
  100064. */
  100065. onNewSkeletonAddedObservable: Observable<Skeleton>;
  100066. /**
  100067. * An event triggered when a skeleton is removed
  100068. */
  100069. onSkeletonRemovedObservable: Observable<Skeleton>;
  100070. /**
  100071. * An event triggered when a material is created
  100072. */
  100073. onNewMaterialAddedObservable: Observable<Material>;
  100074. /**
  100075. * An event triggered when a material is removed
  100076. */
  100077. onMaterialRemovedObservable: Observable<Material>;
  100078. /**
  100079. * An event triggered when a texture is created
  100080. */
  100081. onNewTextureAddedObservable: Observable<BaseTexture>;
  100082. /**
  100083. * An event triggered when a texture is removed
  100084. */
  100085. onTextureRemovedObservable: Observable<BaseTexture>;
  100086. /**
  100087. * An event triggered when render targets are about to be rendered
  100088. * Can happen multiple times per frame.
  100089. */
  100090. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  100091. /**
  100092. * An event triggered when render targets were rendered.
  100093. * Can happen multiple times per frame.
  100094. */
  100095. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  100096. /**
  100097. * An event triggered before calculating deterministic simulation step
  100098. */
  100099. onBeforeStepObservable: Observable<Scene>;
  100100. /**
  100101. * An event triggered after calculating deterministic simulation step
  100102. */
  100103. onAfterStepObservable: Observable<Scene>;
  100104. /**
  100105. * An event triggered when the activeCamera property is updated
  100106. */
  100107. onActiveCameraChanged: Observable<Scene>;
  100108. /**
  100109. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  100110. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100111. * 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)
  100112. */
  100113. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100114. /**
  100115. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  100116. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100117. * 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)
  100118. */
  100119. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100120. /**
  100121. * This Observable will when a mesh has been imported into the scene.
  100122. */
  100123. onMeshImportedObservable: Observable<AbstractMesh>;
  100124. /**
  100125. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  100126. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  100127. */
  100128. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  100129. /** @hidden */
  100130. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  100131. /**
  100132. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  100133. */
  100134. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  100135. /**
  100136. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  100137. */
  100138. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  100139. /**
  100140. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  100141. */
  100142. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  100143. /** Callback called when a pointer move is detected */
  100144. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100145. /** Callback called when a pointer down is detected */
  100146. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100147. /** Callback called when a pointer up is detected */
  100148. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  100149. /** Callback called when a pointer pick is detected */
  100150. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  100151. /**
  100152. * 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).
  100153. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  100154. */
  100155. onPrePointerObservable: Observable<PointerInfoPre>;
  100156. /**
  100157. * Observable event triggered each time an input event is received from the rendering canvas
  100158. */
  100159. onPointerObservable: Observable<PointerInfo>;
  100160. /**
  100161. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  100162. */
  100163. readonly unTranslatedPointer: Vector2;
  100164. /**
  100165. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  100166. */
  100167. static DragMovementThreshold: number;
  100168. /**
  100169. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  100170. */
  100171. static LongPressDelay: number;
  100172. /**
  100173. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  100174. */
  100175. static DoubleClickDelay: number;
  100176. /** If you need to check double click without raising a single click at first click, enable this flag */
  100177. static ExclusiveDoubleClickMode: boolean;
  100178. /** @hidden */
  100179. _mirroredCameraPosition: Nullable<Vector3>;
  100180. /**
  100181. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  100182. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  100183. */
  100184. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  100185. /**
  100186. * Observable event triggered each time an keyboard event is received from the hosting window
  100187. */
  100188. onKeyboardObservable: Observable<KeyboardInfo>;
  100189. private _useRightHandedSystem;
  100190. /**
  100191. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  100192. */
  100193. useRightHandedSystem: boolean;
  100194. private _timeAccumulator;
  100195. private _currentStepId;
  100196. private _currentInternalStep;
  100197. /**
  100198. * Sets the step Id used by deterministic lock step
  100199. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100200. * @param newStepId defines the step Id
  100201. */
  100202. setStepId(newStepId: number): void;
  100203. /**
  100204. * Gets the step Id used by deterministic lock step
  100205. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100206. * @returns the step Id
  100207. */
  100208. getStepId(): number;
  100209. /**
  100210. * Gets the internal step used by deterministic lock step
  100211. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100212. * @returns the internal step
  100213. */
  100214. getInternalStep(): number;
  100215. private _fogEnabled;
  100216. /**
  100217. * Gets or sets a boolean indicating if fog is enabled on this scene
  100218. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100219. * (Default is true)
  100220. */
  100221. fogEnabled: boolean;
  100222. private _fogMode;
  100223. /**
  100224. * Gets or sets the fog mode to use
  100225. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100226. * | mode | value |
  100227. * | --- | --- |
  100228. * | FOGMODE_NONE | 0 |
  100229. * | FOGMODE_EXP | 1 |
  100230. * | FOGMODE_EXP2 | 2 |
  100231. * | FOGMODE_LINEAR | 3 |
  100232. */
  100233. fogMode: number;
  100234. /**
  100235. * Gets or sets the fog color to use
  100236. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100237. * (Default is Color3(0.2, 0.2, 0.3))
  100238. */
  100239. fogColor: Color3;
  100240. /**
  100241. * Gets or sets the fog density to use
  100242. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100243. * (Default is 0.1)
  100244. */
  100245. fogDensity: number;
  100246. /**
  100247. * Gets or sets the fog start distance to use
  100248. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100249. * (Default is 0)
  100250. */
  100251. fogStart: number;
  100252. /**
  100253. * Gets or sets the fog end distance to use
  100254. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100255. * (Default is 1000)
  100256. */
  100257. fogEnd: number;
  100258. private _shadowsEnabled;
  100259. /**
  100260. * Gets or sets a boolean indicating if shadows are enabled on this scene
  100261. */
  100262. shadowsEnabled: boolean;
  100263. private _lightsEnabled;
  100264. /**
  100265. * Gets or sets a boolean indicating if lights are enabled on this scene
  100266. */
  100267. lightsEnabled: boolean;
  100268. /** All of the active cameras added to this scene. */
  100269. activeCameras: Camera[];
  100270. /** @hidden */
  100271. _activeCamera: Nullable<Camera>;
  100272. /** Gets or sets the current active camera */
  100273. activeCamera: Nullable<Camera>;
  100274. private _defaultMaterial;
  100275. /** The default material used on meshes when no material is affected */
  100276. /** The default material used on meshes when no material is affected */
  100277. defaultMaterial: Material;
  100278. private _texturesEnabled;
  100279. /**
  100280. * Gets or sets a boolean indicating if textures are enabled on this scene
  100281. */
  100282. texturesEnabled: boolean;
  100283. /**
  100284. * Gets or sets a boolean indicating if particles are enabled on this scene
  100285. */
  100286. particlesEnabled: boolean;
  100287. /**
  100288. * Gets or sets a boolean indicating if sprites are enabled on this scene
  100289. */
  100290. spritesEnabled: boolean;
  100291. private _skeletonsEnabled;
  100292. /**
  100293. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  100294. */
  100295. skeletonsEnabled: boolean;
  100296. /**
  100297. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  100298. */
  100299. lensFlaresEnabled: boolean;
  100300. /**
  100301. * Gets or sets a boolean indicating if collisions are enabled on this scene
  100302. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100303. */
  100304. collisionsEnabled: boolean;
  100305. private _collisionCoordinator;
  100306. /** @hidden */
  100307. readonly collisionCoordinator: ICollisionCoordinator;
  100308. /**
  100309. * Defines the gravity applied to this scene (used only for collisions)
  100310. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100311. */
  100312. gravity: Vector3;
  100313. /**
  100314. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  100315. */
  100316. postProcessesEnabled: boolean;
  100317. /**
  100318. * The list of postprocesses added to the scene
  100319. */
  100320. postProcesses: PostProcess[];
  100321. /**
  100322. * Gets the current postprocess manager
  100323. */
  100324. postProcessManager: PostProcessManager;
  100325. /**
  100326. * Gets or sets a boolean indicating if render targets are enabled on this scene
  100327. */
  100328. renderTargetsEnabled: boolean;
  100329. /**
  100330. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  100331. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  100332. */
  100333. dumpNextRenderTargets: boolean;
  100334. /**
  100335. * The list of user defined render targets added to the scene
  100336. */
  100337. customRenderTargets: RenderTargetTexture[];
  100338. /**
  100339. * Defines if texture loading must be delayed
  100340. * If true, textures will only be loaded when they need to be rendered
  100341. */
  100342. useDelayedTextureLoading: boolean;
  100343. /**
  100344. * Gets the list of meshes imported to the scene through SceneLoader
  100345. */
  100346. importedMeshesFiles: String[];
  100347. /**
  100348. * Gets or sets a boolean indicating if probes are enabled on this scene
  100349. */
  100350. probesEnabled: boolean;
  100351. /**
  100352. * Gets or sets the current offline provider to use to store scene data
  100353. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  100354. */
  100355. offlineProvider: IOfflineProvider;
  100356. /**
  100357. * Gets or sets the action manager associated with the scene
  100358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100359. */
  100360. actionManager: AbstractActionManager;
  100361. private _meshesForIntersections;
  100362. /**
  100363. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  100364. */
  100365. proceduralTexturesEnabled: boolean;
  100366. private _engine;
  100367. private _totalVertices;
  100368. /** @hidden */
  100369. _activeIndices: PerfCounter;
  100370. /** @hidden */
  100371. _activeParticles: PerfCounter;
  100372. /** @hidden */
  100373. _activeBones: PerfCounter;
  100374. private _animationRatio;
  100375. /** @hidden */
  100376. _animationTimeLast: number;
  100377. /** @hidden */
  100378. _animationTime: number;
  100379. /**
  100380. * Gets or sets a general scale for animation speed
  100381. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  100382. */
  100383. animationTimeScale: number;
  100384. /** @hidden */
  100385. _cachedMaterial: Nullable<Material>;
  100386. /** @hidden */
  100387. _cachedEffect: Nullable<Effect>;
  100388. /** @hidden */
  100389. _cachedVisibility: Nullable<number>;
  100390. private _renderId;
  100391. private _frameId;
  100392. private _executeWhenReadyTimeoutId;
  100393. private _intermediateRendering;
  100394. private _viewUpdateFlag;
  100395. private _projectionUpdateFlag;
  100396. /** @hidden */
  100397. _toBeDisposed: Nullable<IDisposable>[];
  100398. private _activeRequests;
  100399. /** @hidden */
  100400. _pendingData: any[];
  100401. private _isDisposed;
  100402. /**
  100403. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  100404. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  100405. */
  100406. dispatchAllSubMeshesOfActiveMeshes: boolean;
  100407. private _activeMeshes;
  100408. private _processedMaterials;
  100409. private _renderTargets;
  100410. /** @hidden */
  100411. _activeParticleSystems: SmartArray<IParticleSystem>;
  100412. private _activeSkeletons;
  100413. private _softwareSkinnedMeshes;
  100414. private _renderingManager;
  100415. /** @hidden */
  100416. _activeAnimatables: Animatable[];
  100417. private _transformMatrix;
  100418. private _sceneUbo;
  100419. /** @hidden */
  100420. _viewMatrix: Matrix;
  100421. private _projectionMatrix;
  100422. /** @hidden */
  100423. _forcedViewPosition: Nullable<Vector3>;
  100424. /** @hidden */
  100425. _frustumPlanes: Plane[];
  100426. /**
  100427. * Gets the list of frustum planes (built from the active camera)
  100428. */
  100429. readonly frustumPlanes: Plane[];
  100430. /**
  100431. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  100432. * This is useful if there are more lights that the maximum simulteanous authorized
  100433. */
  100434. requireLightSorting: boolean;
  100435. /** @hidden */
  100436. readonly useMaterialMeshMap: boolean;
  100437. /** @hidden */
  100438. readonly useClonedMeshhMap: boolean;
  100439. private _externalData;
  100440. private _uid;
  100441. /**
  100442. * @hidden
  100443. * Backing store of defined scene components.
  100444. */
  100445. _components: ISceneComponent[];
  100446. /**
  100447. * @hidden
  100448. * Backing store of defined scene components.
  100449. */
  100450. _serializableComponents: ISceneSerializableComponent[];
  100451. /**
  100452. * List of components to register on the next registration step.
  100453. */
  100454. private _transientComponents;
  100455. /**
  100456. * Registers the transient components if needed.
  100457. */
  100458. private _registerTransientComponents;
  100459. /**
  100460. * @hidden
  100461. * Add a component to the scene.
  100462. * Note that the ccomponent could be registered on th next frame if this is called after
  100463. * the register component stage.
  100464. * @param component Defines the component to add to the scene
  100465. */
  100466. _addComponent(component: ISceneComponent): void;
  100467. /**
  100468. * @hidden
  100469. * Gets a component from the scene.
  100470. * @param name defines the name of the component to retrieve
  100471. * @returns the component or null if not present
  100472. */
  100473. _getComponent(name: string): Nullable<ISceneComponent>;
  100474. /**
  100475. * @hidden
  100476. * Defines the actions happening before camera updates.
  100477. */
  100478. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  100479. /**
  100480. * @hidden
  100481. * Defines the actions happening before clear the canvas.
  100482. */
  100483. _beforeClearStage: Stage<SimpleStageAction>;
  100484. /**
  100485. * @hidden
  100486. * Defines the actions when collecting render targets for the frame.
  100487. */
  100488. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100489. /**
  100490. * @hidden
  100491. * Defines the actions happening for one camera in the frame.
  100492. */
  100493. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100494. /**
  100495. * @hidden
  100496. * Defines the actions happening during the per mesh ready checks.
  100497. */
  100498. _isReadyForMeshStage: Stage<MeshStageAction>;
  100499. /**
  100500. * @hidden
  100501. * Defines the actions happening before evaluate active mesh checks.
  100502. */
  100503. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  100504. /**
  100505. * @hidden
  100506. * Defines the actions happening during the evaluate sub mesh checks.
  100507. */
  100508. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  100509. /**
  100510. * @hidden
  100511. * Defines the actions happening during the active mesh stage.
  100512. */
  100513. _activeMeshStage: Stage<ActiveMeshStageAction>;
  100514. /**
  100515. * @hidden
  100516. * Defines the actions happening during the per camera render target step.
  100517. */
  100518. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  100519. /**
  100520. * @hidden
  100521. * Defines the actions happening just before the active camera is drawing.
  100522. */
  100523. _beforeCameraDrawStage: Stage<CameraStageAction>;
  100524. /**
  100525. * @hidden
  100526. * Defines the actions happening just before a render target is drawing.
  100527. */
  100528. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100529. /**
  100530. * @hidden
  100531. * Defines the actions happening just before a rendering group is drawing.
  100532. */
  100533. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100534. /**
  100535. * @hidden
  100536. * Defines the actions happening just before a mesh is drawing.
  100537. */
  100538. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100539. /**
  100540. * @hidden
  100541. * Defines the actions happening just after a mesh has been drawn.
  100542. */
  100543. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100544. /**
  100545. * @hidden
  100546. * Defines the actions happening just after a rendering group has been drawn.
  100547. */
  100548. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100549. /**
  100550. * @hidden
  100551. * Defines the actions happening just after the active camera has been drawn.
  100552. */
  100553. _afterCameraDrawStage: Stage<CameraStageAction>;
  100554. /**
  100555. * @hidden
  100556. * Defines the actions happening just after a render target has been drawn.
  100557. */
  100558. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100559. /**
  100560. * @hidden
  100561. * Defines the actions happening just after rendering all cameras and computing intersections.
  100562. */
  100563. _afterRenderStage: Stage<SimpleStageAction>;
  100564. /**
  100565. * @hidden
  100566. * Defines the actions happening when a pointer move event happens.
  100567. */
  100568. _pointerMoveStage: Stage<PointerMoveStageAction>;
  100569. /**
  100570. * @hidden
  100571. * Defines the actions happening when a pointer down event happens.
  100572. */
  100573. _pointerDownStage: Stage<PointerUpDownStageAction>;
  100574. /**
  100575. * @hidden
  100576. * Defines the actions happening when a pointer up event happens.
  100577. */
  100578. _pointerUpStage: Stage<PointerUpDownStageAction>;
  100579. /**
  100580. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  100581. */
  100582. private geometriesByUniqueId;
  100583. /**
  100584. * Creates a new Scene
  100585. * @param engine defines the engine to use to render this scene
  100586. * @param options defines the scene options
  100587. */
  100588. constructor(engine: Engine, options?: SceneOptions);
  100589. /**
  100590. * Gets a string idenfifying the name of the class
  100591. * @returns "Scene" string
  100592. */
  100593. getClassName(): string;
  100594. private _defaultMeshCandidates;
  100595. /**
  100596. * @hidden
  100597. */
  100598. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100599. private _defaultSubMeshCandidates;
  100600. /**
  100601. * @hidden
  100602. */
  100603. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100604. /**
  100605. * Sets the default candidate providers for the scene.
  100606. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  100607. * and getCollidingSubMeshCandidates to their default function
  100608. */
  100609. setDefaultCandidateProviders(): void;
  100610. /**
  100611. * Gets the mesh that is currently under the pointer
  100612. */
  100613. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100614. /**
  100615. * Gets or sets the current on-screen X position of the pointer
  100616. */
  100617. pointerX: number;
  100618. /**
  100619. * Gets or sets the current on-screen Y position of the pointer
  100620. */
  100621. pointerY: number;
  100622. /**
  100623. * Gets the cached material (ie. the latest rendered one)
  100624. * @returns the cached material
  100625. */
  100626. getCachedMaterial(): Nullable<Material>;
  100627. /**
  100628. * Gets the cached effect (ie. the latest rendered one)
  100629. * @returns the cached effect
  100630. */
  100631. getCachedEffect(): Nullable<Effect>;
  100632. /**
  100633. * Gets the cached visibility state (ie. the latest rendered one)
  100634. * @returns the cached visibility state
  100635. */
  100636. getCachedVisibility(): Nullable<number>;
  100637. /**
  100638. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  100639. * @param material defines the current material
  100640. * @param effect defines the current effect
  100641. * @param visibility defines the current visibility state
  100642. * @returns true if one parameter is not cached
  100643. */
  100644. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  100645. /**
  100646. * Gets the engine associated with the scene
  100647. * @returns an Engine
  100648. */
  100649. getEngine(): Engine;
  100650. /**
  100651. * Gets the total number of vertices rendered per frame
  100652. * @returns the total number of vertices rendered per frame
  100653. */
  100654. getTotalVertices(): number;
  100655. /**
  100656. * Gets the performance counter for total vertices
  100657. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100658. */
  100659. readonly totalVerticesPerfCounter: PerfCounter;
  100660. /**
  100661. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  100662. * @returns the total number of active indices rendered per frame
  100663. */
  100664. getActiveIndices(): number;
  100665. /**
  100666. * Gets the performance counter for active indices
  100667. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100668. */
  100669. readonly totalActiveIndicesPerfCounter: PerfCounter;
  100670. /**
  100671. * Gets the total number of active particles rendered per frame
  100672. * @returns the total number of active particles rendered per frame
  100673. */
  100674. getActiveParticles(): number;
  100675. /**
  100676. * Gets the performance counter for active particles
  100677. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100678. */
  100679. readonly activeParticlesPerfCounter: PerfCounter;
  100680. /**
  100681. * Gets the total number of active bones rendered per frame
  100682. * @returns the total number of active bones rendered per frame
  100683. */
  100684. getActiveBones(): number;
  100685. /**
  100686. * Gets the performance counter for active bones
  100687. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100688. */
  100689. readonly activeBonesPerfCounter: PerfCounter;
  100690. /**
  100691. * Gets the array of active meshes
  100692. * @returns an array of AbstractMesh
  100693. */
  100694. getActiveMeshes(): SmartArray<AbstractMesh>;
  100695. /**
  100696. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  100697. * @returns a number
  100698. */
  100699. getAnimationRatio(): number;
  100700. /**
  100701. * Gets an unique Id for the current render phase
  100702. * @returns a number
  100703. */
  100704. getRenderId(): number;
  100705. /**
  100706. * Gets an unique Id for the current frame
  100707. * @returns a number
  100708. */
  100709. getFrameId(): number;
  100710. /** Call this function if you want to manually increment the render Id*/
  100711. incrementRenderId(): void;
  100712. private _createUbo;
  100713. /**
  100714. * Use this method to simulate a pointer move on a mesh
  100715. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100716. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100717. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100718. * @returns the current scene
  100719. */
  100720. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100721. /**
  100722. * Use this method to simulate a pointer down on a mesh
  100723. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100724. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100725. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100726. * @returns the current scene
  100727. */
  100728. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100729. /**
  100730. * Use this method to simulate a pointer up on a mesh
  100731. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100732. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100733. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100734. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100735. * @returns the current scene
  100736. */
  100737. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  100738. /**
  100739. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100740. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100741. * @returns true if the pointer was captured
  100742. */
  100743. isPointerCaptured(pointerId?: number): boolean;
  100744. /**
  100745. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100746. * @param attachUp defines if you want to attach events to pointerup
  100747. * @param attachDown defines if you want to attach events to pointerdown
  100748. * @param attachMove defines if you want to attach events to pointermove
  100749. */
  100750. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100751. /** Detaches all event handlers*/
  100752. detachControl(): void;
  100753. /**
  100754. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  100755. * Delay loaded resources are not taking in account
  100756. * @return true if all required resources are ready
  100757. */
  100758. isReady(): boolean;
  100759. /** Resets all cached information relative to material (including effect and visibility) */
  100760. resetCachedMaterial(): void;
  100761. /**
  100762. * Registers a function to be called before every frame render
  100763. * @param func defines the function to register
  100764. */
  100765. registerBeforeRender(func: () => void): void;
  100766. /**
  100767. * Unregisters a function called before every frame render
  100768. * @param func defines the function to unregister
  100769. */
  100770. unregisterBeforeRender(func: () => void): void;
  100771. /**
  100772. * Registers a function to be called after every frame render
  100773. * @param func defines the function to register
  100774. */
  100775. registerAfterRender(func: () => void): void;
  100776. /**
  100777. * Unregisters a function called after every frame render
  100778. * @param func defines the function to unregister
  100779. */
  100780. unregisterAfterRender(func: () => void): void;
  100781. private _executeOnceBeforeRender;
  100782. /**
  100783. * The provided function will run before render once and will be disposed afterwards.
  100784. * A timeout delay can be provided so that the function will be executed in N ms.
  100785. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  100786. * @param func The function to be executed.
  100787. * @param timeout optional delay in ms
  100788. */
  100789. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  100790. /** @hidden */
  100791. _addPendingData(data: any): void;
  100792. /** @hidden */
  100793. _removePendingData(data: any): void;
  100794. /**
  100795. * Returns the number of items waiting to be loaded
  100796. * @returns the number of items waiting to be loaded
  100797. */
  100798. getWaitingItemsCount(): number;
  100799. /**
  100800. * Returns a boolean indicating if the scene is still loading data
  100801. */
  100802. readonly isLoading: boolean;
  100803. /**
  100804. * Registers a function to be executed when the scene is ready
  100805. * @param {Function} func - the function to be executed
  100806. */
  100807. executeWhenReady(func: () => void): void;
  100808. /**
  100809. * Returns a promise that resolves when the scene is ready
  100810. * @returns A promise that resolves when the scene is ready
  100811. */
  100812. whenReadyAsync(): Promise<void>;
  100813. /** @hidden */
  100814. _checkIsReady(): void;
  100815. /**
  100816. * Gets all animatable attached to the scene
  100817. */
  100818. readonly animatables: Animatable[];
  100819. /**
  100820. * Resets the last animation time frame.
  100821. * Useful to override when animations start running when loading a scene for the first time.
  100822. */
  100823. resetLastAnimationTimeFrame(): void;
  100824. /**
  100825. * Gets the current view matrix
  100826. * @returns a Matrix
  100827. */
  100828. getViewMatrix(): Matrix;
  100829. /**
  100830. * Gets the current projection matrix
  100831. * @returns a Matrix
  100832. */
  100833. getProjectionMatrix(): Matrix;
  100834. /**
  100835. * Gets the current transform matrix
  100836. * @returns a Matrix made of View * Projection
  100837. */
  100838. getTransformMatrix(): Matrix;
  100839. /**
  100840. * Sets the current transform matrix
  100841. * @param viewL defines the View matrix to use
  100842. * @param projectionL defines the Projection matrix to use
  100843. * @param viewR defines the right View matrix to use (if provided)
  100844. * @param projectionR defines the right Projection matrix to use (if provided)
  100845. */
  100846. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  100847. /**
  100848. * Gets the uniform buffer used to store scene data
  100849. * @returns a UniformBuffer
  100850. */
  100851. getSceneUniformBuffer(): UniformBuffer;
  100852. /**
  100853. * Gets an unique (relatively to the current scene) Id
  100854. * @returns an unique number for the scene
  100855. */
  100856. getUniqueId(): number;
  100857. /**
  100858. * Add a mesh to the list of scene's meshes
  100859. * @param newMesh defines the mesh to add
  100860. * @param recursive if all child meshes should also be added to the scene
  100861. */
  100862. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  100863. /**
  100864. * Remove a mesh for the list of scene's meshes
  100865. * @param toRemove defines the mesh to remove
  100866. * @param recursive if all child meshes should also be removed from the scene
  100867. * @returns the index where the mesh was in the mesh list
  100868. */
  100869. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  100870. /**
  100871. * Add a transform node to the list of scene's transform nodes
  100872. * @param newTransformNode defines the transform node to add
  100873. */
  100874. addTransformNode(newTransformNode: TransformNode): void;
  100875. /**
  100876. * Remove a transform node for the list of scene's transform nodes
  100877. * @param toRemove defines the transform node to remove
  100878. * @returns the index where the transform node was in the transform node list
  100879. */
  100880. removeTransformNode(toRemove: TransformNode): number;
  100881. /**
  100882. * Remove a skeleton for the list of scene's skeletons
  100883. * @param toRemove defines the skeleton to remove
  100884. * @returns the index where the skeleton was in the skeleton list
  100885. */
  100886. removeSkeleton(toRemove: Skeleton): number;
  100887. /**
  100888. * Remove a morph target for the list of scene's morph targets
  100889. * @param toRemove defines the morph target to remove
  100890. * @returns the index where the morph target was in the morph target list
  100891. */
  100892. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  100893. /**
  100894. * Remove a light for the list of scene's lights
  100895. * @param toRemove defines the light to remove
  100896. * @returns the index where the light was in the light list
  100897. */
  100898. removeLight(toRemove: Light): number;
  100899. /**
  100900. * Remove a camera for the list of scene's cameras
  100901. * @param toRemove defines the camera to remove
  100902. * @returns the index where the camera was in the camera list
  100903. */
  100904. removeCamera(toRemove: Camera): number;
  100905. /**
  100906. * Remove a particle system for the list of scene's particle systems
  100907. * @param toRemove defines the particle system to remove
  100908. * @returns the index where the particle system was in the particle system list
  100909. */
  100910. removeParticleSystem(toRemove: IParticleSystem): number;
  100911. /**
  100912. * Remove a animation for the list of scene's animations
  100913. * @param toRemove defines the animation to remove
  100914. * @returns the index where the animation was in the animation list
  100915. */
  100916. removeAnimation(toRemove: Animation): number;
  100917. /**
  100918. * Will stop the animation of the given target
  100919. * @param target - the target
  100920. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  100921. * @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)
  100922. */
  100923. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  100924. /**
  100925. * Removes the given animation group from this scene.
  100926. * @param toRemove The animation group to remove
  100927. * @returns The index of the removed animation group
  100928. */
  100929. removeAnimationGroup(toRemove: AnimationGroup): number;
  100930. /**
  100931. * Removes the given multi-material from this scene.
  100932. * @param toRemove The multi-material to remove
  100933. * @returns The index of the removed multi-material
  100934. */
  100935. removeMultiMaterial(toRemove: MultiMaterial): number;
  100936. /**
  100937. * Removes the given material from this scene.
  100938. * @param toRemove The material to remove
  100939. * @returns The index of the removed material
  100940. */
  100941. removeMaterial(toRemove: Material): number;
  100942. /**
  100943. * Removes the given action manager from this scene.
  100944. * @param toRemove The action manager to remove
  100945. * @returns The index of the removed action manager
  100946. */
  100947. removeActionManager(toRemove: AbstractActionManager): number;
  100948. /**
  100949. * Removes the given texture from this scene.
  100950. * @param toRemove The texture to remove
  100951. * @returns The index of the removed texture
  100952. */
  100953. removeTexture(toRemove: BaseTexture): number;
  100954. /**
  100955. * Adds the given light to this scene
  100956. * @param newLight The light to add
  100957. */
  100958. addLight(newLight: Light): void;
  100959. /**
  100960. * Sorts the list list based on light priorities
  100961. */
  100962. sortLightsByPriority(): void;
  100963. /**
  100964. * Adds the given camera to this scene
  100965. * @param newCamera The camera to add
  100966. */
  100967. addCamera(newCamera: Camera): void;
  100968. /**
  100969. * Adds the given skeleton to this scene
  100970. * @param newSkeleton The skeleton to add
  100971. */
  100972. addSkeleton(newSkeleton: Skeleton): void;
  100973. /**
  100974. * Adds the given particle system to this scene
  100975. * @param newParticleSystem The particle system to add
  100976. */
  100977. addParticleSystem(newParticleSystem: IParticleSystem): void;
  100978. /**
  100979. * Adds the given animation to this scene
  100980. * @param newAnimation The animation to add
  100981. */
  100982. addAnimation(newAnimation: Animation): void;
  100983. /**
  100984. * Adds the given animation group to this scene.
  100985. * @param newAnimationGroup The animation group to add
  100986. */
  100987. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  100988. /**
  100989. * Adds the given multi-material to this scene
  100990. * @param newMultiMaterial The multi-material to add
  100991. */
  100992. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  100993. /**
  100994. * Adds the given material to this scene
  100995. * @param newMaterial The material to add
  100996. */
  100997. addMaterial(newMaterial: Material): void;
  100998. /**
  100999. * Adds the given morph target to this scene
  101000. * @param newMorphTargetManager The morph target to add
  101001. */
  101002. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  101003. /**
  101004. * Adds the given geometry to this scene
  101005. * @param newGeometry The geometry to add
  101006. */
  101007. addGeometry(newGeometry: Geometry): void;
  101008. /**
  101009. * Adds the given action manager to this scene
  101010. * @param newActionManager The action manager to add
  101011. */
  101012. addActionManager(newActionManager: AbstractActionManager): void;
  101013. /**
  101014. * Adds the given texture to this scene.
  101015. * @param newTexture The texture to add
  101016. */
  101017. addTexture(newTexture: BaseTexture): void;
  101018. /**
  101019. * Switch active camera
  101020. * @param newCamera defines the new active camera
  101021. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  101022. */
  101023. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  101024. /**
  101025. * sets the active camera of the scene using its ID
  101026. * @param id defines the camera's ID
  101027. * @return the new active camera or null if none found.
  101028. */
  101029. setActiveCameraByID(id: string): Nullable<Camera>;
  101030. /**
  101031. * sets the active camera of the scene using its name
  101032. * @param name defines the camera's name
  101033. * @returns the new active camera or null if none found.
  101034. */
  101035. setActiveCameraByName(name: string): Nullable<Camera>;
  101036. /**
  101037. * get an animation group using its name
  101038. * @param name defines the material's name
  101039. * @return the animation group or null if none found.
  101040. */
  101041. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  101042. /**
  101043. * Get a material using its unique id
  101044. * @param uniqueId defines the material's unique id
  101045. * @return the material or null if none found.
  101046. */
  101047. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  101048. /**
  101049. * get a material using its id
  101050. * @param id defines the material's ID
  101051. * @return the material or null if none found.
  101052. */
  101053. getMaterialByID(id: string): Nullable<Material>;
  101054. /**
  101055. * Gets a the last added material using a given id
  101056. * @param id defines the material's ID
  101057. * @return the last material with the given id or null if none found.
  101058. */
  101059. getLastMaterialByID(id: string): Nullable<Material>;
  101060. /**
  101061. * Gets a material using its name
  101062. * @param name defines the material's name
  101063. * @return the material or null if none found.
  101064. */
  101065. getMaterialByName(name: string): Nullable<Material>;
  101066. /**
  101067. * Get a texture using its unique id
  101068. * @param uniqueId defines the texture's unique id
  101069. * @return the texture or null if none found.
  101070. */
  101071. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  101072. /**
  101073. * Gets a camera using its id
  101074. * @param id defines the id to look for
  101075. * @returns the camera or null if not found
  101076. */
  101077. getCameraByID(id: string): Nullable<Camera>;
  101078. /**
  101079. * Gets a camera using its unique id
  101080. * @param uniqueId defines the unique id to look for
  101081. * @returns the camera or null if not found
  101082. */
  101083. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  101084. /**
  101085. * Gets a camera using its name
  101086. * @param name defines the camera's name
  101087. * @return the camera or null if none found.
  101088. */
  101089. getCameraByName(name: string): Nullable<Camera>;
  101090. /**
  101091. * Gets a bone using its id
  101092. * @param id defines the bone's id
  101093. * @return the bone or null if not found
  101094. */
  101095. getBoneByID(id: string): Nullable<Bone>;
  101096. /**
  101097. * Gets a bone using its id
  101098. * @param name defines the bone's name
  101099. * @return the bone or null if not found
  101100. */
  101101. getBoneByName(name: string): Nullable<Bone>;
  101102. /**
  101103. * Gets a light node using its name
  101104. * @param name defines the the light's name
  101105. * @return the light or null if none found.
  101106. */
  101107. getLightByName(name: string): Nullable<Light>;
  101108. /**
  101109. * Gets a light node using its id
  101110. * @param id defines the light's id
  101111. * @return the light or null if none found.
  101112. */
  101113. getLightByID(id: string): Nullable<Light>;
  101114. /**
  101115. * Gets a light node using its scene-generated unique ID
  101116. * @param uniqueId defines the light's unique id
  101117. * @return the light or null if none found.
  101118. */
  101119. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  101120. /**
  101121. * Gets a particle system by id
  101122. * @param id defines the particle system id
  101123. * @return the corresponding system or null if none found
  101124. */
  101125. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  101126. /**
  101127. * Gets a geometry using its ID
  101128. * @param id defines the geometry's id
  101129. * @return the geometry or null if none found.
  101130. */
  101131. getGeometryByID(id: string): Nullable<Geometry>;
  101132. private _getGeometryByUniqueID;
  101133. /**
  101134. * Add a new geometry to this scene
  101135. * @param geometry defines the geometry to be added to the scene.
  101136. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  101137. * @return a boolean defining if the geometry was added or not
  101138. */
  101139. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  101140. /**
  101141. * Removes an existing geometry
  101142. * @param geometry defines the geometry to be removed from the scene
  101143. * @return a boolean defining if the geometry was removed or not
  101144. */
  101145. removeGeometry(geometry: Geometry): boolean;
  101146. /**
  101147. * Gets the list of geometries attached to the scene
  101148. * @returns an array of Geometry
  101149. */
  101150. getGeometries(): Geometry[];
  101151. /**
  101152. * Gets the first added mesh found of a given ID
  101153. * @param id defines the id to search for
  101154. * @return the mesh found or null if not found at all
  101155. */
  101156. getMeshByID(id: string): Nullable<AbstractMesh>;
  101157. /**
  101158. * Gets a list of meshes using their id
  101159. * @param id defines the id to search for
  101160. * @returns a list of meshes
  101161. */
  101162. getMeshesByID(id: string): Array<AbstractMesh>;
  101163. /**
  101164. * Gets the first added transform node found of a given ID
  101165. * @param id defines the id to search for
  101166. * @return the found transform node or null if not found at all.
  101167. */
  101168. getTransformNodeByID(id: string): Nullable<TransformNode>;
  101169. /**
  101170. * Gets a transform node with its auto-generated unique id
  101171. * @param uniqueId efines the unique id to search for
  101172. * @return the found transform node or null if not found at all.
  101173. */
  101174. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  101175. /**
  101176. * Gets a list of transform nodes using their id
  101177. * @param id defines the id to search for
  101178. * @returns a list of transform nodes
  101179. */
  101180. getTransformNodesByID(id: string): Array<TransformNode>;
  101181. /**
  101182. * Gets a mesh with its auto-generated unique id
  101183. * @param uniqueId defines the unique id to search for
  101184. * @return the found mesh or null if not found at all.
  101185. */
  101186. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  101187. /**
  101188. * Gets a the last added mesh using a given id
  101189. * @param id defines the id to search for
  101190. * @return the found mesh or null if not found at all.
  101191. */
  101192. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  101193. /**
  101194. * Gets a the last added node (Mesh, Camera, Light) using a given id
  101195. * @param id defines the id to search for
  101196. * @return the found node or null if not found at all
  101197. */
  101198. getLastEntryByID(id: string): Nullable<Node>;
  101199. /**
  101200. * Gets a node (Mesh, Camera, Light) using a given id
  101201. * @param id defines the id to search for
  101202. * @return the found node or null if not found at all
  101203. */
  101204. getNodeByID(id: string): Nullable<Node>;
  101205. /**
  101206. * Gets a node (Mesh, Camera, Light) using a given name
  101207. * @param name defines the name to search for
  101208. * @return the found node or null if not found at all.
  101209. */
  101210. getNodeByName(name: string): Nullable<Node>;
  101211. /**
  101212. * Gets a mesh using a given name
  101213. * @param name defines the name to search for
  101214. * @return the found mesh or null if not found at all.
  101215. */
  101216. getMeshByName(name: string): Nullable<AbstractMesh>;
  101217. /**
  101218. * Gets a transform node using a given name
  101219. * @param name defines the name to search for
  101220. * @return the found transform node or null if not found at all.
  101221. */
  101222. getTransformNodeByName(name: string): Nullable<TransformNode>;
  101223. /**
  101224. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  101225. * @param id defines the id to search for
  101226. * @return the found skeleton or null if not found at all.
  101227. */
  101228. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  101229. /**
  101230. * Gets a skeleton using a given auto generated unique id
  101231. * @param uniqueId defines the unique id to search for
  101232. * @return the found skeleton or null if not found at all.
  101233. */
  101234. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  101235. /**
  101236. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  101237. * @param id defines the id to search for
  101238. * @return the found skeleton or null if not found at all.
  101239. */
  101240. getSkeletonById(id: string): Nullable<Skeleton>;
  101241. /**
  101242. * Gets a skeleton using a given name
  101243. * @param name defines the name to search for
  101244. * @return the found skeleton or null if not found at all.
  101245. */
  101246. getSkeletonByName(name: string): Nullable<Skeleton>;
  101247. /**
  101248. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  101249. * @param id defines the id to search for
  101250. * @return the found morph target manager or null if not found at all.
  101251. */
  101252. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  101253. /**
  101254. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  101255. * @param id defines the id to search for
  101256. * @return the found morph target or null if not found at all.
  101257. */
  101258. getMorphTargetById(id: string): Nullable<MorphTarget>;
  101259. /**
  101260. * Gets a boolean indicating if the given mesh is active
  101261. * @param mesh defines the mesh to look for
  101262. * @returns true if the mesh is in the active list
  101263. */
  101264. isActiveMesh(mesh: AbstractMesh): boolean;
  101265. /**
  101266. * Return a unique id as a string which can serve as an identifier for the scene
  101267. */
  101268. readonly uid: string;
  101269. /**
  101270. * Add an externaly attached data from its key.
  101271. * This method call will fail and return false, if such key already exists.
  101272. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  101273. * @param key the unique key that identifies the data
  101274. * @param data the data object to associate to the key for this Engine instance
  101275. * @return true if no such key were already present and the data was added successfully, false otherwise
  101276. */
  101277. addExternalData<T>(key: string, data: T): boolean;
  101278. /**
  101279. * Get an externaly attached data from its key
  101280. * @param key the unique key that identifies the data
  101281. * @return the associated data, if present (can be null), or undefined if not present
  101282. */
  101283. getExternalData<T>(key: string): Nullable<T>;
  101284. /**
  101285. * Get an externaly attached data from its key, create it using a factory if it's not already present
  101286. * @param key the unique key that identifies the data
  101287. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  101288. * @return the associated data, can be null if the factory returned null.
  101289. */
  101290. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  101291. /**
  101292. * Remove an externaly attached data from the Engine instance
  101293. * @param key the unique key that identifies the data
  101294. * @return true if the data was successfully removed, false if it doesn't exist
  101295. */
  101296. removeExternalData(key: string): boolean;
  101297. private _evaluateSubMesh;
  101298. /**
  101299. * Clear the processed materials smart array preventing retention point in material dispose.
  101300. */
  101301. freeProcessedMaterials(): void;
  101302. private _preventFreeActiveMeshesAndRenderingGroups;
  101303. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  101304. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  101305. * when disposing several meshes in a row or a hierarchy of meshes.
  101306. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  101307. */
  101308. blockfreeActiveMeshesAndRenderingGroups: boolean;
  101309. /**
  101310. * Clear the active meshes smart array preventing retention point in mesh dispose.
  101311. */
  101312. freeActiveMeshes(): void;
  101313. /**
  101314. * Clear the info related to rendering groups preventing retention points during dispose.
  101315. */
  101316. freeRenderingGroups(): void;
  101317. /** @hidden */
  101318. _isInIntermediateRendering(): boolean;
  101319. /**
  101320. * Lambda returning the list of potentially active meshes.
  101321. */
  101322. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  101323. /**
  101324. * Lambda returning the list of potentially active sub meshes.
  101325. */
  101326. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  101327. /**
  101328. * Lambda returning the list of potentially intersecting sub meshes.
  101329. */
  101330. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  101331. /**
  101332. * Lambda returning the list of potentially colliding sub meshes.
  101333. */
  101334. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  101335. private _activeMeshesFrozen;
  101336. /**
  101337. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  101338. * @returns the current scene
  101339. */
  101340. freezeActiveMeshes(): Scene;
  101341. /**
  101342. * Use this function to restart evaluating active meshes on every frame
  101343. * @returns the current scene
  101344. */
  101345. unfreezeActiveMeshes(): Scene;
  101346. private _evaluateActiveMeshes;
  101347. private _activeMesh;
  101348. /**
  101349. * Update the transform matrix to update from the current active camera
  101350. * @param force defines a boolean used to force the update even if cache is up to date
  101351. */
  101352. updateTransformMatrix(force?: boolean): void;
  101353. private _bindFrameBuffer;
  101354. /** @hidden */
  101355. _allowPostProcessClearColor: boolean;
  101356. /** @hidden */
  101357. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  101358. private _processSubCameras;
  101359. private _checkIntersections;
  101360. /** @hidden */
  101361. _advancePhysicsEngineStep(step: number): void;
  101362. /**
  101363. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  101364. */
  101365. getDeterministicFrameTime: () => number;
  101366. /** @hidden */
  101367. _animate(): void;
  101368. /** Execute all animations (for a frame) */
  101369. animate(): void;
  101370. /**
  101371. * Render the scene
  101372. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  101373. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  101374. */
  101375. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  101376. /**
  101377. * Freeze all materials
  101378. * A frozen material will not be updatable but should be faster to render
  101379. */
  101380. freezeMaterials(): void;
  101381. /**
  101382. * Unfreeze all materials
  101383. * A frozen material will not be updatable but should be faster to render
  101384. */
  101385. unfreezeMaterials(): void;
  101386. /**
  101387. * Releases all held ressources
  101388. */
  101389. dispose(): void;
  101390. /**
  101391. * Gets if the scene is already disposed
  101392. */
  101393. readonly isDisposed: boolean;
  101394. /**
  101395. * Call this function to reduce memory footprint of the scene.
  101396. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  101397. */
  101398. clearCachedVertexData(): void;
  101399. /**
  101400. * This function will remove the local cached buffer data from texture.
  101401. * It will save memory but will prevent the texture from being rebuilt
  101402. */
  101403. cleanCachedTextureBuffer(): void;
  101404. /**
  101405. * Get the world extend vectors with an optional filter
  101406. *
  101407. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  101408. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  101409. */
  101410. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  101411. min: Vector3;
  101412. max: Vector3;
  101413. };
  101414. /**
  101415. * Creates a ray that can be used to pick in the scene
  101416. * @param x defines the x coordinate of the origin (on-screen)
  101417. * @param y defines the y coordinate of the origin (on-screen)
  101418. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101419. * @param camera defines the camera to use for the picking
  101420. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101421. * @returns a Ray
  101422. */
  101423. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  101424. /**
  101425. * Creates a ray that can be used to pick in the scene
  101426. * @param x defines the x coordinate of the origin (on-screen)
  101427. * @param y defines the y coordinate of the origin (on-screen)
  101428. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101429. * @param result defines the ray where to store the picking ray
  101430. * @param camera defines the camera to use for the picking
  101431. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101432. * @returns the current scene
  101433. */
  101434. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  101435. /**
  101436. * Creates a ray that can be used to pick in the scene
  101437. * @param x defines the x coordinate of the origin (on-screen)
  101438. * @param y defines the y coordinate of the origin (on-screen)
  101439. * @param camera defines the camera to use for the picking
  101440. * @returns a Ray
  101441. */
  101442. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  101443. /**
  101444. * Creates a ray that can be used to pick in the scene
  101445. * @param x defines the x coordinate of the origin (on-screen)
  101446. * @param y defines the y coordinate of the origin (on-screen)
  101447. * @param result defines the ray where to store the picking ray
  101448. * @param camera defines the camera to use for the picking
  101449. * @returns the current scene
  101450. */
  101451. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  101452. /** Launch a ray to try to pick a mesh in the scene
  101453. * @param x position on screen
  101454. * @param y position on screen
  101455. * @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
  101456. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  101457. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101458. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101459. * @returns a PickingInfo
  101460. */
  101461. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101462. /** Use the given ray to pick a mesh in the scene
  101463. * @param ray The ray to use to pick meshes
  101464. * @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
  101465. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  101466. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101467. * @returns a PickingInfo
  101468. */
  101469. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101470. /**
  101471. * Launch a ray to try to pick a mesh in the scene
  101472. * @param x X position on screen
  101473. * @param y Y position on screen
  101474. * @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
  101475. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101476. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101477. * @returns an array of PickingInfo
  101478. */
  101479. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101480. /**
  101481. * Launch a ray to try to pick a mesh in the scene
  101482. * @param ray Ray to use
  101483. * @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
  101484. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101485. * @returns an array of PickingInfo
  101486. */
  101487. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101488. /**
  101489. * Force the value of meshUnderPointer
  101490. * @param mesh defines the mesh to use
  101491. */
  101492. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101493. /**
  101494. * Gets the mesh under the pointer
  101495. * @returns a Mesh or null if no mesh is under the pointer
  101496. */
  101497. getPointerOverMesh(): Nullable<AbstractMesh>;
  101498. /** @hidden */
  101499. _rebuildGeometries(): void;
  101500. /** @hidden */
  101501. _rebuildTextures(): void;
  101502. private _getByTags;
  101503. /**
  101504. * Get a list of meshes by tags
  101505. * @param tagsQuery defines the tags query to use
  101506. * @param forEach defines a predicate used to filter results
  101507. * @returns an array of Mesh
  101508. */
  101509. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  101510. /**
  101511. * Get a list of cameras by tags
  101512. * @param tagsQuery defines the tags query to use
  101513. * @param forEach defines a predicate used to filter results
  101514. * @returns an array of Camera
  101515. */
  101516. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  101517. /**
  101518. * Get a list of lights by tags
  101519. * @param tagsQuery defines the tags query to use
  101520. * @param forEach defines a predicate used to filter results
  101521. * @returns an array of Light
  101522. */
  101523. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  101524. /**
  101525. * Get a list of materials by tags
  101526. * @param tagsQuery defines the tags query to use
  101527. * @param forEach defines a predicate used to filter results
  101528. * @returns an array of Material
  101529. */
  101530. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  101531. /**
  101532. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101533. * This allowed control for front to back rendering or reversly depending of the special needs.
  101534. *
  101535. * @param renderingGroupId The rendering group id corresponding to its index
  101536. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101537. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101538. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101539. */
  101540. 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;
  101541. /**
  101542. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101543. *
  101544. * @param renderingGroupId The rendering group id corresponding to its index
  101545. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101546. * @param depth Automatically clears depth between groups if true and autoClear is true.
  101547. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  101548. */
  101549. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  101550. /**
  101551. * Gets the current auto clear configuration for one rendering group of the rendering
  101552. * manager.
  101553. * @param index the rendering group index to get the information for
  101554. * @returns The auto clear setup for the requested rendering group
  101555. */
  101556. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  101557. private _blockMaterialDirtyMechanism;
  101558. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  101559. blockMaterialDirtyMechanism: boolean;
  101560. /**
  101561. * Will flag all materials as dirty to trigger new shader compilation
  101562. * @param flag defines the flag used to specify which material part must be marked as dirty
  101563. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  101564. */
  101565. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  101566. /** @hidden */
  101567. _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;
  101568. /** @hidden */
  101569. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  101570. }
  101571. }
  101572. declare module BABYLON {
  101573. /**
  101574. * Set of assets to keep when moving a scene into an asset container.
  101575. */
  101576. export class KeepAssets extends AbstractScene {
  101577. }
  101578. /**
  101579. * Container with a set of assets that can be added or removed from a scene.
  101580. */
  101581. export class AssetContainer extends AbstractScene {
  101582. /**
  101583. * The scene the AssetContainer belongs to.
  101584. */
  101585. scene: Scene;
  101586. /**
  101587. * Instantiates an AssetContainer.
  101588. * @param scene The scene the AssetContainer belongs to.
  101589. */
  101590. constructor(scene: Scene);
  101591. /**
  101592. * Adds all the assets from the container to the scene.
  101593. */
  101594. addAllToScene(): void;
  101595. /**
  101596. * Removes all the assets in the container from the scene
  101597. */
  101598. removeAllFromScene(): void;
  101599. /**
  101600. * Disposes all the assets in the container
  101601. */
  101602. dispose(): void;
  101603. private _moveAssets;
  101604. /**
  101605. * Removes all the assets contained in the scene and adds them to the container.
  101606. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  101607. */
  101608. moveAllFromScene(keepAssets?: KeepAssets): void;
  101609. /**
  101610. * 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.
  101611. * @returns the root mesh
  101612. */
  101613. createRootMesh(): Mesh;
  101614. }
  101615. }
  101616. declare module BABYLON {
  101617. /**
  101618. * Defines how the parser contract is defined.
  101619. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  101620. */
  101621. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  101622. /**
  101623. * Defines how the individual parser contract is defined.
  101624. * These parser can parse an individual asset
  101625. */
  101626. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  101627. /**
  101628. * Base class of the scene acting as a container for the different elements composing a scene.
  101629. * This class is dynamically extended by the different components of the scene increasing
  101630. * flexibility and reducing coupling
  101631. */
  101632. export abstract class AbstractScene {
  101633. /**
  101634. * Stores the list of available parsers in the application.
  101635. */
  101636. private static _BabylonFileParsers;
  101637. /**
  101638. * Stores the list of available individual parsers in the application.
  101639. */
  101640. private static _IndividualBabylonFileParsers;
  101641. /**
  101642. * Adds a parser in the list of available ones
  101643. * @param name Defines the name of the parser
  101644. * @param parser Defines the parser to add
  101645. */
  101646. static AddParser(name: string, parser: BabylonFileParser): void;
  101647. /**
  101648. * Gets a general parser from the list of avaialble ones
  101649. * @param name Defines the name of the parser
  101650. * @returns the requested parser or null
  101651. */
  101652. static GetParser(name: string): Nullable<BabylonFileParser>;
  101653. /**
  101654. * Adds n individual parser in the list of available ones
  101655. * @param name Defines the name of the parser
  101656. * @param parser Defines the parser to add
  101657. */
  101658. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  101659. /**
  101660. * Gets an individual parser from the list of avaialble ones
  101661. * @param name Defines the name of the parser
  101662. * @returns the requested parser or null
  101663. */
  101664. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  101665. /**
  101666. * Parser json data and populate both a scene and its associated container object
  101667. * @param jsonData Defines the data to parse
  101668. * @param scene Defines the scene to parse the data for
  101669. * @param container Defines the container attached to the parsing sequence
  101670. * @param rootUrl Defines the root url of the data
  101671. */
  101672. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  101673. /**
  101674. * Gets the list of root nodes (ie. nodes with no parent)
  101675. */
  101676. rootNodes: Node[];
  101677. /** All of the cameras added to this scene
  101678. * @see http://doc.babylonjs.com/babylon101/cameras
  101679. */
  101680. cameras: Camera[];
  101681. /**
  101682. * All of the lights added to this scene
  101683. * @see http://doc.babylonjs.com/babylon101/lights
  101684. */
  101685. lights: Light[];
  101686. /**
  101687. * All of the (abstract) meshes added to this scene
  101688. */
  101689. meshes: AbstractMesh[];
  101690. /**
  101691. * The list of skeletons added to the scene
  101692. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101693. */
  101694. skeletons: Skeleton[];
  101695. /**
  101696. * All of the particle systems added to this scene
  101697. * @see http://doc.babylonjs.com/babylon101/particles
  101698. */
  101699. particleSystems: IParticleSystem[];
  101700. /**
  101701. * Gets a list of Animations associated with the scene
  101702. */
  101703. animations: Animation[];
  101704. /**
  101705. * All of the animation groups added to this scene
  101706. * @see http://doc.babylonjs.com/how_to/group
  101707. */
  101708. animationGroups: AnimationGroup[];
  101709. /**
  101710. * All of the multi-materials added to this scene
  101711. * @see http://doc.babylonjs.com/how_to/multi_materials
  101712. */
  101713. multiMaterials: MultiMaterial[];
  101714. /**
  101715. * All of the materials added to this scene
  101716. * In the context of a Scene, it is not supposed to be modified manually.
  101717. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  101718. * Note also that the order of the Material wihin the array is not significant and might change.
  101719. * @see http://doc.babylonjs.com/babylon101/materials
  101720. */
  101721. materials: Material[];
  101722. /**
  101723. * The list of morph target managers added to the scene
  101724. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  101725. */
  101726. morphTargetManagers: MorphTargetManager[];
  101727. /**
  101728. * The list of geometries used in the scene.
  101729. */
  101730. geometries: Geometry[];
  101731. /**
  101732. * All of the tranform nodes added to this scene
  101733. * In the context of a Scene, it is not supposed to be modified manually.
  101734. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  101735. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  101736. * @see http://doc.babylonjs.com/how_to/transformnode
  101737. */
  101738. transformNodes: TransformNode[];
  101739. /**
  101740. * ActionManagers available on the scene.
  101741. */
  101742. actionManagers: AbstractActionManager[];
  101743. /**
  101744. * Textures to keep.
  101745. */
  101746. textures: BaseTexture[];
  101747. /**
  101748. * Environment texture for the scene
  101749. */
  101750. environmentTexture: Nullable<BaseTexture>;
  101751. }
  101752. }
  101753. declare module BABYLON {
  101754. /**
  101755. * Interface used to define options for Sound class
  101756. */
  101757. export interface ISoundOptions {
  101758. /**
  101759. * Does the sound autoplay once loaded.
  101760. */
  101761. autoplay?: boolean;
  101762. /**
  101763. * Does the sound loop after it finishes playing once.
  101764. */
  101765. loop?: boolean;
  101766. /**
  101767. * Sound's volume
  101768. */
  101769. volume?: number;
  101770. /**
  101771. * Is it a spatial sound?
  101772. */
  101773. spatialSound?: boolean;
  101774. /**
  101775. * Maximum distance to hear that sound
  101776. */
  101777. maxDistance?: number;
  101778. /**
  101779. * Uses user defined attenuation function
  101780. */
  101781. useCustomAttenuation?: boolean;
  101782. /**
  101783. * Define the roll off factor of spatial sounds.
  101784. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101785. */
  101786. rolloffFactor?: number;
  101787. /**
  101788. * Define the reference distance the sound should be heard perfectly.
  101789. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101790. */
  101791. refDistance?: number;
  101792. /**
  101793. * Define the distance attenuation model the sound will follow.
  101794. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101795. */
  101796. distanceModel?: string;
  101797. /**
  101798. * Defines the playback speed (1 by default)
  101799. */
  101800. playbackRate?: number;
  101801. /**
  101802. * Defines if the sound is from a streaming source
  101803. */
  101804. streaming?: boolean;
  101805. /**
  101806. * Defines an optional length (in seconds) inside the sound file
  101807. */
  101808. length?: number;
  101809. /**
  101810. * Defines an optional offset (in seconds) inside the sound file
  101811. */
  101812. offset?: number;
  101813. /**
  101814. * If true, URLs will not be required to state the audio file codec to use.
  101815. */
  101816. skipCodecCheck?: boolean;
  101817. }
  101818. /**
  101819. * Defines a sound that can be played in the application.
  101820. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  101821. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101822. */
  101823. export class Sound {
  101824. /**
  101825. * The name of the sound in the scene.
  101826. */
  101827. name: string;
  101828. /**
  101829. * Does the sound autoplay once loaded.
  101830. */
  101831. autoplay: boolean;
  101832. /**
  101833. * Does the sound loop after it finishes playing once.
  101834. */
  101835. loop: boolean;
  101836. /**
  101837. * Does the sound use a custom attenuation curve to simulate the falloff
  101838. * happening when the source gets further away from the camera.
  101839. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101840. */
  101841. useCustomAttenuation: boolean;
  101842. /**
  101843. * The sound track id this sound belongs to.
  101844. */
  101845. soundTrackId: number;
  101846. /**
  101847. * Is this sound currently played.
  101848. */
  101849. isPlaying: boolean;
  101850. /**
  101851. * Is this sound currently paused.
  101852. */
  101853. isPaused: boolean;
  101854. /**
  101855. * Does this sound enables spatial sound.
  101856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101857. */
  101858. spatialSound: boolean;
  101859. /**
  101860. * Define the reference distance the sound should be heard perfectly.
  101861. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101862. */
  101863. refDistance: number;
  101864. /**
  101865. * Define the roll off factor of spatial sounds.
  101866. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101867. */
  101868. rolloffFactor: number;
  101869. /**
  101870. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  101871. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101872. */
  101873. maxDistance: number;
  101874. /**
  101875. * Define the distance attenuation model the sound will follow.
  101876. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101877. */
  101878. distanceModel: string;
  101879. /**
  101880. * @hidden
  101881. * Back Compat
  101882. **/
  101883. onended: () => any;
  101884. /**
  101885. * Observable event when the current playing sound finishes.
  101886. */
  101887. onEndedObservable: Observable<Sound>;
  101888. private _panningModel;
  101889. private _playbackRate;
  101890. private _streaming;
  101891. private _startTime;
  101892. private _startOffset;
  101893. private _position;
  101894. /** @hidden */
  101895. _positionInEmitterSpace: boolean;
  101896. private _localDirection;
  101897. private _volume;
  101898. private _isReadyToPlay;
  101899. private _isDirectional;
  101900. private _readyToPlayCallback;
  101901. private _audioBuffer;
  101902. private _soundSource;
  101903. private _streamingSource;
  101904. private _soundPanner;
  101905. private _soundGain;
  101906. private _inputAudioNode;
  101907. private _outputAudioNode;
  101908. private _coneInnerAngle;
  101909. private _coneOuterAngle;
  101910. private _coneOuterGain;
  101911. private _scene;
  101912. private _connectedTransformNode;
  101913. private _customAttenuationFunction;
  101914. private _registerFunc;
  101915. private _isOutputConnected;
  101916. private _htmlAudioElement;
  101917. private _urlType;
  101918. private _length?;
  101919. private _offset?;
  101920. /** @hidden */
  101921. static _SceneComponentInitialization: (scene: Scene) => void;
  101922. /**
  101923. * Create a sound and attach it to a scene
  101924. * @param name Name of your sound
  101925. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  101926. * @param scene defines the scene the sound belongs to
  101927. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  101928. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  101929. */
  101930. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  101931. /**
  101932. * Release the sound and its associated resources
  101933. */
  101934. dispose(): void;
  101935. /**
  101936. * Gets if the sounds is ready to be played or not.
  101937. * @returns true if ready, otherwise false
  101938. */
  101939. isReady(): boolean;
  101940. private _soundLoaded;
  101941. /**
  101942. * Sets the data of the sound from an audiobuffer
  101943. * @param audioBuffer The audioBuffer containing the data
  101944. */
  101945. setAudioBuffer(audioBuffer: AudioBuffer): void;
  101946. /**
  101947. * Updates the current sounds options such as maxdistance, loop...
  101948. * @param options A JSON object containing values named as the object properties
  101949. */
  101950. updateOptions(options: ISoundOptions): void;
  101951. private _createSpatialParameters;
  101952. private _updateSpatialParameters;
  101953. /**
  101954. * Switch the panning model to HRTF:
  101955. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101956. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101957. */
  101958. switchPanningModelToHRTF(): void;
  101959. /**
  101960. * Switch the panning model to Equal Power:
  101961. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101962. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101963. */
  101964. switchPanningModelToEqualPower(): void;
  101965. private _switchPanningModel;
  101966. /**
  101967. * Connect this sound to a sound track audio node like gain...
  101968. * @param soundTrackAudioNode the sound track audio node to connect to
  101969. */
  101970. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  101971. /**
  101972. * Transform this sound into a directional source
  101973. * @param coneInnerAngle Size of the inner cone in degree
  101974. * @param coneOuterAngle Size of the outer cone in degree
  101975. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  101976. */
  101977. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  101978. /**
  101979. * Gets or sets the inner angle for the directional cone.
  101980. */
  101981. /**
  101982. * Gets or sets the inner angle for the directional cone.
  101983. */
  101984. directionalConeInnerAngle: number;
  101985. /**
  101986. * Gets or sets the outer angle for the directional cone.
  101987. */
  101988. /**
  101989. * Gets or sets the outer angle for the directional cone.
  101990. */
  101991. directionalConeOuterAngle: number;
  101992. /**
  101993. * Sets the position of the emitter if spatial sound is enabled
  101994. * @param newPosition Defines the new posisiton
  101995. */
  101996. setPosition(newPosition: Vector3): void;
  101997. /**
  101998. * Sets the local direction of the emitter if spatial sound is enabled
  101999. * @param newLocalDirection Defines the new local direction
  102000. */
  102001. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  102002. private _updateDirection;
  102003. /** @hidden */
  102004. updateDistanceFromListener(): void;
  102005. /**
  102006. * Sets a new custom attenuation function for the sound.
  102007. * @param callback Defines the function used for the attenuation
  102008. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102009. */
  102010. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  102011. /**
  102012. * Play the sound
  102013. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  102014. * @param offset (optional) Start the sound at a specific time in seconds
  102015. * @param length (optional) Sound duration (in seconds)
  102016. */
  102017. play(time?: number, offset?: number, length?: number): void;
  102018. private _onended;
  102019. /**
  102020. * Stop the sound
  102021. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  102022. */
  102023. stop(time?: number): void;
  102024. /**
  102025. * Put the sound in pause
  102026. */
  102027. pause(): void;
  102028. /**
  102029. * Sets a dedicated volume for this sounds
  102030. * @param newVolume Define the new volume of the sound
  102031. * @param time Define time for gradual change to new volume
  102032. */
  102033. setVolume(newVolume: number, time?: number): void;
  102034. /**
  102035. * Set the sound play back rate
  102036. * @param newPlaybackRate Define the playback rate the sound should be played at
  102037. */
  102038. setPlaybackRate(newPlaybackRate: number): void;
  102039. /**
  102040. * Gets the volume of the sound.
  102041. * @returns the volume of the sound
  102042. */
  102043. getVolume(): number;
  102044. /**
  102045. * Attach the sound to a dedicated mesh
  102046. * @param transformNode The transform node to connect the sound with
  102047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102048. */
  102049. attachToMesh(transformNode: TransformNode): void;
  102050. /**
  102051. * Detach the sound from the previously attached mesh
  102052. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102053. */
  102054. detachFromMesh(): void;
  102055. private _onRegisterAfterWorldMatrixUpdate;
  102056. /**
  102057. * Clone the current sound in the scene.
  102058. * @returns the new sound clone
  102059. */
  102060. clone(): Nullable<Sound>;
  102061. /**
  102062. * Gets the current underlying audio buffer containing the data
  102063. * @returns the audio buffer
  102064. */
  102065. getAudioBuffer(): Nullable<AudioBuffer>;
  102066. /**
  102067. * Serializes the Sound in a JSON representation
  102068. * @returns the JSON representation of the sound
  102069. */
  102070. serialize(): any;
  102071. /**
  102072. * Parse a JSON representation of a sound to innstantiate in a given scene
  102073. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  102074. * @param scene Define the scene the new parsed sound should be created in
  102075. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  102076. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  102077. * @returns the newly parsed sound
  102078. */
  102079. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  102080. }
  102081. }
  102082. declare module BABYLON {
  102083. /**
  102084. * This defines an action helpful to play a defined sound on a triggered action.
  102085. */
  102086. export class PlaySoundAction extends Action {
  102087. private _sound;
  102088. /**
  102089. * Instantiate the action
  102090. * @param triggerOptions defines the trigger options
  102091. * @param sound defines the sound to play
  102092. * @param condition defines the trigger related conditions
  102093. */
  102094. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102095. /** @hidden */
  102096. _prepare(): void;
  102097. /**
  102098. * Execute the action and play the sound.
  102099. */
  102100. execute(): void;
  102101. /**
  102102. * Serializes the actions and its related information.
  102103. * @param parent defines the object to serialize in
  102104. * @returns the serialized object
  102105. */
  102106. serialize(parent: any): any;
  102107. }
  102108. /**
  102109. * This defines an action helpful to stop a defined sound on a triggered action.
  102110. */
  102111. export class StopSoundAction extends Action {
  102112. private _sound;
  102113. /**
  102114. * Instantiate the action
  102115. * @param triggerOptions defines the trigger options
  102116. * @param sound defines the sound to stop
  102117. * @param condition defines the trigger related conditions
  102118. */
  102119. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102120. /** @hidden */
  102121. _prepare(): void;
  102122. /**
  102123. * Execute the action and stop the sound.
  102124. */
  102125. execute(): void;
  102126. /**
  102127. * Serializes the actions and its related information.
  102128. * @param parent defines the object to serialize in
  102129. * @returns the serialized object
  102130. */
  102131. serialize(parent: any): any;
  102132. }
  102133. }
  102134. declare module BABYLON {
  102135. /**
  102136. * This defines an action responsible to change the value of a property
  102137. * by interpolating between its current value and the newly set one once triggered.
  102138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102139. */
  102140. export class InterpolateValueAction extends Action {
  102141. /**
  102142. * Defines the path of the property where the value should be interpolated
  102143. */
  102144. propertyPath: string;
  102145. /**
  102146. * Defines the target value at the end of the interpolation.
  102147. */
  102148. value: any;
  102149. /**
  102150. * Defines the time it will take for the property to interpolate to the value.
  102151. */
  102152. duration: number;
  102153. /**
  102154. * Defines if the other scene animations should be stopped when the action has been triggered
  102155. */
  102156. stopOtherAnimations?: boolean;
  102157. /**
  102158. * Defines a callback raised once the interpolation animation has been done.
  102159. */
  102160. onInterpolationDone?: () => void;
  102161. /**
  102162. * Observable triggered once the interpolation animation has been done.
  102163. */
  102164. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  102165. private _target;
  102166. private _effectiveTarget;
  102167. private _property;
  102168. /**
  102169. * Instantiate the action
  102170. * @param triggerOptions defines the trigger options
  102171. * @param target defines the object containing the value to interpolate
  102172. * @param propertyPath defines the path to the property in the target object
  102173. * @param value defines the target value at the end of the interpolation
  102174. * @param duration deines the time it will take for the property to interpolate to the value.
  102175. * @param condition defines the trigger related conditions
  102176. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  102177. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  102178. */
  102179. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  102180. /** @hidden */
  102181. _prepare(): void;
  102182. /**
  102183. * Execute the action starts the value interpolation.
  102184. */
  102185. execute(): void;
  102186. /**
  102187. * Serializes the actions and its related information.
  102188. * @param parent defines the object to serialize in
  102189. * @returns the serialized object
  102190. */
  102191. serialize(parent: any): any;
  102192. }
  102193. }
  102194. declare module BABYLON {
  102195. /**
  102196. * Options allowed during the creation of a sound track.
  102197. */
  102198. export interface ISoundTrackOptions {
  102199. /**
  102200. * The volume the sound track should take during creation
  102201. */
  102202. volume?: number;
  102203. /**
  102204. * Define if the sound track is the main sound track of the scene
  102205. */
  102206. mainTrack?: boolean;
  102207. }
  102208. /**
  102209. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  102210. * It will be also used in a future release to apply effects on a specific track.
  102211. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102212. */
  102213. export class SoundTrack {
  102214. /**
  102215. * The unique identifier of the sound track in the scene.
  102216. */
  102217. id: number;
  102218. /**
  102219. * The list of sounds included in the sound track.
  102220. */
  102221. soundCollection: Array<Sound>;
  102222. private _outputAudioNode;
  102223. private _scene;
  102224. private _isMainTrack;
  102225. private _connectedAnalyser;
  102226. private _options;
  102227. private _isInitialized;
  102228. /**
  102229. * Creates a new sound track.
  102230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102231. * @param scene Define the scene the sound track belongs to
  102232. * @param options
  102233. */
  102234. constructor(scene: Scene, options?: ISoundTrackOptions);
  102235. private _initializeSoundTrackAudioGraph;
  102236. /**
  102237. * Release the sound track and its associated resources
  102238. */
  102239. dispose(): void;
  102240. /**
  102241. * Adds a sound to this sound track
  102242. * @param sound define the cound to add
  102243. * @ignoreNaming
  102244. */
  102245. AddSound(sound: Sound): void;
  102246. /**
  102247. * Removes a sound to this sound track
  102248. * @param sound define the cound to remove
  102249. * @ignoreNaming
  102250. */
  102251. RemoveSound(sound: Sound): void;
  102252. /**
  102253. * Set a global volume for the full sound track.
  102254. * @param newVolume Define the new volume of the sound track
  102255. */
  102256. setVolume(newVolume: number): void;
  102257. /**
  102258. * Switch the panning model to HRTF:
  102259. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102261. */
  102262. switchPanningModelToHRTF(): void;
  102263. /**
  102264. * Switch the panning model to Equal Power:
  102265. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102266. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102267. */
  102268. switchPanningModelToEqualPower(): void;
  102269. /**
  102270. * Connect the sound track to an audio analyser allowing some amazing
  102271. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  102272. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  102273. * @param analyser The analyser to connect to the engine
  102274. */
  102275. connectToAnalyser(analyser: Analyser): void;
  102276. }
  102277. }
  102278. declare module BABYLON {
  102279. interface AbstractScene {
  102280. /**
  102281. * The list of sounds used in the scene.
  102282. */
  102283. sounds: Nullable<Array<Sound>>;
  102284. }
  102285. interface Scene {
  102286. /**
  102287. * @hidden
  102288. * Backing field
  102289. */
  102290. _mainSoundTrack: SoundTrack;
  102291. /**
  102292. * The main sound track played by the scene.
  102293. * It cotains your primary collection of sounds.
  102294. */
  102295. mainSoundTrack: SoundTrack;
  102296. /**
  102297. * The list of sound tracks added to the scene
  102298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102299. */
  102300. soundTracks: Nullable<Array<SoundTrack>>;
  102301. /**
  102302. * Gets a sound using a given name
  102303. * @param name defines the name to search for
  102304. * @return the found sound or null if not found at all.
  102305. */
  102306. getSoundByName(name: string): Nullable<Sound>;
  102307. /**
  102308. * Gets or sets if audio support is enabled
  102309. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102310. */
  102311. audioEnabled: boolean;
  102312. /**
  102313. * Gets or sets if audio will be output to headphones
  102314. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102315. */
  102316. headphone: boolean;
  102317. /**
  102318. * Gets or sets custom audio listener position provider
  102319. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102320. */
  102321. audioListenerPositionProvider: Nullable<() => Vector3>;
  102322. }
  102323. /**
  102324. * Defines the sound scene component responsible to manage any sounds
  102325. * in a given scene.
  102326. */
  102327. export class AudioSceneComponent implements ISceneSerializableComponent {
  102328. /**
  102329. * The component name helpfull to identify the component in the list of scene components.
  102330. */
  102331. readonly name: string;
  102332. /**
  102333. * The scene the component belongs to.
  102334. */
  102335. scene: Scene;
  102336. private _audioEnabled;
  102337. /**
  102338. * Gets whether audio is enabled or not.
  102339. * Please use related enable/disable method to switch state.
  102340. */
  102341. readonly audioEnabled: boolean;
  102342. private _headphone;
  102343. /**
  102344. * Gets whether audio is outputing to headphone or not.
  102345. * Please use the according Switch methods to change output.
  102346. */
  102347. readonly headphone: boolean;
  102348. private _audioListenerPositionProvider;
  102349. /**
  102350. * Gets the current audio listener position provider
  102351. */
  102352. /**
  102353. * Sets a custom listener position for all sounds in the scene
  102354. * By default, this is the position of the first active camera
  102355. */
  102356. audioListenerPositionProvider: Nullable<() => Vector3>;
  102357. /**
  102358. * Creates a new instance of the component for the given scene
  102359. * @param scene Defines the scene to register the component in
  102360. */
  102361. constructor(scene: Scene);
  102362. /**
  102363. * Registers the component in a given scene
  102364. */
  102365. register(): void;
  102366. /**
  102367. * Rebuilds the elements related to this component in case of
  102368. * context lost for instance.
  102369. */
  102370. rebuild(): void;
  102371. /**
  102372. * Serializes the component data to the specified json object
  102373. * @param serializationObject The object to serialize to
  102374. */
  102375. serialize(serializationObject: any): void;
  102376. /**
  102377. * Adds all the elements from the container to the scene
  102378. * @param container the container holding the elements
  102379. */
  102380. addFromContainer(container: AbstractScene): void;
  102381. /**
  102382. * Removes all the elements in the container from the scene
  102383. * @param container contains the elements to remove
  102384. * @param dispose if the removed element should be disposed (default: false)
  102385. */
  102386. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  102387. /**
  102388. * Disposes the component and the associated ressources.
  102389. */
  102390. dispose(): void;
  102391. /**
  102392. * Disables audio in the associated scene.
  102393. */
  102394. disableAudio(): void;
  102395. /**
  102396. * Enables audio in the associated scene.
  102397. */
  102398. enableAudio(): void;
  102399. /**
  102400. * Switch audio to headphone output.
  102401. */
  102402. switchAudioModeForHeadphones(): void;
  102403. /**
  102404. * Switch audio to normal speakers.
  102405. */
  102406. switchAudioModeForNormalSpeakers(): void;
  102407. private _afterRender;
  102408. }
  102409. }
  102410. declare module BABYLON {
  102411. /**
  102412. * Wraps one or more Sound objects and selects one with random weight for playback.
  102413. */
  102414. export class WeightedSound {
  102415. /** When true a Sound will be selected and played when the current playing Sound completes. */
  102416. loop: boolean;
  102417. private _coneInnerAngle;
  102418. private _coneOuterAngle;
  102419. private _volume;
  102420. /** A Sound is currently playing. */
  102421. isPlaying: boolean;
  102422. /** A Sound is currently paused. */
  102423. isPaused: boolean;
  102424. private _sounds;
  102425. private _weights;
  102426. private _currentIndex?;
  102427. /**
  102428. * Creates a new WeightedSound from the list of sounds given.
  102429. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  102430. * @param sounds Array of Sounds that will be selected from.
  102431. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  102432. */
  102433. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  102434. /**
  102435. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  102436. */
  102437. /**
  102438. * The size of cone in degress for a directional sound in which there will be no attenuation.
  102439. */
  102440. directionalConeInnerAngle: number;
  102441. /**
  102442. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102443. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102444. */
  102445. /**
  102446. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102447. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102448. */
  102449. directionalConeOuterAngle: number;
  102450. /**
  102451. * Playback volume.
  102452. */
  102453. /**
  102454. * Playback volume.
  102455. */
  102456. volume: number;
  102457. private _onended;
  102458. /**
  102459. * Suspend playback
  102460. */
  102461. pause(): void;
  102462. /**
  102463. * Stop playback
  102464. */
  102465. stop(): void;
  102466. /**
  102467. * Start playback.
  102468. * @param startOffset Position the clip head at a specific time in seconds.
  102469. */
  102470. play(startOffset?: number): void;
  102471. }
  102472. }
  102473. declare module BABYLON {
  102474. /**
  102475. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  102476. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102477. */
  102478. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  102479. /**
  102480. * Gets the name of the behavior.
  102481. */
  102482. readonly name: string;
  102483. /**
  102484. * The easing function used by animations
  102485. */
  102486. static EasingFunction: BackEase;
  102487. /**
  102488. * The easing mode used by animations
  102489. */
  102490. static EasingMode: number;
  102491. /**
  102492. * The duration of the animation, in milliseconds
  102493. */
  102494. transitionDuration: number;
  102495. /**
  102496. * Length of the distance animated by the transition when lower radius is reached
  102497. */
  102498. lowerRadiusTransitionRange: number;
  102499. /**
  102500. * Length of the distance animated by the transition when upper radius is reached
  102501. */
  102502. upperRadiusTransitionRange: number;
  102503. private _autoTransitionRange;
  102504. /**
  102505. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102506. */
  102507. /**
  102508. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102509. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  102510. */
  102511. autoTransitionRange: boolean;
  102512. private _attachedCamera;
  102513. private _onAfterCheckInputsObserver;
  102514. private _onMeshTargetChangedObserver;
  102515. /**
  102516. * Initializes the behavior.
  102517. */
  102518. init(): void;
  102519. /**
  102520. * Attaches the behavior to its arc rotate camera.
  102521. * @param camera Defines the camera to attach the behavior to
  102522. */
  102523. attach(camera: ArcRotateCamera): void;
  102524. /**
  102525. * Detaches the behavior from its current arc rotate camera.
  102526. */
  102527. detach(): void;
  102528. private _radiusIsAnimating;
  102529. private _radiusBounceTransition;
  102530. private _animatables;
  102531. private _cachedWheelPrecision;
  102532. /**
  102533. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  102534. * @param radiusLimit The limit to check against.
  102535. * @return Bool to indicate if at limit.
  102536. */
  102537. private _isRadiusAtLimit;
  102538. /**
  102539. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  102540. * @param radiusDelta The delta by which to animate to. Can be negative.
  102541. */
  102542. private _applyBoundRadiusAnimation;
  102543. /**
  102544. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  102545. */
  102546. protected _clearAnimationLocks(): void;
  102547. /**
  102548. * Stops and removes all animations that have been applied to the camera
  102549. */
  102550. stopAllAnimations(): void;
  102551. }
  102552. }
  102553. declare module BABYLON {
  102554. /**
  102555. * 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.
  102556. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102557. */
  102558. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  102559. /**
  102560. * Gets the name of the behavior.
  102561. */
  102562. readonly name: string;
  102563. private _mode;
  102564. private _radiusScale;
  102565. private _positionScale;
  102566. private _defaultElevation;
  102567. private _elevationReturnTime;
  102568. private _elevationReturnWaitTime;
  102569. private _zoomStopsAnimation;
  102570. private _framingTime;
  102571. /**
  102572. * The easing function used by animations
  102573. */
  102574. static EasingFunction: ExponentialEase;
  102575. /**
  102576. * The easing mode used by animations
  102577. */
  102578. static EasingMode: number;
  102579. /**
  102580. * Sets the current mode used by the behavior
  102581. */
  102582. /**
  102583. * Gets current mode used by the behavior.
  102584. */
  102585. mode: number;
  102586. /**
  102587. * Sets the scale applied to the radius (1 by default)
  102588. */
  102589. /**
  102590. * Gets the scale applied to the radius
  102591. */
  102592. radiusScale: number;
  102593. /**
  102594. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102595. */
  102596. /**
  102597. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102598. */
  102599. positionScale: number;
  102600. /**
  102601. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102602. * behaviour is triggered, in radians.
  102603. */
  102604. /**
  102605. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102606. * behaviour is triggered, in radians.
  102607. */
  102608. defaultElevation: number;
  102609. /**
  102610. * Sets the time (in milliseconds) taken to return to the default beta position.
  102611. * Negative value indicates camera should not return to default.
  102612. */
  102613. /**
  102614. * Gets the time (in milliseconds) taken to return to the default beta position.
  102615. * Negative value indicates camera should not return to default.
  102616. */
  102617. elevationReturnTime: number;
  102618. /**
  102619. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102620. */
  102621. /**
  102622. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102623. */
  102624. elevationReturnWaitTime: number;
  102625. /**
  102626. * Sets the flag that indicates if user zooming should stop animation.
  102627. */
  102628. /**
  102629. * Gets the flag that indicates if user zooming should stop animation.
  102630. */
  102631. zoomStopsAnimation: boolean;
  102632. /**
  102633. * Sets the transition time when framing the mesh, in milliseconds
  102634. */
  102635. /**
  102636. * Gets the transition time when framing the mesh, in milliseconds
  102637. */
  102638. framingTime: number;
  102639. /**
  102640. * Define if the behavior should automatically change the configured
  102641. * camera limits and sensibilities.
  102642. */
  102643. autoCorrectCameraLimitsAndSensibility: boolean;
  102644. private _onPrePointerObservableObserver;
  102645. private _onAfterCheckInputsObserver;
  102646. private _onMeshTargetChangedObserver;
  102647. private _attachedCamera;
  102648. private _isPointerDown;
  102649. private _lastInteractionTime;
  102650. /**
  102651. * Initializes the behavior.
  102652. */
  102653. init(): void;
  102654. /**
  102655. * Attaches the behavior to its arc rotate camera.
  102656. * @param camera Defines the camera to attach the behavior to
  102657. */
  102658. attach(camera: ArcRotateCamera): void;
  102659. /**
  102660. * Detaches the behavior from its current arc rotate camera.
  102661. */
  102662. detach(): void;
  102663. private _animatables;
  102664. private _betaIsAnimating;
  102665. private _betaTransition;
  102666. private _radiusTransition;
  102667. private _vectorTransition;
  102668. /**
  102669. * Targets the given mesh and updates zoom level accordingly.
  102670. * @param mesh The mesh to target.
  102671. * @param radius Optional. If a cached radius position already exists, overrides default.
  102672. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102673. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102674. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102675. */
  102676. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102677. /**
  102678. * Targets the given mesh with its children and updates zoom level accordingly.
  102679. * @param mesh The mesh to target.
  102680. * @param radius Optional. If a cached radius position already exists, overrides default.
  102681. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102682. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102683. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102684. */
  102685. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102686. /**
  102687. * Targets the given meshes with their children and updates zoom level accordingly.
  102688. * @param meshes The mesh to target.
  102689. * @param radius Optional. If a cached radius position already exists, overrides default.
  102690. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102691. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102692. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102693. */
  102694. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102695. /**
  102696. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  102697. * @param minimumWorld Determines the smaller position of the bounding box extend
  102698. * @param maximumWorld Determines the bigger position of the bounding box extend
  102699. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102700. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102701. */
  102702. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102703. /**
  102704. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  102705. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  102706. * frustum width.
  102707. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  102708. * to fully enclose the mesh in the viewing frustum.
  102709. */
  102710. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  102711. /**
  102712. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  102713. * is automatically returned to its default position (expected to be above ground plane).
  102714. */
  102715. private _maintainCameraAboveGround;
  102716. /**
  102717. * Returns the frustum slope based on the canvas ratio and camera FOV
  102718. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  102719. */
  102720. private _getFrustumSlope;
  102721. /**
  102722. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  102723. */
  102724. private _clearAnimationLocks;
  102725. /**
  102726. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102727. */
  102728. private _applyUserInteraction;
  102729. /**
  102730. * Stops and removes all animations that have been applied to the camera
  102731. */
  102732. stopAllAnimations(): void;
  102733. /**
  102734. * Gets a value indicating if the user is moving the camera
  102735. */
  102736. readonly isUserIsMoving: boolean;
  102737. /**
  102738. * The camera can move all the way towards the mesh.
  102739. */
  102740. static IgnoreBoundsSizeMode: number;
  102741. /**
  102742. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  102743. */
  102744. static FitFrustumSidesMode: number;
  102745. }
  102746. }
  102747. declare module BABYLON {
  102748. /**
  102749. * Base class for Camera Pointer Inputs.
  102750. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  102751. * for example usage.
  102752. */
  102753. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  102754. /**
  102755. * Defines the camera the input is attached to.
  102756. */
  102757. abstract camera: Camera;
  102758. /**
  102759. * Whether keyboard modifier keys are pressed at time of last mouse event.
  102760. */
  102761. protected _altKey: boolean;
  102762. protected _ctrlKey: boolean;
  102763. protected _metaKey: boolean;
  102764. protected _shiftKey: boolean;
  102765. /**
  102766. * Which mouse buttons were pressed at time of last mouse event.
  102767. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  102768. */
  102769. protected _buttonsPressed: number;
  102770. /**
  102771. * Defines the buttons associated with the input to handle camera move.
  102772. */
  102773. buttons: number[];
  102774. /**
  102775. * Attach the input controls to a specific dom element to get the input from.
  102776. * @param element Defines the element the controls should be listened from
  102777. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102778. */
  102779. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102780. /**
  102781. * Detach the current controls from the specified dom element.
  102782. * @param element Defines the element to stop listening the inputs from
  102783. */
  102784. detachControl(element: Nullable<HTMLElement>): void;
  102785. /**
  102786. * Gets the class name of the current input.
  102787. * @returns the class name
  102788. */
  102789. getClassName(): string;
  102790. /**
  102791. * Get the friendly name associated with the input class.
  102792. * @returns the input friendly name
  102793. */
  102794. getSimpleName(): string;
  102795. /**
  102796. * Called on pointer POINTERDOUBLETAP event.
  102797. * Override this method to provide functionality on POINTERDOUBLETAP event.
  102798. */
  102799. protected onDoubleTap(type: string): void;
  102800. /**
  102801. * Called on pointer POINTERMOVE event if only a single touch is active.
  102802. * Override this method to provide functionality.
  102803. */
  102804. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102805. /**
  102806. * Called on pointer POINTERMOVE event if multiple touches are active.
  102807. * Override this method to provide functionality.
  102808. */
  102809. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102810. /**
  102811. * Called on JS contextmenu event.
  102812. * Override this method to provide functionality.
  102813. */
  102814. protected onContextMenu(evt: PointerEvent): void;
  102815. /**
  102816. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102817. * press.
  102818. * Override this method to provide functionality.
  102819. */
  102820. protected onButtonDown(evt: PointerEvent): void;
  102821. /**
  102822. * Called each time a new POINTERUP event occurs. Ie, for each button
  102823. * release.
  102824. * Override this method to provide functionality.
  102825. */
  102826. protected onButtonUp(evt: PointerEvent): void;
  102827. /**
  102828. * Called when window becomes inactive.
  102829. * Override this method to provide functionality.
  102830. */
  102831. protected onLostFocus(): void;
  102832. private _pointerInput;
  102833. private _observer;
  102834. private _onLostFocus;
  102835. private pointA;
  102836. private pointB;
  102837. }
  102838. }
  102839. declare module BABYLON {
  102840. /**
  102841. * Manage the pointers inputs to control an arc rotate camera.
  102842. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102843. */
  102844. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  102845. /**
  102846. * Defines the camera the input is attached to.
  102847. */
  102848. camera: ArcRotateCamera;
  102849. /**
  102850. * Gets the class name of the current input.
  102851. * @returns the class name
  102852. */
  102853. getClassName(): string;
  102854. /**
  102855. * Defines the buttons associated with the input to handle camera move.
  102856. */
  102857. buttons: number[];
  102858. /**
  102859. * Defines the pointer angular sensibility along the X axis or how fast is
  102860. * the camera rotating.
  102861. */
  102862. angularSensibilityX: number;
  102863. /**
  102864. * Defines the pointer angular sensibility along the Y axis or how fast is
  102865. * the camera rotating.
  102866. */
  102867. angularSensibilityY: number;
  102868. /**
  102869. * Defines the pointer pinch precision or how fast is the camera zooming.
  102870. */
  102871. pinchPrecision: number;
  102872. /**
  102873. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  102874. * from 0.
  102875. * It defines the percentage of current camera.radius to use as delta when
  102876. * pinch zoom is used.
  102877. */
  102878. pinchDeltaPercentage: number;
  102879. /**
  102880. * Defines the pointer panning sensibility or how fast is the camera moving.
  102881. */
  102882. panningSensibility: number;
  102883. /**
  102884. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  102885. */
  102886. multiTouchPanning: boolean;
  102887. /**
  102888. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  102889. * zoom (pinch) through multitouch.
  102890. */
  102891. multiTouchPanAndZoom: boolean;
  102892. /**
  102893. * Revers pinch action direction.
  102894. */
  102895. pinchInwards: boolean;
  102896. private _isPanClick;
  102897. private _twoFingerActivityCount;
  102898. private _isPinching;
  102899. /**
  102900. * Called on pointer POINTERMOVE event if only a single touch is active.
  102901. */
  102902. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102903. /**
  102904. * Called on pointer POINTERDOUBLETAP event.
  102905. */
  102906. protected onDoubleTap(type: string): void;
  102907. /**
  102908. * Called on pointer POINTERMOVE event if multiple touches are active.
  102909. */
  102910. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102911. /**
  102912. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102913. * press.
  102914. */
  102915. protected onButtonDown(evt: PointerEvent): void;
  102916. /**
  102917. * Called each time a new POINTERUP event occurs. Ie, for each button
  102918. * release.
  102919. */
  102920. protected onButtonUp(evt: PointerEvent): void;
  102921. /**
  102922. * Called when window becomes inactive.
  102923. */
  102924. protected onLostFocus(): void;
  102925. }
  102926. }
  102927. declare module BABYLON {
  102928. /**
  102929. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  102930. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102931. */
  102932. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  102933. /**
  102934. * Defines the camera the input is attached to.
  102935. */
  102936. camera: ArcRotateCamera;
  102937. /**
  102938. * Defines the list of key codes associated with the up action (increase alpha)
  102939. */
  102940. keysUp: number[];
  102941. /**
  102942. * Defines the list of key codes associated with the down action (decrease alpha)
  102943. */
  102944. keysDown: number[];
  102945. /**
  102946. * Defines the list of key codes associated with the left action (increase beta)
  102947. */
  102948. keysLeft: number[];
  102949. /**
  102950. * Defines the list of key codes associated with the right action (decrease beta)
  102951. */
  102952. keysRight: number[];
  102953. /**
  102954. * Defines the list of key codes associated with the reset action.
  102955. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  102956. */
  102957. keysReset: number[];
  102958. /**
  102959. * Defines the panning sensibility of the inputs.
  102960. * (How fast is the camera paning)
  102961. */
  102962. panningSensibility: number;
  102963. /**
  102964. * Defines the zooming sensibility of the inputs.
  102965. * (How fast is the camera zooming)
  102966. */
  102967. zoomingSensibility: number;
  102968. /**
  102969. * Defines wether maintaining the alt key down switch the movement mode from
  102970. * orientation to zoom.
  102971. */
  102972. useAltToZoom: boolean;
  102973. /**
  102974. * Rotation speed of the camera
  102975. */
  102976. angularSpeed: number;
  102977. private _keys;
  102978. private _ctrlPressed;
  102979. private _altPressed;
  102980. private _onCanvasBlurObserver;
  102981. private _onKeyboardObserver;
  102982. private _engine;
  102983. private _scene;
  102984. /**
  102985. * Attach the input controls to a specific dom element to get the input from.
  102986. * @param element Defines the element the controls should be listened from
  102987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102988. */
  102989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102990. /**
  102991. * Detach the current controls from the specified dom element.
  102992. * @param element Defines the element to stop listening the inputs from
  102993. */
  102994. detachControl(element: Nullable<HTMLElement>): void;
  102995. /**
  102996. * Update the current camera state depending on the inputs that have been used this frame.
  102997. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102998. */
  102999. checkInputs(): void;
  103000. /**
  103001. * Gets the class name of the current intput.
  103002. * @returns the class name
  103003. */
  103004. getClassName(): string;
  103005. /**
  103006. * Get the friendly name associated with the input class.
  103007. * @returns the input friendly name
  103008. */
  103009. getSimpleName(): string;
  103010. }
  103011. }
  103012. declare module BABYLON {
  103013. /**
  103014. * Manage the mouse wheel inputs to control an arc rotate camera.
  103015. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103016. */
  103017. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  103018. /**
  103019. * Defines the camera the input is attached to.
  103020. */
  103021. camera: ArcRotateCamera;
  103022. /**
  103023. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103024. */
  103025. wheelPrecision: number;
  103026. /**
  103027. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103028. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103029. */
  103030. wheelDeltaPercentage: number;
  103031. private _wheel;
  103032. private _observer;
  103033. private computeDeltaFromMouseWheelLegacyEvent;
  103034. /**
  103035. * Attach the input controls to a specific dom element to get the input from.
  103036. * @param element Defines the element the controls should be listened from
  103037. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103038. */
  103039. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103040. /**
  103041. * Detach the current controls from the specified dom element.
  103042. * @param element Defines the element to stop listening the inputs from
  103043. */
  103044. detachControl(element: Nullable<HTMLElement>): void;
  103045. /**
  103046. * Gets the class name of the current intput.
  103047. * @returns the class name
  103048. */
  103049. getClassName(): string;
  103050. /**
  103051. * Get the friendly name associated with the input class.
  103052. * @returns the input friendly name
  103053. */
  103054. getSimpleName(): string;
  103055. }
  103056. }
  103057. declare module BABYLON {
  103058. /**
  103059. * Default Inputs manager for the ArcRotateCamera.
  103060. * It groups all the default supported inputs for ease of use.
  103061. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103062. */
  103063. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  103064. /**
  103065. * Instantiates a new ArcRotateCameraInputsManager.
  103066. * @param camera Defines the camera the inputs belong to
  103067. */
  103068. constructor(camera: ArcRotateCamera);
  103069. /**
  103070. * Add mouse wheel input support to the input manager.
  103071. * @returns the current input manager
  103072. */
  103073. addMouseWheel(): ArcRotateCameraInputsManager;
  103074. /**
  103075. * Add pointers input support to the input manager.
  103076. * @returns the current input manager
  103077. */
  103078. addPointers(): ArcRotateCameraInputsManager;
  103079. /**
  103080. * Add keyboard input support to the input manager.
  103081. * @returns the current input manager
  103082. */
  103083. addKeyboard(): ArcRotateCameraInputsManager;
  103084. }
  103085. }
  103086. declare module BABYLON {
  103087. /**
  103088. * This represents an orbital type of camera.
  103089. *
  103090. * 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.
  103091. * 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.
  103092. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  103093. */
  103094. export class ArcRotateCamera extends TargetCamera {
  103095. /**
  103096. * Defines the rotation angle of the camera along the longitudinal axis.
  103097. */
  103098. alpha: number;
  103099. /**
  103100. * Defines the rotation angle of the camera along the latitudinal axis.
  103101. */
  103102. beta: number;
  103103. /**
  103104. * Defines the radius of the camera from it s target point.
  103105. */
  103106. radius: number;
  103107. protected _target: Vector3;
  103108. protected _targetHost: Nullable<AbstractMesh>;
  103109. /**
  103110. * Defines the target point of the camera.
  103111. * The camera looks towards it form the radius distance.
  103112. */
  103113. target: Vector3;
  103114. /**
  103115. * Define the current local position of the camera in the scene
  103116. */
  103117. position: Vector3;
  103118. protected _upVector: Vector3;
  103119. protected _upToYMatrix: Matrix;
  103120. protected _YToUpMatrix: Matrix;
  103121. /**
  103122. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  103123. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  103124. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  103125. */
  103126. upVector: Vector3;
  103127. /**
  103128. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  103129. */
  103130. setMatUp(): void;
  103131. /**
  103132. * Current inertia value on the longitudinal axis.
  103133. * The bigger this number the longer it will take for the camera to stop.
  103134. */
  103135. inertialAlphaOffset: number;
  103136. /**
  103137. * Current inertia value on the latitudinal axis.
  103138. * The bigger this number the longer it will take for the camera to stop.
  103139. */
  103140. inertialBetaOffset: number;
  103141. /**
  103142. * Current inertia value on the radius axis.
  103143. * The bigger this number the longer it will take for the camera to stop.
  103144. */
  103145. inertialRadiusOffset: number;
  103146. /**
  103147. * Minimum allowed angle on the longitudinal axis.
  103148. * This can help limiting how the Camera is able to move in the scene.
  103149. */
  103150. lowerAlphaLimit: Nullable<number>;
  103151. /**
  103152. * Maximum allowed angle on the longitudinal axis.
  103153. * This can help limiting how the Camera is able to move in the scene.
  103154. */
  103155. upperAlphaLimit: Nullable<number>;
  103156. /**
  103157. * Minimum allowed angle on the latitudinal axis.
  103158. * This can help limiting how the Camera is able to move in the scene.
  103159. */
  103160. lowerBetaLimit: number;
  103161. /**
  103162. * Maximum allowed angle on the latitudinal axis.
  103163. * This can help limiting how the Camera is able to move in the scene.
  103164. */
  103165. upperBetaLimit: number;
  103166. /**
  103167. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  103168. * This can help limiting how the Camera is able to move in the scene.
  103169. */
  103170. lowerRadiusLimit: Nullable<number>;
  103171. /**
  103172. * Maximum allowed distance of the camera to the target (The camera can not get further).
  103173. * This can help limiting how the Camera is able to move in the scene.
  103174. */
  103175. upperRadiusLimit: Nullable<number>;
  103176. /**
  103177. * Defines the current inertia value used during panning of the camera along the X axis.
  103178. */
  103179. inertialPanningX: number;
  103180. /**
  103181. * Defines the current inertia value used during panning of the camera along the Y axis.
  103182. */
  103183. inertialPanningY: number;
  103184. /**
  103185. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  103186. * Basically if your fingers moves away from more than this distance you will be considered
  103187. * in pinch mode.
  103188. */
  103189. pinchToPanMaxDistance: number;
  103190. /**
  103191. * Defines the maximum distance the camera can pan.
  103192. * This could help keeping the cammera always in your scene.
  103193. */
  103194. panningDistanceLimit: Nullable<number>;
  103195. /**
  103196. * Defines the target of the camera before paning.
  103197. */
  103198. panningOriginTarget: Vector3;
  103199. /**
  103200. * Defines the value of the inertia used during panning.
  103201. * 0 would mean stop inertia and one would mean no decelleration at all.
  103202. */
  103203. panningInertia: number;
  103204. /**
  103205. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  103206. */
  103207. angularSensibilityX: number;
  103208. /**
  103209. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  103210. */
  103211. angularSensibilityY: number;
  103212. /**
  103213. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  103214. */
  103215. pinchPrecision: number;
  103216. /**
  103217. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  103218. * It will be used instead of pinchDeltaPrecision if different from 0.
  103219. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103220. */
  103221. pinchDeltaPercentage: number;
  103222. /**
  103223. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  103224. */
  103225. panningSensibility: number;
  103226. /**
  103227. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  103228. */
  103229. keysUp: number[];
  103230. /**
  103231. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  103232. */
  103233. keysDown: number[];
  103234. /**
  103235. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  103236. */
  103237. keysLeft: number[];
  103238. /**
  103239. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  103240. */
  103241. keysRight: number[];
  103242. /**
  103243. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103244. */
  103245. wheelPrecision: number;
  103246. /**
  103247. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  103248. * It will be used instead of pinchDeltaPrecision if different from 0.
  103249. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103250. */
  103251. wheelDeltaPercentage: number;
  103252. /**
  103253. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  103254. */
  103255. zoomOnFactor: number;
  103256. /**
  103257. * Defines a screen offset for the camera position.
  103258. */
  103259. targetScreenOffset: Vector2;
  103260. /**
  103261. * Allows the camera to be completely reversed.
  103262. * If false the camera can not arrive upside down.
  103263. */
  103264. allowUpsideDown: boolean;
  103265. /**
  103266. * Define if double tap/click is used to restore the previously saved state of the camera.
  103267. */
  103268. useInputToRestoreState: boolean;
  103269. /** @hidden */
  103270. _viewMatrix: Matrix;
  103271. /** @hidden */
  103272. _useCtrlForPanning: boolean;
  103273. /** @hidden */
  103274. _panningMouseButton: number;
  103275. /**
  103276. * Defines the input associated to the camera.
  103277. */
  103278. inputs: ArcRotateCameraInputsManager;
  103279. /** @hidden */
  103280. _reset: () => void;
  103281. /**
  103282. * Defines the allowed panning axis.
  103283. */
  103284. panningAxis: Vector3;
  103285. protected _localDirection: Vector3;
  103286. protected _transformedDirection: Vector3;
  103287. private _bouncingBehavior;
  103288. /**
  103289. * Gets the bouncing behavior of the camera if it has been enabled.
  103290. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103291. */
  103292. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  103293. /**
  103294. * Defines if the bouncing behavior of the camera is enabled on the camera.
  103295. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103296. */
  103297. useBouncingBehavior: boolean;
  103298. private _framingBehavior;
  103299. /**
  103300. * Gets the framing behavior of the camera if it has been enabled.
  103301. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103302. */
  103303. readonly framingBehavior: Nullable<FramingBehavior>;
  103304. /**
  103305. * Defines if the framing behavior of the camera is enabled on the camera.
  103306. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103307. */
  103308. useFramingBehavior: boolean;
  103309. private _autoRotationBehavior;
  103310. /**
  103311. * Gets the auto rotation behavior of the camera if it has been enabled.
  103312. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103313. */
  103314. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  103315. /**
  103316. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  103317. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103318. */
  103319. useAutoRotationBehavior: boolean;
  103320. /**
  103321. * Observable triggered when the mesh target has been changed on the camera.
  103322. */
  103323. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  103324. /**
  103325. * Event raised when the camera is colliding with a mesh.
  103326. */
  103327. onCollide: (collidedMesh: AbstractMesh) => void;
  103328. /**
  103329. * Defines whether the camera should check collision with the objects oh the scene.
  103330. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  103331. */
  103332. checkCollisions: boolean;
  103333. /**
  103334. * Defines the collision radius of the camera.
  103335. * This simulates a sphere around the camera.
  103336. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103337. */
  103338. collisionRadius: Vector3;
  103339. protected _collider: Collider;
  103340. protected _previousPosition: Vector3;
  103341. protected _collisionVelocity: Vector3;
  103342. protected _newPosition: Vector3;
  103343. protected _previousAlpha: number;
  103344. protected _previousBeta: number;
  103345. protected _previousRadius: number;
  103346. protected _collisionTriggered: boolean;
  103347. protected _targetBoundingCenter: Nullable<Vector3>;
  103348. private _computationVector;
  103349. /**
  103350. * Instantiates a new ArcRotateCamera in a given scene
  103351. * @param name Defines the name of the camera
  103352. * @param alpha Defines the camera rotation along the logitudinal axis
  103353. * @param beta Defines the camera rotation along the latitudinal axis
  103354. * @param radius Defines the camera distance from its target
  103355. * @param target Defines the camera target
  103356. * @param scene Defines the scene the camera belongs to
  103357. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  103358. */
  103359. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103360. /** @hidden */
  103361. _initCache(): void;
  103362. /** @hidden */
  103363. _updateCache(ignoreParentClass?: boolean): void;
  103364. protected _getTargetPosition(): Vector3;
  103365. private _storedAlpha;
  103366. private _storedBeta;
  103367. private _storedRadius;
  103368. private _storedTarget;
  103369. private _storedTargetScreenOffset;
  103370. /**
  103371. * Stores the current state of the camera (alpha, beta, radius and target)
  103372. * @returns the camera itself
  103373. */
  103374. storeState(): Camera;
  103375. /**
  103376. * @hidden
  103377. * Restored camera state. You must call storeState() first
  103378. */
  103379. _restoreStateValues(): boolean;
  103380. /** @hidden */
  103381. _isSynchronizedViewMatrix(): boolean;
  103382. /**
  103383. * Attached controls to the current camera.
  103384. * @param element Defines the element the controls should be listened from
  103385. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103386. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  103387. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  103388. */
  103389. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  103390. /**
  103391. * Detach the current controls from the camera.
  103392. * The camera will stop reacting to inputs.
  103393. * @param element Defines the element to stop listening the inputs from
  103394. */
  103395. detachControl(element: HTMLElement): void;
  103396. /** @hidden */
  103397. _checkInputs(): void;
  103398. protected _checkLimits(): void;
  103399. /**
  103400. * Rebuilds angles (alpha, beta) and radius from the give position and target
  103401. */
  103402. rebuildAnglesAndRadius(): void;
  103403. /**
  103404. * Use a position to define the current camera related information like alpha, beta and radius
  103405. * @param position Defines the position to set the camera at
  103406. */
  103407. setPosition(position: Vector3): void;
  103408. /**
  103409. * Defines the target the camera should look at.
  103410. * This will automatically adapt alpha beta and radius to fit within the new target.
  103411. * @param target Defines the new target as a Vector or a mesh
  103412. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  103413. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  103414. */
  103415. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  103416. /** @hidden */
  103417. _getViewMatrix(): Matrix;
  103418. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  103419. /**
  103420. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  103421. * @param meshes Defines the mesh to zoom on
  103422. * @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)
  103423. */
  103424. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  103425. /**
  103426. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  103427. * The target will be changed but the radius
  103428. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  103429. * @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)
  103430. */
  103431. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  103432. min: Vector3;
  103433. max: Vector3;
  103434. distance: number;
  103435. }, doNotUpdateMaxZ?: boolean): void;
  103436. /**
  103437. * @override
  103438. * Override Camera.createRigCamera
  103439. */
  103440. createRigCamera(name: string, cameraIndex: number): Camera;
  103441. /**
  103442. * @hidden
  103443. * @override
  103444. * Override Camera._updateRigCameras
  103445. */
  103446. _updateRigCameras(): void;
  103447. /**
  103448. * Destroy the camera and release the current resources hold by it.
  103449. */
  103450. dispose(): void;
  103451. /**
  103452. * Gets the current object class name.
  103453. * @return the class name
  103454. */
  103455. getClassName(): string;
  103456. }
  103457. }
  103458. declare module BABYLON {
  103459. /**
  103460. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  103461. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103462. */
  103463. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  103464. /**
  103465. * Gets the name of the behavior.
  103466. */
  103467. readonly name: string;
  103468. private _zoomStopsAnimation;
  103469. private _idleRotationSpeed;
  103470. private _idleRotationWaitTime;
  103471. private _idleRotationSpinupTime;
  103472. /**
  103473. * Sets the flag that indicates if user zooming should stop animation.
  103474. */
  103475. /**
  103476. * Gets the flag that indicates if user zooming should stop animation.
  103477. */
  103478. zoomStopsAnimation: boolean;
  103479. /**
  103480. * Sets the default speed at which the camera rotates around the model.
  103481. */
  103482. /**
  103483. * Gets the default speed at which the camera rotates around the model.
  103484. */
  103485. idleRotationSpeed: number;
  103486. /**
  103487. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  103488. */
  103489. /**
  103490. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  103491. */
  103492. idleRotationWaitTime: number;
  103493. /**
  103494. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103495. */
  103496. /**
  103497. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103498. */
  103499. idleRotationSpinupTime: number;
  103500. /**
  103501. * Gets a value indicating if the camera is currently rotating because of this behavior
  103502. */
  103503. readonly rotationInProgress: boolean;
  103504. private _onPrePointerObservableObserver;
  103505. private _onAfterCheckInputsObserver;
  103506. private _attachedCamera;
  103507. private _isPointerDown;
  103508. private _lastFrameTime;
  103509. private _lastInteractionTime;
  103510. private _cameraRotationSpeed;
  103511. /**
  103512. * Initializes the behavior.
  103513. */
  103514. init(): void;
  103515. /**
  103516. * Attaches the behavior to its arc rotate camera.
  103517. * @param camera Defines the camera to attach the behavior to
  103518. */
  103519. attach(camera: ArcRotateCamera): void;
  103520. /**
  103521. * Detaches the behavior from its current arc rotate camera.
  103522. */
  103523. detach(): void;
  103524. /**
  103525. * Returns true if user is scrolling.
  103526. * @return true if user is scrolling.
  103527. */
  103528. private _userIsZooming;
  103529. private _lastFrameRadius;
  103530. private _shouldAnimationStopForInteraction;
  103531. /**
  103532. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103533. */
  103534. private _applyUserInteraction;
  103535. private _userIsMoving;
  103536. }
  103537. }
  103538. declare module BABYLON {
  103539. /**
  103540. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  103541. */
  103542. export class AttachToBoxBehavior implements Behavior<Mesh> {
  103543. private ui;
  103544. /**
  103545. * The name of the behavior
  103546. */
  103547. name: string;
  103548. /**
  103549. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  103550. */
  103551. distanceAwayFromFace: number;
  103552. /**
  103553. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  103554. */
  103555. distanceAwayFromBottomOfFace: number;
  103556. private _faceVectors;
  103557. private _target;
  103558. private _scene;
  103559. private _onRenderObserver;
  103560. private _tmpMatrix;
  103561. private _tmpVector;
  103562. /**
  103563. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  103564. * @param ui The transform node that should be attched to the mesh
  103565. */
  103566. constructor(ui: TransformNode);
  103567. /**
  103568. * Initializes the behavior
  103569. */
  103570. init(): void;
  103571. private _closestFace;
  103572. private _zeroVector;
  103573. private _lookAtTmpMatrix;
  103574. private _lookAtToRef;
  103575. /**
  103576. * Attaches the AttachToBoxBehavior to the passed in mesh
  103577. * @param target The mesh that the specified node will be attached to
  103578. */
  103579. attach(target: Mesh): void;
  103580. /**
  103581. * Detaches the behavior from the mesh
  103582. */
  103583. detach(): void;
  103584. }
  103585. }
  103586. declare module BABYLON {
  103587. /**
  103588. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  103589. */
  103590. export class FadeInOutBehavior implements Behavior<Mesh> {
  103591. /**
  103592. * Time in milliseconds to delay before fading in (Default: 0)
  103593. */
  103594. delay: number;
  103595. /**
  103596. * Time in milliseconds for the mesh to fade in (Default: 300)
  103597. */
  103598. fadeInTime: number;
  103599. private _millisecondsPerFrame;
  103600. private _hovered;
  103601. private _hoverValue;
  103602. private _ownerNode;
  103603. /**
  103604. * Instatiates the FadeInOutBehavior
  103605. */
  103606. constructor();
  103607. /**
  103608. * The name of the behavior
  103609. */
  103610. readonly name: string;
  103611. /**
  103612. * Initializes the behavior
  103613. */
  103614. init(): void;
  103615. /**
  103616. * Attaches the fade behavior on the passed in mesh
  103617. * @param ownerNode The mesh that will be faded in/out once attached
  103618. */
  103619. attach(ownerNode: Mesh): void;
  103620. /**
  103621. * Detaches the behavior from the mesh
  103622. */
  103623. detach(): void;
  103624. /**
  103625. * Triggers the mesh to begin fading in or out
  103626. * @param value if the object should fade in or out (true to fade in)
  103627. */
  103628. fadeIn(value: boolean): void;
  103629. private _update;
  103630. private _setAllVisibility;
  103631. }
  103632. }
  103633. declare module BABYLON {
  103634. /**
  103635. * Class containing a set of static utilities functions for managing Pivots
  103636. * @hidden
  103637. */
  103638. export class PivotTools {
  103639. private static _PivotCached;
  103640. private static _OldPivotPoint;
  103641. private static _PivotTranslation;
  103642. private static _PivotTmpVector;
  103643. /** @hidden */
  103644. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  103645. /** @hidden */
  103646. static _RestorePivotPoint(mesh: AbstractMesh): void;
  103647. }
  103648. }
  103649. declare module BABYLON {
  103650. /**
  103651. * Class containing static functions to help procedurally build meshes
  103652. */
  103653. export class PlaneBuilder {
  103654. /**
  103655. * Creates a plane mesh
  103656. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  103657. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  103658. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  103659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103660. * * 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
  103661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103662. * @param name defines the name of the mesh
  103663. * @param options defines the options used to create the mesh
  103664. * @param scene defines the hosting scene
  103665. * @returns the plane mesh
  103666. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  103667. */
  103668. static CreatePlane(name: string, options: {
  103669. size?: number;
  103670. width?: number;
  103671. height?: number;
  103672. sideOrientation?: number;
  103673. frontUVs?: Vector4;
  103674. backUVs?: Vector4;
  103675. updatable?: boolean;
  103676. sourcePlane?: Plane;
  103677. }, scene?: Nullable<Scene>): Mesh;
  103678. }
  103679. }
  103680. declare module BABYLON {
  103681. /**
  103682. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  103683. */
  103684. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  103685. private static _AnyMouseID;
  103686. /**
  103687. * Abstract mesh the behavior is set on
  103688. */
  103689. attachedNode: AbstractMesh;
  103690. private _dragPlane;
  103691. private _scene;
  103692. private _pointerObserver;
  103693. private _beforeRenderObserver;
  103694. private static _planeScene;
  103695. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  103696. /**
  103697. * 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)
  103698. */
  103699. maxDragAngle: number;
  103700. /**
  103701. * @hidden
  103702. */
  103703. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  103704. /**
  103705. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103706. */
  103707. currentDraggingPointerID: number;
  103708. /**
  103709. * The last position where the pointer hit the drag plane in world space
  103710. */
  103711. lastDragPosition: Vector3;
  103712. /**
  103713. * If the behavior is currently in a dragging state
  103714. */
  103715. dragging: boolean;
  103716. /**
  103717. * 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)
  103718. */
  103719. dragDeltaRatio: number;
  103720. /**
  103721. * If the drag plane orientation should be updated during the dragging (Default: true)
  103722. */
  103723. updateDragPlane: boolean;
  103724. private _debugMode;
  103725. private _moving;
  103726. /**
  103727. * Fires each time the attached mesh is dragged with the pointer
  103728. * * delta between last drag position and current drag position in world space
  103729. * * dragDistance along the drag axis
  103730. * * dragPlaneNormal normal of the current drag plane used during the drag
  103731. * * dragPlanePoint in world space where the drag intersects the drag plane
  103732. */
  103733. onDragObservable: Observable<{
  103734. delta: Vector3;
  103735. dragPlanePoint: Vector3;
  103736. dragPlaneNormal: Vector3;
  103737. dragDistance: number;
  103738. pointerId: number;
  103739. }>;
  103740. /**
  103741. * Fires each time a drag begins (eg. mouse down on mesh)
  103742. */
  103743. onDragStartObservable: Observable<{
  103744. dragPlanePoint: Vector3;
  103745. pointerId: number;
  103746. }>;
  103747. /**
  103748. * Fires each time a drag ends (eg. mouse release after drag)
  103749. */
  103750. onDragEndObservable: Observable<{
  103751. dragPlanePoint: Vector3;
  103752. pointerId: number;
  103753. }>;
  103754. /**
  103755. * If the attached mesh should be moved when dragged
  103756. */
  103757. moveAttached: boolean;
  103758. /**
  103759. * If the drag behavior will react to drag events (Default: true)
  103760. */
  103761. enabled: boolean;
  103762. /**
  103763. * If pointer events should start and release the drag (Default: true)
  103764. */
  103765. startAndReleaseDragOnPointerEvents: boolean;
  103766. /**
  103767. * If camera controls should be detached during the drag
  103768. */
  103769. detachCameraControls: boolean;
  103770. /**
  103771. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  103772. */
  103773. useObjectOrienationForDragging: boolean;
  103774. private _options;
  103775. /**
  103776. * Creates a pointer drag behavior that can be attached to a mesh
  103777. * @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)
  103778. */
  103779. constructor(options?: {
  103780. dragAxis?: Vector3;
  103781. dragPlaneNormal?: Vector3;
  103782. });
  103783. /**
  103784. * Predicate to determine if it is valid to move the object to a new position when it is moved
  103785. */
  103786. validateDrag: (targetPosition: Vector3) => boolean;
  103787. /**
  103788. * The name of the behavior
  103789. */
  103790. readonly name: string;
  103791. /**
  103792. * Initializes the behavior
  103793. */
  103794. init(): void;
  103795. private _tmpVector;
  103796. private _alternatePickedPoint;
  103797. private _worldDragAxis;
  103798. private _targetPosition;
  103799. private _attachedElement;
  103800. /**
  103801. * Attaches the drag behavior the passed in mesh
  103802. * @param ownerNode The mesh that will be dragged around once attached
  103803. * @param predicate Predicate to use for pick filtering
  103804. */
  103805. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  103806. /**
  103807. * Force relase the drag action by code.
  103808. */
  103809. releaseDrag(): void;
  103810. private _startDragRay;
  103811. private _lastPointerRay;
  103812. /**
  103813. * Simulates the start of a pointer drag event on the behavior
  103814. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  103815. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  103816. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  103817. */
  103818. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  103819. private _startDrag;
  103820. private _dragDelta;
  103821. private _moveDrag;
  103822. private _pickWithRayOnDragPlane;
  103823. private _pointA;
  103824. private _pointB;
  103825. private _pointC;
  103826. private _lineA;
  103827. private _lineB;
  103828. private _localAxis;
  103829. private _lookAt;
  103830. private _updateDragPlanePosition;
  103831. /**
  103832. * Detaches the behavior from the mesh
  103833. */
  103834. detach(): void;
  103835. }
  103836. }
  103837. declare module BABYLON {
  103838. /**
  103839. * A behavior that when attached to a mesh will allow the mesh to be scaled
  103840. */
  103841. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  103842. private _dragBehaviorA;
  103843. private _dragBehaviorB;
  103844. private _startDistance;
  103845. private _initialScale;
  103846. private _targetScale;
  103847. private _ownerNode;
  103848. private _sceneRenderObserver;
  103849. /**
  103850. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  103851. */
  103852. constructor();
  103853. /**
  103854. * The name of the behavior
  103855. */
  103856. readonly name: string;
  103857. /**
  103858. * Initializes the behavior
  103859. */
  103860. init(): void;
  103861. private _getCurrentDistance;
  103862. /**
  103863. * Attaches the scale behavior the passed in mesh
  103864. * @param ownerNode The mesh that will be scaled around once attached
  103865. */
  103866. attach(ownerNode: Mesh): void;
  103867. /**
  103868. * Detaches the behavior from the mesh
  103869. */
  103870. detach(): void;
  103871. }
  103872. }
  103873. declare module BABYLON {
  103874. /**
  103875. * 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
  103876. */
  103877. export class SixDofDragBehavior implements Behavior<Mesh> {
  103878. private static _virtualScene;
  103879. private _ownerNode;
  103880. private _sceneRenderObserver;
  103881. private _scene;
  103882. private _targetPosition;
  103883. private _virtualOriginMesh;
  103884. private _virtualDragMesh;
  103885. private _pointerObserver;
  103886. private _moving;
  103887. private _startingOrientation;
  103888. /**
  103889. * 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)
  103890. */
  103891. private zDragFactor;
  103892. /**
  103893. * If the object should rotate to face the drag origin
  103894. */
  103895. rotateDraggedObject: boolean;
  103896. /**
  103897. * If the behavior is currently in a dragging state
  103898. */
  103899. dragging: boolean;
  103900. /**
  103901. * 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)
  103902. */
  103903. dragDeltaRatio: number;
  103904. /**
  103905. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103906. */
  103907. currentDraggingPointerID: number;
  103908. /**
  103909. * If camera controls should be detached during the drag
  103910. */
  103911. detachCameraControls: boolean;
  103912. /**
  103913. * Fires each time a drag starts
  103914. */
  103915. onDragStartObservable: Observable<{}>;
  103916. /**
  103917. * Fires each time a drag ends (eg. mouse release after drag)
  103918. */
  103919. onDragEndObservable: Observable<{}>;
  103920. /**
  103921. * 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
  103922. */
  103923. constructor();
  103924. /**
  103925. * The name of the behavior
  103926. */
  103927. readonly name: string;
  103928. /**
  103929. * Initializes the behavior
  103930. */
  103931. init(): void;
  103932. /**
  103933. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  103934. */
  103935. private readonly _pointerCamera;
  103936. /**
  103937. * Attaches the scale behavior the passed in mesh
  103938. * @param ownerNode The mesh that will be scaled around once attached
  103939. */
  103940. attach(ownerNode: Mesh): void;
  103941. /**
  103942. * Detaches the behavior from the mesh
  103943. */
  103944. detach(): void;
  103945. }
  103946. }
  103947. declare module BABYLON {
  103948. /**
  103949. * Class used to apply inverse kinematics to bones
  103950. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  103951. */
  103952. export class BoneIKController {
  103953. private static _tmpVecs;
  103954. private static _tmpQuat;
  103955. private static _tmpMats;
  103956. /**
  103957. * Gets or sets the target mesh
  103958. */
  103959. targetMesh: AbstractMesh;
  103960. /** Gets or sets the mesh used as pole */
  103961. poleTargetMesh: AbstractMesh;
  103962. /**
  103963. * Gets or sets the bone used as pole
  103964. */
  103965. poleTargetBone: Nullable<Bone>;
  103966. /**
  103967. * Gets or sets the target position
  103968. */
  103969. targetPosition: Vector3;
  103970. /**
  103971. * Gets or sets the pole target position
  103972. */
  103973. poleTargetPosition: Vector3;
  103974. /**
  103975. * Gets or sets the pole target local offset
  103976. */
  103977. poleTargetLocalOffset: Vector3;
  103978. /**
  103979. * Gets or sets the pole angle
  103980. */
  103981. poleAngle: number;
  103982. /**
  103983. * Gets or sets the mesh associated with the controller
  103984. */
  103985. mesh: AbstractMesh;
  103986. /**
  103987. * 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)
  103988. */
  103989. slerpAmount: number;
  103990. private _bone1Quat;
  103991. private _bone1Mat;
  103992. private _bone2Ang;
  103993. private _bone1;
  103994. private _bone2;
  103995. private _bone1Length;
  103996. private _bone2Length;
  103997. private _maxAngle;
  103998. private _maxReach;
  103999. private _rightHandedSystem;
  104000. private _bendAxis;
  104001. private _slerping;
  104002. private _adjustRoll;
  104003. /**
  104004. * Gets or sets maximum allowed angle
  104005. */
  104006. maxAngle: number;
  104007. /**
  104008. * Creates a new BoneIKController
  104009. * @param mesh defines the mesh to control
  104010. * @param bone defines the bone to control
  104011. * @param options defines options to set up the controller
  104012. */
  104013. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  104014. targetMesh?: AbstractMesh;
  104015. poleTargetMesh?: AbstractMesh;
  104016. poleTargetBone?: Bone;
  104017. poleTargetLocalOffset?: Vector3;
  104018. poleAngle?: number;
  104019. bendAxis?: Vector3;
  104020. maxAngle?: number;
  104021. slerpAmount?: number;
  104022. });
  104023. private _setMaxAngle;
  104024. /**
  104025. * Force the controller to update the bones
  104026. */
  104027. update(): void;
  104028. }
  104029. }
  104030. declare module BABYLON {
  104031. /**
  104032. * Class used to make a bone look toward a point in space
  104033. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  104034. */
  104035. export class BoneLookController {
  104036. private static _tmpVecs;
  104037. private static _tmpQuat;
  104038. private static _tmpMats;
  104039. /**
  104040. * The target Vector3 that the bone will look at
  104041. */
  104042. target: Vector3;
  104043. /**
  104044. * The mesh that the bone is attached to
  104045. */
  104046. mesh: AbstractMesh;
  104047. /**
  104048. * The bone that will be looking to the target
  104049. */
  104050. bone: Bone;
  104051. /**
  104052. * The up axis of the coordinate system that is used when the bone is rotated
  104053. */
  104054. upAxis: Vector3;
  104055. /**
  104056. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  104057. */
  104058. upAxisSpace: Space;
  104059. /**
  104060. * Used to make an adjustment to the yaw of the bone
  104061. */
  104062. adjustYaw: number;
  104063. /**
  104064. * Used to make an adjustment to the pitch of the bone
  104065. */
  104066. adjustPitch: number;
  104067. /**
  104068. * Used to make an adjustment to the roll of the bone
  104069. */
  104070. adjustRoll: number;
  104071. /**
  104072. * 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)
  104073. */
  104074. slerpAmount: number;
  104075. private _minYaw;
  104076. private _maxYaw;
  104077. private _minPitch;
  104078. private _maxPitch;
  104079. private _minYawSin;
  104080. private _minYawCos;
  104081. private _maxYawSin;
  104082. private _maxYawCos;
  104083. private _midYawConstraint;
  104084. private _minPitchTan;
  104085. private _maxPitchTan;
  104086. private _boneQuat;
  104087. private _slerping;
  104088. private _transformYawPitch;
  104089. private _transformYawPitchInv;
  104090. private _firstFrameSkipped;
  104091. private _yawRange;
  104092. private _fowardAxis;
  104093. /**
  104094. * Gets or sets the minimum yaw angle that the bone can look to
  104095. */
  104096. minYaw: number;
  104097. /**
  104098. * Gets or sets the maximum yaw angle that the bone can look to
  104099. */
  104100. maxYaw: number;
  104101. /**
  104102. * Gets or sets the minimum pitch angle that the bone can look to
  104103. */
  104104. minPitch: number;
  104105. /**
  104106. * Gets or sets the maximum pitch angle that the bone can look to
  104107. */
  104108. maxPitch: number;
  104109. /**
  104110. * Create a BoneLookController
  104111. * @param mesh the mesh that the bone belongs to
  104112. * @param bone the bone that will be looking to the target
  104113. * @param target the target Vector3 to look at
  104114. * @param options optional settings:
  104115. * * maxYaw: the maximum angle the bone will yaw to
  104116. * * minYaw: the minimum angle the bone will yaw to
  104117. * * maxPitch: the maximum angle the bone will pitch to
  104118. * * minPitch: the minimum angle the bone will yaw to
  104119. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  104120. * * upAxis: the up axis of the coordinate system
  104121. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  104122. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  104123. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  104124. * * adjustYaw: used to make an adjustment to the yaw of the bone
  104125. * * adjustPitch: used to make an adjustment to the pitch of the bone
  104126. * * adjustRoll: used to make an adjustment to the roll of the bone
  104127. **/
  104128. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  104129. maxYaw?: number;
  104130. minYaw?: number;
  104131. maxPitch?: number;
  104132. minPitch?: number;
  104133. slerpAmount?: number;
  104134. upAxis?: Vector3;
  104135. upAxisSpace?: Space;
  104136. yawAxis?: Vector3;
  104137. pitchAxis?: Vector3;
  104138. adjustYaw?: number;
  104139. adjustPitch?: number;
  104140. adjustRoll?: number;
  104141. });
  104142. /**
  104143. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  104144. */
  104145. update(): void;
  104146. private _getAngleDiff;
  104147. private _getAngleBetween;
  104148. private _isAngleBetween;
  104149. }
  104150. }
  104151. declare module BABYLON {
  104152. /**
  104153. * Manage the gamepad inputs to control an arc rotate camera.
  104154. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104155. */
  104156. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  104157. /**
  104158. * Defines the camera the input is attached to.
  104159. */
  104160. camera: ArcRotateCamera;
  104161. /**
  104162. * Defines the gamepad the input is gathering event from.
  104163. */
  104164. gamepad: Nullable<Gamepad>;
  104165. /**
  104166. * Defines the gamepad rotation sensiblity.
  104167. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104168. */
  104169. gamepadRotationSensibility: number;
  104170. /**
  104171. * Defines the gamepad move sensiblity.
  104172. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104173. */
  104174. gamepadMoveSensibility: number;
  104175. private _yAxisScale;
  104176. /**
  104177. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  104178. */
  104179. invertYAxis: boolean;
  104180. private _onGamepadConnectedObserver;
  104181. private _onGamepadDisconnectedObserver;
  104182. /**
  104183. * Attach the input controls to a specific dom element to get the input from.
  104184. * @param element Defines the element the controls should be listened from
  104185. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104186. */
  104187. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104188. /**
  104189. * Detach the current controls from the specified dom element.
  104190. * @param element Defines the element to stop listening the inputs from
  104191. */
  104192. detachControl(element: Nullable<HTMLElement>): void;
  104193. /**
  104194. * Update the current camera state depending on the inputs that have been used this frame.
  104195. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104196. */
  104197. checkInputs(): void;
  104198. /**
  104199. * Gets the class name of the current intput.
  104200. * @returns the class name
  104201. */
  104202. getClassName(): string;
  104203. /**
  104204. * Get the friendly name associated with the input class.
  104205. * @returns the input friendly name
  104206. */
  104207. getSimpleName(): string;
  104208. }
  104209. }
  104210. declare module BABYLON {
  104211. interface ArcRotateCameraInputsManager {
  104212. /**
  104213. * Add orientation input support to the input manager.
  104214. * @returns the current input manager
  104215. */
  104216. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  104217. }
  104218. /**
  104219. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  104220. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104221. */
  104222. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  104223. /**
  104224. * Defines the camera the input is attached to.
  104225. */
  104226. camera: ArcRotateCamera;
  104227. /**
  104228. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  104229. */
  104230. alphaCorrection: number;
  104231. /**
  104232. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  104233. */
  104234. gammaCorrection: number;
  104235. private _alpha;
  104236. private _gamma;
  104237. private _dirty;
  104238. private _deviceOrientationHandler;
  104239. /**
  104240. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  104241. */
  104242. constructor();
  104243. /**
  104244. * Attach the input controls to a specific dom element to get the input from.
  104245. * @param element Defines the element the controls should be listened from
  104246. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104247. */
  104248. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104249. /** @hidden */
  104250. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  104251. /**
  104252. * Update the current camera state depending on the inputs that have been used this frame.
  104253. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104254. */
  104255. checkInputs(): void;
  104256. /**
  104257. * Detach the current controls from the specified dom element.
  104258. * @param element Defines the element to stop listening the inputs from
  104259. */
  104260. detachControl(element: Nullable<HTMLElement>): void;
  104261. /**
  104262. * Gets the class name of the current intput.
  104263. * @returns the class name
  104264. */
  104265. getClassName(): string;
  104266. /**
  104267. * Get the friendly name associated with the input class.
  104268. * @returns the input friendly name
  104269. */
  104270. getSimpleName(): string;
  104271. }
  104272. }
  104273. declare module BABYLON {
  104274. /**
  104275. * Listen to mouse events to control the camera.
  104276. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104277. */
  104278. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  104279. /**
  104280. * Defines the camera the input is attached to.
  104281. */
  104282. camera: FlyCamera;
  104283. /**
  104284. * Defines if touch is enabled. (Default is true.)
  104285. */
  104286. touchEnabled: boolean;
  104287. /**
  104288. * Defines the buttons associated with the input to handle camera rotation.
  104289. */
  104290. buttons: number[];
  104291. /**
  104292. * Assign buttons for Yaw control.
  104293. */
  104294. buttonsYaw: number[];
  104295. /**
  104296. * Assign buttons for Pitch control.
  104297. */
  104298. buttonsPitch: number[];
  104299. /**
  104300. * Assign buttons for Roll control.
  104301. */
  104302. buttonsRoll: number[];
  104303. /**
  104304. * Detect if any button is being pressed while mouse is moved.
  104305. * -1 = Mouse locked.
  104306. * 0 = Left button.
  104307. * 1 = Middle Button.
  104308. * 2 = Right Button.
  104309. */
  104310. activeButton: number;
  104311. /**
  104312. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  104313. * Higher values reduce its sensitivity.
  104314. */
  104315. angularSensibility: number;
  104316. private _mousemoveCallback;
  104317. private _observer;
  104318. private _rollObserver;
  104319. private previousPosition;
  104320. private noPreventDefault;
  104321. private element;
  104322. /**
  104323. * Listen to mouse events to control the camera.
  104324. * @param touchEnabled Define if touch is enabled. (Default is true.)
  104325. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104326. */
  104327. constructor(touchEnabled?: boolean);
  104328. /**
  104329. * Attach the mouse control to the HTML DOM element.
  104330. * @param element Defines the element that listens to the input events.
  104331. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  104332. */
  104333. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104334. /**
  104335. * Detach the current controls from the specified dom element.
  104336. * @param element Defines the element to stop listening the inputs from
  104337. */
  104338. detachControl(element: Nullable<HTMLElement>): void;
  104339. /**
  104340. * Gets the class name of the current input.
  104341. * @returns the class name.
  104342. */
  104343. getClassName(): string;
  104344. /**
  104345. * Get the friendly name associated with the input class.
  104346. * @returns the input's friendly name.
  104347. */
  104348. getSimpleName(): string;
  104349. private _pointerInput;
  104350. private _onMouseMove;
  104351. /**
  104352. * Rotate camera by mouse offset.
  104353. */
  104354. private rotateCamera;
  104355. }
  104356. }
  104357. declare module BABYLON {
  104358. /**
  104359. * Default Inputs manager for the FlyCamera.
  104360. * It groups all the default supported inputs for ease of use.
  104361. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104362. */
  104363. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  104364. /**
  104365. * Instantiates a new FlyCameraInputsManager.
  104366. * @param camera Defines the camera the inputs belong to.
  104367. */
  104368. constructor(camera: FlyCamera);
  104369. /**
  104370. * Add keyboard input support to the input manager.
  104371. * @returns the new FlyCameraKeyboardMoveInput().
  104372. */
  104373. addKeyboard(): FlyCameraInputsManager;
  104374. /**
  104375. * Add mouse input support to the input manager.
  104376. * @param touchEnabled Enable touch screen support.
  104377. * @returns the new FlyCameraMouseInput().
  104378. */
  104379. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  104380. }
  104381. }
  104382. declare module BABYLON {
  104383. /**
  104384. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104385. * such as in a 3D Space Shooter or a Flight Simulator.
  104386. */
  104387. export class FlyCamera extends TargetCamera {
  104388. /**
  104389. * Define the collision ellipsoid of the camera.
  104390. * This is helpful for simulating a camera body, like a player's body.
  104391. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104392. */
  104393. ellipsoid: Vector3;
  104394. /**
  104395. * Define an offset for the position of the ellipsoid around the camera.
  104396. * This can be helpful if the camera is attached away from the player's body center,
  104397. * such as at its head.
  104398. */
  104399. ellipsoidOffset: Vector3;
  104400. /**
  104401. * Enable or disable collisions of the camera with the rest of the scene objects.
  104402. */
  104403. checkCollisions: boolean;
  104404. /**
  104405. * Enable or disable gravity on the camera.
  104406. */
  104407. applyGravity: boolean;
  104408. /**
  104409. * Define the current direction the camera is moving to.
  104410. */
  104411. cameraDirection: Vector3;
  104412. /**
  104413. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  104414. * This overrides and empties cameraRotation.
  104415. */
  104416. rotationQuaternion: Quaternion;
  104417. /**
  104418. * Track Roll to maintain the wanted Rolling when looking around.
  104419. */
  104420. _trackRoll: number;
  104421. /**
  104422. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  104423. */
  104424. rollCorrect: number;
  104425. /**
  104426. * Mimic a banked turn, Rolling the camera when Yawing.
  104427. * It's recommended to use rollCorrect = 10 for faster banking correction.
  104428. */
  104429. bankedTurn: boolean;
  104430. /**
  104431. * Limit in radians for how much Roll banking will add. (Default: 90°)
  104432. */
  104433. bankedTurnLimit: number;
  104434. /**
  104435. * Value of 0 disables the banked Roll.
  104436. * Value of 1 is equal to the Yaw angle in radians.
  104437. */
  104438. bankedTurnMultiplier: number;
  104439. /**
  104440. * The inputs manager loads all the input sources, such as keyboard and mouse.
  104441. */
  104442. inputs: FlyCameraInputsManager;
  104443. /**
  104444. * Gets the input sensibility for mouse input.
  104445. * Higher values reduce sensitivity.
  104446. */
  104447. /**
  104448. * Sets the input sensibility for a mouse input.
  104449. * Higher values reduce sensitivity.
  104450. */
  104451. angularSensibility: number;
  104452. /**
  104453. * Get the keys for camera movement forward.
  104454. */
  104455. /**
  104456. * Set the keys for camera movement forward.
  104457. */
  104458. keysForward: number[];
  104459. /**
  104460. * Get the keys for camera movement backward.
  104461. */
  104462. keysBackward: number[];
  104463. /**
  104464. * Get the keys for camera movement up.
  104465. */
  104466. /**
  104467. * Set the keys for camera movement up.
  104468. */
  104469. keysUp: number[];
  104470. /**
  104471. * Get the keys for camera movement down.
  104472. */
  104473. /**
  104474. * Set the keys for camera movement down.
  104475. */
  104476. keysDown: number[];
  104477. /**
  104478. * Get the keys for camera movement left.
  104479. */
  104480. /**
  104481. * Set the keys for camera movement left.
  104482. */
  104483. keysLeft: number[];
  104484. /**
  104485. * Set the keys for camera movement right.
  104486. */
  104487. /**
  104488. * Set the keys for camera movement right.
  104489. */
  104490. keysRight: number[];
  104491. /**
  104492. * Event raised when the camera collides with a mesh in the scene.
  104493. */
  104494. onCollide: (collidedMesh: AbstractMesh) => void;
  104495. private _collider;
  104496. private _needMoveForGravity;
  104497. private _oldPosition;
  104498. private _diffPosition;
  104499. private _newPosition;
  104500. /** @hidden */
  104501. _localDirection: Vector3;
  104502. /** @hidden */
  104503. _transformedDirection: Vector3;
  104504. /**
  104505. * Instantiates a FlyCamera.
  104506. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104507. * such as in a 3D Space Shooter or a Flight Simulator.
  104508. * @param name Define the name of the camera in the scene.
  104509. * @param position Define the starting position of the camera in the scene.
  104510. * @param scene Define the scene the camera belongs to.
  104511. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  104512. */
  104513. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104514. /**
  104515. * Attach a control to the HTML DOM element.
  104516. * @param element Defines the element that listens to the input events.
  104517. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  104518. */
  104519. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104520. /**
  104521. * Detach a control from the HTML DOM element.
  104522. * The camera will stop reacting to that input.
  104523. * @param element Defines the element that listens to the input events.
  104524. */
  104525. detachControl(element: HTMLElement): void;
  104526. private _collisionMask;
  104527. /**
  104528. * Get the mask that the camera ignores in collision events.
  104529. */
  104530. /**
  104531. * Set the mask that the camera ignores in collision events.
  104532. */
  104533. collisionMask: number;
  104534. /** @hidden */
  104535. _collideWithWorld(displacement: Vector3): void;
  104536. /** @hidden */
  104537. private _onCollisionPositionChange;
  104538. /** @hidden */
  104539. _checkInputs(): void;
  104540. /** @hidden */
  104541. _decideIfNeedsToMove(): boolean;
  104542. /** @hidden */
  104543. _updatePosition(): void;
  104544. /**
  104545. * Restore the Roll to its target value at the rate specified.
  104546. * @param rate - Higher means slower restoring.
  104547. * @hidden
  104548. */
  104549. restoreRoll(rate: number): void;
  104550. /**
  104551. * Destroy the camera and release the current resources held by it.
  104552. */
  104553. dispose(): void;
  104554. /**
  104555. * Get the current object class name.
  104556. * @returns the class name.
  104557. */
  104558. getClassName(): string;
  104559. }
  104560. }
  104561. declare module BABYLON {
  104562. /**
  104563. * Listen to keyboard events to control the camera.
  104564. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104565. */
  104566. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  104567. /**
  104568. * Defines the camera the input is attached to.
  104569. */
  104570. camera: FlyCamera;
  104571. /**
  104572. * The list of keyboard keys used to control the forward move of the camera.
  104573. */
  104574. keysForward: number[];
  104575. /**
  104576. * The list of keyboard keys used to control the backward move of the camera.
  104577. */
  104578. keysBackward: number[];
  104579. /**
  104580. * The list of keyboard keys used to control the forward move of the camera.
  104581. */
  104582. keysUp: number[];
  104583. /**
  104584. * The list of keyboard keys used to control the backward move of the camera.
  104585. */
  104586. keysDown: number[];
  104587. /**
  104588. * The list of keyboard keys used to control the right strafe move of the camera.
  104589. */
  104590. keysRight: number[];
  104591. /**
  104592. * The list of keyboard keys used to control the left strafe move of the camera.
  104593. */
  104594. keysLeft: number[];
  104595. private _keys;
  104596. private _onCanvasBlurObserver;
  104597. private _onKeyboardObserver;
  104598. private _engine;
  104599. private _scene;
  104600. /**
  104601. * Attach the input controls to a specific dom element to get the input from.
  104602. * @param element Defines the element the controls should be listened from
  104603. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104604. */
  104605. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104606. /**
  104607. * Detach the current controls from the specified dom element.
  104608. * @param element Defines the element to stop listening the inputs from
  104609. */
  104610. detachControl(element: Nullable<HTMLElement>): void;
  104611. /**
  104612. * Gets the class name of the current intput.
  104613. * @returns the class name
  104614. */
  104615. getClassName(): string;
  104616. /** @hidden */
  104617. _onLostFocus(e: FocusEvent): void;
  104618. /**
  104619. * Get the friendly name associated with the input class.
  104620. * @returns the input friendly name
  104621. */
  104622. getSimpleName(): string;
  104623. /**
  104624. * Update the current camera state depending on the inputs that have been used this frame.
  104625. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104626. */
  104627. checkInputs(): void;
  104628. }
  104629. }
  104630. declare module BABYLON {
  104631. /**
  104632. * Manage the mouse wheel inputs to control a follow camera.
  104633. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104634. */
  104635. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  104636. /**
  104637. * Defines the camera the input is attached to.
  104638. */
  104639. camera: FollowCamera;
  104640. /**
  104641. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  104642. */
  104643. axisControlRadius: boolean;
  104644. /**
  104645. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  104646. */
  104647. axisControlHeight: boolean;
  104648. /**
  104649. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  104650. */
  104651. axisControlRotation: boolean;
  104652. /**
  104653. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  104654. * relation to mouseWheel events.
  104655. */
  104656. wheelPrecision: number;
  104657. /**
  104658. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104659. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104660. */
  104661. wheelDeltaPercentage: number;
  104662. private _wheel;
  104663. private _observer;
  104664. /**
  104665. * Attach the input controls to a specific dom element to get the input from.
  104666. * @param element Defines the element the controls should be listened from
  104667. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104668. */
  104669. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104670. /**
  104671. * Detach the current controls from the specified dom element.
  104672. * @param element Defines the element to stop listening the inputs from
  104673. */
  104674. detachControl(element: Nullable<HTMLElement>): void;
  104675. /**
  104676. * Gets the class name of the current intput.
  104677. * @returns the class name
  104678. */
  104679. getClassName(): string;
  104680. /**
  104681. * Get the friendly name associated with the input class.
  104682. * @returns the input friendly name
  104683. */
  104684. getSimpleName(): string;
  104685. }
  104686. }
  104687. declare module BABYLON {
  104688. /**
  104689. * Manage the pointers inputs to control an follow camera.
  104690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104691. */
  104692. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  104693. /**
  104694. * Defines the camera the input is attached to.
  104695. */
  104696. camera: FollowCamera;
  104697. /**
  104698. * Gets the class name of the current input.
  104699. * @returns the class name
  104700. */
  104701. getClassName(): string;
  104702. /**
  104703. * Defines the pointer angular sensibility along the X axis or how fast is
  104704. * the camera rotating.
  104705. * A negative number will reverse the axis direction.
  104706. */
  104707. angularSensibilityX: number;
  104708. /**
  104709. * Defines the pointer angular sensibility along the Y axis or how fast is
  104710. * the camera rotating.
  104711. * A negative number will reverse the axis direction.
  104712. */
  104713. angularSensibilityY: number;
  104714. /**
  104715. * Defines the pointer pinch precision or how fast is the camera zooming.
  104716. * A negative number will reverse the axis direction.
  104717. */
  104718. pinchPrecision: number;
  104719. /**
  104720. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104721. * from 0.
  104722. * It defines the percentage of current camera.radius to use as delta when
  104723. * pinch zoom is used.
  104724. */
  104725. pinchDeltaPercentage: number;
  104726. /**
  104727. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  104728. */
  104729. axisXControlRadius: boolean;
  104730. /**
  104731. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  104732. */
  104733. axisXControlHeight: boolean;
  104734. /**
  104735. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  104736. */
  104737. axisXControlRotation: boolean;
  104738. /**
  104739. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  104740. */
  104741. axisYControlRadius: boolean;
  104742. /**
  104743. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  104744. */
  104745. axisYControlHeight: boolean;
  104746. /**
  104747. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  104748. */
  104749. axisYControlRotation: boolean;
  104750. /**
  104751. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  104752. */
  104753. axisPinchControlRadius: boolean;
  104754. /**
  104755. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  104756. */
  104757. axisPinchControlHeight: boolean;
  104758. /**
  104759. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  104760. */
  104761. axisPinchControlRotation: boolean;
  104762. /**
  104763. * Log error messages if basic misconfiguration has occurred.
  104764. */
  104765. warningEnable: boolean;
  104766. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104767. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104768. private _warningCounter;
  104769. private _warning;
  104770. }
  104771. }
  104772. declare module BABYLON {
  104773. /**
  104774. * Default Inputs manager for the FollowCamera.
  104775. * It groups all the default supported inputs for ease of use.
  104776. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104777. */
  104778. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  104779. /**
  104780. * Instantiates a new FollowCameraInputsManager.
  104781. * @param camera Defines the camera the inputs belong to
  104782. */
  104783. constructor(camera: FollowCamera);
  104784. /**
  104785. * Add keyboard input support to the input manager.
  104786. * @returns the current input manager
  104787. */
  104788. addKeyboard(): FollowCameraInputsManager;
  104789. /**
  104790. * Add mouse wheel input support to the input manager.
  104791. * @returns the current input manager
  104792. */
  104793. addMouseWheel(): FollowCameraInputsManager;
  104794. /**
  104795. * Add pointers input support to the input manager.
  104796. * @returns the current input manager
  104797. */
  104798. addPointers(): FollowCameraInputsManager;
  104799. /**
  104800. * Add orientation input support to the input manager.
  104801. * @returns the current input manager
  104802. */
  104803. addVRDeviceOrientation(): FollowCameraInputsManager;
  104804. }
  104805. }
  104806. declare module BABYLON {
  104807. /**
  104808. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  104809. * an arc rotate version arcFollowCamera are available.
  104810. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104811. */
  104812. export class FollowCamera extends TargetCamera {
  104813. /**
  104814. * Distance the follow camera should follow an object at
  104815. */
  104816. radius: number;
  104817. /**
  104818. * Minimum allowed distance of the camera to the axis of rotation
  104819. * (The camera can not get closer).
  104820. * This can help limiting how the Camera is able to move in the scene.
  104821. */
  104822. lowerRadiusLimit: Nullable<number>;
  104823. /**
  104824. * Maximum allowed distance of the camera to the axis of rotation
  104825. * (The camera can not get further).
  104826. * This can help limiting how the Camera is able to move in the scene.
  104827. */
  104828. upperRadiusLimit: Nullable<number>;
  104829. /**
  104830. * Define a rotation offset between the camera and the object it follows
  104831. */
  104832. rotationOffset: number;
  104833. /**
  104834. * Minimum allowed angle to camera position relative to target object.
  104835. * This can help limiting how the Camera is able to move in the scene.
  104836. */
  104837. lowerRotationOffsetLimit: Nullable<number>;
  104838. /**
  104839. * Maximum allowed angle to camera position relative to target object.
  104840. * This can help limiting how the Camera is able to move in the scene.
  104841. */
  104842. upperRotationOffsetLimit: Nullable<number>;
  104843. /**
  104844. * Define a height offset between the camera and the object it follows.
  104845. * It can help following an object from the top (like a car chaing a plane)
  104846. */
  104847. heightOffset: number;
  104848. /**
  104849. * Minimum allowed height of camera position relative to target object.
  104850. * This can help limiting how the Camera is able to move in the scene.
  104851. */
  104852. lowerHeightOffsetLimit: Nullable<number>;
  104853. /**
  104854. * Maximum allowed height of camera position relative to target object.
  104855. * This can help limiting how the Camera is able to move in the scene.
  104856. */
  104857. upperHeightOffsetLimit: Nullable<number>;
  104858. /**
  104859. * Define how fast the camera can accelerate to follow it s target.
  104860. */
  104861. cameraAcceleration: number;
  104862. /**
  104863. * Define the speed limit of the camera following an object.
  104864. */
  104865. maxCameraSpeed: number;
  104866. /**
  104867. * Define the target of the camera.
  104868. */
  104869. lockedTarget: Nullable<AbstractMesh>;
  104870. /**
  104871. * Defines the input associated with the camera.
  104872. */
  104873. inputs: FollowCameraInputsManager;
  104874. /**
  104875. * Instantiates the follow camera.
  104876. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104877. * @param name Define the name of the camera in the scene
  104878. * @param position Define the position of the camera
  104879. * @param scene Define the scene the camera belong to
  104880. * @param lockedTarget Define the target of the camera
  104881. */
  104882. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  104883. private _follow;
  104884. /**
  104885. * Attached controls to the current camera.
  104886. * @param element Defines the element the controls should be listened from
  104887. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104888. */
  104889. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104890. /**
  104891. * Detach the current controls from the camera.
  104892. * The camera will stop reacting to inputs.
  104893. * @param element Defines the element to stop listening the inputs from
  104894. */
  104895. detachControl(element: HTMLElement): void;
  104896. /** @hidden */
  104897. _checkInputs(): void;
  104898. private _checkLimits;
  104899. /**
  104900. * Gets the camera class name.
  104901. * @returns the class name
  104902. */
  104903. getClassName(): string;
  104904. }
  104905. /**
  104906. * Arc Rotate version of the follow camera.
  104907. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  104908. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104909. */
  104910. export class ArcFollowCamera extends TargetCamera {
  104911. /** The longitudinal angle of the camera */
  104912. alpha: number;
  104913. /** The latitudinal angle of the camera */
  104914. beta: number;
  104915. /** The radius of the camera from its target */
  104916. radius: number;
  104917. /** Define the camera target (the messh it should follow) */
  104918. target: Nullable<AbstractMesh>;
  104919. private _cartesianCoordinates;
  104920. /**
  104921. * Instantiates a new ArcFollowCamera
  104922. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104923. * @param name Define the name of the camera
  104924. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  104925. * @param beta Define the rotation angle of the camera around the elevation axis
  104926. * @param radius Define the radius of the camera from its target point
  104927. * @param target Define the target of the camera
  104928. * @param scene Define the scene the camera belongs to
  104929. */
  104930. constructor(name: string,
  104931. /** The longitudinal angle of the camera */
  104932. alpha: number,
  104933. /** The latitudinal angle of the camera */
  104934. beta: number,
  104935. /** The radius of the camera from its target */
  104936. radius: number,
  104937. /** Define the camera target (the messh it should follow) */
  104938. target: Nullable<AbstractMesh>, scene: Scene);
  104939. private _follow;
  104940. /** @hidden */
  104941. _checkInputs(): void;
  104942. /**
  104943. * Returns the class name of the object.
  104944. * It is mostly used internally for serialization purposes.
  104945. */
  104946. getClassName(): string;
  104947. }
  104948. }
  104949. declare module BABYLON {
  104950. /**
  104951. * Manage the keyboard inputs to control the movement of a follow camera.
  104952. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104953. */
  104954. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  104955. /**
  104956. * Defines the camera the input is attached to.
  104957. */
  104958. camera: FollowCamera;
  104959. /**
  104960. * Defines the list of key codes associated with the up action (increase heightOffset)
  104961. */
  104962. keysHeightOffsetIncr: number[];
  104963. /**
  104964. * Defines the list of key codes associated with the down action (decrease heightOffset)
  104965. */
  104966. keysHeightOffsetDecr: number[];
  104967. /**
  104968. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  104969. */
  104970. keysHeightOffsetModifierAlt: boolean;
  104971. /**
  104972. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  104973. */
  104974. keysHeightOffsetModifierCtrl: boolean;
  104975. /**
  104976. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  104977. */
  104978. keysHeightOffsetModifierShift: boolean;
  104979. /**
  104980. * Defines the list of key codes associated with the left action (increase rotationOffset)
  104981. */
  104982. keysRotationOffsetIncr: number[];
  104983. /**
  104984. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  104985. */
  104986. keysRotationOffsetDecr: number[];
  104987. /**
  104988. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  104989. */
  104990. keysRotationOffsetModifierAlt: boolean;
  104991. /**
  104992. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  104993. */
  104994. keysRotationOffsetModifierCtrl: boolean;
  104995. /**
  104996. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  104997. */
  104998. keysRotationOffsetModifierShift: boolean;
  104999. /**
  105000. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  105001. */
  105002. keysRadiusIncr: number[];
  105003. /**
  105004. * Defines the list of key codes associated with the zoom-out action (increase radius)
  105005. */
  105006. keysRadiusDecr: number[];
  105007. /**
  105008. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  105009. */
  105010. keysRadiusModifierAlt: boolean;
  105011. /**
  105012. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  105013. */
  105014. keysRadiusModifierCtrl: boolean;
  105015. /**
  105016. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  105017. */
  105018. keysRadiusModifierShift: boolean;
  105019. /**
  105020. * Defines the rate of change of heightOffset.
  105021. */
  105022. heightSensibility: number;
  105023. /**
  105024. * Defines the rate of change of rotationOffset.
  105025. */
  105026. rotationSensibility: number;
  105027. /**
  105028. * Defines the rate of change of radius.
  105029. */
  105030. radiusSensibility: number;
  105031. private _keys;
  105032. private _ctrlPressed;
  105033. private _altPressed;
  105034. private _shiftPressed;
  105035. private _onCanvasBlurObserver;
  105036. private _onKeyboardObserver;
  105037. private _engine;
  105038. private _scene;
  105039. /**
  105040. * Attach the input controls to a specific dom element to get the input from.
  105041. * @param element Defines the element the controls should be listened from
  105042. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105043. */
  105044. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105045. /**
  105046. * Detach the current controls from the specified dom element.
  105047. * @param element Defines the element to stop listening the inputs from
  105048. */
  105049. detachControl(element: Nullable<HTMLElement>): void;
  105050. /**
  105051. * Update the current camera state depending on the inputs that have been used this frame.
  105052. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105053. */
  105054. checkInputs(): void;
  105055. /**
  105056. * Gets the class name of the current input.
  105057. * @returns the class name
  105058. */
  105059. getClassName(): string;
  105060. /**
  105061. * Get the friendly name associated with the input class.
  105062. * @returns the input friendly name
  105063. */
  105064. getSimpleName(): string;
  105065. /**
  105066. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105067. * allow modification of the heightOffset value.
  105068. */
  105069. private _modifierHeightOffset;
  105070. /**
  105071. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105072. * allow modification of the rotationOffset value.
  105073. */
  105074. private _modifierRotationOffset;
  105075. /**
  105076. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105077. * allow modification of the radius value.
  105078. */
  105079. private _modifierRadius;
  105080. }
  105081. }
  105082. declare module BABYLON {
  105083. interface FreeCameraInputsManager {
  105084. /**
  105085. * @hidden
  105086. */
  105087. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  105088. /**
  105089. * Add orientation input support to the input manager.
  105090. * @returns the current input manager
  105091. */
  105092. addDeviceOrientation(): FreeCameraInputsManager;
  105093. }
  105094. /**
  105095. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  105096. * Screen rotation is taken into account.
  105097. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105098. */
  105099. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  105100. private _camera;
  105101. private _screenOrientationAngle;
  105102. private _constantTranform;
  105103. private _screenQuaternion;
  105104. private _alpha;
  105105. private _beta;
  105106. private _gamma;
  105107. /**
  105108. * Can be used to detect if a device orientation sensor is availible on a device
  105109. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  105110. * @returns a promise that will resolve on orientation change
  105111. */
  105112. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  105113. /**
  105114. * @hidden
  105115. */
  105116. _onDeviceOrientationChangedObservable: Observable<void>;
  105117. /**
  105118. * Instantiates a new input
  105119. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105120. */
  105121. constructor();
  105122. /**
  105123. * Define the camera controlled by the input.
  105124. */
  105125. camera: FreeCamera;
  105126. /**
  105127. * Attach the input controls to a specific dom element to get the input from.
  105128. * @param element Defines the element the controls should be listened from
  105129. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105130. */
  105131. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105132. private _orientationChanged;
  105133. private _deviceOrientation;
  105134. /**
  105135. * Detach the current controls from the specified dom element.
  105136. * @param element Defines the element to stop listening the inputs from
  105137. */
  105138. detachControl(element: Nullable<HTMLElement>): void;
  105139. /**
  105140. * Update the current camera state depending on the inputs that have been used this frame.
  105141. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105142. */
  105143. checkInputs(): void;
  105144. /**
  105145. * Gets the class name of the current intput.
  105146. * @returns the class name
  105147. */
  105148. getClassName(): string;
  105149. /**
  105150. * Get the friendly name associated with the input class.
  105151. * @returns the input friendly name
  105152. */
  105153. getSimpleName(): string;
  105154. }
  105155. }
  105156. declare module BABYLON {
  105157. /**
  105158. * Manage the gamepad inputs to control a free camera.
  105159. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105160. */
  105161. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  105162. /**
  105163. * Define the camera the input is attached to.
  105164. */
  105165. camera: FreeCamera;
  105166. /**
  105167. * Define the Gamepad controlling the input
  105168. */
  105169. gamepad: Nullable<Gamepad>;
  105170. /**
  105171. * Defines the gamepad rotation sensiblity.
  105172. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105173. */
  105174. gamepadAngularSensibility: number;
  105175. /**
  105176. * Defines the gamepad move sensiblity.
  105177. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105178. */
  105179. gamepadMoveSensibility: number;
  105180. private _yAxisScale;
  105181. /**
  105182. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  105183. */
  105184. invertYAxis: boolean;
  105185. private _onGamepadConnectedObserver;
  105186. private _onGamepadDisconnectedObserver;
  105187. private _cameraTransform;
  105188. private _deltaTransform;
  105189. private _vector3;
  105190. private _vector2;
  105191. /**
  105192. * Attach the input controls to a specific dom element to get the input from.
  105193. * @param element Defines the element the controls should be listened from
  105194. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105195. */
  105196. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105197. /**
  105198. * Detach the current controls from the specified dom element.
  105199. * @param element Defines the element to stop listening the inputs from
  105200. */
  105201. detachControl(element: Nullable<HTMLElement>): void;
  105202. /**
  105203. * Update the current camera state depending on the inputs that have been used this frame.
  105204. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105205. */
  105206. checkInputs(): void;
  105207. /**
  105208. * Gets the class name of the current intput.
  105209. * @returns the class name
  105210. */
  105211. getClassName(): string;
  105212. /**
  105213. * Get the friendly name associated with the input class.
  105214. * @returns the input friendly name
  105215. */
  105216. getSimpleName(): string;
  105217. }
  105218. }
  105219. declare module BABYLON {
  105220. /**
  105221. * Defines the potential axis of a Joystick
  105222. */
  105223. export enum JoystickAxis {
  105224. /** X axis */
  105225. X = 0,
  105226. /** Y axis */
  105227. Y = 1,
  105228. /** Z axis */
  105229. Z = 2
  105230. }
  105231. /**
  105232. * Class used to define virtual joystick (used in touch mode)
  105233. */
  105234. export class VirtualJoystick {
  105235. /**
  105236. * Gets or sets a boolean indicating that left and right values must be inverted
  105237. */
  105238. reverseLeftRight: boolean;
  105239. /**
  105240. * Gets or sets a boolean indicating that up and down values must be inverted
  105241. */
  105242. reverseUpDown: boolean;
  105243. /**
  105244. * Gets the offset value for the position (ie. the change of the position value)
  105245. */
  105246. deltaPosition: Vector3;
  105247. /**
  105248. * Gets a boolean indicating if the virtual joystick was pressed
  105249. */
  105250. pressed: boolean;
  105251. /**
  105252. * Canvas the virtual joystick will render onto, default z-index of this is 5
  105253. */
  105254. static Canvas: Nullable<HTMLCanvasElement>;
  105255. private static _globalJoystickIndex;
  105256. private static vjCanvasContext;
  105257. private static vjCanvasWidth;
  105258. private static vjCanvasHeight;
  105259. private static halfWidth;
  105260. private _action;
  105261. private _axisTargetedByLeftAndRight;
  105262. private _axisTargetedByUpAndDown;
  105263. private _joystickSensibility;
  105264. private _inversedSensibility;
  105265. private _joystickPointerID;
  105266. private _joystickColor;
  105267. private _joystickPointerPos;
  105268. private _joystickPreviousPointerPos;
  105269. private _joystickPointerStartPos;
  105270. private _deltaJoystickVector;
  105271. private _leftJoystick;
  105272. private _touches;
  105273. private _onPointerDownHandlerRef;
  105274. private _onPointerMoveHandlerRef;
  105275. private _onPointerUpHandlerRef;
  105276. private _onResize;
  105277. /**
  105278. * Creates a new virtual joystick
  105279. * @param leftJoystick defines that the joystick is for left hand (false by default)
  105280. */
  105281. constructor(leftJoystick?: boolean);
  105282. /**
  105283. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  105284. * @param newJoystickSensibility defines the new sensibility
  105285. */
  105286. setJoystickSensibility(newJoystickSensibility: number): void;
  105287. private _onPointerDown;
  105288. private _onPointerMove;
  105289. private _onPointerUp;
  105290. /**
  105291. * Change the color of the virtual joystick
  105292. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  105293. */
  105294. setJoystickColor(newColor: string): void;
  105295. /**
  105296. * Defines a callback to call when the joystick is touched
  105297. * @param action defines the callback
  105298. */
  105299. setActionOnTouch(action: () => any): void;
  105300. /**
  105301. * Defines which axis you'd like to control for left & right
  105302. * @param axis defines the axis to use
  105303. */
  105304. setAxisForLeftRight(axis: JoystickAxis): void;
  105305. /**
  105306. * Defines which axis you'd like to control for up & down
  105307. * @param axis defines the axis to use
  105308. */
  105309. setAxisForUpDown(axis: JoystickAxis): void;
  105310. private _drawVirtualJoystick;
  105311. /**
  105312. * Release internal HTML canvas
  105313. */
  105314. releaseCanvas(): void;
  105315. }
  105316. }
  105317. declare module BABYLON {
  105318. interface FreeCameraInputsManager {
  105319. /**
  105320. * Add virtual joystick input support to the input manager.
  105321. * @returns the current input manager
  105322. */
  105323. addVirtualJoystick(): FreeCameraInputsManager;
  105324. }
  105325. /**
  105326. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  105327. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105328. */
  105329. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  105330. /**
  105331. * Defines the camera the input is attached to.
  105332. */
  105333. camera: FreeCamera;
  105334. private _leftjoystick;
  105335. private _rightjoystick;
  105336. /**
  105337. * Gets the left stick of the virtual joystick.
  105338. * @returns The virtual Joystick
  105339. */
  105340. getLeftJoystick(): VirtualJoystick;
  105341. /**
  105342. * Gets the right stick of the virtual joystick.
  105343. * @returns The virtual Joystick
  105344. */
  105345. getRightJoystick(): VirtualJoystick;
  105346. /**
  105347. * Update the current camera state depending on the inputs that have been used this frame.
  105348. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105349. */
  105350. checkInputs(): void;
  105351. /**
  105352. * Attach the input controls to a specific dom element to get the input from.
  105353. * @param element Defines the element the controls should be listened from
  105354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105355. */
  105356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105357. /**
  105358. * Detach the current controls from the specified dom element.
  105359. * @param element Defines the element to stop listening the inputs from
  105360. */
  105361. detachControl(element: Nullable<HTMLElement>): void;
  105362. /**
  105363. * Gets the class name of the current intput.
  105364. * @returns the class name
  105365. */
  105366. getClassName(): string;
  105367. /**
  105368. * Get the friendly name associated with the input class.
  105369. * @returns the input friendly name
  105370. */
  105371. getSimpleName(): string;
  105372. }
  105373. }
  105374. declare module BABYLON {
  105375. /**
  105376. * This represents a FPS type of camera controlled by touch.
  105377. * This is like a universal camera minus the Gamepad controls.
  105378. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105379. */
  105380. export class TouchCamera extends FreeCamera {
  105381. /**
  105382. * Defines the touch sensibility for rotation.
  105383. * The higher the faster.
  105384. */
  105385. touchAngularSensibility: number;
  105386. /**
  105387. * Defines the touch sensibility for move.
  105388. * The higher the faster.
  105389. */
  105390. touchMoveSensibility: number;
  105391. /**
  105392. * Instantiates a new touch camera.
  105393. * This represents a FPS type of camera controlled by touch.
  105394. * This is like a universal camera minus the Gamepad controls.
  105395. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105396. * @param name Define the name of the camera in the scene
  105397. * @param position Define the start position of the camera in the scene
  105398. * @param scene Define the scene the camera belongs to
  105399. */
  105400. constructor(name: string, position: Vector3, scene: Scene);
  105401. /**
  105402. * Gets the current object class name.
  105403. * @return the class name
  105404. */
  105405. getClassName(): string;
  105406. /** @hidden */
  105407. _setupInputs(): void;
  105408. }
  105409. }
  105410. declare module BABYLON {
  105411. /**
  105412. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  105413. * being tilted forward or back and left or right.
  105414. */
  105415. export class DeviceOrientationCamera extends FreeCamera {
  105416. private _initialQuaternion;
  105417. private _quaternionCache;
  105418. private _tmpDragQuaternion;
  105419. private _disablePointerInputWhenUsingDeviceOrientation;
  105420. /**
  105421. * Creates a new device orientation camera
  105422. * @param name The name of the camera
  105423. * @param position The start position camera
  105424. * @param scene The scene the camera belongs to
  105425. */
  105426. constructor(name: string, position: Vector3, scene: Scene);
  105427. /**
  105428. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  105429. */
  105430. disablePointerInputWhenUsingDeviceOrientation: boolean;
  105431. private _dragFactor;
  105432. /**
  105433. * Enabled turning on the y axis when the orientation sensor is active
  105434. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  105435. */
  105436. enableHorizontalDragging(dragFactor?: number): void;
  105437. /**
  105438. * Gets the current instance class name ("DeviceOrientationCamera").
  105439. * This helps avoiding instanceof at run time.
  105440. * @returns the class name
  105441. */
  105442. getClassName(): string;
  105443. /**
  105444. * @hidden
  105445. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  105446. */
  105447. _checkInputs(): void;
  105448. /**
  105449. * Reset the camera to its default orientation on the specified axis only.
  105450. * @param axis The axis to reset
  105451. */
  105452. resetToCurrentRotation(axis?: Axis): void;
  105453. }
  105454. }
  105455. declare module BABYLON {
  105456. /**
  105457. * Defines supported buttons for XBox360 compatible gamepads
  105458. */
  105459. export enum Xbox360Button {
  105460. /** A */
  105461. A = 0,
  105462. /** B */
  105463. B = 1,
  105464. /** X */
  105465. X = 2,
  105466. /** Y */
  105467. Y = 3,
  105468. /** Start */
  105469. Start = 4,
  105470. /** Back */
  105471. Back = 5,
  105472. /** Left button */
  105473. LB = 6,
  105474. /** Right button */
  105475. RB = 7,
  105476. /** Left stick */
  105477. LeftStick = 8,
  105478. /** Right stick */
  105479. RightStick = 9
  105480. }
  105481. /** Defines values for XBox360 DPad */
  105482. export enum Xbox360Dpad {
  105483. /** Up */
  105484. Up = 0,
  105485. /** Down */
  105486. Down = 1,
  105487. /** Left */
  105488. Left = 2,
  105489. /** Right */
  105490. Right = 3
  105491. }
  105492. /**
  105493. * Defines a XBox360 gamepad
  105494. */
  105495. export class Xbox360Pad extends Gamepad {
  105496. private _leftTrigger;
  105497. private _rightTrigger;
  105498. private _onlefttriggerchanged;
  105499. private _onrighttriggerchanged;
  105500. private _onbuttondown;
  105501. private _onbuttonup;
  105502. private _ondpaddown;
  105503. private _ondpadup;
  105504. /** Observable raised when a button is pressed */
  105505. onButtonDownObservable: Observable<Xbox360Button>;
  105506. /** Observable raised when a button is released */
  105507. onButtonUpObservable: Observable<Xbox360Button>;
  105508. /** Observable raised when a pad is pressed */
  105509. onPadDownObservable: Observable<Xbox360Dpad>;
  105510. /** Observable raised when a pad is released */
  105511. onPadUpObservable: Observable<Xbox360Dpad>;
  105512. private _buttonA;
  105513. private _buttonB;
  105514. private _buttonX;
  105515. private _buttonY;
  105516. private _buttonBack;
  105517. private _buttonStart;
  105518. private _buttonLB;
  105519. private _buttonRB;
  105520. private _buttonLeftStick;
  105521. private _buttonRightStick;
  105522. private _dPadUp;
  105523. private _dPadDown;
  105524. private _dPadLeft;
  105525. private _dPadRight;
  105526. private _isXboxOnePad;
  105527. /**
  105528. * Creates a new XBox360 gamepad object
  105529. * @param id defines the id of this gamepad
  105530. * @param index defines its index
  105531. * @param gamepad defines the internal HTML gamepad object
  105532. * @param xboxOne defines if it is a XBox One gamepad
  105533. */
  105534. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  105535. /**
  105536. * Defines the callback to call when left trigger is pressed
  105537. * @param callback defines the callback to use
  105538. */
  105539. onlefttriggerchanged(callback: (value: number) => void): void;
  105540. /**
  105541. * Defines the callback to call when right trigger is pressed
  105542. * @param callback defines the callback to use
  105543. */
  105544. onrighttriggerchanged(callback: (value: number) => void): void;
  105545. /**
  105546. * Gets the left trigger value
  105547. */
  105548. /**
  105549. * Sets the left trigger value
  105550. */
  105551. leftTrigger: number;
  105552. /**
  105553. * Gets the right trigger value
  105554. */
  105555. /**
  105556. * Sets the right trigger value
  105557. */
  105558. rightTrigger: number;
  105559. /**
  105560. * Defines the callback to call when a button is pressed
  105561. * @param callback defines the callback to use
  105562. */
  105563. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  105564. /**
  105565. * Defines the callback to call when a button is released
  105566. * @param callback defines the callback to use
  105567. */
  105568. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  105569. /**
  105570. * Defines the callback to call when a pad is pressed
  105571. * @param callback defines the callback to use
  105572. */
  105573. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  105574. /**
  105575. * Defines the callback to call when a pad is released
  105576. * @param callback defines the callback to use
  105577. */
  105578. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  105579. private _setButtonValue;
  105580. private _setDPadValue;
  105581. /**
  105582. * Gets the value of the `A` button
  105583. */
  105584. /**
  105585. * Sets the value of the `A` button
  105586. */
  105587. buttonA: number;
  105588. /**
  105589. * Gets the value of the `B` button
  105590. */
  105591. /**
  105592. * Sets the value of the `B` button
  105593. */
  105594. buttonB: number;
  105595. /**
  105596. * Gets the value of the `X` button
  105597. */
  105598. /**
  105599. * Sets the value of the `X` button
  105600. */
  105601. buttonX: number;
  105602. /**
  105603. * Gets the value of the `Y` button
  105604. */
  105605. /**
  105606. * Sets the value of the `Y` button
  105607. */
  105608. buttonY: number;
  105609. /**
  105610. * Gets the value of the `Start` button
  105611. */
  105612. /**
  105613. * Sets the value of the `Start` button
  105614. */
  105615. buttonStart: number;
  105616. /**
  105617. * Gets the value of the `Back` button
  105618. */
  105619. /**
  105620. * Sets the value of the `Back` button
  105621. */
  105622. buttonBack: number;
  105623. /**
  105624. * Gets the value of the `Left` button
  105625. */
  105626. /**
  105627. * Sets the value of the `Left` button
  105628. */
  105629. buttonLB: number;
  105630. /**
  105631. * Gets the value of the `Right` button
  105632. */
  105633. /**
  105634. * Sets the value of the `Right` button
  105635. */
  105636. buttonRB: number;
  105637. /**
  105638. * Gets the value of the Left joystick
  105639. */
  105640. /**
  105641. * Sets the value of the Left joystick
  105642. */
  105643. buttonLeftStick: number;
  105644. /**
  105645. * Gets the value of the Right joystick
  105646. */
  105647. /**
  105648. * Sets the value of the Right joystick
  105649. */
  105650. buttonRightStick: number;
  105651. /**
  105652. * Gets the value of D-pad up
  105653. */
  105654. /**
  105655. * Sets the value of D-pad up
  105656. */
  105657. dPadUp: number;
  105658. /**
  105659. * Gets the value of D-pad down
  105660. */
  105661. /**
  105662. * Sets the value of D-pad down
  105663. */
  105664. dPadDown: number;
  105665. /**
  105666. * Gets the value of D-pad left
  105667. */
  105668. /**
  105669. * Sets the value of D-pad left
  105670. */
  105671. dPadLeft: number;
  105672. /**
  105673. * Gets the value of D-pad right
  105674. */
  105675. /**
  105676. * Sets the value of D-pad right
  105677. */
  105678. dPadRight: number;
  105679. /**
  105680. * Force the gamepad to synchronize with device values
  105681. */
  105682. update(): void;
  105683. /**
  105684. * Disposes the gamepad
  105685. */
  105686. dispose(): void;
  105687. }
  105688. }
  105689. declare module BABYLON {
  105690. /**
  105691. * Defines supported buttons for DualShock compatible gamepads
  105692. */
  105693. export enum DualShockButton {
  105694. /** Cross */
  105695. Cross = 0,
  105696. /** Circle */
  105697. Circle = 1,
  105698. /** Square */
  105699. Square = 2,
  105700. /** Triangle */
  105701. Triangle = 3,
  105702. /** Options */
  105703. Options = 4,
  105704. /** Share */
  105705. Share = 5,
  105706. /** L1 */
  105707. L1 = 6,
  105708. /** R1 */
  105709. R1 = 7,
  105710. /** Left stick */
  105711. LeftStick = 8,
  105712. /** Right stick */
  105713. RightStick = 9
  105714. }
  105715. /** Defines values for DualShock DPad */
  105716. export enum DualShockDpad {
  105717. /** Up */
  105718. Up = 0,
  105719. /** Down */
  105720. Down = 1,
  105721. /** Left */
  105722. Left = 2,
  105723. /** Right */
  105724. Right = 3
  105725. }
  105726. /**
  105727. * Defines a DualShock gamepad
  105728. */
  105729. export class DualShockPad extends Gamepad {
  105730. private _leftTrigger;
  105731. private _rightTrigger;
  105732. private _onlefttriggerchanged;
  105733. private _onrighttriggerchanged;
  105734. private _onbuttondown;
  105735. private _onbuttonup;
  105736. private _ondpaddown;
  105737. private _ondpadup;
  105738. /** Observable raised when a button is pressed */
  105739. onButtonDownObservable: Observable<DualShockButton>;
  105740. /** Observable raised when a button is released */
  105741. onButtonUpObservable: Observable<DualShockButton>;
  105742. /** Observable raised when a pad is pressed */
  105743. onPadDownObservable: Observable<DualShockDpad>;
  105744. /** Observable raised when a pad is released */
  105745. onPadUpObservable: Observable<DualShockDpad>;
  105746. private _buttonCross;
  105747. private _buttonCircle;
  105748. private _buttonSquare;
  105749. private _buttonTriangle;
  105750. private _buttonShare;
  105751. private _buttonOptions;
  105752. private _buttonL1;
  105753. private _buttonR1;
  105754. private _buttonLeftStick;
  105755. private _buttonRightStick;
  105756. private _dPadUp;
  105757. private _dPadDown;
  105758. private _dPadLeft;
  105759. private _dPadRight;
  105760. /**
  105761. * Creates a new DualShock gamepad object
  105762. * @param id defines the id of this gamepad
  105763. * @param index defines its index
  105764. * @param gamepad defines the internal HTML gamepad object
  105765. */
  105766. constructor(id: string, index: number, gamepad: any);
  105767. /**
  105768. * Defines the callback to call when left trigger is pressed
  105769. * @param callback defines the callback to use
  105770. */
  105771. onlefttriggerchanged(callback: (value: number) => void): void;
  105772. /**
  105773. * Defines the callback to call when right trigger is pressed
  105774. * @param callback defines the callback to use
  105775. */
  105776. onrighttriggerchanged(callback: (value: number) => void): void;
  105777. /**
  105778. * Gets the left trigger value
  105779. */
  105780. /**
  105781. * Sets the left trigger value
  105782. */
  105783. leftTrigger: number;
  105784. /**
  105785. * Gets the right trigger value
  105786. */
  105787. /**
  105788. * Sets the right trigger value
  105789. */
  105790. rightTrigger: number;
  105791. /**
  105792. * Defines the callback to call when a button is pressed
  105793. * @param callback defines the callback to use
  105794. */
  105795. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  105796. /**
  105797. * Defines the callback to call when a button is released
  105798. * @param callback defines the callback to use
  105799. */
  105800. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  105801. /**
  105802. * Defines the callback to call when a pad is pressed
  105803. * @param callback defines the callback to use
  105804. */
  105805. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  105806. /**
  105807. * Defines the callback to call when a pad is released
  105808. * @param callback defines the callback to use
  105809. */
  105810. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  105811. private _setButtonValue;
  105812. private _setDPadValue;
  105813. /**
  105814. * Gets the value of the `Cross` button
  105815. */
  105816. /**
  105817. * Sets the value of the `Cross` button
  105818. */
  105819. buttonCross: number;
  105820. /**
  105821. * Gets the value of the `Circle` button
  105822. */
  105823. /**
  105824. * Sets the value of the `Circle` button
  105825. */
  105826. buttonCircle: number;
  105827. /**
  105828. * Gets the value of the `Square` button
  105829. */
  105830. /**
  105831. * Sets the value of the `Square` button
  105832. */
  105833. buttonSquare: number;
  105834. /**
  105835. * Gets the value of the `Triangle` button
  105836. */
  105837. /**
  105838. * Sets the value of the `Triangle` button
  105839. */
  105840. buttonTriangle: number;
  105841. /**
  105842. * Gets the value of the `Options` button
  105843. */
  105844. /**
  105845. * Sets the value of the `Options` button
  105846. */
  105847. buttonOptions: number;
  105848. /**
  105849. * Gets the value of the `Share` button
  105850. */
  105851. /**
  105852. * Sets the value of the `Share` button
  105853. */
  105854. buttonShare: number;
  105855. /**
  105856. * Gets the value of the `L1` button
  105857. */
  105858. /**
  105859. * Sets the value of the `L1` button
  105860. */
  105861. buttonL1: number;
  105862. /**
  105863. * Gets the value of the `R1` button
  105864. */
  105865. /**
  105866. * Sets the value of the `R1` button
  105867. */
  105868. buttonR1: number;
  105869. /**
  105870. * Gets the value of the Left joystick
  105871. */
  105872. /**
  105873. * Sets the value of the Left joystick
  105874. */
  105875. buttonLeftStick: number;
  105876. /**
  105877. * Gets the value of the Right joystick
  105878. */
  105879. /**
  105880. * Sets the value of the Right joystick
  105881. */
  105882. buttonRightStick: number;
  105883. /**
  105884. * Gets the value of D-pad up
  105885. */
  105886. /**
  105887. * Sets the value of D-pad up
  105888. */
  105889. dPadUp: number;
  105890. /**
  105891. * Gets the value of D-pad down
  105892. */
  105893. /**
  105894. * Sets the value of D-pad down
  105895. */
  105896. dPadDown: number;
  105897. /**
  105898. * Gets the value of D-pad left
  105899. */
  105900. /**
  105901. * Sets the value of D-pad left
  105902. */
  105903. dPadLeft: number;
  105904. /**
  105905. * Gets the value of D-pad right
  105906. */
  105907. /**
  105908. * Sets the value of D-pad right
  105909. */
  105910. dPadRight: number;
  105911. /**
  105912. * Force the gamepad to synchronize with device values
  105913. */
  105914. update(): void;
  105915. /**
  105916. * Disposes the gamepad
  105917. */
  105918. dispose(): void;
  105919. }
  105920. }
  105921. declare module BABYLON {
  105922. /**
  105923. * Manager for handling gamepads
  105924. */
  105925. export class GamepadManager {
  105926. private _scene?;
  105927. private _babylonGamepads;
  105928. private _oneGamepadConnected;
  105929. /** @hidden */
  105930. _isMonitoring: boolean;
  105931. private _gamepadEventSupported;
  105932. private _gamepadSupport;
  105933. /**
  105934. * observable to be triggered when the gamepad controller has been connected
  105935. */
  105936. onGamepadConnectedObservable: Observable<Gamepad>;
  105937. /**
  105938. * observable to be triggered when the gamepad controller has been disconnected
  105939. */
  105940. onGamepadDisconnectedObservable: Observable<Gamepad>;
  105941. private _onGamepadConnectedEvent;
  105942. private _onGamepadDisconnectedEvent;
  105943. /**
  105944. * Initializes the gamepad manager
  105945. * @param _scene BabylonJS scene
  105946. */
  105947. constructor(_scene?: Scene | undefined);
  105948. /**
  105949. * The gamepads in the game pad manager
  105950. */
  105951. readonly gamepads: Gamepad[];
  105952. /**
  105953. * Get the gamepad controllers based on type
  105954. * @param type The type of gamepad controller
  105955. * @returns Nullable gamepad
  105956. */
  105957. getGamepadByType(type?: number): Nullable<Gamepad>;
  105958. /**
  105959. * Disposes the gamepad manager
  105960. */
  105961. dispose(): void;
  105962. private _addNewGamepad;
  105963. private _startMonitoringGamepads;
  105964. private _stopMonitoringGamepads;
  105965. /** @hidden */
  105966. _checkGamepadsStatus(): void;
  105967. private _updateGamepadObjects;
  105968. }
  105969. }
  105970. declare module BABYLON {
  105971. interface Scene {
  105972. /** @hidden */
  105973. _gamepadManager: Nullable<GamepadManager>;
  105974. /**
  105975. * Gets the gamepad manager associated with the scene
  105976. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  105977. */
  105978. gamepadManager: GamepadManager;
  105979. }
  105980. /**
  105981. * Interface representing a free camera inputs manager
  105982. */
  105983. interface FreeCameraInputsManager {
  105984. /**
  105985. * Adds gamepad input support to the FreeCameraInputsManager.
  105986. * @returns the FreeCameraInputsManager
  105987. */
  105988. addGamepad(): FreeCameraInputsManager;
  105989. }
  105990. /**
  105991. * Interface representing an arc rotate camera inputs manager
  105992. */
  105993. interface ArcRotateCameraInputsManager {
  105994. /**
  105995. * Adds gamepad input support to the ArcRotateCamera InputManager.
  105996. * @returns the camera inputs manager
  105997. */
  105998. addGamepad(): ArcRotateCameraInputsManager;
  105999. }
  106000. /**
  106001. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  106002. */
  106003. export class GamepadSystemSceneComponent implements ISceneComponent {
  106004. /**
  106005. * The component name helpfull to identify the component in the list of scene components.
  106006. */
  106007. readonly name: string;
  106008. /**
  106009. * The scene the component belongs to.
  106010. */
  106011. scene: Scene;
  106012. /**
  106013. * Creates a new instance of the component for the given scene
  106014. * @param scene Defines the scene to register the component in
  106015. */
  106016. constructor(scene: Scene);
  106017. /**
  106018. * Registers the component in a given scene
  106019. */
  106020. register(): void;
  106021. /**
  106022. * Rebuilds the elements related to this component in case of
  106023. * context lost for instance.
  106024. */
  106025. rebuild(): void;
  106026. /**
  106027. * Disposes the component and the associated ressources
  106028. */
  106029. dispose(): void;
  106030. private _beforeCameraUpdate;
  106031. }
  106032. }
  106033. declare module BABYLON {
  106034. /**
  106035. * 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,
  106036. * which still works and will still be found in many Playgrounds.
  106037. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106038. */
  106039. export class UniversalCamera extends TouchCamera {
  106040. /**
  106041. * Defines the gamepad rotation sensiblity.
  106042. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106043. */
  106044. gamepadAngularSensibility: number;
  106045. /**
  106046. * Defines the gamepad move sensiblity.
  106047. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106048. */
  106049. gamepadMoveSensibility: number;
  106050. /**
  106051. * 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,
  106052. * which still works and will still be found in many Playgrounds.
  106053. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106054. * @param name Define the name of the camera in the scene
  106055. * @param position Define the start position of the camera in the scene
  106056. * @param scene Define the scene the camera belongs to
  106057. */
  106058. constructor(name: string, position: Vector3, scene: Scene);
  106059. /**
  106060. * Gets the current object class name.
  106061. * @return the class name
  106062. */
  106063. getClassName(): string;
  106064. }
  106065. }
  106066. declare module BABYLON {
  106067. /**
  106068. * This represents a FPS type of camera. This is only here for back compat purpose.
  106069. * Please use the UniversalCamera instead as both are identical.
  106070. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106071. */
  106072. export class GamepadCamera extends UniversalCamera {
  106073. /**
  106074. * Instantiates a new Gamepad Camera
  106075. * This represents a FPS type of camera. This is only here for back compat purpose.
  106076. * Please use the UniversalCamera instead as both are identical.
  106077. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106078. * @param name Define the name of the camera in the scene
  106079. * @param position Define the start position of the camera in the scene
  106080. * @param scene Define the scene the camera belongs to
  106081. */
  106082. constructor(name: string, position: Vector3, scene: Scene);
  106083. /**
  106084. * Gets the current object class name.
  106085. * @return the class name
  106086. */
  106087. getClassName(): string;
  106088. }
  106089. }
  106090. declare module BABYLON {
  106091. /** @hidden */
  106092. export var passPixelShader: {
  106093. name: string;
  106094. shader: string;
  106095. };
  106096. }
  106097. declare module BABYLON {
  106098. /** @hidden */
  106099. export var passCubePixelShader: {
  106100. name: string;
  106101. shader: string;
  106102. };
  106103. }
  106104. declare module BABYLON {
  106105. /**
  106106. * PassPostProcess which produces an output the same as it's input
  106107. */
  106108. export class PassPostProcess extends PostProcess {
  106109. /**
  106110. * Creates the PassPostProcess
  106111. * @param name The name of the effect.
  106112. * @param options The required width/height ratio to downsize to before computing the render pass.
  106113. * @param camera The camera to apply the render pass to.
  106114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106115. * @param engine The engine which the post process will be applied. (default: current engine)
  106116. * @param reusable If the post process can be reused on the same frame. (default: false)
  106117. * @param textureType The type of texture to be used when performing the post processing.
  106118. * @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)
  106119. */
  106120. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106121. }
  106122. /**
  106123. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  106124. */
  106125. export class PassCubePostProcess extends PostProcess {
  106126. private _face;
  106127. /**
  106128. * Gets or sets the cube face to display.
  106129. * * 0 is +X
  106130. * * 1 is -X
  106131. * * 2 is +Y
  106132. * * 3 is -Y
  106133. * * 4 is +Z
  106134. * * 5 is -Z
  106135. */
  106136. face: number;
  106137. /**
  106138. * Creates the PassCubePostProcess
  106139. * @param name The name of the effect.
  106140. * @param options The required width/height ratio to downsize to before computing the render pass.
  106141. * @param camera The camera to apply the render pass to.
  106142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106143. * @param engine The engine which the post process will be applied. (default: current engine)
  106144. * @param reusable If the post process can be reused on the same frame. (default: false)
  106145. * @param textureType The type of texture to be used when performing the post processing.
  106146. * @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)
  106147. */
  106148. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106149. }
  106150. }
  106151. declare module BABYLON {
  106152. /** @hidden */
  106153. export var anaglyphPixelShader: {
  106154. name: string;
  106155. shader: string;
  106156. };
  106157. }
  106158. declare module BABYLON {
  106159. /**
  106160. * Postprocess used to generate anaglyphic rendering
  106161. */
  106162. export class AnaglyphPostProcess extends PostProcess {
  106163. private _passedProcess;
  106164. /**
  106165. * Creates a new AnaglyphPostProcess
  106166. * @param name defines postprocess name
  106167. * @param options defines creation options or target ratio scale
  106168. * @param rigCameras defines cameras using this postprocess
  106169. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  106170. * @param engine defines hosting engine
  106171. * @param reusable defines if the postprocess will be reused multiple times per frame
  106172. */
  106173. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  106174. }
  106175. }
  106176. declare module BABYLON {
  106177. /**
  106178. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  106179. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106180. */
  106181. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  106182. /**
  106183. * Creates a new AnaglyphArcRotateCamera
  106184. * @param name defines camera name
  106185. * @param alpha defines alpha angle (in radians)
  106186. * @param beta defines beta angle (in radians)
  106187. * @param radius defines radius
  106188. * @param target defines camera target
  106189. * @param interaxialDistance defines distance between each color axis
  106190. * @param scene defines the hosting scene
  106191. */
  106192. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  106193. /**
  106194. * Gets camera class name
  106195. * @returns AnaglyphArcRotateCamera
  106196. */
  106197. getClassName(): string;
  106198. }
  106199. }
  106200. declare module BABYLON {
  106201. /**
  106202. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  106203. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106204. */
  106205. export class AnaglyphFreeCamera extends FreeCamera {
  106206. /**
  106207. * Creates a new AnaglyphFreeCamera
  106208. * @param name defines camera name
  106209. * @param position defines initial position
  106210. * @param interaxialDistance defines distance between each color axis
  106211. * @param scene defines the hosting scene
  106212. */
  106213. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106214. /**
  106215. * Gets camera class name
  106216. * @returns AnaglyphFreeCamera
  106217. */
  106218. getClassName(): string;
  106219. }
  106220. }
  106221. declare module BABYLON {
  106222. /**
  106223. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  106224. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106225. */
  106226. export class AnaglyphGamepadCamera extends GamepadCamera {
  106227. /**
  106228. * Creates a new AnaglyphGamepadCamera
  106229. * @param name defines camera name
  106230. * @param position defines initial position
  106231. * @param interaxialDistance defines distance between each color axis
  106232. * @param scene defines the hosting scene
  106233. */
  106234. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106235. /**
  106236. * Gets camera class name
  106237. * @returns AnaglyphGamepadCamera
  106238. */
  106239. getClassName(): string;
  106240. }
  106241. }
  106242. declare module BABYLON {
  106243. /**
  106244. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  106245. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106246. */
  106247. export class AnaglyphUniversalCamera extends UniversalCamera {
  106248. /**
  106249. * Creates a new AnaglyphUniversalCamera
  106250. * @param name defines camera name
  106251. * @param position defines initial position
  106252. * @param interaxialDistance defines distance between each color axis
  106253. * @param scene defines the hosting scene
  106254. */
  106255. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106256. /**
  106257. * Gets camera class name
  106258. * @returns AnaglyphUniversalCamera
  106259. */
  106260. getClassName(): string;
  106261. }
  106262. }
  106263. declare module BABYLON {
  106264. /** @hidden */
  106265. export var stereoscopicInterlacePixelShader: {
  106266. name: string;
  106267. shader: string;
  106268. };
  106269. }
  106270. declare module BABYLON {
  106271. /**
  106272. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  106273. */
  106274. export class StereoscopicInterlacePostProcess extends PostProcess {
  106275. private _stepSize;
  106276. private _passedProcess;
  106277. /**
  106278. * Initializes a StereoscopicInterlacePostProcess
  106279. * @param name The name of the effect.
  106280. * @param rigCameras The rig cameras to be appled to the post process
  106281. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  106282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106283. * @param engine The engine which the post process will be applied. (default: current engine)
  106284. * @param reusable If the post process can be reused on the same frame. (default: false)
  106285. */
  106286. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106287. }
  106288. }
  106289. declare module BABYLON {
  106290. /**
  106291. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  106292. * @see http://doc.babylonjs.com/features/cameras
  106293. */
  106294. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  106295. /**
  106296. * Creates a new StereoscopicArcRotateCamera
  106297. * @param name defines camera name
  106298. * @param alpha defines alpha angle (in radians)
  106299. * @param beta defines beta angle (in radians)
  106300. * @param radius defines radius
  106301. * @param target defines camera target
  106302. * @param interaxialDistance defines distance between each color axis
  106303. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106304. * @param scene defines the hosting scene
  106305. */
  106306. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106307. /**
  106308. * Gets camera class name
  106309. * @returns StereoscopicArcRotateCamera
  106310. */
  106311. getClassName(): string;
  106312. }
  106313. }
  106314. declare module BABYLON {
  106315. /**
  106316. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  106317. * @see http://doc.babylonjs.com/features/cameras
  106318. */
  106319. export class StereoscopicFreeCamera extends FreeCamera {
  106320. /**
  106321. * Creates a new StereoscopicFreeCamera
  106322. * @param name defines camera name
  106323. * @param position defines initial position
  106324. * @param interaxialDistance defines distance between each color axis
  106325. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106326. * @param scene defines the hosting scene
  106327. */
  106328. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106329. /**
  106330. * Gets camera class name
  106331. * @returns StereoscopicFreeCamera
  106332. */
  106333. getClassName(): string;
  106334. }
  106335. }
  106336. declare module BABYLON {
  106337. /**
  106338. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  106339. * @see http://doc.babylonjs.com/features/cameras
  106340. */
  106341. export class StereoscopicGamepadCamera extends GamepadCamera {
  106342. /**
  106343. * Creates a new StereoscopicGamepadCamera
  106344. * @param name defines camera name
  106345. * @param position defines initial position
  106346. * @param interaxialDistance defines distance between each color axis
  106347. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106348. * @param scene defines the hosting scene
  106349. */
  106350. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106351. /**
  106352. * Gets camera class name
  106353. * @returns StereoscopicGamepadCamera
  106354. */
  106355. getClassName(): string;
  106356. }
  106357. }
  106358. declare module BABYLON {
  106359. /**
  106360. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  106361. * @see http://doc.babylonjs.com/features/cameras
  106362. */
  106363. export class StereoscopicUniversalCamera extends UniversalCamera {
  106364. /**
  106365. * Creates a new StereoscopicUniversalCamera
  106366. * @param name defines camera name
  106367. * @param position defines initial position
  106368. * @param interaxialDistance defines distance between each color axis
  106369. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106370. * @param scene defines the hosting scene
  106371. */
  106372. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106373. /**
  106374. * Gets camera class name
  106375. * @returns StereoscopicUniversalCamera
  106376. */
  106377. getClassName(): string;
  106378. }
  106379. }
  106380. declare module BABYLON {
  106381. /**
  106382. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  106383. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106384. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106385. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106386. */
  106387. export class VirtualJoysticksCamera extends FreeCamera {
  106388. /**
  106389. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  106390. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106391. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106392. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106393. * @param name Define the name of the camera in the scene
  106394. * @param position Define the start position of the camera in the scene
  106395. * @param scene Define the scene the camera belongs to
  106396. */
  106397. constructor(name: string, position: Vector3, scene: Scene);
  106398. /**
  106399. * Gets the current object class name.
  106400. * @return the class name
  106401. */
  106402. getClassName(): string;
  106403. }
  106404. }
  106405. declare module BABYLON {
  106406. /**
  106407. * This represents all the required metrics to create a VR camera.
  106408. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  106409. */
  106410. export class VRCameraMetrics {
  106411. /**
  106412. * Define the horizontal resolution off the screen.
  106413. */
  106414. hResolution: number;
  106415. /**
  106416. * Define the vertical resolution off the screen.
  106417. */
  106418. vResolution: number;
  106419. /**
  106420. * Define the horizontal screen size.
  106421. */
  106422. hScreenSize: number;
  106423. /**
  106424. * Define the vertical screen size.
  106425. */
  106426. vScreenSize: number;
  106427. /**
  106428. * Define the vertical screen center position.
  106429. */
  106430. vScreenCenter: number;
  106431. /**
  106432. * Define the distance of the eyes to the screen.
  106433. */
  106434. eyeToScreenDistance: number;
  106435. /**
  106436. * Define the distance between both lenses
  106437. */
  106438. lensSeparationDistance: number;
  106439. /**
  106440. * Define the distance between both viewer's eyes.
  106441. */
  106442. interpupillaryDistance: number;
  106443. /**
  106444. * Define the distortion factor of the VR postprocess.
  106445. * Please, touch with care.
  106446. */
  106447. distortionK: number[];
  106448. /**
  106449. * Define the chromatic aberration correction factors for the VR post process.
  106450. */
  106451. chromaAbCorrection: number[];
  106452. /**
  106453. * Define the scale factor of the post process.
  106454. * The smaller the better but the slower.
  106455. */
  106456. postProcessScaleFactor: number;
  106457. /**
  106458. * Define an offset for the lens center.
  106459. */
  106460. lensCenterOffset: number;
  106461. /**
  106462. * Define if the current vr camera should compensate the distortion of the lense or not.
  106463. */
  106464. compensateDistortion: boolean;
  106465. /**
  106466. * Defines if multiview should be enabled when rendering (Default: false)
  106467. */
  106468. multiviewEnabled: boolean;
  106469. /**
  106470. * Gets the rendering aspect ratio based on the provided resolutions.
  106471. */
  106472. readonly aspectRatio: number;
  106473. /**
  106474. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  106475. */
  106476. readonly aspectRatioFov: number;
  106477. /**
  106478. * @hidden
  106479. */
  106480. readonly leftHMatrix: Matrix;
  106481. /**
  106482. * @hidden
  106483. */
  106484. readonly rightHMatrix: Matrix;
  106485. /**
  106486. * @hidden
  106487. */
  106488. readonly leftPreViewMatrix: Matrix;
  106489. /**
  106490. * @hidden
  106491. */
  106492. readonly rightPreViewMatrix: Matrix;
  106493. /**
  106494. * Get the default VRMetrics based on the most generic setup.
  106495. * @returns the default vr metrics
  106496. */
  106497. static GetDefault(): VRCameraMetrics;
  106498. }
  106499. }
  106500. declare module BABYLON {
  106501. /** @hidden */
  106502. export var vrDistortionCorrectionPixelShader: {
  106503. name: string;
  106504. shader: string;
  106505. };
  106506. }
  106507. declare module BABYLON {
  106508. /**
  106509. * VRDistortionCorrectionPostProcess used for mobile VR
  106510. */
  106511. export class VRDistortionCorrectionPostProcess extends PostProcess {
  106512. private _isRightEye;
  106513. private _distortionFactors;
  106514. private _postProcessScaleFactor;
  106515. private _lensCenterOffset;
  106516. private _scaleIn;
  106517. private _scaleFactor;
  106518. private _lensCenter;
  106519. /**
  106520. * Initializes the VRDistortionCorrectionPostProcess
  106521. * @param name The name of the effect.
  106522. * @param camera The camera to apply the render pass to.
  106523. * @param isRightEye If this is for the right eye distortion
  106524. * @param vrMetrics All the required metrics for the VR camera
  106525. */
  106526. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  106527. }
  106528. }
  106529. declare module BABYLON {
  106530. /**
  106531. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  106532. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106533. */
  106534. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  106535. /**
  106536. * Creates a new VRDeviceOrientationArcRotateCamera
  106537. * @param name defines camera name
  106538. * @param alpha defines the camera rotation along the logitudinal axis
  106539. * @param beta defines the camera rotation along the latitudinal axis
  106540. * @param radius defines the camera distance from its target
  106541. * @param target defines the camera target
  106542. * @param scene defines the scene the camera belongs to
  106543. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106544. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106545. */
  106546. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106547. /**
  106548. * Gets camera class name
  106549. * @returns VRDeviceOrientationArcRotateCamera
  106550. */
  106551. getClassName(): string;
  106552. }
  106553. }
  106554. declare module BABYLON {
  106555. /**
  106556. * Camera used to simulate VR rendering (based on FreeCamera)
  106557. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106558. */
  106559. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  106560. /**
  106561. * Creates a new VRDeviceOrientationFreeCamera
  106562. * @param name defines camera name
  106563. * @param position defines the start position of the camera
  106564. * @param scene defines the scene the camera belongs to
  106565. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106566. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106567. */
  106568. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106569. /**
  106570. * Gets camera class name
  106571. * @returns VRDeviceOrientationFreeCamera
  106572. */
  106573. getClassName(): string;
  106574. }
  106575. }
  106576. declare module BABYLON {
  106577. /**
  106578. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  106579. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106580. */
  106581. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  106582. /**
  106583. * Creates a new VRDeviceOrientationGamepadCamera
  106584. * @param name defines camera name
  106585. * @param position defines the start position of the camera
  106586. * @param scene defines the scene the camera belongs to
  106587. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106588. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106589. */
  106590. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106591. /**
  106592. * Gets camera class name
  106593. * @returns VRDeviceOrientationGamepadCamera
  106594. */
  106595. getClassName(): string;
  106596. }
  106597. }
  106598. declare module BABYLON {
  106599. /**
  106600. * Base class of materials working in push mode in babylon JS
  106601. * @hidden
  106602. */
  106603. export class PushMaterial extends Material {
  106604. protected _activeEffect: Effect;
  106605. protected _normalMatrix: Matrix;
  106606. /**
  106607. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  106608. * This means that the material can keep using a previous shader while a new one is being compiled.
  106609. * This is mostly used when shader parallel compilation is supported (true by default)
  106610. */
  106611. allowShaderHotSwapping: boolean;
  106612. constructor(name: string, scene: Scene);
  106613. getEffect(): Effect;
  106614. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  106615. /**
  106616. * Binds the given world matrix to the active effect
  106617. *
  106618. * @param world the matrix to bind
  106619. */
  106620. bindOnlyWorldMatrix(world: Matrix): void;
  106621. /**
  106622. * Binds the given normal matrix to the active effect
  106623. *
  106624. * @param normalMatrix the matrix to bind
  106625. */
  106626. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  106627. bind(world: Matrix, mesh?: Mesh): void;
  106628. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  106629. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  106630. }
  106631. }
  106632. declare module BABYLON {
  106633. /**
  106634. * This groups all the flags used to control the materials channel.
  106635. */
  106636. export class MaterialFlags {
  106637. private static _DiffuseTextureEnabled;
  106638. /**
  106639. * Are diffuse textures enabled in the application.
  106640. */
  106641. static DiffuseTextureEnabled: boolean;
  106642. private static _AmbientTextureEnabled;
  106643. /**
  106644. * Are ambient textures enabled in the application.
  106645. */
  106646. static AmbientTextureEnabled: boolean;
  106647. private static _OpacityTextureEnabled;
  106648. /**
  106649. * Are opacity textures enabled in the application.
  106650. */
  106651. static OpacityTextureEnabled: boolean;
  106652. private static _ReflectionTextureEnabled;
  106653. /**
  106654. * Are reflection textures enabled in the application.
  106655. */
  106656. static ReflectionTextureEnabled: boolean;
  106657. private static _EmissiveTextureEnabled;
  106658. /**
  106659. * Are emissive textures enabled in the application.
  106660. */
  106661. static EmissiveTextureEnabled: boolean;
  106662. private static _SpecularTextureEnabled;
  106663. /**
  106664. * Are specular textures enabled in the application.
  106665. */
  106666. static SpecularTextureEnabled: boolean;
  106667. private static _BumpTextureEnabled;
  106668. /**
  106669. * Are bump textures enabled in the application.
  106670. */
  106671. static BumpTextureEnabled: boolean;
  106672. private static _LightmapTextureEnabled;
  106673. /**
  106674. * Are lightmap textures enabled in the application.
  106675. */
  106676. static LightmapTextureEnabled: boolean;
  106677. private static _RefractionTextureEnabled;
  106678. /**
  106679. * Are refraction textures enabled in the application.
  106680. */
  106681. static RefractionTextureEnabled: boolean;
  106682. private static _ColorGradingTextureEnabled;
  106683. /**
  106684. * Are color grading textures enabled in the application.
  106685. */
  106686. static ColorGradingTextureEnabled: boolean;
  106687. private static _FresnelEnabled;
  106688. /**
  106689. * Are fresnels enabled in the application.
  106690. */
  106691. static FresnelEnabled: boolean;
  106692. private static _ClearCoatTextureEnabled;
  106693. /**
  106694. * Are clear coat textures enabled in the application.
  106695. */
  106696. static ClearCoatTextureEnabled: boolean;
  106697. private static _ClearCoatBumpTextureEnabled;
  106698. /**
  106699. * Are clear coat bump textures enabled in the application.
  106700. */
  106701. static ClearCoatBumpTextureEnabled: boolean;
  106702. private static _ClearCoatTintTextureEnabled;
  106703. /**
  106704. * Are clear coat tint textures enabled in the application.
  106705. */
  106706. static ClearCoatTintTextureEnabled: boolean;
  106707. private static _SheenTextureEnabled;
  106708. /**
  106709. * Are sheen textures enabled in the application.
  106710. */
  106711. static SheenTextureEnabled: boolean;
  106712. private static _AnisotropicTextureEnabled;
  106713. /**
  106714. * Are anisotropic textures enabled in the application.
  106715. */
  106716. static AnisotropicTextureEnabled: boolean;
  106717. private static _ThicknessTextureEnabled;
  106718. /**
  106719. * Are thickness textures enabled in the application.
  106720. */
  106721. static ThicknessTextureEnabled: boolean;
  106722. }
  106723. }
  106724. declare module BABYLON {
  106725. /** @hidden */
  106726. export var defaultFragmentDeclaration: {
  106727. name: string;
  106728. shader: string;
  106729. };
  106730. }
  106731. declare module BABYLON {
  106732. /** @hidden */
  106733. export var defaultUboDeclaration: {
  106734. name: string;
  106735. shader: string;
  106736. };
  106737. }
  106738. declare module BABYLON {
  106739. /** @hidden */
  106740. export var lightFragmentDeclaration: {
  106741. name: string;
  106742. shader: string;
  106743. };
  106744. }
  106745. declare module BABYLON {
  106746. /** @hidden */
  106747. export var lightUboDeclaration: {
  106748. name: string;
  106749. shader: string;
  106750. };
  106751. }
  106752. declare module BABYLON {
  106753. /** @hidden */
  106754. export var lightsFragmentFunctions: {
  106755. name: string;
  106756. shader: string;
  106757. };
  106758. }
  106759. declare module BABYLON {
  106760. /** @hidden */
  106761. export var shadowsFragmentFunctions: {
  106762. name: string;
  106763. shader: string;
  106764. };
  106765. }
  106766. declare module BABYLON {
  106767. /** @hidden */
  106768. export var fresnelFunction: {
  106769. name: string;
  106770. shader: string;
  106771. };
  106772. }
  106773. declare module BABYLON {
  106774. /** @hidden */
  106775. export var reflectionFunction: {
  106776. name: string;
  106777. shader: string;
  106778. };
  106779. }
  106780. declare module BABYLON {
  106781. /** @hidden */
  106782. export var bumpFragmentFunctions: {
  106783. name: string;
  106784. shader: string;
  106785. };
  106786. }
  106787. declare module BABYLON {
  106788. /** @hidden */
  106789. export var logDepthDeclaration: {
  106790. name: string;
  106791. shader: string;
  106792. };
  106793. }
  106794. declare module BABYLON {
  106795. /** @hidden */
  106796. export var bumpFragment: {
  106797. name: string;
  106798. shader: string;
  106799. };
  106800. }
  106801. declare module BABYLON {
  106802. /** @hidden */
  106803. export var depthPrePass: {
  106804. name: string;
  106805. shader: string;
  106806. };
  106807. }
  106808. declare module BABYLON {
  106809. /** @hidden */
  106810. export var lightFragment: {
  106811. name: string;
  106812. shader: string;
  106813. };
  106814. }
  106815. declare module BABYLON {
  106816. /** @hidden */
  106817. export var logDepthFragment: {
  106818. name: string;
  106819. shader: string;
  106820. };
  106821. }
  106822. declare module BABYLON {
  106823. /** @hidden */
  106824. export var defaultPixelShader: {
  106825. name: string;
  106826. shader: string;
  106827. };
  106828. }
  106829. declare module BABYLON {
  106830. /** @hidden */
  106831. export var defaultVertexDeclaration: {
  106832. name: string;
  106833. shader: string;
  106834. };
  106835. }
  106836. declare module BABYLON {
  106837. /** @hidden */
  106838. export var bumpVertexDeclaration: {
  106839. name: string;
  106840. shader: string;
  106841. };
  106842. }
  106843. declare module BABYLON {
  106844. /** @hidden */
  106845. export var bumpVertex: {
  106846. name: string;
  106847. shader: string;
  106848. };
  106849. }
  106850. declare module BABYLON {
  106851. /** @hidden */
  106852. export var fogVertex: {
  106853. name: string;
  106854. shader: string;
  106855. };
  106856. }
  106857. declare module BABYLON {
  106858. /** @hidden */
  106859. export var shadowsVertex: {
  106860. name: string;
  106861. shader: string;
  106862. };
  106863. }
  106864. declare module BABYLON {
  106865. /** @hidden */
  106866. export var pointCloudVertex: {
  106867. name: string;
  106868. shader: string;
  106869. };
  106870. }
  106871. declare module BABYLON {
  106872. /** @hidden */
  106873. export var logDepthVertex: {
  106874. name: string;
  106875. shader: string;
  106876. };
  106877. }
  106878. declare module BABYLON {
  106879. /** @hidden */
  106880. export var defaultVertexShader: {
  106881. name: string;
  106882. shader: string;
  106883. };
  106884. }
  106885. declare module BABYLON {
  106886. /** @hidden */
  106887. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  106888. MAINUV1: boolean;
  106889. MAINUV2: boolean;
  106890. DIFFUSE: boolean;
  106891. DIFFUSEDIRECTUV: number;
  106892. AMBIENT: boolean;
  106893. AMBIENTDIRECTUV: number;
  106894. OPACITY: boolean;
  106895. OPACITYDIRECTUV: number;
  106896. OPACITYRGB: boolean;
  106897. REFLECTION: boolean;
  106898. EMISSIVE: boolean;
  106899. EMISSIVEDIRECTUV: number;
  106900. SPECULAR: boolean;
  106901. SPECULARDIRECTUV: number;
  106902. BUMP: boolean;
  106903. BUMPDIRECTUV: number;
  106904. PARALLAX: boolean;
  106905. PARALLAXOCCLUSION: boolean;
  106906. SPECULAROVERALPHA: boolean;
  106907. CLIPPLANE: boolean;
  106908. CLIPPLANE2: boolean;
  106909. CLIPPLANE3: boolean;
  106910. CLIPPLANE4: boolean;
  106911. ALPHATEST: boolean;
  106912. DEPTHPREPASS: boolean;
  106913. ALPHAFROMDIFFUSE: boolean;
  106914. POINTSIZE: boolean;
  106915. FOG: boolean;
  106916. SPECULARTERM: boolean;
  106917. DIFFUSEFRESNEL: boolean;
  106918. OPACITYFRESNEL: boolean;
  106919. REFLECTIONFRESNEL: boolean;
  106920. REFRACTIONFRESNEL: boolean;
  106921. EMISSIVEFRESNEL: boolean;
  106922. FRESNEL: boolean;
  106923. NORMAL: boolean;
  106924. UV1: boolean;
  106925. UV2: boolean;
  106926. VERTEXCOLOR: boolean;
  106927. VERTEXALPHA: boolean;
  106928. NUM_BONE_INFLUENCERS: number;
  106929. BonesPerMesh: number;
  106930. BONETEXTURE: boolean;
  106931. INSTANCES: boolean;
  106932. GLOSSINESS: boolean;
  106933. ROUGHNESS: boolean;
  106934. EMISSIVEASILLUMINATION: boolean;
  106935. LINKEMISSIVEWITHDIFFUSE: boolean;
  106936. REFLECTIONFRESNELFROMSPECULAR: boolean;
  106937. LIGHTMAP: boolean;
  106938. LIGHTMAPDIRECTUV: number;
  106939. OBJECTSPACE_NORMALMAP: boolean;
  106940. USELIGHTMAPASSHADOWMAP: boolean;
  106941. REFLECTIONMAP_3D: boolean;
  106942. REFLECTIONMAP_SPHERICAL: boolean;
  106943. REFLECTIONMAP_PLANAR: boolean;
  106944. REFLECTIONMAP_CUBIC: boolean;
  106945. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106946. REFLECTIONMAP_PROJECTION: boolean;
  106947. REFLECTIONMAP_SKYBOX: boolean;
  106948. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  106949. REFLECTIONMAP_EXPLICIT: boolean;
  106950. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106951. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106952. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106953. INVERTCUBICMAP: boolean;
  106954. LOGARITHMICDEPTH: boolean;
  106955. REFRACTION: boolean;
  106956. REFRACTIONMAP_3D: boolean;
  106957. REFLECTIONOVERALPHA: boolean;
  106958. TWOSIDEDLIGHTING: boolean;
  106959. SHADOWFLOAT: boolean;
  106960. MORPHTARGETS: boolean;
  106961. MORPHTARGETS_NORMAL: boolean;
  106962. MORPHTARGETS_TANGENT: boolean;
  106963. MORPHTARGETS_UV: boolean;
  106964. NUM_MORPH_INFLUENCERS: number;
  106965. NONUNIFORMSCALING: boolean;
  106966. PREMULTIPLYALPHA: boolean;
  106967. IMAGEPROCESSING: boolean;
  106968. VIGNETTE: boolean;
  106969. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106970. VIGNETTEBLENDMODEOPAQUE: boolean;
  106971. TONEMAPPING: boolean;
  106972. TONEMAPPING_ACES: boolean;
  106973. CONTRAST: boolean;
  106974. COLORCURVES: boolean;
  106975. COLORGRADING: boolean;
  106976. COLORGRADING3D: boolean;
  106977. SAMPLER3DGREENDEPTH: boolean;
  106978. SAMPLER3DBGRMAP: boolean;
  106979. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106980. MULTIVIEW: boolean;
  106981. /**
  106982. * If the reflection texture on this material is in linear color space
  106983. * @hidden
  106984. */
  106985. IS_REFLECTION_LINEAR: boolean;
  106986. /**
  106987. * If the refraction texture on this material is in linear color space
  106988. * @hidden
  106989. */
  106990. IS_REFRACTION_LINEAR: boolean;
  106991. EXPOSURE: boolean;
  106992. constructor();
  106993. setReflectionMode(modeToEnable: string): void;
  106994. }
  106995. /**
  106996. * This is the default material used in Babylon. It is the best trade off between quality
  106997. * and performances.
  106998. * @see http://doc.babylonjs.com/babylon101/materials
  106999. */
  107000. export class StandardMaterial extends PushMaterial {
  107001. private _diffuseTexture;
  107002. /**
  107003. * The basic texture of the material as viewed under a light.
  107004. */
  107005. diffuseTexture: Nullable<BaseTexture>;
  107006. private _ambientTexture;
  107007. /**
  107008. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107009. */
  107010. ambientTexture: Nullable<BaseTexture>;
  107011. private _opacityTexture;
  107012. /**
  107013. * Define the transparency of the material from a texture.
  107014. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107015. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107016. */
  107017. opacityTexture: Nullable<BaseTexture>;
  107018. private _reflectionTexture;
  107019. /**
  107020. * Define the texture used to display the reflection.
  107021. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107022. */
  107023. reflectionTexture: Nullable<BaseTexture>;
  107024. private _emissiveTexture;
  107025. /**
  107026. * Define texture of the material as if self lit.
  107027. * This will be mixed in the final result even in the absence of light.
  107028. */
  107029. emissiveTexture: Nullable<BaseTexture>;
  107030. private _specularTexture;
  107031. /**
  107032. * Define how the color and intensity of the highlight given by the light in the material.
  107033. */
  107034. specularTexture: Nullable<BaseTexture>;
  107035. private _bumpTexture;
  107036. /**
  107037. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107038. * 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.
  107039. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  107040. */
  107041. bumpTexture: Nullable<BaseTexture>;
  107042. private _lightmapTexture;
  107043. /**
  107044. * Complex lighting can be computationally expensive to compute at runtime.
  107045. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107046. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  107047. */
  107048. lightmapTexture: Nullable<BaseTexture>;
  107049. private _refractionTexture;
  107050. /**
  107051. * Define the texture used to display the refraction.
  107052. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107053. */
  107054. refractionTexture: Nullable<BaseTexture>;
  107055. /**
  107056. * The color of the material lit by the environmental background lighting.
  107057. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107058. */
  107059. ambientColor: Color3;
  107060. /**
  107061. * The basic color of the material as viewed under a light.
  107062. */
  107063. diffuseColor: Color3;
  107064. /**
  107065. * Define how the color and intensity of the highlight given by the light in the material.
  107066. */
  107067. specularColor: Color3;
  107068. /**
  107069. * Define the color of the material as if self lit.
  107070. * This will be mixed in the final result even in the absence of light.
  107071. */
  107072. emissiveColor: Color3;
  107073. /**
  107074. * Defines how sharp are the highlights in the material.
  107075. * The bigger the value the sharper giving a more glossy feeling to the result.
  107076. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107077. */
  107078. specularPower: number;
  107079. private _useAlphaFromDiffuseTexture;
  107080. /**
  107081. * Does the transparency come from the diffuse texture alpha channel.
  107082. */
  107083. useAlphaFromDiffuseTexture: boolean;
  107084. private _useEmissiveAsIllumination;
  107085. /**
  107086. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107087. */
  107088. useEmissiveAsIllumination: boolean;
  107089. private _linkEmissiveWithDiffuse;
  107090. /**
  107091. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107092. * the emissive level when the final color is close to one.
  107093. */
  107094. linkEmissiveWithDiffuse: boolean;
  107095. private _useSpecularOverAlpha;
  107096. /**
  107097. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107098. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107099. */
  107100. useSpecularOverAlpha: boolean;
  107101. private _useReflectionOverAlpha;
  107102. /**
  107103. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107104. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107105. */
  107106. useReflectionOverAlpha: boolean;
  107107. private _disableLighting;
  107108. /**
  107109. * Does lights from the scene impacts this material.
  107110. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107111. */
  107112. disableLighting: boolean;
  107113. private _useObjectSpaceNormalMap;
  107114. /**
  107115. * Allows using an object space normal map (instead of tangent space).
  107116. */
  107117. useObjectSpaceNormalMap: boolean;
  107118. private _useParallax;
  107119. /**
  107120. * Is parallax enabled or not.
  107121. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107122. */
  107123. useParallax: boolean;
  107124. private _useParallaxOcclusion;
  107125. /**
  107126. * Is parallax occlusion enabled or not.
  107127. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107128. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107129. */
  107130. useParallaxOcclusion: boolean;
  107131. /**
  107132. * 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.
  107133. */
  107134. parallaxScaleBias: number;
  107135. private _roughness;
  107136. /**
  107137. * Helps to define how blurry the reflections should appears in the material.
  107138. */
  107139. roughness: number;
  107140. /**
  107141. * In case of refraction, define the value of the index of refraction.
  107142. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107143. */
  107144. indexOfRefraction: number;
  107145. /**
  107146. * Invert the refraction texture alongside the y axis.
  107147. * It can be useful with procedural textures or probe for instance.
  107148. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107149. */
  107150. invertRefractionY: boolean;
  107151. /**
  107152. * Defines the alpha limits in alpha test mode.
  107153. */
  107154. alphaCutOff: number;
  107155. private _useLightmapAsShadowmap;
  107156. /**
  107157. * In case of light mapping, define whether the map contains light or shadow informations.
  107158. */
  107159. useLightmapAsShadowmap: boolean;
  107160. private _diffuseFresnelParameters;
  107161. /**
  107162. * Define the diffuse fresnel parameters of the material.
  107163. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107164. */
  107165. diffuseFresnelParameters: FresnelParameters;
  107166. private _opacityFresnelParameters;
  107167. /**
  107168. * Define the opacity fresnel parameters of the material.
  107169. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107170. */
  107171. opacityFresnelParameters: FresnelParameters;
  107172. private _reflectionFresnelParameters;
  107173. /**
  107174. * Define the reflection fresnel parameters of the material.
  107175. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107176. */
  107177. reflectionFresnelParameters: FresnelParameters;
  107178. private _refractionFresnelParameters;
  107179. /**
  107180. * Define the refraction fresnel parameters of the material.
  107181. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107182. */
  107183. refractionFresnelParameters: FresnelParameters;
  107184. private _emissiveFresnelParameters;
  107185. /**
  107186. * Define the emissive fresnel parameters of the material.
  107187. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107188. */
  107189. emissiveFresnelParameters: FresnelParameters;
  107190. private _useReflectionFresnelFromSpecular;
  107191. /**
  107192. * If true automatically deducts the fresnels values from the material specularity.
  107193. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107194. */
  107195. useReflectionFresnelFromSpecular: boolean;
  107196. private _useGlossinessFromSpecularMapAlpha;
  107197. /**
  107198. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107199. */
  107200. useGlossinessFromSpecularMapAlpha: boolean;
  107201. private _maxSimultaneousLights;
  107202. /**
  107203. * Defines the maximum number of lights that can be used in the material
  107204. */
  107205. maxSimultaneousLights: number;
  107206. private _invertNormalMapX;
  107207. /**
  107208. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107209. */
  107210. invertNormalMapX: boolean;
  107211. private _invertNormalMapY;
  107212. /**
  107213. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107214. */
  107215. invertNormalMapY: boolean;
  107216. private _twoSidedLighting;
  107217. /**
  107218. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107219. */
  107220. twoSidedLighting: boolean;
  107221. /**
  107222. * Default configuration related to image processing available in the standard Material.
  107223. */
  107224. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107225. /**
  107226. * Gets the image processing configuration used either in this material.
  107227. */
  107228. /**
  107229. * Sets the Default image processing configuration used either in the this material.
  107230. *
  107231. * If sets to null, the scene one is in use.
  107232. */
  107233. imageProcessingConfiguration: ImageProcessingConfiguration;
  107234. /**
  107235. * Keep track of the image processing observer to allow dispose and replace.
  107236. */
  107237. private _imageProcessingObserver;
  107238. /**
  107239. * Attaches a new image processing configuration to the Standard Material.
  107240. * @param configuration
  107241. */
  107242. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107243. /**
  107244. * Gets wether the color curves effect is enabled.
  107245. */
  107246. /**
  107247. * Sets wether the color curves effect is enabled.
  107248. */
  107249. cameraColorCurvesEnabled: boolean;
  107250. /**
  107251. * Gets wether the color grading effect is enabled.
  107252. */
  107253. /**
  107254. * Gets wether the color grading effect is enabled.
  107255. */
  107256. cameraColorGradingEnabled: boolean;
  107257. /**
  107258. * Gets wether tonemapping is enabled or not.
  107259. */
  107260. /**
  107261. * Sets wether tonemapping is enabled or not
  107262. */
  107263. cameraToneMappingEnabled: boolean;
  107264. /**
  107265. * The camera exposure used on this material.
  107266. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107267. * This corresponds to a photographic exposure.
  107268. */
  107269. /**
  107270. * The camera exposure used on this material.
  107271. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107272. * This corresponds to a photographic exposure.
  107273. */
  107274. cameraExposure: number;
  107275. /**
  107276. * Gets The camera contrast used on this material.
  107277. */
  107278. /**
  107279. * Sets The camera contrast used on this material.
  107280. */
  107281. cameraContrast: number;
  107282. /**
  107283. * Gets the Color Grading 2D Lookup Texture.
  107284. */
  107285. /**
  107286. * Sets the Color Grading 2D Lookup Texture.
  107287. */
  107288. cameraColorGradingTexture: Nullable<BaseTexture>;
  107289. /**
  107290. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107291. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107292. * 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;
  107293. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107294. */
  107295. /**
  107296. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107297. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107298. * 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;
  107299. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107300. */
  107301. cameraColorCurves: Nullable<ColorCurves>;
  107302. /**
  107303. * Custom callback helping to override the default shader used in the material.
  107304. */
  107305. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  107306. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107307. protected _worldViewProjectionMatrix: Matrix;
  107308. protected _globalAmbientColor: Color3;
  107309. protected _useLogarithmicDepth: boolean;
  107310. protected _rebuildInParallel: boolean;
  107311. /**
  107312. * Instantiates a new standard material.
  107313. * This is the default material used in Babylon. It is the best trade off between quality
  107314. * and performances.
  107315. * @see http://doc.babylonjs.com/babylon101/materials
  107316. * @param name Define the name of the material in the scene
  107317. * @param scene Define the scene the material belong to
  107318. */
  107319. constructor(name: string, scene: Scene);
  107320. /**
  107321. * Gets a boolean indicating that current material needs to register RTT
  107322. */
  107323. readonly hasRenderTargetTextures: boolean;
  107324. /**
  107325. * Gets the current class name of the material e.g. "StandardMaterial"
  107326. * Mainly use in serialization.
  107327. * @returns the class name
  107328. */
  107329. getClassName(): string;
  107330. /**
  107331. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107332. * You can try switching to logarithmic depth.
  107333. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107334. */
  107335. useLogarithmicDepth: boolean;
  107336. /**
  107337. * Specifies if the material will require alpha blending
  107338. * @returns a boolean specifying if alpha blending is needed
  107339. */
  107340. needAlphaBlending(): boolean;
  107341. /**
  107342. * Specifies if this material should be rendered in alpha test mode
  107343. * @returns a boolean specifying if an alpha test is needed.
  107344. */
  107345. needAlphaTesting(): boolean;
  107346. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107347. /**
  107348. * Get the texture used for alpha test purpose.
  107349. * @returns the diffuse texture in case of the standard material.
  107350. */
  107351. getAlphaTestTexture(): Nullable<BaseTexture>;
  107352. /**
  107353. * Get if the submesh is ready to be used and all its information available.
  107354. * Child classes can use it to update shaders
  107355. * @param mesh defines the mesh to check
  107356. * @param subMesh defines which submesh to check
  107357. * @param useInstances specifies that instances should be used
  107358. * @returns a boolean indicating that the submesh is ready or not
  107359. */
  107360. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107361. /**
  107362. * Builds the material UBO layouts.
  107363. * Used internally during the effect preparation.
  107364. */
  107365. buildUniformLayout(): void;
  107366. /**
  107367. * Unbinds the material from the mesh
  107368. */
  107369. unbind(): void;
  107370. /**
  107371. * Binds the submesh to this material by preparing the effect and shader to draw
  107372. * @param world defines the world transformation matrix
  107373. * @param mesh defines the mesh containing the submesh
  107374. * @param subMesh defines the submesh to bind the material to
  107375. */
  107376. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107377. /**
  107378. * Get the list of animatables in the material.
  107379. * @returns the list of animatables object used in the material
  107380. */
  107381. getAnimatables(): IAnimatable[];
  107382. /**
  107383. * Gets the active textures from the material
  107384. * @returns an array of textures
  107385. */
  107386. getActiveTextures(): BaseTexture[];
  107387. /**
  107388. * Specifies if the material uses a texture
  107389. * @param texture defines the texture to check against the material
  107390. * @returns a boolean specifying if the material uses the texture
  107391. */
  107392. hasTexture(texture: BaseTexture): boolean;
  107393. /**
  107394. * Disposes the material
  107395. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107396. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107397. */
  107398. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107399. /**
  107400. * Makes a duplicate of the material, and gives it a new name
  107401. * @param name defines the new name for the duplicated material
  107402. * @returns the cloned material
  107403. */
  107404. clone(name: string): StandardMaterial;
  107405. /**
  107406. * Serializes this material in a JSON representation
  107407. * @returns the serialized material object
  107408. */
  107409. serialize(): any;
  107410. /**
  107411. * Creates a standard material from parsed material data
  107412. * @param source defines the JSON representation of the material
  107413. * @param scene defines the hosting scene
  107414. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107415. * @returns a new standard material
  107416. */
  107417. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107418. /**
  107419. * Are diffuse textures enabled in the application.
  107420. */
  107421. static DiffuseTextureEnabled: boolean;
  107422. /**
  107423. * Are ambient textures enabled in the application.
  107424. */
  107425. static AmbientTextureEnabled: boolean;
  107426. /**
  107427. * Are opacity textures enabled in the application.
  107428. */
  107429. static OpacityTextureEnabled: boolean;
  107430. /**
  107431. * Are reflection textures enabled in the application.
  107432. */
  107433. static ReflectionTextureEnabled: boolean;
  107434. /**
  107435. * Are emissive textures enabled in the application.
  107436. */
  107437. static EmissiveTextureEnabled: boolean;
  107438. /**
  107439. * Are specular textures enabled in the application.
  107440. */
  107441. static SpecularTextureEnabled: boolean;
  107442. /**
  107443. * Are bump textures enabled in the application.
  107444. */
  107445. static BumpTextureEnabled: boolean;
  107446. /**
  107447. * Are lightmap textures enabled in the application.
  107448. */
  107449. static LightmapTextureEnabled: boolean;
  107450. /**
  107451. * Are refraction textures enabled in the application.
  107452. */
  107453. static RefractionTextureEnabled: boolean;
  107454. /**
  107455. * Are color grading textures enabled in the application.
  107456. */
  107457. static ColorGradingTextureEnabled: boolean;
  107458. /**
  107459. * Are fresnels enabled in the application.
  107460. */
  107461. static FresnelEnabled: boolean;
  107462. }
  107463. }
  107464. declare module BABYLON {
  107465. /** @hidden */
  107466. export var imageProcessingPixelShader: {
  107467. name: string;
  107468. shader: string;
  107469. };
  107470. }
  107471. declare module BABYLON {
  107472. /**
  107473. * ImageProcessingPostProcess
  107474. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  107475. */
  107476. export class ImageProcessingPostProcess extends PostProcess {
  107477. /**
  107478. * Default configuration related to image processing available in the PBR Material.
  107479. */
  107480. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107481. /**
  107482. * Gets the image processing configuration used either in this material.
  107483. */
  107484. /**
  107485. * Sets the Default image processing configuration used either in the this material.
  107486. *
  107487. * If sets to null, the scene one is in use.
  107488. */
  107489. imageProcessingConfiguration: ImageProcessingConfiguration;
  107490. /**
  107491. * Keep track of the image processing observer to allow dispose and replace.
  107492. */
  107493. private _imageProcessingObserver;
  107494. /**
  107495. * Attaches a new image processing configuration to the PBR Material.
  107496. * @param configuration
  107497. */
  107498. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  107499. /**
  107500. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107501. */
  107502. /**
  107503. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107504. */
  107505. colorCurves: Nullable<ColorCurves>;
  107506. /**
  107507. * Gets wether the color curves effect is enabled.
  107508. */
  107509. /**
  107510. * Sets wether the color curves effect is enabled.
  107511. */
  107512. colorCurvesEnabled: boolean;
  107513. /**
  107514. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107515. */
  107516. /**
  107517. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107518. */
  107519. colorGradingTexture: Nullable<BaseTexture>;
  107520. /**
  107521. * Gets wether the color grading effect is enabled.
  107522. */
  107523. /**
  107524. * Gets wether the color grading effect is enabled.
  107525. */
  107526. colorGradingEnabled: boolean;
  107527. /**
  107528. * Gets exposure used in the effect.
  107529. */
  107530. /**
  107531. * Sets exposure used in the effect.
  107532. */
  107533. exposure: number;
  107534. /**
  107535. * Gets wether tonemapping is enabled or not.
  107536. */
  107537. /**
  107538. * Sets wether tonemapping is enabled or not
  107539. */
  107540. toneMappingEnabled: boolean;
  107541. /**
  107542. * Gets the type of tone mapping effect.
  107543. */
  107544. /**
  107545. * Sets the type of tone mapping effect.
  107546. */
  107547. toneMappingType: number;
  107548. /**
  107549. * Gets contrast used in the effect.
  107550. */
  107551. /**
  107552. * Sets contrast used in the effect.
  107553. */
  107554. contrast: number;
  107555. /**
  107556. * Gets Vignette stretch size.
  107557. */
  107558. /**
  107559. * Sets Vignette stretch size.
  107560. */
  107561. vignetteStretch: number;
  107562. /**
  107563. * Gets Vignette centre X Offset.
  107564. */
  107565. /**
  107566. * Sets Vignette centre X Offset.
  107567. */
  107568. vignetteCentreX: number;
  107569. /**
  107570. * Gets Vignette centre Y Offset.
  107571. */
  107572. /**
  107573. * Sets Vignette centre Y Offset.
  107574. */
  107575. vignetteCentreY: number;
  107576. /**
  107577. * Gets Vignette weight or intensity of the vignette effect.
  107578. */
  107579. /**
  107580. * Sets Vignette weight or intensity of the vignette effect.
  107581. */
  107582. vignetteWeight: number;
  107583. /**
  107584. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107585. * if vignetteEnabled is set to true.
  107586. */
  107587. /**
  107588. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107589. * if vignetteEnabled is set to true.
  107590. */
  107591. vignetteColor: Color4;
  107592. /**
  107593. * Gets Camera field of view used by the Vignette effect.
  107594. */
  107595. /**
  107596. * Sets Camera field of view used by the Vignette effect.
  107597. */
  107598. vignetteCameraFov: number;
  107599. /**
  107600. * Gets the vignette blend mode allowing different kind of effect.
  107601. */
  107602. /**
  107603. * Sets the vignette blend mode allowing different kind of effect.
  107604. */
  107605. vignetteBlendMode: number;
  107606. /**
  107607. * Gets wether the vignette effect is enabled.
  107608. */
  107609. /**
  107610. * Sets wether the vignette effect is enabled.
  107611. */
  107612. vignetteEnabled: boolean;
  107613. private _fromLinearSpace;
  107614. /**
  107615. * Gets wether the input of the processing is in Gamma or Linear Space.
  107616. */
  107617. /**
  107618. * Sets wether the input of the processing is in Gamma or Linear Space.
  107619. */
  107620. fromLinearSpace: boolean;
  107621. /**
  107622. * Defines cache preventing GC.
  107623. */
  107624. private _defines;
  107625. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  107626. /**
  107627. * "ImageProcessingPostProcess"
  107628. * @returns "ImageProcessingPostProcess"
  107629. */
  107630. getClassName(): string;
  107631. protected _updateParameters(): void;
  107632. dispose(camera?: Camera): void;
  107633. }
  107634. }
  107635. declare module BABYLON {
  107636. /**
  107637. * Class containing static functions to help procedurally build meshes
  107638. */
  107639. export class GroundBuilder {
  107640. /**
  107641. * Creates a ground mesh
  107642. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107643. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107645. * @param name defines the name of the mesh
  107646. * @param options defines the options used to create the mesh
  107647. * @param scene defines the hosting scene
  107648. * @returns the ground mesh
  107649. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  107650. */
  107651. static CreateGround(name: string, options: {
  107652. width?: number;
  107653. height?: number;
  107654. subdivisions?: number;
  107655. subdivisionsX?: number;
  107656. subdivisionsY?: number;
  107657. updatable?: boolean;
  107658. }, scene: any): Mesh;
  107659. /**
  107660. * Creates a tiled ground mesh
  107661. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  107662. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  107663. * * 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
  107664. * * 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
  107665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107666. * @param name defines the name of the mesh
  107667. * @param options defines the options used to create the mesh
  107668. * @param scene defines the hosting scene
  107669. * @returns the tiled ground mesh
  107670. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  107671. */
  107672. static CreateTiledGround(name: string, options: {
  107673. xmin: number;
  107674. zmin: number;
  107675. xmax: number;
  107676. zmax: number;
  107677. subdivisions?: {
  107678. w: number;
  107679. h: number;
  107680. };
  107681. precision?: {
  107682. w: number;
  107683. h: number;
  107684. };
  107685. updatable?: boolean;
  107686. }, scene?: Nullable<Scene>): Mesh;
  107687. /**
  107688. * Creates a ground mesh from a height map
  107689. * * The parameter `url` sets the URL of the height map image resource.
  107690. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  107691. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  107692. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  107693. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  107694. * * 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.
  107695. * * 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).
  107696. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107698. * @param name defines the name of the mesh
  107699. * @param url defines the url to the height map
  107700. * @param options defines the options used to create the mesh
  107701. * @param scene defines the hosting scene
  107702. * @returns the ground mesh
  107703. * @see https://doc.babylonjs.com/babylon101/height_map
  107704. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  107705. */
  107706. static CreateGroundFromHeightMap(name: string, url: string, options: {
  107707. width?: number;
  107708. height?: number;
  107709. subdivisions?: number;
  107710. minHeight?: number;
  107711. maxHeight?: number;
  107712. colorFilter?: Color3;
  107713. alphaFilter?: number;
  107714. updatable?: boolean;
  107715. onReady?: (mesh: GroundMesh) => void;
  107716. }, scene?: Nullable<Scene>): GroundMesh;
  107717. }
  107718. }
  107719. declare module BABYLON {
  107720. /**
  107721. * Class containing static functions to help procedurally build meshes
  107722. */
  107723. export class TorusBuilder {
  107724. /**
  107725. * Creates a torus mesh
  107726. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107727. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107728. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107730. * * 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
  107731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107732. * @param name defines the name of the mesh
  107733. * @param options defines the options used to create the mesh
  107734. * @param scene defines the hosting scene
  107735. * @returns the torus mesh
  107736. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107737. */
  107738. static CreateTorus(name: string, options: {
  107739. diameter?: number;
  107740. thickness?: number;
  107741. tessellation?: number;
  107742. updatable?: boolean;
  107743. sideOrientation?: number;
  107744. frontUVs?: Vector4;
  107745. backUVs?: Vector4;
  107746. }, scene: any): Mesh;
  107747. }
  107748. }
  107749. declare module BABYLON {
  107750. /**
  107751. * Class containing static functions to help procedurally build meshes
  107752. */
  107753. export class CylinderBuilder {
  107754. /**
  107755. * Creates a cylinder or a cone mesh
  107756. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107757. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107758. * * 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.
  107759. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107760. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107761. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107762. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107763. * * 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).
  107764. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107765. * * 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).
  107766. * * 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
  107767. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107768. * * 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
  107769. * * 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.
  107770. * * If `enclose` is false, a ring surface is one element.
  107771. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107772. * * 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
  107773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107774. * * 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
  107775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107776. * @param name defines the name of the mesh
  107777. * @param options defines the options used to create the mesh
  107778. * @param scene defines the hosting scene
  107779. * @returns the cylinder mesh
  107780. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107781. */
  107782. static CreateCylinder(name: string, options: {
  107783. height?: number;
  107784. diameterTop?: number;
  107785. diameterBottom?: number;
  107786. diameter?: number;
  107787. tessellation?: number;
  107788. subdivisions?: number;
  107789. arc?: number;
  107790. faceColors?: Color4[];
  107791. faceUV?: Vector4[];
  107792. updatable?: boolean;
  107793. hasRings?: boolean;
  107794. enclose?: boolean;
  107795. cap?: number;
  107796. sideOrientation?: number;
  107797. frontUVs?: Vector4;
  107798. backUVs?: Vector4;
  107799. }, scene: any): Mesh;
  107800. }
  107801. }
  107802. declare module BABYLON {
  107803. /**
  107804. * Options to modify the vr teleportation behavior.
  107805. */
  107806. export interface VRTeleportationOptions {
  107807. /**
  107808. * The name of the mesh which should be used as the teleportation floor. (default: null)
  107809. */
  107810. floorMeshName?: string;
  107811. /**
  107812. * A list of meshes to be used as the teleportation floor. (default: empty)
  107813. */
  107814. floorMeshes?: Mesh[];
  107815. }
  107816. /**
  107817. * Options to modify the vr experience helper's behavior.
  107818. */
  107819. export interface VRExperienceHelperOptions extends WebVROptions {
  107820. /**
  107821. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  107822. */
  107823. createDeviceOrientationCamera?: boolean;
  107824. /**
  107825. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  107826. */
  107827. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  107828. /**
  107829. * Uses the main button on the controller to toggle the laser casted. (default: true)
  107830. */
  107831. laserToggle?: boolean;
  107832. /**
  107833. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  107834. */
  107835. floorMeshes?: Mesh[];
  107836. /**
  107837. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  107838. */
  107839. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  107840. }
  107841. /**
  107842. * Event containing information after VR has been entered
  107843. */
  107844. export class OnAfterEnteringVRObservableEvent {
  107845. /**
  107846. * If entering vr was successful
  107847. */
  107848. success: boolean;
  107849. }
  107850. /**
  107851. * Helps to quickly add VR support to an existing scene.
  107852. * See http://doc.babylonjs.com/how_to/webvr_helper
  107853. */
  107854. export class VRExperienceHelper {
  107855. /** Options to modify the vr experience helper's behavior. */
  107856. webVROptions: VRExperienceHelperOptions;
  107857. private _scene;
  107858. private _position;
  107859. private _btnVR;
  107860. private _btnVRDisplayed;
  107861. private _webVRsupported;
  107862. private _webVRready;
  107863. private _webVRrequesting;
  107864. private _webVRpresenting;
  107865. private _hasEnteredVR;
  107866. private _fullscreenVRpresenting;
  107867. private _canvas;
  107868. private _webVRCamera;
  107869. private _vrDeviceOrientationCamera;
  107870. private _deviceOrientationCamera;
  107871. private _existingCamera;
  107872. private _onKeyDown;
  107873. private _onVrDisplayPresentChange;
  107874. private _onVRDisplayChanged;
  107875. private _onVRRequestPresentStart;
  107876. private _onVRRequestPresentComplete;
  107877. /**
  107878. * 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)
  107879. */
  107880. enableGazeEvenWhenNoPointerLock: boolean;
  107881. /**
  107882. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  107883. */
  107884. exitVROnDoubleTap: boolean;
  107885. /**
  107886. * Observable raised right before entering VR.
  107887. */
  107888. onEnteringVRObservable: Observable<VRExperienceHelper>;
  107889. /**
  107890. * Observable raised when entering VR has completed.
  107891. */
  107892. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  107893. /**
  107894. * Observable raised when exiting VR.
  107895. */
  107896. onExitingVRObservable: Observable<VRExperienceHelper>;
  107897. /**
  107898. * Observable raised when controller mesh is loaded.
  107899. */
  107900. onControllerMeshLoadedObservable: Observable<WebVRController>;
  107901. /** Return this.onEnteringVRObservable
  107902. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  107903. */
  107904. readonly onEnteringVR: Observable<VRExperienceHelper>;
  107905. /** Return this.onExitingVRObservable
  107906. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  107907. */
  107908. readonly onExitingVR: Observable<VRExperienceHelper>;
  107909. /** Return this.onControllerMeshLoadedObservable
  107910. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  107911. */
  107912. readonly onControllerMeshLoaded: Observable<WebVRController>;
  107913. private _rayLength;
  107914. private _useCustomVRButton;
  107915. private _teleportationRequested;
  107916. private _teleportActive;
  107917. private _floorMeshName;
  107918. private _floorMeshesCollection;
  107919. private _rotationAllowed;
  107920. private _teleportBackwardsVector;
  107921. private _teleportationTarget;
  107922. private _isDefaultTeleportationTarget;
  107923. private _postProcessMove;
  107924. private _teleportationFillColor;
  107925. private _teleportationBorderColor;
  107926. private _rotationAngle;
  107927. private _haloCenter;
  107928. private _cameraGazer;
  107929. private _padSensibilityUp;
  107930. private _padSensibilityDown;
  107931. private _leftController;
  107932. private _rightController;
  107933. /**
  107934. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  107935. */
  107936. onNewMeshSelected: Observable<AbstractMesh>;
  107937. /**
  107938. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  107939. * This observable will provide the mesh and the controller used to select the mesh
  107940. */
  107941. onMeshSelectedWithController: Observable<{
  107942. mesh: AbstractMesh;
  107943. controller: WebVRController;
  107944. }>;
  107945. /**
  107946. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  107947. */
  107948. onNewMeshPicked: Observable<PickingInfo>;
  107949. private _circleEase;
  107950. /**
  107951. * Observable raised before camera teleportation
  107952. */
  107953. onBeforeCameraTeleport: Observable<Vector3>;
  107954. /**
  107955. * Observable raised after camera teleportation
  107956. */
  107957. onAfterCameraTeleport: Observable<Vector3>;
  107958. /**
  107959. * Observable raised when current selected mesh gets unselected
  107960. */
  107961. onSelectedMeshUnselected: Observable<AbstractMesh>;
  107962. private _raySelectionPredicate;
  107963. /**
  107964. * To be optionaly changed by user to define custom ray selection
  107965. */
  107966. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  107967. /**
  107968. * To be optionaly changed by user to define custom selection logic (after ray selection)
  107969. */
  107970. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107971. /**
  107972. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  107973. */
  107974. teleportationEnabled: boolean;
  107975. private _defaultHeight;
  107976. private _teleportationInitialized;
  107977. private _interactionsEnabled;
  107978. private _interactionsRequested;
  107979. private _displayGaze;
  107980. private _displayLaserPointer;
  107981. /**
  107982. * The mesh used to display where the user is going to teleport.
  107983. */
  107984. /**
  107985. * Sets the mesh to be used to display where the user is going to teleport.
  107986. */
  107987. teleportationTarget: Mesh;
  107988. /**
  107989. * 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
  107990. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  107991. * See http://doc.babylonjs.com/resources/baking_transformations
  107992. */
  107993. gazeTrackerMesh: Mesh;
  107994. /**
  107995. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  107996. */
  107997. updateGazeTrackerScale: boolean;
  107998. /**
  107999. * If the gaze trackers color should be updated when selecting meshes
  108000. */
  108001. updateGazeTrackerColor: boolean;
  108002. /**
  108003. * If the controller laser color should be updated when selecting meshes
  108004. */
  108005. updateControllerLaserColor: boolean;
  108006. /**
  108007. * The gaze tracking mesh corresponding to the left controller
  108008. */
  108009. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  108010. /**
  108011. * The gaze tracking mesh corresponding to the right controller
  108012. */
  108013. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  108014. /**
  108015. * If the ray of the gaze should be displayed.
  108016. */
  108017. /**
  108018. * Sets if the ray of the gaze should be displayed.
  108019. */
  108020. displayGaze: boolean;
  108021. /**
  108022. * If the ray of the LaserPointer should be displayed.
  108023. */
  108024. /**
  108025. * Sets if the ray of the LaserPointer should be displayed.
  108026. */
  108027. displayLaserPointer: boolean;
  108028. /**
  108029. * The deviceOrientationCamera used as the camera when not in VR.
  108030. */
  108031. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  108032. /**
  108033. * Based on the current WebVR support, returns the current VR camera used.
  108034. */
  108035. readonly currentVRCamera: Nullable<Camera>;
  108036. /**
  108037. * The webVRCamera which is used when in VR.
  108038. */
  108039. readonly webVRCamera: WebVRFreeCamera;
  108040. /**
  108041. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  108042. */
  108043. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  108044. /**
  108045. * The html button that is used to trigger entering into VR.
  108046. */
  108047. readonly vrButton: Nullable<HTMLButtonElement>;
  108048. private readonly _teleportationRequestInitiated;
  108049. /**
  108050. * Defines wether or not Pointer lock should be requested when switching to
  108051. * full screen.
  108052. */
  108053. requestPointerLockOnFullScreen: boolean;
  108054. /**
  108055. * Instantiates a VRExperienceHelper.
  108056. * Helps to quickly add VR support to an existing scene.
  108057. * @param scene The scene the VRExperienceHelper belongs to.
  108058. * @param webVROptions Options to modify the vr experience helper's behavior.
  108059. */
  108060. constructor(scene: Scene,
  108061. /** Options to modify the vr experience helper's behavior. */
  108062. webVROptions?: VRExperienceHelperOptions);
  108063. private _onDefaultMeshLoaded;
  108064. private _onResize;
  108065. private _onFullscreenChange;
  108066. /**
  108067. * Gets a value indicating if we are currently in VR mode.
  108068. */
  108069. readonly isInVRMode: boolean;
  108070. private onVrDisplayPresentChange;
  108071. private onVRDisplayChanged;
  108072. private moveButtonToBottomRight;
  108073. private displayVRButton;
  108074. private updateButtonVisibility;
  108075. private _cachedAngularSensibility;
  108076. /**
  108077. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  108078. * Otherwise, will use the fullscreen API.
  108079. */
  108080. enterVR(): void;
  108081. /**
  108082. * Attempt to exit VR, or fullscreen.
  108083. */
  108084. exitVR(): void;
  108085. /**
  108086. * The position of the vr experience helper.
  108087. */
  108088. /**
  108089. * Sets the position of the vr experience helper.
  108090. */
  108091. position: Vector3;
  108092. /**
  108093. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  108094. */
  108095. enableInteractions(): void;
  108096. private readonly _noControllerIsActive;
  108097. private beforeRender;
  108098. private _isTeleportationFloor;
  108099. /**
  108100. * Adds a floor mesh to be used for teleportation.
  108101. * @param floorMesh the mesh to be used for teleportation.
  108102. */
  108103. addFloorMesh(floorMesh: Mesh): void;
  108104. /**
  108105. * Removes a floor mesh from being used for teleportation.
  108106. * @param floorMesh the mesh to be removed.
  108107. */
  108108. removeFloorMesh(floorMesh: Mesh): void;
  108109. /**
  108110. * Enables interactions and teleportation using the VR controllers and gaze.
  108111. * @param vrTeleportationOptions options to modify teleportation behavior.
  108112. */
  108113. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  108114. private _onNewGamepadConnected;
  108115. private _tryEnableInteractionOnController;
  108116. private _onNewGamepadDisconnected;
  108117. private _enableInteractionOnController;
  108118. private _checkTeleportWithRay;
  108119. private _checkRotate;
  108120. private _checkTeleportBackwards;
  108121. private _enableTeleportationOnController;
  108122. private _createTeleportationCircles;
  108123. private _displayTeleportationTarget;
  108124. private _hideTeleportationTarget;
  108125. private _rotateCamera;
  108126. private _moveTeleportationSelectorTo;
  108127. private _workingVector;
  108128. private _workingQuaternion;
  108129. private _workingMatrix;
  108130. /**
  108131. * Teleports the users feet to the desired location
  108132. * @param location The location where the user's feet should be placed
  108133. */
  108134. teleportCamera(location: Vector3): void;
  108135. private _convertNormalToDirectionOfRay;
  108136. private _castRayAndSelectObject;
  108137. private _notifySelectedMeshUnselected;
  108138. /**
  108139. * Sets the color of the laser ray from the vr controllers.
  108140. * @param color new color for the ray.
  108141. */
  108142. changeLaserColor(color: Color3): void;
  108143. /**
  108144. * Sets the color of the ray from the vr headsets gaze.
  108145. * @param color new color for the ray.
  108146. */
  108147. changeGazeColor(color: Color3): void;
  108148. /**
  108149. * Exits VR and disposes of the vr experience helper
  108150. */
  108151. dispose(): void;
  108152. /**
  108153. * Gets the name of the VRExperienceHelper class
  108154. * @returns "VRExperienceHelper"
  108155. */
  108156. getClassName(): string;
  108157. }
  108158. }
  108159. declare module BABYLON {
  108160. /**
  108161. * Manages an XRSession to work with Babylon's engine
  108162. * @see https://doc.babylonjs.com/how_to/webxr
  108163. */
  108164. export class WebXRSessionManager implements IDisposable {
  108165. private scene;
  108166. /**
  108167. * Fires every time a new xrFrame arrives which can be used to update the camera
  108168. */
  108169. onXRFrameObservable: Observable<any>;
  108170. /**
  108171. * Fires when the xr session is ended either by the device or manually done
  108172. */
  108173. onXRSessionEnded: Observable<any>;
  108174. /**
  108175. * Underlying xr session
  108176. */
  108177. session: XRSession;
  108178. /**
  108179. * Type of reference space used when creating the session
  108180. */
  108181. referenceSpace: XRReferenceSpace;
  108182. /** @hidden */
  108183. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  108184. /**
  108185. * Current XR frame
  108186. */
  108187. currentFrame: Nullable<XRFrame>;
  108188. private _xrNavigator;
  108189. private baseLayer;
  108190. /**
  108191. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  108192. * @param scene The scene which the session should be created for
  108193. */
  108194. constructor(scene: Scene);
  108195. /**
  108196. * Initializes the manager
  108197. * After initialization enterXR can be called to start an XR session
  108198. * @returns Promise which resolves after it is initialized
  108199. */
  108200. initializeAsync(): Promise<void>;
  108201. /**
  108202. * Initializes an xr session
  108203. * @param xrSessionMode mode to initialize
  108204. * @returns a promise which will resolve once the session has been initialized
  108205. */
  108206. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  108207. /**
  108208. * Sets the reference space on the xr session
  108209. * @param referenceSpace space to set
  108210. * @returns a promise that will resolve once the reference space has been set
  108211. */
  108212. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  108213. /**
  108214. * Updates the render state of the session
  108215. * @param state state to set
  108216. * @returns a promise that resolves once the render state has been updated
  108217. */
  108218. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  108219. /**
  108220. * Starts rendering to the xr layer
  108221. * @returns a promise that will resolve once rendering has started
  108222. */
  108223. startRenderingToXRAsync(): Promise<void>;
  108224. /**
  108225. * Stops the xrSession and restores the renderloop
  108226. * @returns Promise which resolves after it exits XR
  108227. */
  108228. exitXRAsync(): Promise<unknown>;
  108229. /**
  108230. * Checks if a session would be supported for the creation options specified
  108231. * @param sessionMode session mode to check if supported eg. immersive-vr
  108232. * @returns true if supported
  108233. */
  108234. supportsSessionAsync(sessionMode: XRSessionMode): any;
  108235. /**
  108236. * @hidden
  108237. * Converts the render layer of xrSession to a render target
  108238. * @param session session to create render target for
  108239. * @param scene scene the new render target should be created for
  108240. */
  108241. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  108242. /**
  108243. * Disposes of the session manager
  108244. */
  108245. dispose(): void;
  108246. }
  108247. }
  108248. declare module BABYLON {
  108249. /**
  108250. * WebXR Camera which holds the views for the xrSession
  108251. * @see https://doc.babylonjs.com/how_to/webxr
  108252. */
  108253. export class WebXRCamera extends FreeCamera {
  108254. private static _TmpMatrix;
  108255. /**
  108256. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  108257. * @param name the name of the camera
  108258. * @param scene the scene to add the camera to
  108259. */
  108260. constructor(name: string, scene: Scene);
  108261. private _updateNumberOfRigCameras;
  108262. /** @hidden */
  108263. _updateForDualEyeDebugging(pupilDistance?: number): void;
  108264. /**
  108265. * Updates the cameras position from the current pose information of the XR session
  108266. * @param xrSessionManager the session containing pose information
  108267. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  108268. */
  108269. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  108270. }
  108271. }
  108272. declare module BABYLON {
  108273. /**
  108274. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  108275. */
  108276. export class WebXRManagedOutputCanvas implements IDisposable {
  108277. private helper;
  108278. private _canvas;
  108279. /**
  108280. * xrpresent context of the canvas which can be used to display/mirror xr content
  108281. */
  108282. canvasContext: WebGLRenderingContext;
  108283. /**
  108284. * xr layer for the canvas
  108285. */
  108286. xrLayer: Nullable<XRWebGLLayer>;
  108287. /**
  108288. * Initializes the xr layer for the session
  108289. * @param xrSession xr session
  108290. * @returns a promise that will resolve once the XR Layer has been created
  108291. */
  108292. initializeXRLayerAsync(xrSession: any): any;
  108293. /**
  108294. * Initializes the canvas to be added/removed upon entering/exiting xr
  108295. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  108296. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  108297. */
  108298. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  108299. /**
  108300. * Disposes of the object
  108301. */
  108302. dispose(): void;
  108303. private _setManagedOutputCanvas;
  108304. private _addCanvas;
  108305. private _removeCanvas;
  108306. }
  108307. }
  108308. declare module BABYLON {
  108309. /**
  108310. * States of the webXR experience
  108311. */
  108312. export enum WebXRState {
  108313. /**
  108314. * Transitioning to being in XR mode
  108315. */
  108316. ENTERING_XR = 0,
  108317. /**
  108318. * Transitioning to non XR mode
  108319. */
  108320. EXITING_XR = 1,
  108321. /**
  108322. * In XR mode and presenting
  108323. */
  108324. IN_XR = 2,
  108325. /**
  108326. * Not entered XR mode
  108327. */
  108328. NOT_IN_XR = 3
  108329. }
  108330. /**
  108331. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  108332. * @see https://doc.babylonjs.com/how_to/webxr
  108333. */
  108334. export class WebXRExperienceHelper implements IDisposable {
  108335. private scene;
  108336. /**
  108337. * 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
  108338. */
  108339. container: AbstractMesh;
  108340. /**
  108341. * Camera used to render xr content
  108342. */
  108343. camera: WebXRCamera;
  108344. /**
  108345. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  108346. */
  108347. state: WebXRState;
  108348. private _setState;
  108349. private static _TmpVector;
  108350. /**
  108351. * Fires when the state of the experience helper has changed
  108352. */
  108353. onStateChangedObservable: Observable<WebXRState>;
  108354. /** Session manager used to keep track of xr session */
  108355. sessionManager: WebXRSessionManager;
  108356. private _nonVRCamera;
  108357. private _originalSceneAutoClear;
  108358. private _supported;
  108359. /**
  108360. * Creates the experience helper
  108361. * @param scene the scene to attach the experience helper to
  108362. * @returns a promise for the experience helper
  108363. */
  108364. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  108365. /**
  108366. * Creates a WebXRExperienceHelper
  108367. * @param scene The scene the helper should be created in
  108368. */
  108369. private constructor();
  108370. /**
  108371. * Exits XR mode and returns the scene to its original state
  108372. * @returns promise that resolves after xr mode has exited
  108373. */
  108374. exitXRAsync(): Promise<unknown>;
  108375. /**
  108376. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  108377. * @param sessionCreationOptions options for the XR session
  108378. * @param referenceSpaceType frame of reference of the XR session
  108379. * @param outputCanvas the output canvas that will be used to enter XR mode
  108380. * @returns promise that resolves after xr mode has entered
  108381. */
  108382. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  108383. /**
  108384. * Updates the global position of the camera by moving the camera's container
  108385. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  108386. * @param position The desired global position of the camera
  108387. */
  108388. setPositionOfCameraUsingContainer(position: Vector3): void;
  108389. /**
  108390. * Rotates the xr camera by rotating the camera's container around the camera's position
  108391. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  108392. * @param rotation the desired quaternion rotation to apply to the camera
  108393. */
  108394. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  108395. /**
  108396. * Disposes of the experience helper
  108397. */
  108398. dispose(): void;
  108399. }
  108400. }
  108401. declare module BABYLON {
  108402. /**
  108403. * Button which can be used to enter a different mode of XR
  108404. */
  108405. export class WebXREnterExitUIButton {
  108406. /** button element */
  108407. element: HTMLElement;
  108408. /** XR initialization options for the button */
  108409. sessionMode: XRSessionMode;
  108410. /** Reference space type */
  108411. referenceSpaceType: XRReferenceSpaceType;
  108412. /**
  108413. * Creates a WebXREnterExitUIButton
  108414. * @param element button element
  108415. * @param sessionMode XR initialization session mode
  108416. * @param referenceSpaceType the type of reference space to be used
  108417. */
  108418. constructor(
  108419. /** button element */
  108420. element: HTMLElement,
  108421. /** XR initialization options for the button */
  108422. sessionMode: XRSessionMode,
  108423. /** Reference space type */
  108424. referenceSpaceType: XRReferenceSpaceType);
  108425. /**
  108426. * Overwritable function which can be used to update the button's visuals when the state changes
  108427. * @param activeButton the current active button in the UI
  108428. */
  108429. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  108430. }
  108431. /**
  108432. * Options to create the webXR UI
  108433. */
  108434. export class WebXREnterExitUIOptions {
  108435. /**
  108436. * Context to enter xr with
  108437. */
  108438. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  108439. /**
  108440. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  108441. */
  108442. customButtons?: Array<WebXREnterExitUIButton>;
  108443. }
  108444. /**
  108445. * UI to allow the user to enter/exit XR mode
  108446. */
  108447. export class WebXREnterExitUI implements IDisposable {
  108448. private scene;
  108449. private _overlay;
  108450. private _buttons;
  108451. private _activeButton;
  108452. /**
  108453. * Fired every time the active button is changed.
  108454. *
  108455. * When xr is entered via a button that launches xr that button will be the callback parameter
  108456. *
  108457. * When exiting xr the callback parameter will be null)
  108458. */
  108459. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  108460. /**
  108461. * Creates UI to allow the user to enter/exit XR mode
  108462. * @param scene the scene to add the ui to
  108463. * @param helper the xr experience helper to enter/exit xr with
  108464. * @param options options to configure the UI
  108465. * @returns the created ui
  108466. */
  108467. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  108468. private constructor();
  108469. private _updateButtons;
  108470. /**
  108471. * Disposes of the object
  108472. */
  108473. dispose(): void;
  108474. }
  108475. }
  108476. declare module BABYLON {
  108477. /**
  108478. * Represents an XR input
  108479. */
  108480. export class WebXRController {
  108481. private scene;
  108482. /** The underlying input source for the controller */
  108483. inputSource: XRInputSource;
  108484. private parentContainer;
  108485. /**
  108486. * 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
  108487. */
  108488. grip?: AbstractMesh;
  108489. /**
  108490. * Pointer which can be used to select objects or attach a visible laser to
  108491. */
  108492. pointer: AbstractMesh;
  108493. /**
  108494. * Event that fires when the controller is removed/disposed
  108495. */
  108496. onDisposeObservable: Observable<{}>;
  108497. private _tmpMatrix;
  108498. private _tmpQuaternion;
  108499. private _tmpVector;
  108500. /**
  108501. * Creates the controller
  108502. * @see https://doc.babylonjs.com/how_to/webxr
  108503. * @param scene the scene which the controller should be associated to
  108504. * @param inputSource the underlying input source for the controller
  108505. * @param parentContainer parent that the controller meshes should be children of
  108506. */
  108507. constructor(scene: Scene,
  108508. /** The underlying input source for the controller */
  108509. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  108510. /**
  108511. * Updates the controller pose based on the given XRFrame
  108512. * @param xrFrame xr frame to update the pose with
  108513. * @param referenceSpace reference space to use
  108514. */
  108515. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  108516. /**
  108517. * Gets a world space ray coming from the controller
  108518. * @param result the resulting ray
  108519. */
  108520. getWorldPointerRayToRef(result: Ray): void;
  108521. /**
  108522. * Disposes of the object
  108523. */
  108524. dispose(): void;
  108525. }
  108526. }
  108527. declare module BABYLON {
  108528. /**
  108529. * XR input used to track XR inputs such as controllers/rays
  108530. */
  108531. export class WebXRInput implements IDisposable {
  108532. /**
  108533. * Base experience the input listens to
  108534. */
  108535. baseExperience: WebXRExperienceHelper;
  108536. /**
  108537. * XR controllers being tracked
  108538. */
  108539. controllers: Array<WebXRController>;
  108540. private _frameObserver;
  108541. private _stateObserver;
  108542. /**
  108543. * Event when a controller has been connected/added
  108544. */
  108545. onControllerAddedObservable: Observable<WebXRController>;
  108546. /**
  108547. * Event when a controller has been removed/disconnected
  108548. */
  108549. onControllerRemovedObservable: Observable<WebXRController>;
  108550. /**
  108551. * Initializes the WebXRInput
  108552. * @param baseExperience experience helper which the input should be created for
  108553. */
  108554. constructor(
  108555. /**
  108556. * Base experience the input listens to
  108557. */
  108558. baseExperience: WebXRExperienceHelper);
  108559. private _onInputSourcesChange;
  108560. private _addAndRemoveControllers;
  108561. /**
  108562. * Disposes of the object
  108563. */
  108564. dispose(): void;
  108565. }
  108566. }
  108567. declare module BABYLON {
  108568. /**
  108569. * Enables teleportation
  108570. */
  108571. export class WebXRControllerTeleportation {
  108572. private _teleportationFillColor;
  108573. private _teleportationBorderColor;
  108574. private _tmpRay;
  108575. private _tmpVector;
  108576. /**
  108577. * Creates a WebXRControllerTeleportation
  108578. * @param input input manager to add teleportation to
  108579. * @param floorMeshes floormeshes which can be teleported to
  108580. */
  108581. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  108582. }
  108583. }
  108584. declare module BABYLON {
  108585. /**
  108586. * Handles pointer input automatically for the pointer of XR controllers
  108587. */
  108588. export class WebXRControllerPointerSelection {
  108589. private static _idCounter;
  108590. private _tmpRay;
  108591. /**
  108592. * Creates a WebXRControllerPointerSelection
  108593. * @param input input manager to setup pointer selection
  108594. */
  108595. constructor(input: WebXRInput);
  108596. private _convertNormalToDirectionOfRay;
  108597. private _updatePointerDistance;
  108598. }
  108599. }
  108600. declare module BABYLON {
  108601. /**
  108602. * Class used to represent data loading progression
  108603. */
  108604. export class SceneLoaderProgressEvent {
  108605. /** defines if data length to load can be evaluated */
  108606. readonly lengthComputable: boolean;
  108607. /** defines the loaded data length */
  108608. readonly loaded: number;
  108609. /** defines the data length to load */
  108610. readonly total: number;
  108611. /**
  108612. * Create a new progress event
  108613. * @param lengthComputable defines if data length to load can be evaluated
  108614. * @param loaded defines the loaded data length
  108615. * @param total defines the data length to load
  108616. */
  108617. constructor(
  108618. /** defines if data length to load can be evaluated */
  108619. lengthComputable: boolean,
  108620. /** defines the loaded data length */
  108621. loaded: number,
  108622. /** defines the data length to load */
  108623. total: number);
  108624. /**
  108625. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  108626. * @param event defines the source event
  108627. * @returns a new SceneLoaderProgressEvent
  108628. */
  108629. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  108630. }
  108631. /**
  108632. * Interface used by SceneLoader plugins to define supported file extensions
  108633. */
  108634. export interface ISceneLoaderPluginExtensions {
  108635. /**
  108636. * Defines the list of supported extensions
  108637. */
  108638. [extension: string]: {
  108639. isBinary: boolean;
  108640. };
  108641. }
  108642. /**
  108643. * Interface used by SceneLoader plugin factory
  108644. */
  108645. export interface ISceneLoaderPluginFactory {
  108646. /**
  108647. * Defines the name of the factory
  108648. */
  108649. name: string;
  108650. /**
  108651. * Function called to create a new plugin
  108652. * @return the new plugin
  108653. */
  108654. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  108655. /**
  108656. * Boolean indicating if the plugin can direct load specific data
  108657. */
  108658. canDirectLoad?: (data: string) => boolean;
  108659. }
  108660. /**
  108661. * Interface used to define a SceneLoader plugin
  108662. */
  108663. export interface ISceneLoaderPlugin {
  108664. /**
  108665. * The friendly name of this plugin.
  108666. */
  108667. name: string;
  108668. /**
  108669. * The file extensions supported by this plugin.
  108670. */
  108671. extensions: string | ISceneLoaderPluginExtensions;
  108672. /**
  108673. * Import meshes into a scene.
  108674. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108675. * @param scene The scene to import into
  108676. * @param data The data to import
  108677. * @param rootUrl The root url for scene and resources
  108678. * @param meshes The meshes array to import into
  108679. * @param particleSystems The particle systems array to import into
  108680. * @param skeletons The skeletons array to import into
  108681. * @param onError The callback when import fails
  108682. * @returns True if successful or false otherwise
  108683. */
  108684. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  108685. /**
  108686. * Load into a scene.
  108687. * @param scene The scene to load into
  108688. * @param data The data to import
  108689. * @param rootUrl The root url for scene and resources
  108690. * @param onError The callback when import fails
  108691. * @returns true if successful or false otherwise
  108692. */
  108693. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  108694. /**
  108695. * The callback that returns true if the data can be directly loaded.
  108696. */
  108697. canDirectLoad?: (data: string) => boolean;
  108698. /**
  108699. * The callback that allows custom handling of the root url based on the response url.
  108700. */
  108701. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108702. /**
  108703. * Load into an asset container.
  108704. * @param scene The scene to load into
  108705. * @param data The data to import
  108706. * @param rootUrl The root url for scene and resources
  108707. * @param onError The callback when import fails
  108708. * @returns The loaded asset container
  108709. */
  108710. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  108711. }
  108712. /**
  108713. * Interface used to define an async SceneLoader plugin
  108714. */
  108715. export interface ISceneLoaderPluginAsync {
  108716. /**
  108717. * The friendly name of this plugin.
  108718. */
  108719. name: string;
  108720. /**
  108721. * The file extensions supported by this plugin.
  108722. */
  108723. extensions: string | ISceneLoaderPluginExtensions;
  108724. /**
  108725. * Import meshes into a scene.
  108726. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108727. * @param scene The scene to import into
  108728. * @param data The data to import
  108729. * @param rootUrl The root url for scene and resources
  108730. * @param onProgress The callback when the load progresses
  108731. * @param fileName Defines the name of the file to load
  108732. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  108733. */
  108734. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  108735. meshes: AbstractMesh[];
  108736. particleSystems: IParticleSystem[];
  108737. skeletons: Skeleton[];
  108738. animationGroups: AnimationGroup[];
  108739. }>;
  108740. /**
  108741. * Load into a scene.
  108742. * @param scene The scene to load into
  108743. * @param data The data to import
  108744. * @param rootUrl The root url for scene and resources
  108745. * @param onProgress The callback when the load progresses
  108746. * @param fileName Defines the name of the file to load
  108747. * @returns Nothing
  108748. */
  108749. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  108750. /**
  108751. * The callback that returns true if the data can be directly loaded.
  108752. */
  108753. canDirectLoad?: (data: string) => boolean;
  108754. /**
  108755. * The callback that allows custom handling of the root url based on the response url.
  108756. */
  108757. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108758. /**
  108759. * Load into an asset container.
  108760. * @param scene The scene to load into
  108761. * @param data The data to import
  108762. * @param rootUrl The root url for scene and resources
  108763. * @param onProgress The callback when the load progresses
  108764. * @param fileName Defines the name of the file to load
  108765. * @returns The loaded asset container
  108766. */
  108767. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  108768. }
  108769. /**
  108770. * Class used to load scene from various file formats using registered plugins
  108771. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  108772. */
  108773. export class SceneLoader {
  108774. /**
  108775. * No logging while loading
  108776. */
  108777. static readonly NO_LOGGING: number;
  108778. /**
  108779. * Minimal logging while loading
  108780. */
  108781. static readonly MINIMAL_LOGGING: number;
  108782. /**
  108783. * Summary logging while loading
  108784. */
  108785. static readonly SUMMARY_LOGGING: number;
  108786. /**
  108787. * Detailled logging while loading
  108788. */
  108789. static readonly DETAILED_LOGGING: number;
  108790. /**
  108791. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  108792. */
  108793. static ForceFullSceneLoadingForIncremental: boolean;
  108794. /**
  108795. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  108796. */
  108797. static ShowLoadingScreen: boolean;
  108798. /**
  108799. * Defines the current logging level (while loading the scene)
  108800. * @ignorenaming
  108801. */
  108802. static loggingLevel: number;
  108803. /**
  108804. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  108805. */
  108806. static CleanBoneMatrixWeights: boolean;
  108807. /**
  108808. * Event raised when a plugin is used to load a scene
  108809. */
  108810. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  108811. private static _registeredPlugins;
  108812. private static _getDefaultPlugin;
  108813. private static _getPluginForExtension;
  108814. private static _getPluginForDirectLoad;
  108815. private static _getPluginForFilename;
  108816. private static _getDirectLoad;
  108817. private static _loadData;
  108818. private static _getFileInfo;
  108819. /**
  108820. * Gets a plugin that can load the given extension
  108821. * @param extension defines the extension to load
  108822. * @returns a plugin or null if none works
  108823. */
  108824. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  108825. /**
  108826. * Gets a boolean indicating that the given extension can be loaded
  108827. * @param extension defines the extension to load
  108828. * @returns true if the extension is supported
  108829. */
  108830. static IsPluginForExtensionAvailable(extension: string): boolean;
  108831. /**
  108832. * Adds a new plugin to the list of registered plugins
  108833. * @param plugin defines the plugin to add
  108834. */
  108835. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  108836. /**
  108837. * Import meshes into a scene
  108838. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108839. * @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)
  108840. * @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)
  108841. * @param scene the instance of BABYLON.Scene to append to
  108842. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  108843. * @param onProgress a callback with a progress event for each file being loaded
  108844. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108845. * @param pluginExtension the extension used to determine the plugin
  108846. * @returns The loaded plugin
  108847. */
  108848. 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>;
  108849. /**
  108850. * Import meshes into a scene
  108851. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108852. * @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)
  108853. * @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)
  108854. * @param scene the instance of BABYLON.Scene to append to
  108855. * @param onProgress a callback with a progress event for each file being loaded
  108856. * @param pluginExtension the extension used to determine the plugin
  108857. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  108858. */
  108859. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  108860. meshes: AbstractMesh[];
  108861. particleSystems: IParticleSystem[];
  108862. skeletons: Skeleton[];
  108863. animationGroups: AnimationGroup[];
  108864. }>;
  108865. /**
  108866. * Load a scene
  108867. * @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)
  108868. * @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)
  108869. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108870. * @param onSuccess a callback with the scene when import succeeds
  108871. * @param onProgress a callback with a progress event for each file being loaded
  108872. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108873. * @param pluginExtension the extension used to determine the plugin
  108874. * @returns The loaded plugin
  108875. */
  108876. 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>;
  108877. /**
  108878. * Load a scene
  108879. * @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)
  108880. * @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)
  108881. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108882. * @param onProgress a callback with a progress event for each file being loaded
  108883. * @param pluginExtension the extension used to determine the plugin
  108884. * @returns The loaded scene
  108885. */
  108886. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108887. /**
  108888. * Append a scene
  108889. * @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)
  108890. * @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)
  108891. * @param scene is the instance of BABYLON.Scene to append to
  108892. * @param onSuccess a callback with the scene when import succeeds
  108893. * @param onProgress a callback with a progress event for each file being loaded
  108894. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108895. * @param pluginExtension the extension used to determine the plugin
  108896. * @returns The loaded plugin
  108897. */
  108898. 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>;
  108899. /**
  108900. * Append a scene
  108901. * @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)
  108902. * @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)
  108903. * @param scene is the instance of BABYLON.Scene to append to
  108904. * @param onProgress a callback with a progress event for each file being loaded
  108905. * @param pluginExtension the extension used to determine the plugin
  108906. * @returns The given scene
  108907. */
  108908. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108909. /**
  108910. * Load a scene into an asset container
  108911. * @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)
  108912. * @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)
  108913. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  108914. * @param onSuccess a callback with the scene when import succeeds
  108915. * @param onProgress a callback with a progress event for each file being loaded
  108916. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108917. * @param pluginExtension the extension used to determine the plugin
  108918. * @returns The loaded plugin
  108919. */
  108920. 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>;
  108921. /**
  108922. * Load a scene into an asset container
  108923. * @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)
  108924. * @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)
  108925. * @param scene is the instance of Scene to append to
  108926. * @param onProgress a callback with a progress event for each file being loaded
  108927. * @param pluginExtension the extension used to determine the plugin
  108928. * @returns The loaded asset container
  108929. */
  108930. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  108931. }
  108932. }
  108933. declare module BABYLON {
  108934. /**
  108935. * Generic Controller
  108936. */
  108937. export class GenericController extends WebVRController {
  108938. /**
  108939. * Base Url for the controller model.
  108940. */
  108941. static readonly MODEL_BASE_URL: string;
  108942. /**
  108943. * File name for the controller model.
  108944. */
  108945. static readonly MODEL_FILENAME: string;
  108946. /**
  108947. * Creates a new GenericController from a gamepad
  108948. * @param vrGamepad the gamepad that the controller should be created from
  108949. */
  108950. constructor(vrGamepad: any);
  108951. /**
  108952. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108953. * @param scene scene in which to add meshes
  108954. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108955. */
  108956. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108957. /**
  108958. * Called once for each button that changed state since the last frame
  108959. * @param buttonIdx Which button index changed
  108960. * @param state New state of the button
  108961. * @param changes Which properties on the state changed since last frame
  108962. */
  108963. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108964. }
  108965. }
  108966. declare module BABYLON {
  108967. /**
  108968. * Defines the WindowsMotionController object that the state of the windows motion controller
  108969. */
  108970. export class WindowsMotionController extends WebVRController {
  108971. /**
  108972. * The base url used to load the left and right controller models
  108973. */
  108974. static MODEL_BASE_URL: string;
  108975. /**
  108976. * The name of the left controller model file
  108977. */
  108978. static MODEL_LEFT_FILENAME: string;
  108979. /**
  108980. * The name of the right controller model file
  108981. */
  108982. static MODEL_RIGHT_FILENAME: string;
  108983. /**
  108984. * The controller name prefix for this controller type
  108985. */
  108986. static readonly GAMEPAD_ID_PREFIX: string;
  108987. /**
  108988. * The controller id pattern for this controller type
  108989. */
  108990. private static readonly GAMEPAD_ID_PATTERN;
  108991. private _loadedMeshInfo;
  108992. private readonly _mapping;
  108993. /**
  108994. * Fired when the trackpad on this controller is clicked
  108995. */
  108996. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  108997. /**
  108998. * Fired when the trackpad on this controller is modified
  108999. */
  109000. onTrackpadValuesChangedObservable: Observable<StickValues>;
  109001. /**
  109002. * The current x and y values of this controller's trackpad
  109003. */
  109004. trackpad: StickValues;
  109005. /**
  109006. * Creates a new WindowsMotionController from a gamepad
  109007. * @param vrGamepad the gamepad that the controller should be created from
  109008. */
  109009. constructor(vrGamepad: any);
  109010. /**
  109011. * Fired when the trigger on this controller is modified
  109012. */
  109013. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109014. /**
  109015. * Fired when the menu button on this controller is modified
  109016. */
  109017. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109018. /**
  109019. * Fired when the grip button on this controller is modified
  109020. */
  109021. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109022. /**
  109023. * Fired when the thumbstick button on this controller is modified
  109024. */
  109025. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109026. /**
  109027. * Fired when the touchpad button on this controller is modified
  109028. */
  109029. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109030. /**
  109031. * Fired when the touchpad values on this controller are modified
  109032. */
  109033. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  109034. private _updateTrackpad;
  109035. /**
  109036. * Called once per frame by the engine.
  109037. */
  109038. update(): void;
  109039. /**
  109040. * Called once for each button that changed state since the last frame
  109041. * @param buttonIdx Which button index changed
  109042. * @param state New state of the button
  109043. * @param changes Which properties on the state changed since last frame
  109044. */
  109045. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109046. /**
  109047. * Moves the buttons on the controller mesh based on their current state
  109048. * @param buttonName the name of the button to move
  109049. * @param buttonValue the value of the button which determines the buttons new position
  109050. */
  109051. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  109052. /**
  109053. * Moves the axis on the controller mesh based on its current state
  109054. * @param axis the index of the axis
  109055. * @param axisValue the value of the axis which determines the meshes new position
  109056. * @hidden
  109057. */
  109058. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  109059. /**
  109060. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109061. * @param scene scene in which to add meshes
  109062. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109063. */
  109064. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  109065. /**
  109066. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  109067. * can be transformed by button presses and axes values, based on this._mapping.
  109068. *
  109069. * @param scene scene in which the meshes exist
  109070. * @param meshes list of meshes that make up the controller model to process
  109071. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  109072. */
  109073. private processModel;
  109074. private createMeshInfo;
  109075. /**
  109076. * Gets the ray of the controller in the direction the controller is pointing
  109077. * @param length the length the resulting ray should be
  109078. * @returns a ray in the direction the controller is pointing
  109079. */
  109080. getForwardRay(length?: number): Ray;
  109081. /**
  109082. * Disposes of the controller
  109083. */
  109084. dispose(): void;
  109085. }
  109086. }
  109087. declare module BABYLON {
  109088. /**
  109089. * Oculus Touch Controller
  109090. */
  109091. export class OculusTouchController extends WebVRController {
  109092. /**
  109093. * Base Url for the controller model.
  109094. */
  109095. static MODEL_BASE_URL: string;
  109096. /**
  109097. * File name for the left controller model.
  109098. */
  109099. static MODEL_LEFT_FILENAME: string;
  109100. /**
  109101. * File name for the right controller model.
  109102. */
  109103. static MODEL_RIGHT_FILENAME: string;
  109104. /**
  109105. * Base Url for the Quest controller model.
  109106. */
  109107. static QUEST_MODEL_BASE_URL: string;
  109108. /**
  109109. * @hidden
  109110. * If the controllers are running on a device that needs the updated Quest controller models
  109111. */
  109112. static _IsQuest: boolean;
  109113. /**
  109114. * Fired when the secondary trigger on this controller is modified
  109115. */
  109116. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  109117. /**
  109118. * Fired when the thumb rest on this controller is modified
  109119. */
  109120. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  109121. /**
  109122. * Creates a new OculusTouchController from a gamepad
  109123. * @param vrGamepad the gamepad that the controller should be created from
  109124. */
  109125. constructor(vrGamepad: any);
  109126. /**
  109127. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109128. * @param scene scene in which to add meshes
  109129. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109130. */
  109131. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109132. /**
  109133. * Fired when the A button on this controller is modified
  109134. */
  109135. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109136. /**
  109137. * Fired when the B button on this controller is modified
  109138. */
  109139. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109140. /**
  109141. * Fired when the X button on this controller is modified
  109142. */
  109143. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109144. /**
  109145. * Fired when the Y button on this controller is modified
  109146. */
  109147. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109148. /**
  109149. * Called once for each button that changed state since the last frame
  109150. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  109151. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  109152. * 2) secondary trigger (same)
  109153. * 3) A (right) X (left), touch, pressed = value
  109154. * 4) B / Y
  109155. * 5) thumb rest
  109156. * @param buttonIdx Which button index changed
  109157. * @param state New state of the button
  109158. * @param changes Which properties on the state changed since last frame
  109159. */
  109160. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109161. }
  109162. }
  109163. declare module BABYLON {
  109164. /**
  109165. * Vive Controller
  109166. */
  109167. export class ViveController extends WebVRController {
  109168. /**
  109169. * Base Url for the controller model.
  109170. */
  109171. static MODEL_BASE_URL: string;
  109172. /**
  109173. * File name for the controller model.
  109174. */
  109175. static MODEL_FILENAME: string;
  109176. /**
  109177. * Creates a new ViveController from a gamepad
  109178. * @param vrGamepad the gamepad that the controller should be created from
  109179. */
  109180. constructor(vrGamepad: any);
  109181. /**
  109182. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109183. * @param scene scene in which to add meshes
  109184. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109185. */
  109186. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109187. /**
  109188. * Fired when the left button on this controller is modified
  109189. */
  109190. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109191. /**
  109192. * Fired when the right button on this controller is modified
  109193. */
  109194. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109195. /**
  109196. * Fired when the menu button on this controller is modified
  109197. */
  109198. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109199. /**
  109200. * Called once for each button that changed state since the last frame
  109201. * Vive mapping:
  109202. * 0: touchpad
  109203. * 1: trigger
  109204. * 2: left AND right buttons
  109205. * 3: menu button
  109206. * @param buttonIdx Which button index changed
  109207. * @param state New state of the button
  109208. * @param changes Which properties on the state changed since last frame
  109209. */
  109210. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109211. }
  109212. }
  109213. declare module BABYLON {
  109214. /**
  109215. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  109216. */
  109217. export class WebXRControllerModelLoader {
  109218. /**
  109219. * Creates the WebXRControllerModelLoader
  109220. * @param input xr input that creates the controllers
  109221. */
  109222. constructor(input: WebXRInput);
  109223. }
  109224. }
  109225. declare module BABYLON {
  109226. /**
  109227. * Contains an array of blocks representing the octree
  109228. */
  109229. export interface IOctreeContainer<T> {
  109230. /**
  109231. * Blocks within the octree
  109232. */
  109233. blocks: Array<OctreeBlock<T>>;
  109234. }
  109235. /**
  109236. * Class used to store a cell in an octree
  109237. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109238. */
  109239. export class OctreeBlock<T> {
  109240. /**
  109241. * Gets the content of the current block
  109242. */
  109243. entries: T[];
  109244. /**
  109245. * Gets the list of block children
  109246. */
  109247. blocks: Array<OctreeBlock<T>>;
  109248. private _depth;
  109249. private _maxDepth;
  109250. private _capacity;
  109251. private _minPoint;
  109252. private _maxPoint;
  109253. private _boundingVectors;
  109254. private _creationFunc;
  109255. /**
  109256. * Creates a new block
  109257. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  109258. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  109259. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109260. * @param depth defines the current depth of this block in the octree
  109261. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  109262. * @param creationFunc defines a callback to call when an element is added to the block
  109263. */
  109264. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  109265. /**
  109266. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109267. */
  109268. readonly capacity: number;
  109269. /**
  109270. * Gets the minimum vector (in world space) of the block's bounding box
  109271. */
  109272. readonly minPoint: Vector3;
  109273. /**
  109274. * Gets the maximum vector (in world space) of the block's bounding box
  109275. */
  109276. readonly maxPoint: Vector3;
  109277. /**
  109278. * Add a new element to this block
  109279. * @param entry defines the element to add
  109280. */
  109281. addEntry(entry: T): void;
  109282. /**
  109283. * Remove an element from this block
  109284. * @param entry defines the element to remove
  109285. */
  109286. removeEntry(entry: T): void;
  109287. /**
  109288. * Add an array of elements to this block
  109289. * @param entries defines the array of elements to add
  109290. */
  109291. addEntries(entries: T[]): void;
  109292. /**
  109293. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  109294. * @param frustumPlanes defines the frustum planes to test
  109295. * @param selection defines the array to store current content if selection is positive
  109296. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109297. */
  109298. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109299. /**
  109300. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  109301. * @param sphereCenter defines the bounding sphere center
  109302. * @param sphereRadius defines the bounding sphere radius
  109303. * @param selection defines the array to store current content if selection is positive
  109304. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109305. */
  109306. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109307. /**
  109308. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  109309. * @param ray defines the ray to test with
  109310. * @param selection defines the array to store current content if selection is positive
  109311. */
  109312. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  109313. /**
  109314. * Subdivide the content into child blocks (this block will then be empty)
  109315. */
  109316. createInnerBlocks(): void;
  109317. /**
  109318. * @hidden
  109319. */
  109320. 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;
  109321. }
  109322. }
  109323. declare module BABYLON {
  109324. /**
  109325. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  109326. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109327. */
  109328. export class Octree<T> {
  109329. /** 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.) */
  109330. maxDepth: number;
  109331. /**
  109332. * Blocks within the octree containing objects
  109333. */
  109334. blocks: Array<OctreeBlock<T>>;
  109335. /**
  109336. * Content stored in the octree
  109337. */
  109338. dynamicContent: T[];
  109339. private _maxBlockCapacity;
  109340. private _selectionContent;
  109341. private _creationFunc;
  109342. /**
  109343. * Creates a octree
  109344. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109345. * @param creationFunc function to be used to instatiate the octree
  109346. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  109347. * @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.)
  109348. */
  109349. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  109350. /** 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.) */
  109351. maxDepth?: number);
  109352. /**
  109353. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  109354. * @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);
  109355. * @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);
  109356. * @param entries meshes to be added to the octree blocks
  109357. */
  109358. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  109359. /**
  109360. * Adds a mesh to the octree
  109361. * @param entry Mesh to add to the octree
  109362. */
  109363. addMesh(entry: T): void;
  109364. /**
  109365. * Remove an element from the octree
  109366. * @param entry defines the element to remove
  109367. */
  109368. removeMesh(entry: T): void;
  109369. /**
  109370. * Selects an array of meshes within the frustum
  109371. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  109372. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  109373. * @returns array of meshes within the frustum
  109374. */
  109375. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  109376. /**
  109377. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  109378. * @param sphereCenter defines the bounding sphere center
  109379. * @param sphereRadius defines the bounding sphere radius
  109380. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109381. * @returns an array of objects that intersect the sphere
  109382. */
  109383. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  109384. /**
  109385. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  109386. * @param ray defines the ray to test with
  109387. * @returns array of intersected objects
  109388. */
  109389. intersectsRay(ray: Ray): SmartArray<T>;
  109390. /**
  109391. * Adds a mesh into the octree block if it intersects the block
  109392. */
  109393. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  109394. /**
  109395. * Adds a submesh into the octree block if it intersects the block
  109396. */
  109397. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  109398. }
  109399. }
  109400. declare module BABYLON {
  109401. interface Scene {
  109402. /**
  109403. * @hidden
  109404. * Backing Filed
  109405. */
  109406. _selectionOctree: Octree<AbstractMesh>;
  109407. /**
  109408. * Gets the octree used to boost mesh selection (picking)
  109409. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109410. */
  109411. selectionOctree: Octree<AbstractMesh>;
  109412. /**
  109413. * Creates or updates the octree used to boost selection (picking)
  109414. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109415. * @param maxCapacity defines the maximum capacity per leaf
  109416. * @param maxDepth defines the maximum depth of the octree
  109417. * @returns an octree of AbstractMesh
  109418. */
  109419. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  109420. }
  109421. interface AbstractMesh {
  109422. /**
  109423. * @hidden
  109424. * Backing Field
  109425. */
  109426. _submeshesOctree: Octree<SubMesh>;
  109427. /**
  109428. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  109429. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  109430. * @param maxCapacity defines the maximum size of each block (64 by default)
  109431. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  109432. * @returns the new octree
  109433. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  109434. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109435. */
  109436. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  109437. }
  109438. /**
  109439. * Defines the octree scene component responsible to manage any octrees
  109440. * in a given scene.
  109441. */
  109442. export class OctreeSceneComponent {
  109443. /**
  109444. * The component name help to identify the component in the list of scene components.
  109445. */
  109446. readonly name: string;
  109447. /**
  109448. * The scene the component belongs to.
  109449. */
  109450. scene: Scene;
  109451. /**
  109452. * Indicates if the meshes have been checked to make sure they are isEnabled()
  109453. */
  109454. readonly checksIsEnabled: boolean;
  109455. /**
  109456. * Creates a new instance of the component for the given scene
  109457. * @param scene Defines the scene to register the component in
  109458. */
  109459. constructor(scene: Scene);
  109460. /**
  109461. * Registers the component in a given scene
  109462. */
  109463. register(): void;
  109464. /**
  109465. * Return the list of active meshes
  109466. * @returns the list of active meshes
  109467. */
  109468. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109469. /**
  109470. * Return the list of active sub meshes
  109471. * @param mesh The mesh to get the candidates sub meshes from
  109472. * @returns the list of active sub meshes
  109473. */
  109474. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109475. private _tempRay;
  109476. /**
  109477. * Return the list of sub meshes intersecting with a given local ray
  109478. * @param mesh defines the mesh to find the submesh for
  109479. * @param localRay defines the ray in local space
  109480. * @returns the list of intersecting sub meshes
  109481. */
  109482. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  109483. /**
  109484. * Return the list of sub meshes colliding with a collider
  109485. * @param mesh defines the mesh to find the submesh for
  109486. * @param collider defines the collider to evaluate the collision against
  109487. * @returns the list of colliding sub meshes
  109488. */
  109489. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  109490. /**
  109491. * Rebuilds the elements related to this component in case of
  109492. * context lost for instance.
  109493. */
  109494. rebuild(): void;
  109495. /**
  109496. * Disposes the component and the associated ressources.
  109497. */
  109498. dispose(): void;
  109499. }
  109500. }
  109501. declare module BABYLON {
  109502. /**
  109503. * Renders a layer on top of an existing scene
  109504. */
  109505. export class UtilityLayerRenderer implements IDisposable {
  109506. /** the original scene that will be rendered on top of */
  109507. originalScene: Scene;
  109508. private _pointerCaptures;
  109509. private _lastPointerEvents;
  109510. private static _DefaultUtilityLayer;
  109511. private static _DefaultKeepDepthUtilityLayer;
  109512. private _sharedGizmoLight;
  109513. private _renderCamera;
  109514. /**
  109515. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  109516. * @returns the camera that is used when rendering the utility layer
  109517. */
  109518. getRenderCamera(): Nullable<Camera>;
  109519. /**
  109520. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  109521. * @param cam the camera that should be used when rendering the utility layer
  109522. */
  109523. setRenderCamera(cam: Nullable<Camera>): void;
  109524. /**
  109525. * @hidden
  109526. * Light which used by gizmos to get light shading
  109527. */
  109528. _getSharedGizmoLight(): HemisphericLight;
  109529. /**
  109530. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  109531. */
  109532. pickUtilitySceneFirst: boolean;
  109533. /**
  109534. * 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)
  109535. */
  109536. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  109537. /**
  109538. * 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)
  109539. */
  109540. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  109541. /**
  109542. * The scene that is rendered on top of the original scene
  109543. */
  109544. utilityLayerScene: Scene;
  109545. /**
  109546. * If the utility layer should automatically be rendered on top of existing scene
  109547. */
  109548. shouldRender: boolean;
  109549. /**
  109550. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  109551. */
  109552. onlyCheckPointerDownEvents: boolean;
  109553. /**
  109554. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  109555. */
  109556. processAllEvents: boolean;
  109557. /**
  109558. * Observable raised when the pointer move from the utility layer scene to the main scene
  109559. */
  109560. onPointerOutObservable: Observable<number>;
  109561. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  109562. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  109563. private _afterRenderObserver;
  109564. private _sceneDisposeObserver;
  109565. private _originalPointerObserver;
  109566. /**
  109567. * Instantiates a UtilityLayerRenderer
  109568. * @param originalScene the original scene that will be rendered on top of
  109569. * @param handleEvents boolean indicating if the utility layer should handle events
  109570. */
  109571. constructor(
  109572. /** the original scene that will be rendered on top of */
  109573. originalScene: Scene, handleEvents?: boolean);
  109574. private _notifyObservers;
  109575. /**
  109576. * Renders the utility layers scene on top of the original scene
  109577. */
  109578. render(): void;
  109579. /**
  109580. * Disposes of the renderer
  109581. */
  109582. dispose(): void;
  109583. private _updateCamera;
  109584. }
  109585. }
  109586. declare module BABYLON {
  109587. /**
  109588. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  109589. */
  109590. export class Gizmo implements IDisposable {
  109591. /** The utility layer the gizmo will be added to */
  109592. gizmoLayer: UtilityLayerRenderer;
  109593. /**
  109594. * The root mesh of the gizmo
  109595. */
  109596. _rootMesh: Mesh;
  109597. private _attachedMesh;
  109598. /**
  109599. * Ratio for the scale of the gizmo (Default: 1)
  109600. */
  109601. scaleRatio: number;
  109602. /**
  109603. * If a custom mesh has been set (Default: false)
  109604. */
  109605. protected _customMeshSet: boolean;
  109606. /**
  109607. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  109608. * * When set, interactions will be enabled
  109609. */
  109610. attachedMesh: Nullable<AbstractMesh>;
  109611. /**
  109612. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  109613. * @param mesh The mesh to replace the default mesh of the gizmo
  109614. */
  109615. setCustomMesh(mesh: Mesh): void;
  109616. /**
  109617. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  109618. */
  109619. updateGizmoRotationToMatchAttachedMesh: boolean;
  109620. /**
  109621. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  109622. */
  109623. updateGizmoPositionToMatchAttachedMesh: boolean;
  109624. /**
  109625. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  109626. */
  109627. updateScale: boolean;
  109628. protected _interactionsEnabled: boolean;
  109629. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109630. private _beforeRenderObserver;
  109631. private _tempVector;
  109632. /**
  109633. * Creates a gizmo
  109634. * @param gizmoLayer The utility layer the gizmo will be added to
  109635. */
  109636. constructor(
  109637. /** The utility layer the gizmo will be added to */
  109638. gizmoLayer?: UtilityLayerRenderer);
  109639. /**
  109640. * Updates the gizmo to match the attached mesh's position/rotation
  109641. */
  109642. protected _update(): void;
  109643. /**
  109644. * Disposes of the gizmo
  109645. */
  109646. dispose(): void;
  109647. }
  109648. }
  109649. declare module BABYLON {
  109650. /**
  109651. * Single plane drag gizmo
  109652. */
  109653. export class PlaneDragGizmo extends Gizmo {
  109654. /**
  109655. * Drag behavior responsible for the gizmos dragging interactions
  109656. */
  109657. dragBehavior: PointerDragBehavior;
  109658. private _pointerObserver;
  109659. /**
  109660. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109661. */
  109662. snapDistance: number;
  109663. /**
  109664. * Event that fires each time the gizmo snaps to a new location.
  109665. * * snapDistance is the the change in distance
  109666. */
  109667. onSnapObservable: Observable<{
  109668. snapDistance: number;
  109669. }>;
  109670. private _plane;
  109671. private _coloredMaterial;
  109672. private _hoverMaterial;
  109673. private _isEnabled;
  109674. private _parent;
  109675. /** @hidden */
  109676. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  109677. /** @hidden */
  109678. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109679. /**
  109680. * Creates a PlaneDragGizmo
  109681. * @param gizmoLayer The utility layer the gizmo will be added to
  109682. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  109683. * @param color The color of the gizmo
  109684. */
  109685. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109686. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109687. /**
  109688. * If the gizmo is enabled
  109689. */
  109690. isEnabled: boolean;
  109691. /**
  109692. * Disposes of the gizmo
  109693. */
  109694. dispose(): void;
  109695. }
  109696. }
  109697. declare module BABYLON {
  109698. /**
  109699. * Gizmo that enables dragging a mesh along 3 axis
  109700. */
  109701. export class PositionGizmo extends Gizmo {
  109702. /**
  109703. * Internal gizmo used for interactions on the x axis
  109704. */
  109705. xGizmo: AxisDragGizmo;
  109706. /**
  109707. * Internal gizmo used for interactions on the y axis
  109708. */
  109709. yGizmo: AxisDragGizmo;
  109710. /**
  109711. * Internal gizmo used for interactions on the z axis
  109712. */
  109713. zGizmo: AxisDragGizmo;
  109714. /**
  109715. * Internal gizmo used for interactions on the yz plane
  109716. */
  109717. xPlaneGizmo: PlaneDragGizmo;
  109718. /**
  109719. * Internal gizmo used for interactions on the xz plane
  109720. */
  109721. yPlaneGizmo: PlaneDragGizmo;
  109722. /**
  109723. * Internal gizmo used for interactions on the xy plane
  109724. */
  109725. zPlaneGizmo: PlaneDragGizmo;
  109726. /**
  109727. * private variables
  109728. */
  109729. private _meshAttached;
  109730. private _updateGizmoRotationToMatchAttachedMesh;
  109731. private _snapDistance;
  109732. private _scaleRatio;
  109733. /** Fires an event when any of it's sub gizmos are dragged */
  109734. onDragStartObservable: Observable<unknown>;
  109735. /** Fires an event when any of it's sub gizmos are released from dragging */
  109736. onDragEndObservable: Observable<unknown>;
  109737. /**
  109738. * If set to true, planar drag is enabled
  109739. */
  109740. private _planarGizmoEnabled;
  109741. attachedMesh: Nullable<AbstractMesh>;
  109742. /**
  109743. * Creates a PositionGizmo
  109744. * @param gizmoLayer The utility layer the gizmo will be added to
  109745. */
  109746. constructor(gizmoLayer?: UtilityLayerRenderer);
  109747. /**
  109748. * If the planar drag gizmo is enabled
  109749. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  109750. */
  109751. planarGizmoEnabled: boolean;
  109752. updateGizmoRotationToMatchAttachedMesh: boolean;
  109753. /**
  109754. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109755. */
  109756. snapDistance: number;
  109757. /**
  109758. * Ratio for the scale of the gizmo (Default: 1)
  109759. */
  109760. scaleRatio: number;
  109761. /**
  109762. * Disposes of the gizmo
  109763. */
  109764. dispose(): void;
  109765. /**
  109766. * CustomMeshes are not supported by this gizmo
  109767. * @param mesh The mesh to replace the default mesh of the gizmo
  109768. */
  109769. setCustomMesh(mesh: Mesh): void;
  109770. }
  109771. }
  109772. declare module BABYLON {
  109773. /**
  109774. * Single axis drag gizmo
  109775. */
  109776. export class AxisDragGizmo extends Gizmo {
  109777. /**
  109778. * Drag behavior responsible for the gizmos dragging interactions
  109779. */
  109780. dragBehavior: PointerDragBehavior;
  109781. private _pointerObserver;
  109782. /**
  109783. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109784. */
  109785. snapDistance: number;
  109786. /**
  109787. * Event that fires each time the gizmo snaps to a new location.
  109788. * * snapDistance is the the change in distance
  109789. */
  109790. onSnapObservable: Observable<{
  109791. snapDistance: number;
  109792. }>;
  109793. private _isEnabled;
  109794. private _parent;
  109795. private _arrow;
  109796. private _coloredMaterial;
  109797. private _hoverMaterial;
  109798. /** @hidden */
  109799. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  109800. /** @hidden */
  109801. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109802. /**
  109803. * Creates an AxisDragGizmo
  109804. * @param gizmoLayer The utility layer the gizmo will be added to
  109805. * @param dragAxis The axis which the gizmo will be able to drag on
  109806. * @param color The color of the gizmo
  109807. */
  109808. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109809. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109810. /**
  109811. * If the gizmo is enabled
  109812. */
  109813. isEnabled: boolean;
  109814. /**
  109815. * Disposes of the gizmo
  109816. */
  109817. dispose(): void;
  109818. }
  109819. }
  109820. declare module BABYLON.Debug {
  109821. /**
  109822. * The Axes viewer will show 3 axes in a specific point in space
  109823. */
  109824. export class AxesViewer {
  109825. private _xAxis;
  109826. private _yAxis;
  109827. private _zAxis;
  109828. private _scaleLinesFactor;
  109829. private _instanced;
  109830. /**
  109831. * Gets the hosting scene
  109832. */
  109833. scene: Scene;
  109834. /**
  109835. * Gets or sets a number used to scale line length
  109836. */
  109837. scaleLines: number;
  109838. /** Gets the node hierarchy used to render x-axis */
  109839. readonly xAxis: TransformNode;
  109840. /** Gets the node hierarchy used to render y-axis */
  109841. readonly yAxis: TransformNode;
  109842. /** Gets the node hierarchy used to render z-axis */
  109843. readonly zAxis: TransformNode;
  109844. /**
  109845. * Creates a new AxesViewer
  109846. * @param scene defines the hosting scene
  109847. * @param scaleLines defines a number used to scale line length (1 by default)
  109848. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  109849. * @param xAxis defines the node hierarchy used to render the x-axis
  109850. * @param yAxis defines the node hierarchy used to render the y-axis
  109851. * @param zAxis defines the node hierarchy used to render the z-axis
  109852. */
  109853. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  109854. /**
  109855. * Force the viewer to update
  109856. * @param position defines the position of the viewer
  109857. * @param xaxis defines the x axis of the viewer
  109858. * @param yaxis defines the y axis of the viewer
  109859. * @param zaxis defines the z axis of the viewer
  109860. */
  109861. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  109862. /**
  109863. * Creates an instance of this axes viewer.
  109864. * @returns a new axes viewer with instanced meshes
  109865. */
  109866. createInstance(): AxesViewer;
  109867. /** Releases resources */
  109868. dispose(): void;
  109869. private static _SetRenderingGroupId;
  109870. }
  109871. }
  109872. declare module BABYLON.Debug {
  109873. /**
  109874. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  109875. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  109876. */
  109877. export class BoneAxesViewer extends AxesViewer {
  109878. /**
  109879. * Gets or sets the target mesh where to display the axes viewer
  109880. */
  109881. mesh: Nullable<Mesh>;
  109882. /**
  109883. * Gets or sets the target bone where to display the axes viewer
  109884. */
  109885. bone: Nullable<Bone>;
  109886. /** Gets current position */
  109887. pos: Vector3;
  109888. /** Gets direction of X axis */
  109889. xaxis: Vector3;
  109890. /** Gets direction of Y axis */
  109891. yaxis: Vector3;
  109892. /** Gets direction of Z axis */
  109893. zaxis: Vector3;
  109894. /**
  109895. * Creates a new BoneAxesViewer
  109896. * @param scene defines the hosting scene
  109897. * @param bone defines the target bone
  109898. * @param mesh defines the target mesh
  109899. * @param scaleLines defines a scaling factor for line length (1 by default)
  109900. */
  109901. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  109902. /**
  109903. * Force the viewer to update
  109904. */
  109905. update(): void;
  109906. /** Releases resources */
  109907. dispose(): void;
  109908. }
  109909. }
  109910. declare module BABYLON {
  109911. /**
  109912. * Interface used to define scene explorer extensibility option
  109913. */
  109914. export interface IExplorerExtensibilityOption {
  109915. /**
  109916. * Define the option label
  109917. */
  109918. label: string;
  109919. /**
  109920. * Defines the action to execute on click
  109921. */
  109922. action: (entity: any) => void;
  109923. }
  109924. /**
  109925. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  109926. */
  109927. export interface IExplorerExtensibilityGroup {
  109928. /**
  109929. * Defines a predicate to test if a given type mut be extended
  109930. */
  109931. predicate: (entity: any) => boolean;
  109932. /**
  109933. * Gets the list of options added to a type
  109934. */
  109935. entries: IExplorerExtensibilityOption[];
  109936. }
  109937. /**
  109938. * Interface used to define the options to use to create the Inspector
  109939. */
  109940. export interface IInspectorOptions {
  109941. /**
  109942. * Display in overlay mode (default: false)
  109943. */
  109944. overlay?: boolean;
  109945. /**
  109946. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  109947. */
  109948. globalRoot?: HTMLElement;
  109949. /**
  109950. * Display the Scene explorer
  109951. */
  109952. showExplorer?: boolean;
  109953. /**
  109954. * Display the property inspector
  109955. */
  109956. showInspector?: boolean;
  109957. /**
  109958. * Display in embed mode (both panes on the right)
  109959. */
  109960. embedMode?: boolean;
  109961. /**
  109962. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  109963. */
  109964. handleResize?: boolean;
  109965. /**
  109966. * Allow the panes to popup (default: true)
  109967. */
  109968. enablePopup?: boolean;
  109969. /**
  109970. * Allow the panes to be closed by users (default: true)
  109971. */
  109972. enableClose?: boolean;
  109973. /**
  109974. * Optional list of extensibility entries
  109975. */
  109976. explorerExtensibility?: IExplorerExtensibilityGroup[];
  109977. /**
  109978. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  109979. */
  109980. inspectorURL?: string;
  109981. }
  109982. interface Scene {
  109983. /**
  109984. * @hidden
  109985. * Backing field
  109986. */
  109987. _debugLayer: DebugLayer;
  109988. /**
  109989. * Gets the debug layer (aka Inspector) associated with the scene
  109990. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109991. */
  109992. debugLayer: DebugLayer;
  109993. }
  109994. /**
  109995. * The debug layer (aka Inspector) is the go to tool in order to better understand
  109996. * what is happening in your scene
  109997. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109998. */
  109999. export class DebugLayer {
  110000. /**
  110001. * Define the url to get the inspector script from.
  110002. * By default it uses the babylonjs CDN.
  110003. * @ignoreNaming
  110004. */
  110005. static InspectorURL: string;
  110006. private _scene;
  110007. private BJSINSPECTOR;
  110008. private _onPropertyChangedObservable?;
  110009. /**
  110010. * Observable triggered when a property is changed through the inspector.
  110011. */
  110012. readonly onPropertyChangedObservable: any;
  110013. /**
  110014. * Instantiates a new debug layer.
  110015. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110016. * what is happening in your scene
  110017. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110018. * @param scene Defines the scene to inspect
  110019. */
  110020. constructor(scene: Scene);
  110021. /** Creates the inspector window. */
  110022. private _createInspector;
  110023. /**
  110024. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  110025. * @param entity defines the entity to select
  110026. * @param lineContainerTitle defines the specific block to highlight
  110027. */
  110028. select(entity: any, lineContainerTitle?: string): void;
  110029. /** Get the inspector from bundle or global */
  110030. private _getGlobalInspector;
  110031. /**
  110032. * Get if the inspector is visible or not.
  110033. * @returns true if visible otherwise, false
  110034. */
  110035. isVisible(): boolean;
  110036. /**
  110037. * Hide the inspector and close its window.
  110038. */
  110039. hide(): void;
  110040. /**
  110041. * Launch the debugLayer.
  110042. * @param config Define the configuration of the inspector
  110043. * @return a promise fulfilled when the debug layer is visible
  110044. */
  110045. show(config?: IInspectorOptions): Promise<DebugLayer>;
  110046. }
  110047. }
  110048. declare module BABYLON {
  110049. /**
  110050. * Class containing static functions to help procedurally build meshes
  110051. */
  110052. export class BoxBuilder {
  110053. /**
  110054. * Creates a box mesh
  110055. * * The parameter `size` sets the size (float) of each box side (default 1)
  110056. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110057. * * 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)
  110058. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110060. * * 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
  110061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110062. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110063. * @param name defines the name of the mesh
  110064. * @param options defines the options used to create the mesh
  110065. * @param scene defines the hosting scene
  110066. * @returns the box mesh
  110067. */
  110068. static CreateBox(name: string, options: {
  110069. size?: number;
  110070. width?: number;
  110071. height?: number;
  110072. depth?: number;
  110073. faceUV?: Vector4[];
  110074. faceColors?: Color4[];
  110075. sideOrientation?: number;
  110076. frontUVs?: Vector4;
  110077. backUVs?: Vector4;
  110078. wrap?: boolean;
  110079. topBaseAt?: number;
  110080. bottomBaseAt?: number;
  110081. updatable?: boolean;
  110082. }, scene?: Nullable<Scene>): Mesh;
  110083. }
  110084. }
  110085. declare module BABYLON {
  110086. /**
  110087. * Class containing static functions to help procedurally build meshes
  110088. */
  110089. export class SphereBuilder {
  110090. /**
  110091. * Creates a sphere mesh
  110092. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110093. * * 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`)
  110094. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110095. * * 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
  110096. * * 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)
  110097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110098. * * 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
  110099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110100. * @param name defines the name of the mesh
  110101. * @param options defines the options used to create the mesh
  110102. * @param scene defines the hosting scene
  110103. * @returns the sphere mesh
  110104. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110105. */
  110106. static CreateSphere(name: string, options: {
  110107. segments?: number;
  110108. diameter?: number;
  110109. diameterX?: number;
  110110. diameterY?: number;
  110111. diameterZ?: number;
  110112. arc?: number;
  110113. slice?: number;
  110114. sideOrientation?: number;
  110115. frontUVs?: Vector4;
  110116. backUVs?: Vector4;
  110117. updatable?: boolean;
  110118. }, scene?: Nullable<Scene>): Mesh;
  110119. }
  110120. }
  110121. declare module BABYLON.Debug {
  110122. /**
  110123. * Used to show the physics impostor around the specific mesh
  110124. */
  110125. export class PhysicsViewer {
  110126. /** @hidden */
  110127. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  110128. /** @hidden */
  110129. protected _meshes: Array<Nullable<AbstractMesh>>;
  110130. /** @hidden */
  110131. protected _scene: Nullable<Scene>;
  110132. /** @hidden */
  110133. protected _numMeshes: number;
  110134. /** @hidden */
  110135. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  110136. private _renderFunction;
  110137. private _utilityLayer;
  110138. private _debugBoxMesh;
  110139. private _debugSphereMesh;
  110140. private _debugCylinderMesh;
  110141. private _debugMaterial;
  110142. private _debugMeshMeshes;
  110143. /**
  110144. * Creates a new PhysicsViewer
  110145. * @param scene defines the hosting scene
  110146. */
  110147. constructor(scene: Scene);
  110148. /** @hidden */
  110149. protected _updateDebugMeshes(): void;
  110150. /**
  110151. * Renders a specified physic impostor
  110152. * @param impostor defines the impostor to render
  110153. * @param targetMesh defines the mesh represented by the impostor
  110154. * @returns the new debug mesh used to render the impostor
  110155. */
  110156. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  110157. /**
  110158. * Hides a specified physic impostor
  110159. * @param impostor defines the impostor to hide
  110160. */
  110161. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  110162. private _getDebugMaterial;
  110163. private _getDebugBoxMesh;
  110164. private _getDebugSphereMesh;
  110165. private _getDebugCylinderMesh;
  110166. private _getDebugMeshMesh;
  110167. private _getDebugMesh;
  110168. /** Releases all resources */
  110169. dispose(): void;
  110170. }
  110171. }
  110172. declare module BABYLON {
  110173. /**
  110174. * Class containing static functions to help procedurally build meshes
  110175. */
  110176. export class LinesBuilder {
  110177. /**
  110178. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110179. * * 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
  110180. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110181. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110182. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110183. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110184. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110185. * * 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
  110186. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110188. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110189. * @param name defines the name of the new line system
  110190. * @param options defines the options used to create the line system
  110191. * @param scene defines the hosting scene
  110192. * @returns a new line system mesh
  110193. */
  110194. static CreateLineSystem(name: string, options: {
  110195. lines: Vector3[][];
  110196. updatable?: boolean;
  110197. instance?: Nullable<LinesMesh>;
  110198. colors?: Nullable<Color4[][]>;
  110199. useVertexAlpha?: boolean;
  110200. }, scene: Nullable<Scene>): LinesMesh;
  110201. /**
  110202. * Creates a line mesh
  110203. * 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
  110204. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110205. * * The parameter `points` is an array successive Vector3
  110206. * * 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
  110207. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110208. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110209. * * When updating an instance, remember that only point positions can change, not the number of points
  110210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110211. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110212. * @param name defines the name of the new line system
  110213. * @param options defines the options used to create the line system
  110214. * @param scene defines the hosting scene
  110215. * @returns a new line mesh
  110216. */
  110217. static CreateLines(name: string, options: {
  110218. points: Vector3[];
  110219. updatable?: boolean;
  110220. instance?: Nullable<LinesMesh>;
  110221. colors?: Color4[];
  110222. useVertexAlpha?: boolean;
  110223. }, scene?: Nullable<Scene>): LinesMesh;
  110224. /**
  110225. * Creates a dashed line mesh
  110226. * * 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
  110227. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110228. * * The parameter `points` is an array successive Vector3
  110229. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110230. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110231. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110232. * * 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
  110233. * * When updating an instance, remember that only point positions can change, not the number of points
  110234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110235. * @param name defines the name of the mesh
  110236. * @param options defines the options used to create the mesh
  110237. * @param scene defines the hosting scene
  110238. * @returns the dashed line mesh
  110239. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110240. */
  110241. static CreateDashedLines(name: string, options: {
  110242. points: Vector3[];
  110243. dashSize?: number;
  110244. gapSize?: number;
  110245. dashNb?: number;
  110246. updatable?: boolean;
  110247. instance?: LinesMesh;
  110248. }, scene?: Nullable<Scene>): LinesMesh;
  110249. }
  110250. }
  110251. declare module BABYLON {
  110252. /**
  110253. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110254. * in order to better appreciate the issue one might have.
  110255. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110256. */
  110257. export class RayHelper {
  110258. /**
  110259. * Defines the ray we are currently tryin to visualize.
  110260. */
  110261. ray: Nullable<Ray>;
  110262. private _renderPoints;
  110263. private _renderLine;
  110264. private _renderFunction;
  110265. private _scene;
  110266. private _updateToMeshFunction;
  110267. private _attachedToMesh;
  110268. private _meshSpaceDirection;
  110269. private _meshSpaceOrigin;
  110270. /**
  110271. * Helper function to create a colored helper in a scene in one line.
  110272. * @param ray Defines the ray we are currently tryin to visualize
  110273. * @param scene Defines the scene the ray is used in
  110274. * @param color Defines the color we want to see the ray in
  110275. * @returns The newly created ray helper.
  110276. */
  110277. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  110278. /**
  110279. * Instantiate a new ray helper.
  110280. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110281. * in order to better appreciate the issue one might have.
  110282. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110283. * @param ray Defines the ray we are currently tryin to visualize
  110284. */
  110285. constructor(ray: Ray);
  110286. /**
  110287. * Shows the ray we are willing to debug.
  110288. * @param scene Defines the scene the ray needs to be rendered in
  110289. * @param color Defines the color the ray needs to be rendered in
  110290. */
  110291. show(scene: Scene, color?: Color3): void;
  110292. /**
  110293. * Hides the ray we are debugging.
  110294. */
  110295. hide(): void;
  110296. private _render;
  110297. /**
  110298. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  110299. * @param mesh Defines the mesh we want the helper attached to
  110300. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  110301. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  110302. * @param length Defines the length of the ray
  110303. */
  110304. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  110305. /**
  110306. * Detach the ray helper from the mesh it has previously been attached to.
  110307. */
  110308. detachFromMesh(): void;
  110309. private _updateToMesh;
  110310. /**
  110311. * Dispose the helper and release its associated resources.
  110312. */
  110313. dispose(): void;
  110314. }
  110315. }
  110316. declare module BABYLON.Debug {
  110317. /**
  110318. * Class used to render a debug view of a given skeleton
  110319. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  110320. */
  110321. export class SkeletonViewer {
  110322. /** defines the skeleton to render */
  110323. skeleton: Skeleton;
  110324. /** defines the mesh attached to the skeleton */
  110325. mesh: AbstractMesh;
  110326. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110327. autoUpdateBonesMatrices: boolean;
  110328. /** defines the rendering group id to use with the viewer */
  110329. renderingGroupId: number;
  110330. /** Gets or sets the color used to render the skeleton */
  110331. color: Color3;
  110332. private _scene;
  110333. private _debugLines;
  110334. private _debugMesh;
  110335. private _isEnabled;
  110336. private _renderFunction;
  110337. private _utilityLayer;
  110338. /**
  110339. * Returns the mesh used to render the bones
  110340. */
  110341. readonly debugMesh: Nullable<LinesMesh>;
  110342. /**
  110343. * Creates a new SkeletonViewer
  110344. * @param skeleton defines the skeleton to render
  110345. * @param mesh defines the mesh attached to the skeleton
  110346. * @param scene defines the hosting scene
  110347. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  110348. * @param renderingGroupId defines the rendering group id to use with the viewer
  110349. */
  110350. constructor(
  110351. /** defines the skeleton to render */
  110352. skeleton: Skeleton,
  110353. /** defines the mesh attached to the skeleton */
  110354. mesh: AbstractMesh, scene: Scene,
  110355. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110356. autoUpdateBonesMatrices?: boolean,
  110357. /** defines the rendering group id to use with the viewer */
  110358. renderingGroupId?: number);
  110359. /** Gets or sets a boolean indicating if the viewer is enabled */
  110360. isEnabled: boolean;
  110361. private _getBonePosition;
  110362. private _getLinesForBonesWithLength;
  110363. private _getLinesForBonesNoLength;
  110364. /** Update the viewer to sync with current skeleton state */
  110365. update(): void;
  110366. /** Release associated resources */
  110367. dispose(): void;
  110368. }
  110369. }
  110370. declare module BABYLON {
  110371. /**
  110372. * Options to create the null engine
  110373. */
  110374. export class NullEngineOptions {
  110375. /**
  110376. * Render width (Default: 512)
  110377. */
  110378. renderWidth: number;
  110379. /**
  110380. * Render height (Default: 256)
  110381. */
  110382. renderHeight: number;
  110383. /**
  110384. * Texture size (Default: 512)
  110385. */
  110386. textureSize: number;
  110387. /**
  110388. * If delta time between frames should be constant
  110389. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110390. */
  110391. deterministicLockstep: boolean;
  110392. /**
  110393. * Maximum about of steps between frames (Default: 4)
  110394. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110395. */
  110396. lockstepMaxSteps: number;
  110397. }
  110398. /**
  110399. * The null engine class provides support for headless version of babylon.js.
  110400. * This can be used in server side scenario or for testing purposes
  110401. */
  110402. export class NullEngine extends Engine {
  110403. private _options;
  110404. /**
  110405. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  110406. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110407. * @returns true if engine is in deterministic lock step mode
  110408. */
  110409. isDeterministicLockStep(): boolean;
  110410. /**
  110411. * Gets the max steps when engine is running in deterministic lock step
  110412. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110413. * @returns the max steps
  110414. */
  110415. getLockstepMaxSteps(): number;
  110416. /**
  110417. * Gets the current hardware scaling level.
  110418. * By default the hardware scaling level is computed from the window device ratio.
  110419. * 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.
  110420. * @returns a number indicating the current hardware scaling level
  110421. */
  110422. getHardwareScalingLevel(): number;
  110423. constructor(options?: NullEngineOptions);
  110424. /**
  110425. * Creates a vertex buffer
  110426. * @param vertices the data for the vertex buffer
  110427. * @returns the new WebGL static buffer
  110428. */
  110429. createVertexBuffer(vertices: FloatArray): DataBuffer;
  110430. /**
  110431. * Creates a new index buffer
  110432. * @param indices defines the content of the index buffer
  110433. * @param updatable defines if the index buffer must be updatable
  110434. * @returns a new webGL buffer
  110435. */
  110436. createIndexBuffer(indices: IndicesArray): DataBuffer;
  110437. /**
  110438. * Clear the current render buffer or the current render target (if any is set up)
  110439. * @param color defines the color to use
  110440. * @param backBuffer defines if the back buffer must be cleared
  110441. * @param depth defines if the depth buffer must be cleared
  110442. * @param stencil defines if the stencil buffer must be cleared
  110443. */
  110444. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  110445. /**
  110446. * Gets the current render width
  110447. * @param useScreen defines if screen size must be used (or the current render target if any)
  110448. * @returns a number defining the current render width
  110449. */
  110450. getRenderWidth(useScreen?: boolean): number;
  110451. /**
  110452. * Gets the current render height
  110453. * @param useScreen defines if screen size must be used (or the current render target if any)
  110454. * @returns a number defining the current render height
  110455. */
  110456. getRenderHeight(useScreen?: boolean): number;
  110457. /**
  110458. * Set the WebGL's viewport
  110459. * @param viewport defines the viewport element to be used
  110460. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  110461. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  110462. */
  110463. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  110464. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  110465. /**
  110466. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  110467. * @param pipelineContext defines the pipeline context to use
  110468. * @param uniformsNames defines the list of uniform names
  110469. * @returns an array of webGL uniform locations
  110470. */
  110471. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  110472. /**
  110473. * Gets the lsit of active attributes for a given webGL program
  110474. * @param pipelineContext defines the pipeline context to use
  110475. * @param attributesNames defines the list of attribute names to get
  110476. * @returns an array of indices indicating the offset of each attribute
  110477. */
  110478. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  110479. /**
  110480. * Binds an effect to the webGL context
  110481. * @param effect defines the effect to bind
  110482. */
  110483. bindSamplers(effect: Effect): void;
  110484. /**
  110485. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  110486. * @param effect defines the effect to activate
  110487. */
  110488. enableEffect(effect: Effect): void;
  110489. /**
  110490. * Set various states to the webGL context
  110491. * @param culling defines backface culling state
  110492. * @param zOffset defines the value to apply to zOffset (0 by default)
  110493. * @param force defines if states must be applied even if cache is up to date
  110494. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  110495. */
  110496. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110497. /**
  110498. * Set the value of an uniform to an array of int32
  110499. * @param uniform defines the webGL uniform location where to store the value
  110500. * @param array defines the array of int32 to store
  110501. */
  110502. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  110503. /**
  110504. * Set the value of an uniform to an array of int32 (stored as vec2)
  110505. * @param uniform defines the webGL uniform location where to store the value
  110506. * @param array defines the array of int32 to store
  110507. */
  110508. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  110509. /**
  110510. * Set the value of an uniform to an array of int32 (stored as vec3)
  110511. * @param uniform defines the webGL uniform location where to store the value
  110512. * @param array defines the array of int32 to store
  110513. */
  110514. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  110515. /**
  110516. * Set the value of an uniform to an array of int32 (stored as vec4)
  110517. * @param uniform defines the webGL uniform location where to store the value
  110518. * @param array defines the array of int32 to store
  110519. */
  110520. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  110521. /**
  110522. * Set the value of an uniform to an array of float32
  110523. * @param uniform defines the webGL uniform location where to store the value
  110524. * @param array defines the array of float32 to store
  110525. */
  110526. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  110527. /**
  110528. * Set the value of an uniform to an array of float32 (stored as vec2)
  110529. * @param uniform defines the webGL uniform location where to store the value
  110530. * @param array defines the array of float32 to store
  110531. */
  110532. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  110533. /**
  110534. * Set the value of an uniform to an array of float32 (stored as vec3)
  110535. * @param uniform defines the webGL uniform location where to store the value
  110536. * @param array defines the array of float32 to store
  110537. */
  110538. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  110539. /**
  110540. * Set the value of an uniform to an array of float32 (stored as vec4)
  110541. * @param uniform defines the webGL uniform location where to store the value
  110542. * @param array defines the array of float32 to store
  110543. */
  110544. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  110545. /**
  110546. * Set the value of an uniform to an array of number
  110547. * @param uniform defines the webGL uniform location where to store the value
  110548. * @param array defines the array of number to store
  110549. */
  110550. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  110551. /**
  110552. * Set the value of an uniform to an array of number (stored as vec2)
  110553. * @param uniform defines the webGL uniform location where to store the value
  110554. * @param array defines the array of number to store
  110555. */
  110556. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  110557. /**
  110558. * Set the value of an uniform to an array of number (stored as vec3)
  110559. * @param uniform defines the webGL uniform location where to store the value
  110560. * @param array defines the array of number to store
  110561. */
  110562. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  110563. /**
  110564. * Set the value of an uniform to an array of number (stored as vec4)
  110565. * @param uniform defines the webGL uniform location where to store the value
  110566. * @param array defines the array of number to store
  110567. */
  110568. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  110569. /**
  110570. * Set the value of an uniform to an array of float32 (stored as matrices)
  110571. * @param uniform defines the webGL uniform location where to store the value
  110572. * @param matrices defines the array of float32 to store
  110573. */
  110574. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  110575. /**
  110576. * Set the value of an uniform to a matrix (3x3)
  110577. * @param uniform defines the webGL uniform location where to store the value
  110578. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  110579. */
  110580. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110581. /**
  110582. * Set the value of an uniform to a matrix (2x2)
  110583. * @param uniform defines the webGL uniform location where to store the value
  110584. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  110585. */
  110586. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110587. /**
  110588. * Set the value of an uniform to a number (float)
  110589. * @param uniform defines the webGL uniform location where to store the value
  110590. * @param value defines the float number to store
  110591. */
  110592. setFloat(uniform: WebGLUniformLocation, value: number): void;
  110593. /**
  110594. * Set the value of an uniform to a vec2
  110595. * @param uniform defines the webGL uniform location where to store the value
  110596. * @param x defines the 1st component of the value
  110597. * @param y defines the 2nd component of the value
  110598. */
  110599. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  110600. /**
  110601. * Set the value of an uniform to a vec3
  110602. * @param uniform defines the webGL uniform location where to store the value
  110603. * @param x defines the 1st component of the value
  110604. * @param y defines the 2nd component of the value
  110605. * @param z defines the 3rd component of the value
  110606. */
  110607. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  110608. /**
  110609. * Set the value of an uniform to a boolean
  110610. * @param uniform defines the webGL uniform location where to store the value
  110611. * @param bool defines the boolean to store
  110612. */
  110613. setBool(uniform: WebGLUniformLocation, bool: number): void;
  110614. /**
  110615. * Set the value of an uniform to a vec4
  110616. * @param uniform defines the webGL uniform location where to store the value
  110617. * @param x defines the 1st component of the value
  110618. * @param y defines the 2nd component of the value
  110619. * @param z defines the 3rd component of the value
  110620. * @param w defines the 4th component of the value
  110621. */
  110622. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  110623. /**
  110624. * Sets the current alpha mode
  110625. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  110626. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  110627. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110628. */
  110629. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  110630. /**
  110631. * Bind webGl buffers directly to the webGL context
  110632. * @param vertexBuffers defines the vertex buffer to bind
  110633. * @param indexBuffer defines the index buffer to bind
  110634. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  110635. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  110636. * @param effect defines the effect associated with the vertex buffer
  110637. */
  110638. bindBuffers(vertexBuffers: {
  110639. [key: string]: VertexBuffer;
  110640. }, indexBuffer: DataBuffer, effect: Effect): void;
  110641. /**
  110642. * Force the entire cache to be cleared
  110643. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  110644. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  110645. */
  110646. wipeCaches(bruteForce?: boolean): void;
  110647. /**
  110648. * Send a draw order
  110649. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  110650. * @param indexStart defines the starting index
  110651. * @param indexCount defines the number of index to draw
  110652. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110653. */
  110654. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  110655. /**
  110656. * Draw a list of indexed primitives
  110657. * @param fillMode defines the primitive to use
  110658. * @param indexStart defines the starting index
  110659. * @param indexCount defines the number of index to draw
  110660. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110661. */
  110662. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  110663. /**
  110664. * Draw a list of unindexed primitives
  110665. * @param fillMode defines the primitive to use
  110666. * @param verticesStart defines the index of first vertex to draw
  110667. * @param verticesCount defines the count of vertices to draw
  110668. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110669. */
  110670. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  110671. /** @hidden */
  110672. _createTexture(): WebGLTexture;
  110673. /** @hidden */
  110674. _releaseTexture(texture: InternalTexture): void;
  110675. /**
  110676. * Usually called from Texture.ts.
  110677. * Passed information to create a WebGLTexture
  110678. * @param urlArg defines a value which contains one of the following:
  110679. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  110680. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  110681. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  110682. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110683. * @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)
  110684. * @param scene needed for loading to the correct scene
  110685. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  110686. * @param onLoad optional callback to be called upon successful completion
  110687. * @param onError optional callback to be called upon failure
  110688. * @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
  110689. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110690. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110691. * @param forcedExtension defines the extension to use to pick the right loader
  110692. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  110693. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110694. */
  110695. 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;
  110696. /**
  110697. * Creates a new render target texture
  110698. * @param size defines the size of the texture
  110699. * @param options defines the options used to create the texture
  110700. * @returns a new render target texture stored in an InternalTexture
  110701. */
  110702. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110703. /**
  110704. * Update the sampling mode of a given texture
  110705. * @param samplingMode defines the required sampling mode
  110706. * @param texture defines the texture to update
  110707. */
  110708. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110709. /**
  110710. * Binds the frame buffer to the specified texture.
  110711. * @param texture The texture to render to or null for the default canvas
  110712. * @param faceIndex The face of the texture to render to in case of cube texture
  110713. * @param requiredWidth The width of the target to render to
  110714. * @param requiredHeight The height of the target to render to
  110715. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  110716. * @param depthStencilTexture The depth stencil texture to use to render
  110717. * @param lodLevel defines le lod level to bind to the frame buffer
  110718. */
  110719. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110720. /**
  110721. * Unbind the current render target texture from the webGL context
  110722. * @param texture defines the render target texture to unbind
  110723. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  110724. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  110725. */
  110726. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110727. /**
  110728. * Creates a dynamic vertex buffer
  110729. * @param vertices the data for the dynamic vertex buffer
  110730. * @returns the new WebGL dynamic buffer
  110731. */
  110732. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  110733. /**
  110734. * Update the content of a dynamic texture
  110735. * @param texture defines the texture to update
  110736. * @param canvas defines the canvas containing the source
  110737. * @param invertY defines if data must be stored with Y axis inverted
  110738. * @param premulAlpha defines if alpha is stored as premultiplied
  110739. * @param format defines the format of the data
  110740. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  110741. */
  110742. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  110743. /**
  110744. * Gets a boolean indicating if all created effects are ready
  110745. * @returns true if all effects are ready
  110746. */
  110747. areAllEffectsReady(): boolean;
  110748. /**
  110749. * @hidden
  110750. * Get the current error code of the webGL context
  110751. * @returns the error code
  110752. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  110753. */
  110754. getError(): number;
  110755. /** @hidden */
  110756. _getUnpackAlignement(): number;
  110757. /** @hidden */
  110758. _unpackFlipY(value: boolean): void;
  110759. /**
  110760. * Update a dynamic index buffer
  110761. * @param indexBuffer defines the target index buffer
  110762. * @param indices defines the data to update
  110763. * @param offset defines the offset in the target index buffer where update should start
  110764. */
  110765. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  110766. /**
  110767. * Updates a dynamic vertex buffer.
  110768. * @param vertexBuffer the vertex buffer to update
  110769. * @param vertices the data used to update the vertex buffer
  110770. * @param byteOffset the byte offset of the data (optional)
  110771. * @param byteLength the byte length of the data (optional)
  110772. */
  110773. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  110774. /** @hidden */
  110775. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  110776. /** @hidden */
  110777. _bindTexture(channel: number, texture: InternalTexture): void;
  110778. protected _deleteBuffer(buffer: WebGLBuffer): void;
  110779. /**
  110780. * 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
  110781. */
  110782. releaseEffects(): void;
  110783. displayLoadingUI(): void;
  110784. hideLoadingUI(): void;
  110785. /** @hidden */
  110786. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110787. /** @hidden */
  110788. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110789. /** @hidden */
  110790. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110791. /** @hidden */
  110792. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110793. }
  110794. }
  110795. declare module BABYLON {
  110796. /** @hidden */
  110797. export class _OcclusionDataStorage {
  110798. /** @hidden */
  110799. occlusionInternalRetryCounter: number;
  110800. /** @hidden */
  110801. isOcclusionQueryInProgress: boolean;
  110802. /** @hidden */
  110803. isOccluded: boolean;
  110804. /** @hidden */
  110805. occlusionRetryCount: number;
  110806. /** @hidden */
  110807. occlusionType: number;
  110808. /** @hidden */
  110809. occlusionQueryAlgorithmType: number;
  110810. }
  110811. interface Engine {
  110812. /**
  110813. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  110814. * @return the new query
  110815. */
  110816. createQuery(): WebGLQuery;
  110817. /**
  110818. * Delete and release a webGL query
  110819. * @param query defines the query to delete
  110820. * @return the current engine
  110821. */
  110822. deleteQuery(query: WebGLQuery): Engine;
  110823. /**
  110824. * Check if a given query has resolved and got its value
  110825. * @param query defines the query to check
  110826. * @returns true if the query got its value
  110827. */
  110828. isQueryResultAvailable(query: WebGLQuery): boolean;
  110829. /**
  110830. * Gets the value of a given query
  110831. * @param query defines the query to check
  110832. * @returns the value of the query
  110833. */
  110834. getQueryResult(query: WebGLQuery): number;
  110835. /**
  110836. * Initiates an occlusion query
  110837. * @param algorithmType defines the algorithm to use
  110838. * @param query defines the query to use
  110839. * @returns the current engine
  110840. * @see http://doc.babylonjs.com/features/occlusionquery
  110841. */
  110842. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  110843. /**
  110844. * Ends an occlusion query
  110845. * @see http://doc.babylonjs.com/features/occlusionquery
  110846. * @param algorithmType defines the algorithm to use
  110847. * @returns the current engine
  110848. */
  110849. endOcclusionQuery(algorithmType: number): Engine;
  110850. /**
  110851. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  110852. * Please note that only one query can be issued at a time
  110853. * @returns a time token used to track the time span
  110854. */
  110855. startTimeQuery(): Nullable<_TimeToken>;
  110856. /**
  110857. * Ends a time query
  110858. * @param token defines the token used to measure the time span
  110859. * @returns the time spent (in ns)
  110860. */
  110861. endTimeQuery(token: _TimeToken): int;
  110862. /** @hidden */
  110863. _currentNonTimestampToken: Nullable<_TimeToken>;
  110864. /** @hidden */
  110865. _createTimeQuery(): WebGLQuery;
  110866. /** @hidden */
  110867. _deleteTimeQuery(query: WebGLQuery): void;
  110868. /** @hidden */
  110869. _getGlAlgorithmType(algorithmType: number): number;
  110870. /** @hidden */
  110871. _getTimeQueryResult(query: WebGLQuery): any;
  110872. /** @hidden */
  110873. _getTimeQueryAvailability(query: WebGLQuery): any;
  110874. }
  110875. interface AbstractMesh {
  110876. /**
  110877. * Backing filed
  110878. * @hidden
  110879. */
  110880. __occlusionDataStorage: _OcclusionDataStorage;
  110881. /**
  110882. * Access property
  110883. * @hidden
  110884. */
  110885. _occlusionDataStorage: _OcclusionDataStorage;
  110886. /**
  110887. * 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.
  110888. * The default value is -1 which means don't break the query and wait till the result
  110889. * @see http://doc.babylonjs.com/features/occlusionquery
  110890. */
  110891. occlusionRetryCount: number;
  110892. /**
  110893. * 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:
  110894. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  110895. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  110896. * * 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.
  110897. * @see http://doc.babylonjs.com/features/occlusionquery
  110898. */
  110899. occlusionType: number;
  110900. /**
  110901. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  110902. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  110903. * * 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.
  110904. * @see http://doc.babylonjs.com/features/occlusionquery
  110905. */
  110906. occlusionQueryAlgorithmType: number;
  110907. /**
  110908. * 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
  110909. * @see http://doc.babylonjs.com/features/occlusionquery
  110910. */
  110911. isOccluded: boolean;
  110912. /**
  110913. * Flag to check the progress status of the query
  110914. * @see http://doc.babylonjs.com/features/occlusionquery
  110915. */
  110916. isOcclusionQueryInProgress: boolean;
  110917. }
  110918. }
  110919. declare module BABYLON {
  110920. /** @hidden */
  110921. export var _forceTransformFeedbackToBundle: boolean;
  110922. interface Engine {
  110923. /**
  110924. * Creates a webGL transform feedback object
  110925. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  110926. * @returns the webGL transform feedback object
  110927. */
  110928. createTransformFeedback(): WebGLTransformFeedback;
  110929. /**
  110930. * Delete a webGL transform feedback object
  110931. * @param value defines the webGL transform feedback object to delete
  110932. */
  110933. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  110934. /**
  110935. * Bind a webGL transform feedback object to the webgl context
  110936. * @param value defines the webGL transform feedback object to bind
  110937. */
  110938. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  110939. /**
  110940. * Begins a transform feedback operation
  110941. * @param usePoints defines if points or triangles must be used
  110942. */
  110943. beginTransformFeedback(usePoints: boolean): void;
  110944. /**
  110945. * Ends a transform feedback operation
  110946. */
  110947. endTransformFeedback(): void;
  110948. /**
  110949. * Specify the varyings to use with transform feedback
  110950. * @param program defines the associated webGL program
  110951. * @param value defines the list of strings representing the varying names
  110952. */
  110953. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  110954. /**
  110955. * Bind a webGL buffer for a transform feedback operation
  110956. * @param value defines the webGL buffer to bind
  110957. */
  110958. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  110959. }
  110960. }
  110961. declare module BABYLON {
  110962. /**
  110963. * Creation options of the multi render target texture.
  110964. */
  110965. export interface IMultiRenderTargetOptions {
  110966. /**
  110967. * Define if the texture needs to create mip maps after render.
  110968. */
  110969. generateMipMaps?: boolean;
  110970. /**
  110971. * Define the types of all the draw buffers we want to create
  110972. */
  110973. types?: number[];
  110974. /**
  110975. * Define the sampling modes of all the draw buffers we want to create
  110976. */
  110977. samplingModes?: number[];
  110978. /**
  110979. * Define if a depth buffer is required
  110980. */
  110981. generateDepthBuffer?: boolean;
  110982. /**
  110983. * Define if a stencil buffer is required
  110984. */
  110985. generateStencilBuffer?: boolean;
  110986. /**
  110987. * Define if a depth texture is required instead of a depth buffer
  110988. */
  110989. generateDepthTexture?: boolean;
  110990. /**
  110991. * Define the number of desired draw buffers
  110992. */
  110993. textureCount?: number;
  110994. /**
  110995. * Define if aspect ratio should be adapted to the texture or stay the scene one
  110996. */
  110997. doNotChangeAspectRatio?: boolean;
  110998. /**
  110999. * Define the default type of the buffers we are creating
  111000. */
  111001. defaultType?: number;
  111002. }
  111003. /**
  111004. * A multi render target, like a render target provides the ability to render to a texture.
  111005. * Unlike the render target, it can render to several draw buffers in one draw.
  111006. * This is specially interesting in deferred rendering or for any effects requiring more than
  111007. * just one color from a single pass.
  111008. */
  111009. export class MultiRenderTarget extends RenderTargetTexture {
  111010. private _internalTextures;
  111011. private _textures;
  111012. private _multiRenderTargetOptions;
  111013. /**
  111014. * Get if draw buffers are currently supported by the used hardware and browser.
  111015. */
  111016. readonly isSupported: boolean;
  111017. /**
  111018. * Get the list of textures generated by the multi render target.
  111019. */
  111020. readonly textures: Texture[];
  111021. /**
  111022. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  111023. */
  111024. readonly depthTexture: Texture;
  111025. /**
  111026. * Set the wrapping mode on U of all the textures we are rendering to.
  111027. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111028. */
  111029. wrapU: number;
  111030. /**
  111031. * Set the wrapping mode on V of all the textures we are rendering to.
  111032. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111033. */
  111034. wrapV: number;
  111035. /**
  111036. * Instantiate a new multi render target texture.
  111037. * A multi render target, like a render target provides the ability to render to a texture.
  111038. * Unlike the render target, it can render to several draw buffers in one draw.
  111039. * This is specially interesting in deferred rendering or for any effects requiring more than
  111040. * just one color from a single pass.
  111041. * @param name Define the name of the texture
  111042. * @param size Define the size of the buffers to render to
  111043. * @param count Define the number of target we are rendering into
  111044. * @param scene Define the scene the texture belongs to
  111045. * @param options Define the options used to create the multi render target
  111046. */
  111047. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  111048. /** @hidden */
  111049. _rebuild(): void;
  111050. private _createInternalTextures;
  111051. private _createTextures;
  111052. /**
  111053. * Define the number of samples used if MSAA is enabled.
  111054. */
  111055. samples: number;
  111056. /**
  111057. * Resize all the textures in the multi render target.
  111058. * Be carrefull as it will recreate all the data in the new texture.
  111059. * @param size Define the new size
  111060. */
  111061. resize(size: any): void;
  111062. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  111063. /**
  111064. * Dispose the render targets and their associated resources
  111065. */
  111066. dispose(): void;
  111067. /**
  111068. * Release all the underlying texture used as draw buffers.
  111069. */
  111070. releaseInternalTextures(): void;
  111071. }
  111072. }
  111073. declare module BABYLON {
  111074. interface ThinEngine {
  111075. /**
  111076. * Unbind a list of render target textures from the webGL context
  111077. * This is used only when drawBuffer extension or webGL2 are active
  111078. * @param textures defines the render target textures to unbind
  111079. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111080. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111081. */
  111082. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  111083. /**
  111084. * Create a multi render target texture
  111085. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  111086. * @param size defines the size of the texture
  111087. * @param options defines the creation options
  111088. * @returns the cube texture as an InternalTexture
  111089. */
  111090. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  111091. /**
  111092. * Update the sample count for a given multiple render target texture
  111093. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  111094. * @param textures defines the textures to update
  111095. * @param samples defines the sample count to set
  111096. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  111097. */
  111098. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  111099. }
  111100. }
  111101. declare module BABYLON {
  111102. /**
  111103. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  111104. */
  111105. export interface CubeMapInfo {
  111106. /**
  111107. * The pixel array for the front face.
  111108. * This is stored in format, left to right, up to down format.
  111109. */
  111110. front: Nullable<ArrayBufferView>;
  111111. /**
  111112. * The pixel array for the back face.
  111113. * This is stored in format, left to right, up to down format.
  111114. */
  111115. back: Nullable<ArrayBufferView>;
  111116. /**
  111117. * The pixel array for the left face.
  111118. * This is stored in format, left to right, up to down format.
  111119. */
  111120. left: Nullable<ArrayBufferView>;
  111121. /**
  111122. * The pixel array for the right face.
  111123. * This is stored in format, left to right, up to down format.
  111124. */
  111125. right: Nullable<ArrayBufferView>;
  111126. /**
  111127. * The pixel array for the up face.
  111128. * This is stored in format, left to right, up to down format.
  111129. */
  111130. up: Nullable<ArrayBufferView>;
  111131. /**
  111132. * The pixel array for the down face.
  111133. * This is stored in format, left to right, up to down format.
  111134. */
  111135. down: Nullable<ArrayBufferView>;
  111136. /**
  111137. * The size of the cubemap stored.
  111138. *
  111139. * Each faces will be size * size pixels.
  111140. */
  111141. size: number;
  111142. /**
  111143. * The format of the texture.
  111144. *
  111145. * RGBA, RGB.
  111146. */
  111147. format: number;
  111148. /**
  111149. * The type of the texture data.
  111150. *
  111151. * UNSIGNED_INT, FLOAT.
  111152. */
  111153. type: number;
  111154. /**
  111155. * Specifies whether the texture is in gamma space.
  111156. */
  111157. gammaSpace: boolean;
  111158. }
  111159. /**
  111160. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  111161. */
  111162. export class PanoramaToCubeMapTools {
  111163. private static FACE_FRONT;
  111164. private static FACE_BACK;
  111165. private static FACE_RIGHT;
  111166. private static FACE_LEFT;
  111167. private static FACE_DOWN;
  111168. private static FACE_UP;
  111169. /**
  111170. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  111171. *
  111172. * @param float32Array The source data.
  111173. * @param inputWidth The width of the input panorama.
  111174. * @param inputHeight The height of the input panorama.
  111175. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  111176. * @return The cubemap data
  111177. */
  111178. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  111179. private static CreateCubemapTexture;
  111180. private static CalcProjectionSpherical;
  111181. }
  111182. }
  111183. declare module BABYLON {
  111184. /**
  111185. * Helper class dealing with the extraction of spherical polynomial dataArray
  111186. * from a cube map.
  111187. */
  111188. export class CubeMapToSphericalPolynomialTools {
  111189. private static FileFaces;
  111190. /**
  111191. * Converts a texture to the according Spherical Polynomial data.
  111192. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111193. *
  111194. * @param texture The texture to extract the information from.
  111195. * @return The Spherical Polynomial data.
  111196. */
  111197. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  111198. /**
  111199. * Converts a cubemap to the according Spherical Polynomial data.
  111200. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111201. *
  111202. * @param cubeInfo The Cube map to extract the information from.
  111203. * @return The Spherical Polynomial data.
  111204. */
  111205. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  111206. }
  111207. }
  111208. declare module BABYLON {
  111209. interface BaseTexture {
  111210. /**
  111211. * Get the polynomial representation of the texture data.
  111212. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  111213. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  111214. */
  111215. sphericalPolynomial: Nullable<SphericalPolynomial>;
  111216. }
  111217. }
  111218. declare module BABYLON {
  111219. /** @hidden */
  111220. export var rgbdEncodePixelShader: {
  111221. name: string;
  111222. shader: string;
  111223. };
  111224. }
  111225. declare module BABYLON {
  111226. /** @hidden */
  111227. export var rgbdDecodePixelShader: {
  111228. name: string;
  111229. shader: string;
  111230. };
  111231. }
  111232. declare module BABYLON {
  111233. /**
  111234. * Raw texture data and descriptor sufficient for WebGL texture upload
  111235. */
  111236. export interface EnvironmentTextureInfo {
  111237. /**
  111238. * Version of the environment map
  111239. */
  111240. version: number;
  111241. /**
  111242. * Width of image
  111243. */
  111244. width: number;
  111245. /**
  111246. * Irradiance information stored in the file.
  111247. */
  111248. irradiance: any;
  111249. /**
  111250. * Specular information stored in the file.
  111251. */
  111252. specular: any;
  111253. }
  111254. /**
  111255. * Defines One Image in the file. It requires only the position in the file
  111256. * as well as the length.
  111257. */
  111258. interface BufferImageData {
  111259. /**
  111260. * Length of the image data.
  111261. */
  111262. length: number;
  111263. /**
  111264. * Position of the data from the null terminator delimiting the end of the JSON.
  111265. */
  111266. position: number;
  111267. }
  111268. /**
  111269. * Defines the specular data enclosed in the file.
  111270. * This corresponds to the version 1 of the data.
  111271. */
  111272. export interface EnvironmentTextureSpecularInfoV1 {
  111273. /**
  111274. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  111275. */
  111276. specularDataPosition?: number;
  111277. /**
  111278. * This contains all the images data needed to reconstruct the cubemap.
  111279. */
  111280. mipmaps: Array<BufferImageData>;
  111281. /**
  111282. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  111283. */
  111284. lodGenerationScale: number;
  111285. }
  111286. /**
  111287. * Sets of helpers addressing the serialization and deserialization of environment texture
  111288. * stored in a BabylonJS env file.
  111289. * Those files are usually stored as .env files.
  111290. */
  111291. export class EnvironmentTextureTools {
  111292. /**
  111293. * Magic number identifying the env file.
  111294. */
  111295. private static _MagicBytes;
  111296. /**
  111297. * Gets the environment info from an env file.
  111298. * @param data The array buffer containing the .env bytes.
  111299. * @returns the environment file info (the json header) if successfully parsed.
  111300. */
  111301. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  111302. /**
  111303. * Creates an environment texture from a loaded cube texture.
  111304. * @param texture defines the cube texture to convert in env file
  111305. * @return a promise containing the environment data if succesfull.
  111306. */
  111307. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  111308. /**
  111309. * Creates a JSON representation of the spherical data.
  111310. * @param texture defines the texture containing the polynomials
  111311. * @return the JSON representation of the spherical info
  111312. */
  111313. private static _CreateEnvTextureIrradiance;
  111314. /**
  111315. * Creates the ArrayBufferViews used for initializing environment texture image data.
  111316. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  111317. * @param info parameters that determine what views will be created for accessing the underlying buffer
  111318. * @return the views described by info providing access to the underlying buffer
  111319. */
  111320. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  111321. /**
  111322. * Uploads the texture info contained in the env file to the GPU.
  111323. * @param texture defines the internal texture to upload to
  111324. * @param arrayBuffer defines the buffer cotaining the data to load
  111325. * @param info defines the texture info retrieved through the GetEnvInfo method
  111326. * @returns a promise
  111327. */
  111328. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  111329. /**
  111330. * Uploads the levels of image data to the GPU.
  111331. * @param texture defines the internal texture to upload to
  111332. * @param imageData defines the array buffer views of image data [mipmap][face]
  111333. * @returns a promise
  111334. */
  111335. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111336. /**
  111337. * Uploads spherical polynomials information to the texture.
  111338. * @param texture defines the texture we are trying to upload the information to
  111339. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111340. */
  111341. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111342. /** @hidden */
  111343. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111344. }
  111345. }
  111346. declare module BABYLON {
  111347. /**
  111348. * Contains position and normal vectors for a vertex
  111349. */
  111350. export class PositionNormalVertex {
  111351. /** the position of the vertex (defaut: 0,0,0) */
  111352. position: Vector3;
  111353. /** the normal of the vertex (defaut: 0,1,0) */
  111354. normal: Vector3;
  111355. /**
  111356. * Creates a PositionNormalVertex
  111357. * @param position the position of the vertex (defaut: 0,0,0)
  111358. * @param normal the normal of the vertex (defaut: 0,1,0)
  111359. */
  111360. constructor(
  111361. /** the position of the vertex (defaut: 0,0,0) */
  111362. position?: Vector3,
  111363. /** the normal of the vertex (defaut: 0,1,0) */
  111364. normal?: Vector3);
  111365. /**
  111366. * Clones the PositionNormalVertex
  111367. * @returns the cloned PositionNormalVertex
  111368. */
  111369. clone(): PositionNormalVertex;
  111370. }
  111371. /**
  111372. * Contains position, normal and uv vectors for a vertex
  111373. */
  111374. export class PositionNormalTextureVertex {
  111375. /** the position of the vertex (defaut: 0,0,0) */
  111376. position: Vector3;
  111377. /** the normal of the vertex (defaut: 0,1,0) */
  111378. normal: Vector3;
  111379. /** the uv of the vertex (default: 0,0) */
  111380. uv: Vector2;
  111381. /**
  111382. * Creates a PositionNormalTextureVertex
  111383. * @param position the position of the vertex (defaut: 0,0,0)
  111384. * @param normal the normal of the vertex (defaut: 0,1,0)
  111385. * @param uv the uv of the vertex (default: 0,0)
  111386. */
  111387. constructor(
  111388. /** the position of the vertex (defaut: 0,0,0) */
  111389. position?: Vector3,
  111390. /** the normal of the vertex (defaut: 0,1,0) */
  111391. normal?: Vector3,
  111392. /** the uv of the vertex (default: 0,0) */
  111393. uv?: Vector2);
  111394. /**
  111395. * Clones the PositionNormalTextureVertex
  111396. * @returns the cloned PositionNormalTextureVertex
  111397. */
  111398. clone(): PositionNormalTextureVertex;
  111399. }
  111400. }
  111401. declare module BABYLON {
  111402. /** @hidden */
  111403. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  111404. private _genericAttributeLocation;
  111405. private _varyingLocationCount;
  111406. private _varyingLocationMap;
  111407. private _replacements;
  111408. private _textureCount;
  111409. private _uniforms;
  111410. lineProcessor(line: string): string;
  111411. attributeProcessor(attribute: string): string;
  111412. varyingProcessor(varying: string, isFragment: boolean): string;
  111413. uniformProcessor(uniform: string): string;
  111414. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  111415. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111416. }
  111417. }
  111418. declare module BABYLON {
  111419. /**
  111420. * Container for accessors for natively-stored mesh data buffers.
  111421. */
  111422. class NativeDataBuffer extends DataBuffer {
  111423. /**
  111424. * Accessor value used to identify/retrieve a natively-stored index buffer.
  111425. */
  111426. nativeIndexBuffer?: any;
  111427. /**
  111428. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  111429. */
  111430. nativeVertexBuffer?: any;
  111431. }
  111432. /** @hidden */
  111433. export class NativeEngine extends Engine {
  111434. private readonly _native;
  111435. getHardwareScalingLevel(): number;
  111436. constructor();
  111437. /**
  111438. * Can be used to override the current requestAnimationFrame requester.
  111439. * @hidden
  111440. */
  111441. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  111442. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111443. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  111444. createVertexBuffer(data: DataArray): NativeDataBuffer;
  111445. recordVertexArrayObject(vertexBuffers: {
  111446. [key: string]: VertexBuffer;
  111447. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  111448. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111449. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111450. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111451. /**
  111452. * Draw a list of indexed primitives
  111453. * @param fillMode defines the primitive to use
  111454. * @param indexStart defines the starting index
  111455. * @param indexCount defines the number of index to draw
  111456. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111457. */
  111458. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111459. /**
  111460. * Draw a list of unindexed primitives
  111461. * @param fillMode defines the primitive to use
  111462. * @param verticesStart defines the index of first vertex to draw
  111463. * @param verticesCount defines the count of vertices to draw
  111464. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111465. */
  111466. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111467. createPipelineContext(): IPipelineContext;
  111468. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  111469. /** @hidden */
  111470. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  111471. /** @hidden */
  111472. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  111473. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111474. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111475. protected _setProgram(program: WebGLProgram): void;
  111476. _releaseEffect(effect: Effect): void;
  111477. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  111478. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  111479. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  111480. bindSamplers(effect: Effect): void;
  111481. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  111482. getRenderWidth(useScreen?: boolean): number;
  111483. getRenderHeight(useScreen?: boolean): number;
  111484. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  111485. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111486. /**
  111487. * Set the z offset to apply to current rendering
  111488. * @param value defines the offset to apply
  111489. */
  111490. setZOffset(value: number): void;
  111491. /**
  111492. * Gets the current value of the zOffset
  111493. * @returns the current zOffset state
  111494. */
  111495. getZOffset(): number;
  111496. /**
  111497. * Enable or disable depth buffering
  111498. * @param enable defines the state to set
  111499. */
  111500. setDepthBuffer(enable: boolean): void;
  111501. /**
  111502. * Gets a boolean indicating if depth writing is enabled
  111503. * @returns the current depth writing state
  111504. */
  111505. getDepthWrite(): boolean;
  111506. /**
  111507. * Enable or disable depth writing
  111508. * @param enable defines the state to set
  111509. */
  111510. setDepthWrite(enable: boolean): void;
  111511. /**
  111512. * Enable or disable color writing
  111513. * @param enable defines the state to set
  111514. */
  111515. setColorWrite(enable: boolean): void;
  111516. /**
  111517. * Gets a boolean indicating if color writing is enabled
  111518. * @returns the current color writing state
  111519. */
  111520. getColorWrite(): boolean;
  111521. /**
  111522. * Sets alpha constants used by some alpha blending modes
  111523. * @param r defines the red component
  111524. * @param g defines the green component
  111525. * @param b defines the blue component
  111526. * @param a defines the alpha component
  111527. */
  111528. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  111529. /**
  111530. * Sets the current alpha mode
  111531. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  111532. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111533. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111534. */
  111535. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111536. /**
  111537. * Gets the current alpha mode
  111538. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111539. * @returns the current alpha mode
  111540. */
  111541. getAlphaMode(): number;
  111542. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111543. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111544. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111545. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111546. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111547. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111548. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111549. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111550. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111551. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111552. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111553. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111554. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111555. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111556. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111557. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111558. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111559. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111560. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111561. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111562. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  111563. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  111564. wipeCaches(bruteForce?: boolean): void;
  111565. _createTexture(): WebGLTexture;
  111566. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  111567. /**
  111568. * Usually called from BABYLON.Texture.ts.
  111569. * Passed information to create a WebGLTexture
  111570. * @param urlArg defines a value which contains one of the following:
  111571. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111572. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111573. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111574. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111575. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  111576. * @param scene needed for loading to the correct scene
  111577. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  111578. * @param onLoad optional callback to be called upon successful completion
  111579. * @param onError optional callback to be called upon failure
  111580. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  111581. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111582. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111583. * @param forcedExtension defines the extension to use to pick the right loader
  111584. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111585. */
  111586. 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;
  111587. /**
  111588. * Creates a cube texture
  111589. * @param rootUrl defines the url where the files to load is located
  111590. * @param scene defines the current scene
  111591. * @param files defines the list of files to load (1 per face)
  111592. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  111593. * @param onLoad defines an optional callback raised when the texture is loaded
  111594. * @param onError defines an optional callback raised if there is an issue to load the texture
  111595. * @param format defines the format of the data
  111596. * @param forcedExtension defines the extension to use to pick the right loader
  111597. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  111598. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  111599. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  111600. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  111601. * @returns the cube texture as an InternalTexture
  111602. */
  111603. 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;
  111604. private _getSamplingFilter;
  111605. private static _GetNativeTextureFormat;
  111606. createRenderTargetTexture(size: number | {
  111607. width: number;
  111608. height: number;
  111609. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111610. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111611. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111612. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111613. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  111614. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  111615. /**
  111616. * Updates a dynamic vertex buffer.
  111617. * @param vertexBuffer the vertex buffer to update
  111618. * @param data the data used to update the vertex buffer
  111619. * @param byteOffset the byte offset of the data (optional)
  111620. * @param byteLength the byte length of the data (optional)
  111621. */
  111622. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  111623. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  111624. private _updateAnisotropicLevel;
  111625. private _getAddressMode;
  111626. /** @hidden */
  111627. _bindTexture(channel: number, texture: InternalTexture): void;
  111628. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  111629. releaseEffects(): void;
  111630. /** @hidden */
  111631. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111632. /** @hidden */
  111633. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111634. /** @hidden */
  111635. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111636. /** @hidden */
  111637. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111638. }
  111639. }
  111640. declare module BABYLON {
  111641. /**
  111642. * Gather the list of clipboard event types as constants.
  111643. */
  111644. export class ClipboardEventTypes {
  111645. /**
  111646. * The clipboard event is fired when a copy command is active (pressed).
  111647. */
  111648. static readonly COPY: number;
  111649. /**
  111650. * The clipboard event is fired when a cut command is active (pressed).
  111651. */
  111652. static readonly CUT: number;
  111653. /**
  111654. * The clipboard event is fired when a paste command is active (pressed).
  111655. */
  111656. static readonly PASTE: number;
  111657. }
  111658. /**
  111659. * This class is used to store clipboard related info for the onClipboardObservable event.
  111660. */
  111661. export class ClipboardInfo {
  111662. /**
  111663. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111664. */
  111665. type: number;
  111666. /**
  111667. * Defines the related dom event
  111668. */
  111669. event: ClipboardEvent;
  111670. /**
  111671. *Creates an instance of ClipboardInfo.
  111672. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  111673. * @param event Defines the related dom event
  111674. */
  111675. constructor(
  111676. /**
  111677. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111678. */
  111679. type: number,
  111680. /**
  111681. * Defines the related dom event
  111682. */
  111683. event: ClipboardEvent);
  111684. /**
  111685. * Get the clipboard event's type from the keycode.
  111686. * @param keyCode Defines the keyCode for the current keyboard event.
  111687. * @return {number}
  111688. */
  111689. static GetTypeFromCharacter(keyCode: number): number;
  111690. }
  111691. }
  111692. declare module BABYLON {
  111693. /**
  111694. * Google Daydream controller
  111695. */
  111696. export class DaydreamController extends WebVRController {
  111697. /**
  111698. * Base Url for the controller model.
  111699. */
  111700. static MODEL_BASE_URL: string;
  111701. /**
  111702. * File name for the controller model.
  111703. */
  111704. static MODEL_FILENAME: string;
  111705. /**
  111706. * Gamepad Id prefix used to identify Daydream Controller.
  111707. */
  111708. static readonly GAMEPAD_ID_PREFIX: string;
  111709. /**
  111710. * Creates a new DaydreamController from a gamepad
  111711. * @param vrGamepad the gamepad that the controller should be created from
  111712. */
  111713. constructor(vrGamepad: any);
  111714. /**
  111715. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111716. * @param scene scene in which to add meshes
  111717. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111718. */
  111719. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111720. /**
  111721. * Called once for each button that changed state since the last frame
  111722. * @param buttonIdx Which button index changed
  111723. * @param state New state of the button
  111724. * @param changes Which properties on the state changed since last frame
  111725. */
  111726. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111727. }
  111728. }
  111729. declare module BABYLON {
  111730. /**
  111731. * Gear VR Controller
  111732. */
  111733. export class GearVRController extends WebVRController {
  111734. /**
  111735. * Base Url for the controller model.
  111736. */
  111737. static MODEL_BASE_URL: string;
  111738. /**
  111739. * File name for the controller model.
  111740. */
  111741. static MODEL_FILENAME: string;
  111742. /**
  111743. * Gamepad Id prefix used to identify this controller.
  111744. */
  111745. static readonly GAMEPAD_ID_PREFIX: string;
  111746. private readonly _buttonIndexToObservableNameMap;
  111747. /**
  111748. * Creates a new GearVRController from a gamepad
  111749. * @param vrGamepad the gamepad that the controller should be created from
  111750. */
  111751. constructor(vrGamepad: any);
  111752. /**
  111753. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111754. * @param scene scene in which to add meshes
  111755. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111756. */
  111757. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111758. /**
  111759. * Called once for each button that changed state since the last frame
  111760. * @param buttonIdx Which button index changed
  111761. * @param state New state of the button
  111762. * @param changes Which properties on the state changed since last frame
  111763. */
  111764. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111765. }
  111766. }
  111767. declare module BABYLON {
  111768. /**
  111769. * Class containing static functions to help procedurally build meshes
  111770. */
  111771. export class PolyhedronBuilder {
  111772. /**
  111773. * Creates a polyhedron mesh
  111774. * * 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
  111775. * * The parameter `size` (positive float, default 1) sets the polygon size
  111776. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  111777. * * 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`
  111778. * * 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
  111779. * * 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)`)
  111780. * * 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
  111781. * * 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
  111782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111783. * * 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
  111784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111785. * @param name defines the name of the mesh
  111786. * @param options defines the options used to create the mesh
  111787. * @param scene defines the hosting scene
  111788. * @returns the polyhedron mesh
  111789. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  111790. */
  111791. static CreatePolyhedron(name: string, options: {
  111792. type?: number;
  111793. size?: number;
  111794. sizeX?: number;
  111795. sizeY?: number;
  111796. sizeZ?: number;
  111797. custom?: any;
  111798. faceUV?: Vector4[];
  111799. faceColors?: Color4[];
  111800. flat?: boolean;
  111801. updatable?: boolean;
  111802. sideOrientation?: number;
  111803. frontUVs?: Vector4;
  111804. backUVs?: Vector4;
  111805. }, scene?: Nullable<Scene>): Mesh;
  111806. }
  111807. }
  111808. declare module BABYLON {
  111809. /**
  111810. * Gizmo that enables scaling a mesh along 3 axis
  111811. */
  111812. export class ScaleGizmo extends Gizmo {
  111813. /**
  111814. * Internal gizmo used for interactions on the x axis
  111815. */
  111816. xGizmo: AxisScaleGizmo;
  111817. /**
  111818. * Internal gizmo used for interactions on the y axis
  111819. */
  111820. yGizmo: AxisScaleGizmo;
  111821. /**
  111822. * Internal gizmo used for interactions on the z axis
  111823. */
  111824. zGizmo: AxisScaleGizmo;
  111825. /**
  111826. * Internal gizmo used to scale all axis equally
  111827. */
  111828. uniformScaleGizmo: AxisScaleGizmo;
  111829. private _meshAttached;
  111830. private _updateGizmoRotationToMatchAttachedMesh;
  111831. private _snapDistance;
  111832. private _scaleRatio;
  111833. private _uniformScalingMesh;
  111834. private _octahedron;
  111835. /** Fires an event when any of it's sub gizmos are dragged */
  111836. onDragStartObservable: Observable<unknown>;
  111837. /** Fires an event when any of it's sub gizmos are released from dragging */
  111838. onDragEndObservable: Observable<unknown>;
  111839. attachedMesh: Nullable<AbstractMesh>;
  111840. /**
  111841. * Creates a ScaleGizmo
  111842. * @param gizmoLayer The utility layer the gizmo will be added to
  111843. */
  111844. constructor(gizmoLayer?: UtilityLayerRenderer);
  111845. updateGizmoRotationToMatchAttachedMesh: boolean;
  111846. /**
  111847. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111848. */
  111849. snapDistance: number;
  111850. /**
  111851. * Ratio for the scale of the gizmo (Default: 1)
  111852. */
  111853. scaleRatio: number;
  111854. /**
  111855. * Disposes of the gizmo
  111856. */
  111857. dispose(): void;
  111858. }
  111859. }
  111860. declare module BABYLON {
  111861. /**
  111862. * Single axis scale gizmo
  111863. */
  111864. export class AxisScaleGizmo extends Gizmo {
  111865. /**
  111866. * Drag behavior responsible for the gizmos dragging interactions
  111867. */
  111868. dragBehavior: PointerDragBehavior;
  111869. private _pointerObserver;
  111870. /**
  111871. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111872. */
  111873. snapDistance: number;
  111874. /**
  111875. * Event that fires each time the gizmo snaps to a new location.
  111876. * * snapDistance is the the change in distance
  111877. */
  111878. onSnapObservable: Observable<{
  111879. snapDistance: number;
  111880. }>;
  111881. /**
  111882. * If the scaling operation should be done on all axis (default: false)
  111883. */
  111884. uniformScaling: boolean;
  111885. private _isEnabled;
  111886. private _parent;
  111887. private _arrow;
  111888. private _coloredMaterial;
  111889. private _hoverMaterial;
  111890. /**
  111891. * Creates an AxisScaleGizmo
  111892. * @param gizmoLayer The utility layer the gizmo will be added to
  111893. * @param dragAxis The axis which the gizmo will be able to scale on
  111894. * @param color The color of the gizmo
  111895. */
  111896. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  111897. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111898. /**
  111899. * If the gizmo is enabled
  111900. */
  111901. isEnabled: boolean;
  111902. /**
  111903. * Disposes of the gizmo
  111904. */
  111905. dispose(): void;
  111906. /**
  111907. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111908. * @param mesh The mesh to replace the default mesh of the gizmo
  111909. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  111910. */
  111911. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  111912. }
  111913. }
  111914. declare module BABYLON {
  111915. /**
  111916. * Bounding box gizmo
  111917. */
  111918. export class BoundingBoxGizmo extends Gizmo {
  111919. private _lineBoundingBox;
  111920. private _rotateSpheresParent;
  111921. private _scaleBoxesParent;
  111922. private _boundingDimensions;
  111923. private _renderObserver;
  111924. private _pointerObserver;
  111925. private _scaleDragSpeed;
  111926. private _tmpQuaternion;
  111927. private _tmpVector;
  111928. private _tmpRotationMatrix;
  111929. /**
  111930. * 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)
  111931. */
  111932. ignoreChildren: boolean;
  111933. /**
  111934. * 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)
  111935. */
  111936. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  111937. /**
  111938. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  111939. */
  111940. rotationSphereSize: number;
  111941. /**
  111942. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  111943. */
  111944. scaleBoxSize: number;
  111945. /**
  111946. * 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)
  111947. */
  111948. fixedDragMeshScreenSize: boolean;
  111949. /**
  111950. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  111951. */
  111952. fixedDragMeshScreenSizeDistanceFactor: number;
  111953. /**
  111954. * Fired when a rotation sphere or scale box is dragged
  111955. */
  111956. onDragStartObservable: Observable<{}>;
  111957. /**
  111958. * Fired when a scale box is dragged
  111959. */
  111960. onScaleBoxDragObservable: Observable<{}>;
  111961. /**
  111962. * Fired when a scale box drag is ended
  111963. */
  111964. onScaleBoxDragEndObservable: Observable<{}>;
  111965. /**
  111966. * Fired when a rotation sphere is dragged
  111967. */
  111968. onRotationSphereDragObservable: Observable<{}>;
  111969. /**
  111970. * Fired when a rotation sphere drag is ended
  111971. */
  111972. onRotationSphereDragEndObservable: Observable<{}>;
  111973. /**
  111974. * 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)
  111975. */
  111976. scalePivot: Nullable<Vector3>;
  111977. /**
  111978. * Mesh used as a pivot to rotate the attached mesh
  111979. */
  111980. private _anchorMesh;
  111981. private _existingMeshScale;
  111982. private _dragMesh;
  111983. private pointerDragBehavior;
  111984. private coloredMaterial;
  111985. private hoverColoredMaterial;
  111986. /**
  111987. * Sets the color of the bounding box gizmo
  111988. * @param color the color to set
  111989. */
  111990. setColor(color: Color3): void;
  111991. /**
  111992. * Creates an BoundingBoxGizmo
  111993. * @param gizmoLayer The utility layer the gizmo will be added to
  111994. * @param color The color of the gizmo
  111995. */
  111996. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  111997. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111998. private _selectNode;
  111999. /**
  112000. * Updates the bounding box information for the Gizmo
  112001. */
  112002. updateBoundingBox(): void;
  112003. private _updateRotationSpheres;
  112004. private _updateScaleBoxes;
  112005. /**
  112006. * Enables rotation on the specified axis and disables rotation on the others
  112007. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  112008. */
  112009. setEnabledRotationAxis(axis: string): void;
  112010. /**
  112011. * Enables/disables scaling
  112012. * @param enable if scaling should be enabled
  112013. */
  112014. setEnabledScaling(enable: boolean): void;
  112015. private _updateDummy;
  112016. /**
  112017. * Enables a pointer drag behavior on the bounding box of the gizmo
  112018. */
  112019. enableDragBehavior(): void;
  112020. /**
  112021. * Disposes of the gizmo
  112022. */
  112023. dispose(): void;
  112024. /**
  112025. * 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)
  112026. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  112027. * @returns the bounding box mesh with the passed in mesh as a child
  112028. */
  112029. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  112030. /**
  112031. * CustomMeshes are not supported by this gizmo
  112032. * @param mesh The mesh to replace the default mesh of the gizmo
  112033. */
  112034. setCustomMesh(mesh: Mesh): void;
  112035. }
  112036. }
  112037. declare module BABYLON {
  112038. /**
  112039. * Single plane rotation gizmo
  112040. */
  112041. export class PlaneRotationGizmo extends Gizmo {
  112042. /**
  112043. * Drag behavior responsible for the gizmos dragging interactions
  112044. */
  112045. dragBehavior: PointerDragBehavior;
  112046. private _pointerObserver;
  112047. /**
  112048. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  112049. */
  112050. snapDistance: number;
  112051. /**
  112052. * Event that fires each time the gizmo snaps to a new location.
  112053. * * snapDistance is the the change in distance
  112054. */
  112055. onSnapObservable: Observable<{
  112056. snapDistance: number;
  112057. }>;
  112058. private _isEnabled;
  112059. private _parent;
  112060. /**
  112061. * Creates a PlaneRotationGizmo
  112062. * @param gizmoLayer The utility layer the gizmo will be added to
  112063. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  112064. * @param color The color of the gizmo
  112065. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112066. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112067. */
  112068. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  112069. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112070. /**
  112071. * If the gizmo is enabled
  112072. */
  112073. isEnabled: boolean;
  112074. /**
  112075. * Disposes of the gizmo
  112076. */
  112077. dispose(): void;
  112078. }
  112079. }
  112080. declare module BABYLON {
  112081. /**
  112082. * Gizmo that enables rotating a mesh along 3 axis
  112083. */
  112084. export class RotationGizmo extends Gizmo {
  112085. /**
  112086. * Internal gizmo used for interactions on the x axis
  112087. */
  112088. xGizmo: PlaneRotationGizmo;
  112089. /**
  112090. * Internal gizmo used for interactions on the y axis
  112091. */
  112092. yGizmo: PlaneRotationGizmo;
  112093. /**
  112094. * Internal gizmo used for interactions on the z axis
  112095. */
  112096. zGizmo: PlaneRotationGizmo;
  112097. /** Fires an event when any of it's sub gizmos are dragged */
  112098. onDragStartObservable: Observable<unknown>;
  112099. /** Fires an event when any of it's sub gizmos are released from dragging */
  112100. onDragEndObservable: Observable<unknown>;
  112101. private _meshAttached;
  112102. attachedMesh: Nullable<AbstractMesh>;
  112103. /**
  112104. * Creates a RotationGizmo
  112105. * @param gizmoLayer The utility layer the gizmo will be added to
  112106. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112107. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112108. */
  112109. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  112110. updateGizmoRotationToMatchAttachedMesh: boolean;
  112111. /**
  112112. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112113. */
  112114. snapDistance: number;
  112115. /**
  112116. * Ratio for the scale of the gizmo (Default: 1)
  112117. */
  112118. scaleRatio: number;
  112119. /**
  112120. * Disposes of the gizmo
  112121. */
  112122. dispose(): void;
  112123. /**
  112124. * CustomMeshes are not supported by this gizmo
  112125. * @param mesh The mesh to replace the default mesh of the gizmo
  112126. */
  112127. setCustomMesh(mesh: Mesh): void;
  112128. }
  112129. }
  112130. declare module BABYLON {
  112131. /**
  112132. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  112133. */
  112134. export class GizmoManager implements IDisposable {
  112135. private scene;
  112136. /**
  112137. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  112138. */
  112139. gizmos: {
  112140. positionGizmo: Nullable<PositionGizmo>;
  112141. rotationGizmo: Nullable<RotationGizmo>;
  112142. scaleGizmo: Nullable<ScaleGizmo>;
  112143. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  112144. };
  112145. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  112146. clearGizmoOnEmptyPointerEvent: boolean;
  112147. /** Fires an event when the manager is attached to a mesh */
  112148. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  112149. private _gizmosEnabled;
  112150. private _pointerObserver;
  112151. private _attachedMesh;
  112152. private _boundingBoxColor;
  112153. private _defaultUtilityLayer;
  112154. private _defaultKeepDepthUtilityLayer;
  112155. /**
  112156. * When bounding box gizmo is enabled, this can be used to track drag/end events
  112157. */
  112158. boundingBoxDragBehavior: SixDofDragBehavior;
  112159. /**
  112160. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  112161. */
  112162. attachableMeshes: Nullable<Array<AbstractMesh>>;
  112163. /**
  112164. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  112165. */
  112166. usePointerToAttachGizmos: boolean;
  112167. /**
  112168. * Utility layer that the bounding box gizmo belongs to
  112169. */
  112170. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  112171. /**
  112172. * Utility layer that all gizmos besides bounding box belong to
  112173. */
  112174. readonly utilityLayer: UtilityLayerRenderer;
  112175. /**
  112176. * Instatiates a gizmo manager
  112177. * @param scene the scene to overlay the gizmos on top of
  112178. */
  112179. constructor(scene: Scene);
  112180. /**
  112181. * Attaches a set of gizmos to the specified mesh
  112182. * @param mesh The mesh the gizmo's should be attached to
  112183. */
  112184. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112185. /**
  112186. * If the position gizmo is enabled
  112187. */
  112188. positionGizmoEnabled: boolean;
  112189. /**
  112190. * If the rotation gizmo is enabled
  112191. */
  112192. rotationGizmoEnabled: boolean;
  112193. /**
  112194. * If the scale gizmo is enabled
  112195. */
  112196. scaleGizmoEnabled: boolean;
  112197. /**
  112198. * If the boundingBox gizmo is enabled
  112199. */
  112200. boundingBoxGizmoEnabled: boolean;
  112201. /**
  112202. * Disposes of the gizmo manager
  112203. */
  112204. dispose(): void;
  112205. }
  112206. }
  112207. declare module BABYLON {
  112208. /**
  112209. * A directional light is defined by a direction (what a surprise!).
  112210. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  112211. * 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.
  112212. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112213. */
  112214. export class DirectionalLight extends ShadowLight {
  112215. private _shadowFrustumSize;
  112216. /**
  112217. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  112218. */
  112219. /**
  112220. * Specifies a fix frustum size for the shadow generation.
  112221. */
  112222. shadowFrustumSize: number;
  112223. private _shadowOrthoScale;
  112224. /**
  112225. * Gets the shadow projection scale against the optimal computed one.
  112226. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112227. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112228. */
  112229. /**
  112230. * Sets the shadow projection scale against the optimal computed one.
  112231. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112232. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112233. */
  112234. shadowOrthoScale: number;
  112235. /**
  112236. * Automatically compute the projection matrix to best fit (including all the casters)
  112237. * on each frame.
  112238. */
  112239. autoUpdateExtends: boolean;
  112240. private _orthoLeft;
  112241. private _orthoRight;
  112242. private _orthoTop;
  112243. private _orthoBottom;
  112244. /**
  112245. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  112246. * The directional light is emitted from everywhere in the given direction.
  112247. * It can cast shadows.
  112248. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112249. * @param name The friendly name of the light
  112250. * @param direction The direction of the light
  112251. * @param scene The scene the light belongs to
  112252. */
  112253. constructor(name: string, direction: Vector3, scene: Scene);
  112254. /**
  112255. * Returns the string "DirectionalLight".
  112256. * @return The class name
  112257. */
  112258. getClassName(): string;
  112259. /**
  112260. * Returns the integer 1.
  112261. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112262. */
  112263. getTypeID(): number;
  112264. /**
  112265. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  112266. * Returns the DirectionalLight Shadow projection matrix.
  112267. */
  112268. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112269. /**
  112270. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  112271. * Returns the DirectionalLight Shadow projection matrix.
  112272. */
  112273. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  112274. /**
  112275. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  112276. * Returns the DirectionalLight Shadow projection matrix.
  112277. */
  112278. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112279. protected _buildUniformLayout(): void;
  112280. /**
  112281. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  112282. * @param effect The effect to update
  112283. * @param lightIndex The index of the light in the effect to update
  112284. * @returns The directional light
  112285. */
  112286. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  112287. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  112288. /**
  112289. * Gets the minZ used for shadow according to both the scene and the light.
  112290. *
  112291. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112292. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112293. * @param activeCamera The camera we are returning the min for
  112294. * @returns the depth min z
  112295. */
  112296. getDepthMinZ(activeCamera: Camera): number;
  112297. /**
  112298. * Gets the maxZ used for shadow according to both the scene and the light.
  112299. *
  112300. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112301. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112302. * @param activeCamera The camera we are returning the max for
  112303. * @returns the depth max z
  112304. */
  112305. getDepthMaxZ(activeCamera: Camera): number;
  112306. /**
  112307. * Prepares the list of defines specific to the light type.
  112308. * @param defines the list of defines
  112309. * @param lightIndex defines the index of the light for the effect
  112310. */
  112311. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112312. }
  112313. }
  112314. declare module BABYLON {
  112315. /**
  112316. * Class containing static functions to help procedurally build meshes
  112317. */
  112318. export class HemisphereBuilder {
  112319. /**
  112320. * Creates a hemisphere mesh
  112321. * @param name defines the name of the mesh
  112322. * @param options defines the options used to create the mesh
  112323. * @param scene defines the hosting scene
  112324. * @returns the hemisphere mesh
  112325. */
  112326. static CreateHemisphere(name: string, options: {
  112327. segments?: number;
  112328. diameter?: number;
  112329. sideOrientation?: number;
  112330. }, scene: any): Mesh;
  112331. }
  112332. }
  112333. declare module BABYLON {
  112334. /**
  112335. * A spot light is defined by a position, a direction, an angle, and an exponent.
  112336. * These values define a cone of light starting from the position, emitting toward the direction.
  112337. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  112338. * and the exponent defines the speed of the decay of the light with distance (reach).
  112339. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112340. */
  112341. export class SpotLight extends ShadowLight {
  112342. private _angle;
  112343. private _innerAngle;
  112344. private _cosHalfAngle;
  112345. private _lightAngleScale;
  112346. private _lightAngleOffset;
  112347. /**
  112348. * Gets the cone angle of the spot light in Radians.
  112349. */
  112350. /**
  112351. * Sets the cone angle of the spot light in Radians.
  112352. */
  112353. angle: number;
  112354. /**
  112355. * Only used in gltf falloff mode, this defines the angle where
  112356. * the directional falloff will start before cutting at angle which could be seen
  112357. * as outer angle.
  112358. */
  112359. /**
  112360. * Only used in gltf falloff mode, this defines the angle where
  112361. * the directional falloff will start before cutting at angle which could be seen
  112362. * as outer angle.
  112363. */
  112364. innerAngle: number;
  112365. private _shadowAngleScale;
  112366. /**
  112367. * Allows scaling the angle of the light for shadow generation only.
  112368. */
  112369. /**
  112370. * Allows scaling the angle of the light for shadow generation only.
  112371. */
  112372. shadowAngleScale: number;
  112373. /**
  112374. * The light decay speed with the distance from the emission spot.
  112375. */
  112376. exponent: number;
  112377. private _projectionTextureMatrix;
  112378. /**
  112379. * Allows reading the projecton texture
  112380. */
  112381. readonly projectionTextureMatrix: Matrix;
  112382. protected _projectionTextureLightNear: number;
  112383. /**
  112384. * Gets the near clip of the Spotlight for texture projection.
  112385. */
  112386. /**
  112387. * Sets the near clip of the Spotlight for texture projection.
  112388. */
  112389. projectionTextureLightNear: number;
  112390. protected _projectionTextureLightFar: number;
  112391. /**
  112392. * Gets the far clip of the Spotlight for texture projection.
  112393. */
  112394. /**
  112395. * Sets the far clip of the Spotlight for texture projection.
  112396. */
  112397. projectionTextureLightFar: number;
  112398. protected _projectionTextureUpDirection: Vector3;
  112399. /**
  112400. * Gets the Up vector of the Spotlight for texture projection.
  112401. */
  112402. /**
  112403. * Sets the Up vector of the Spotlight for texture projection.
  112404. */
  112405. projectionTextureUpDirection: Vector3;
  112406. private _projectionTexture;
  112407. /**
  112408. * Gets the projection texture of the light.
  112409. */
  112410. /**
  112411. * Sets the projection texture of the light.
  112412. */
  112413. projectionTexture: Nullable<BaseTexture>;
  112414. private _projectionTextureViewLightDirty;
  112415. private _projectionTextureProjectionLightDirty;
  112416. private _projectionTextureDirty;
  112417. private _projectionTextureViewTargetVector;
  112418. private _projectionTextureViewLightMatrix;
  112419. private _projectionTextureProjectionLightMatrix;
  112420. private _projectionTextureScalingMatrix;
  112421. /**
  112422. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  112423. * It can cast shadows.
  112424. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112425. * @param name The light friendly name
  112426. * @param position The position of the spot light in the scene
  112427. * @param direction The direction of the light in the scene
  112428. * @param angle The cone angle of the light in Radians
  112429. * @param exponent The light decay speed with the distance from the emission spot
  112430. * @param scene The scene the lights belongs to
  112431. */
  112432. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  112433. /**
  112434. * Returns the string "SpotLight".
  112435. * @returns the class name
  112436. */
  112437. getClassName(): string;
  112438. /**
  112439. * Returns the integer 2.
  112440. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112441. */
  112442. getTypeID(): number;
  112443. /**
  112444. * Overrides the direction setter to recompute the projection texture view light Matrix.
  112445. */
  112446. protected _setDirection(value: Vector3): void;
  112447. /**
  112448. * Overrides the position setter to recompute the projection texture view light Matrix.
  112449. */
  112450. protected _setPosition(value: Vector3): void;
  112451. /**
  112452. * 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.
  112453. * Returns the SpotLight.
  112454. */
  112455. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112456. protected _computeProjectionTextureViewLightMatrix(): void;
  112457. protected _computeProjectionTextureProjectionLightMatrix(): void;
  112458. /**
  112459. * Main function for light texture projection matrix computing.
  112460. */
  112461. protected _computeProjectionTextureMatrix(): void;
  112462. protected _buildUniformLayout(): void;
  112463. private _computeAngleValues;
  112464. /**
  112465. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  112466. * @param effect The effect to update
  112467. * @param lightIndex The index of the light in the effect to update
  112468. * @returns The spot light
  112469. */
  112470. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  112471. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  112472. /**
  112473. * Disposes the light and the associated resources.
  112474. */
  112475. dispose(): void;
  112476. /**
  112477. * Prepares the list of defines specific to the light type.
  112478. * @param defines the list of defines
  112479. * @param lightIndex defines the index of the light for the effect
  112480. */
  112481. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112482. }
  112483. }
  112484. declare module BABYLON {
  112485. /**
  112486. * Gizmo that enables viewing a light
  112487. */
  112488. export class LightGizmo extends Gizmo {
  112489. private _lightMesh;
  112490. private _material;
  112491. private cachedPosition;
  112492. private cachedForward;
  112493. /**
  112494. * Creates a LightGizmo
  112495. * @param gizmoLayer The utility layer the gizmo will be added to
  112496. */
  112497. constructor(gizmoLayer?: UtilityLayerRenderer);
  112498. private _light;
  112499. /**
  112500. * The light that the gizmo is attached to
  112501. */
  112502. light: Nullable<Light>;
  112503. /**
  112504. * Gets the material used to render the light gizmo
  112505. */
  112506. readonly material: StandardMaterial;
  112507. /**
  112508. * @hidden
  112509. * Updates the gizmo to match the attached mesh's position/rotation
  112510. */
  112511. protected _update(): void;
  112512. private static _Scale;
  112513. /**
  112514. * Creates the lines for a light mesh
  112515. */
  112516. private static _createLightLines;
  112517. /**
  112518. * Disposes of the light gizmo
  112519. */
  112520. dispose(): void;
  112521. private static _CreateHemisphericLightMesh;
  112522. private static _CreatePointLightMesh;
  112523. private static _CreateSpotLightMesh;
  112524. private static _CreateDirectionalLightMesh;
  112525. }
  112526. }
  112527. declare module BABYLON {
  112528. /** @hidden */
  112529. export var backgroundFragmentDeclaration: {
  112530. name: string;
  112531. shader: string;
  112532. };
  112533. }
  112534. declare module BABYLON {
  112535. /** @hidden */
  112536. export var backgroundUboDeclaration: {
  112537. name: string;
  112538. shader: string;
  112539. };
  112540. }
  112541. declare module BABYLON {
  112542. /** @hidden */
  112543. export var backgroundPixelShader: {
  112544. name: string;
  112545. shader: string;
  112546. };
  112547. }
  112548. declare module BABYLON {
  112549. /** @hidden */
  112550. export var backgroundVertexDeclaration: {
  112551. name: string;
  112552. shader: string;
  112553. };
  112554. }
  112555. declare module BABYLON {
  112556. /** @hidden */
  112557. export var backgroundVertexShader: {
  112558. name: string;
  112559. shader: string;
  112560. };
  112561. }
  112562. declare module BABYLON {
  112563. /**
  112564. * Background material used to create an efficient environement around your scene.
  112565. */
  112566. export class BackgroundMaterial extends PushMaterial {
  112567. /**
  112568. * Standard reflectance value at parallel view angle.
  112569. */
  112570. static StandardReflectance0: number;
  112571. /**
  112572. * Standard reflectance value at grazing angle.
  112573. */
  112574. static StandardReflectance90: number;
  112575. protected _primaryColor: Color3;
  112576. /**
  112577. * Key light Color (multiply against the environement texture)
  112578. */
  112579. primaryColor: Color3;
  112580. protected __perceptualColor: Nullable<Color3>;
  112581. /**
  112582. * Experimental Internal Use Only.
  112583. *
  112584. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  112585. * This acts as a helper to set the primary color to a more "human friendly" value.
  112586. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  112587. * output color as close as possible from the chosen value.
  112588. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  112589. * part of lighting setup.)
  112590. */
  112591. _perceptualColor: Nullable<Color3>;
  112592. protected _primaryColorShadowLevel: float;
  112593. /**
  112594. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  112595. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  112596. */
  112597. primaryColorShadowLevel: float;
  112598. protected _primaryColorHighlightLevel: float;
  112599. /**
  112600. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  112601. * The primary color is used at the level chosen to define what the white area would look.
  112602. */
  112603. primaryColorHighlightLevel: float;
  112604. protected _reflectionTexture: Nullable<BaseTexture>;
  112605. /**
  112606. * Reflection Texture used in the material.
  112607. * Should be author in a specific way for the best result (refer to the documentation).
  112608. */
  112609. reflectionTexture: Nullable<BaseTexture>;
  112610. protected _reflectionBlur: float;
  112611. /**
  112612. * Reflection Texture level of blur.
  112613. *
  112614. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  112615. * texture twice.
  112616. */
  112617. reflectionBlur: float;
  112618. protected _diffuseTexture: Nullable<BaseTexture>;
  112619. /**
  112620. * Diffuse Texture used in the material.
  112621. * Should be author in a specific way for the best result (refer to the documentation).
  112622. */
  112623. diffuseTexture: Nullable<BaseTexture>;
  112624. protected _shadowLights: Nullable<IShadowLight[]>;
  112625. /**
  112626. * Specify the list of lights casting shadow on the material.
  112627. * All scene shadow lights will be included if null.
  112628. */
  112629. shadowLights: Nullable<IShadowLight[]>;
  112630. protected _shadowLevel: float;
  112631. /**
  112632. * Helps adjusting the shadow to a softer level if required.
  112633. * 0 means black shadows and 1 means no shadows.
  112634. */
  112635. shadowLevel: float;
  112636. protected _sceneCenter: Vector3;
  112637. /**
  112638. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  112639. * It is usually zero but might be interesting to modify according to your setup.
  112640. */
  112641. sceneCenter: Vector3;
  112642. protected _opacityFresnel: boolean;
  112643. /**
  112644. * This helps specifying that the material is falling off to the sky box at grazing angle.
  112645. * This helps ensuring a nice transition when the camera goes under the ground.
  112646. */
  112647. opacityFresnel: boolean;
  112648. protected _reflectionFresnel: boolean;
  112649. /**
  112650. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  112651. * This helps adding a mirror texture on the ground.
  112652. */
  112653. reflectionFresnel: boolean;
  112654. protected _reflectionFalloffDistance: number;
  112655. /**
  112656. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  112657. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  112658. */
  112659. reflectionFalloffDistance: number;
  112660. protected _reflectionAmount: number;
  112661. /**
  112662. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  112663. */
  112664. reflectionAmount: number;
  112665. protected _reflectionReflectance0: number;
  112666. /**
  112667. * This specifies the weight of the reflection at grazing angle.
  112668. */
  112669. reflectionReflectance0: number;
  112670. protected _reflectionReflectance90: number;
  112671. /**
  112672. * This specifies the weight of the reflection at a perpendicular point of view.
  112673. */
  112674. reflectionReflectance90: number;
  112675. /**
  112676. * Sets the reflection reflectance fresnel values according to the default standard
  112677. * empirically know to work well :-)
  112678. */
  112679. reflectionStandardFresnelWeight: number;
  112680. protected _useRGBColor: boolean;
  112681. /**
  112682. * Helps to directly use the maps channels instead of their level.
  112683. */
  112684. useRGBColor: boolean;
  112685. protected _enableNoise: boolean;
  112686. /**
  112687. * This helps reducing the banding effect that could occur on the background.
  112688. */
  112689. enableNoise: boolean;
  112690. /**
  112691. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112692. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  112693. * Recommended to be keep at 1.0 except for special cases.
  112694. */
  112695. fovMultiplier: number;
  112696. private _fovMultiplier;
  112697. /**
  112698. * Enable the FOV adjustment feature controlled by fovMultiplier.
  112699. */
  112700. useEquirectangularFOV: boolean;
  112701. private _maxSimultaneousLights;
  112702. /**
  112703. * Number of Simultaneous lights allowed on the material.
  112704. */
  112705. maxSimultaneousLights: int;
  112706. /**
  112707. * Default configuration related to image processing available in the Background Material.
  112708. */
  112709. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112710. /**
  112711. * Keep track of the image processing observer to allow dispose and replace.
  112712. */
  112713. private _imageProcessingObserver;
  112714. /**
  112715. * Attaches a new image processing configuration to the PBR Material.
  112716. * @param configuration (if null the scene configuration will be use)
  112717. */
  112718. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  112719. /**
  112720. * Gets the image processing configuration used either in this material.
  112721. */
  112722. /**
  112723. * Sets the Default image processing configuration used either in the this material.
  112724. *
  112725. * If sets to null, the scene one is in use.
  112726. */
  112727. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  112728. /**
  112729. * Gets wether the color curves effect is enabled.
  112730. */
  112731. /**
  112732. * Sets wether the color curves effect is enabled.
  112733. */
  112734. cameraColorCurvesEnabled: boolean;
  112735. /**
  112736. * Gets wether the color grading effect is enabled.
  112737. */
  112738. /**
  112739. * Gets wether the color grading effect is enabled.
  112740. */
  112741. cameraColorGradingEnabled: boolean;
  112742. /**
  112743. * Gets wether tonemapping is enabled or not.
  112744. */
  112745. /**
  112746. * Sets wether tonemapping is enabled or not
  112747. */
  112748. cameraToneMappingEnabled: boolean;
  112749. /**
  112750. * The camera exposure used on this material.
  112751. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112752. * This corresponds to a photographic exposure.
  112753. */
  112754. /**
  112755. * The camera exposure used on this material.
  112756. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112757. * This corresponds to a photographic exposure.
  112758. */
  112759. cameraExposure: float;
  112760. /**
  112761. * Gets The camera contrast used on this material.
  112762. */
  112763. /**
  112764. * Sets The camera contrast used on this material.
  112765. */
  112766. cameraContrast: float;
  112767. /**
  112768. * Gets the Color Grading 2D Lookup Texture.
  112769. */
  112770. /**
  112771. * Sets the Color Grading 2D Lookup Texture.
  112772. */
  112773. cameraColorGradingTexture: Nullable<BaseTexture>;
  112774. /**
  112775. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112776. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112777. * 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;
  112778. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112779. */
  112780. /**
  112781. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112782. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112783. * 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;
  112784. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112785. */
  112786. cameraColorCurves: Nullable<ColorCurves>;
  112787. /**
  112788. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  112789. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  112790. */
  112791. switchToBGR: boolean;
  112792. private _renderTargets;
  112793. private _reflectionControls;
  112794. private _white;
  112795. private _primaryShadowColor;
  112796. private _primaryHighlightColor;
  112797. /**
  112798. * Instantiates a Background Material in the given scene
  112799. * @param name The friendly name of the material
  112800. * @param scene The scene to add the material to
  112801. */
  112802. constructor(name: string, scene: Scene);
  112803. /**
  112804. * Gets a boolean indicating that current material needs to register RTT
  112805. */
  112806. readonly hasRenderTargetTextures: boolean;
  112807. /**
  112808. * The entire material has been created in order to prevent overdraw.
  112809. * @returns false
  112810. */
  112811. needAlphaTesting(): boolean;
  112812. /**
  112813. * The entire material has been created in order to prevent overdraw.
  112814. * @returns true if blending is enable
  112815. */
  112816. needAlphaBlending(): boolean;
  112817. /**
  112818. * Checks wether the material is ready to be rendered for a given mesh.
  112819. * @param mesh The mesh to render
  112820. * @param subMesh The submesh to check against
  112821. * @param useInstances Specify wether or not the material is used with instances
  112822. * @returns true if all the dependencies are ready (Textures, Effects...)
  112823. */
  112824. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  112825. /**
  112826. * Compute the primary color according to the chosen perceptual color.
  112827. */
  112828. private _computePrimaryColorFromPerceptualColor;
  112829. /**
  112830. * Compute the highlights and shadow colors according to their chosen levels.
  112831. */
  112832. private _computePrimaryColors;
  112833. /**
  112834. * Build the uniform buffer used in the material.
  112835. */
  112836. buildUniformLayout(): void;
  112837. /**
  112838. * Unbind the material.
  112839. */
  112840. unbind(): void;
  112841. /**
  112842. * Bind only the world matrix to the material.
  112843. * @param world The world matrix to bind.
  112844. */
  112845. bindOnlyWorldMatrix(world: Matrix): void;
  112846. /**
  112847. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  112848. * @param world The world matrix to bind.
  112849. * @param subMesh The submesh to bind for.
  112850. */
  112851. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  112852. /**
  112853. * Checks to see if a texture is used in the material.
  112854. * @param texture - Base texture to use.
  112855. * @returns - Boolean specifying if a texture is used in the material.
  112856. */
  112857. hasTexture(texture: BaseTexture): boolean;
  112858. /**
  112859. * Dispose the material.
  112860. * @param forceDisposeEffect Force disposal of the associated effect.
  112861. * @param forceDisposeTextures Force disposal of the associated textures.
  112862. */
  112863. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  112864. /**
  112865. * Clones the material.
  112866. * @param name The cloned name.
  112867. * @returns The cloned material.
  112868. */
  112869. clone(name: string): BackgroundMaterial;
  112870. /**
  112871. * Serializes the current material to its JSON representation.
  112872. * @returns The JSON representation.
  112873. */
  112874. serialize(): any;
  112875. /**
  112876. * Gets the class name of the material
  112877. * @returns "BackgroundMaterial"
  112878. */
  112879. getClassName(): string;
  112880. /**
  112881. * Parse a JSON input to create back a background material.
  112882. * @param source The JSON data to parse
  112883. * @param scene The scene to create the parsed material in
  112884. * @param rootUrl The root url of the assets the material depends upon
  112885. * @returns the instantiated BackgroundMaterial.
  112886. */
  112887. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  112888. }
  112889. }
  112890. declare module BABYLON {
  112891. /**
  112892. * Represents the different options available during the creation of
  112893. * a Environment helper.
  112894. *
  112895. * This can control the default ground, skybox and image processing setup of your scene.
  112896. */
  112897. export interface IEnvironmentHelperOptions {
  112898. /**
  112899. * Specifies wether or not to create a ground.
  112900. * True by default.
  112901. */
  112902. createGround: boolean;
  112903. /**
  112904. * Specifies the ground size.
  112905. * 15 by default.
  112906. */
  112907. groundSize: number;
  112908. /**
  112909. * The texture used on the ground for the main color.
  112910. * Comes from the BabylonJS CDN by default.
  112911. *
  112912. * Remarks: Can be either a texture or a url.
  112913. */
  112914. groundTexture: string | BaseTexture;
  112915. /**
  112916. * The color mixed in the ground texture by default.
  112917. * BabylonJS clearColor by default.
  112918. */
  112919. groundColor: Color3;
  112920. /**
  112921. * Specifies the ground opacity.
  112922. * 1 by default.
  112923. */
  112924. groundOpacity: number;
  112925. /**
  112926. * Enables the ground to receive shadows.
  112927. * True by default.
  112928. */
  112929. enableGroundShadow: boolean;
  112930. /**
  112931. * Helps preventing the shadow to be fully black on the ground.
  112932. * 0.5 by default.
  112933. */
  112934. groundShadowLevel: number;
  112935. /**
  112936. * Creates a mirror texture attach to the ground.
  112937. * false by default.
  112938. */
  112939. enableGroundMirror: boolean;
  112940. /**
  112941. * Specifies the ground mirror size ratio.
  112942. * 0.3 by default as the default kernel is 64.
  112943. */
  112944. groundMirrorSizeRatio: number;
  112945. /**
  112946. * Specifies the ground mirror blur kernel size.
  112947. * 64 by default.
  112948. */
  112949. groundMirrorBlurKernel: number;
  112950. /**
  112951. * Specifies the ground mirror visibility amount.
  112952. * 1 by default
  112953. */
  112954. groundMirrorAmount: number;
  112955. /**
  112956. * Specifies the ground mirror reflectance weight.
  112957. * This uses the standard weight of the background material to setup the fresnel effect
  112958. * of the mirror.
  112959. * 1 by default.
  112960. */
  112961. groundMirrorFresnelWeight: number;
  112962. /**
  112963. * Specifies the ground mirror Falloff distance.
  112964. * This can helps reducing the size of the reflection.
  112965. * 0 by Default.
  112966. */
  112967. groundMirrorFallOffDistance: number;
  112968. /**
  112969. * Specifies the ground mirror texture type.
  112970. * Unsigned Int by Default.
  112971. */
  112972. groundMirrorTextureType: number;
  112973. /**
  112974. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  112975. * the shown objects.
  112976. */
  112977. groundYBias: number;
  112978. /**
  112979. * Specifies wether or not to create a skybox.
  112980. * True by default.
  112981. */
  112982. createSkybox: boolean;
  112983. /**
  112984. * Specifies the skybox size.
  112985. * 20 by default.
  112986. */
  112987. skyboxSize: number;
  112988. /**
  112989. * The texture used on the skybox for the main color.
  112990. * Comes from the BabylonJS CDN by default.
  112991. *
  112992. * Remarks: Can be either a texture or a url.
  112993. */
  112994. skyboxTexture: string | BaseTexture;
  112995. /**
  112996. * The color mixed in the skybox texture by default.
  112997. * BabylonJS clearColor by default.
  112998. */
  112999. skyboxColor: Color3;
  113000. /**
  113001. * The background rotation around the Y axis of the scene.
  113002. * This helps aligning the key lights of your scene with the background.
  113003. * 0 by default.
  113004. */
  113005. backgroundYRotation: number;
  113006. /**
  113007. * Compute automatically the size of the elements to best fit with the scene.
  113008. */
  113009. sizeAuto: boolean;
  113010. /**
  113011. * Default position of the rootMesh if autoSize is not true.
  113012. */
  113013. rootPosition: Vector3;
  113014. /**
  113015. * Sets up the image processing in the scene.
  113016. * true by default.
  113017. */
  113018. setupImageProcessing: boolean;
  113019. /**
  113020. * The texture used as your environment texture in the scene.
  113021. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  113022. *
  113023. * Remarks: Can be either a texture or a url.
  113024. */
  113025. environmentTexture: string | BaseTexture;
  113026. /**
  113027. * The value of the exposure to apply to the scene.
  113028. * 0.6 by default if setupImageProcessing is true.
  113029. */
  113030. cameraExposure: number;
  113031. /**
  113032. * The value of the contrast to apply to the scene.
  113033. * 1.6 by default if setupImageProcessing is true.
  113034. */
  113035. cameraContrast: number;
  113036. /**
  113037. * Specifies wether or not tonemapping should be enabled in the scene.
  113038. * true by default if setupImageProcessing is true.
  113039. */
  113040. toneMappingEnabled: boolean;
  113041. }
  113042. /**
  113043. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  113044. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  113045. * It also helps with the default setup of your imageProcessing configuration.
  113046. */
  113047. export class EnvironmentHelper {
  113048. /**
  113049. * Default ground texture URL.
  113050. */
  113051. private static _groundTextureCDNUrl;
  113052. /**
  113053. * Default skybox texture URL.
  113054. */
  113055. private static _skyboxTextureCDNUrl;
  113056. /**
  113057. * Default environment texture URL.
  113058. */
  113059. private static _environmentTextureCDNUrl;
  113060. /**
  113061. * Creates the default options for the helper.
  113062. */
  113063. private static _getDefaultOptions;
  113064. private _rootMesh;
  113065. /**
  113066. * Gets the root mesh created by the helper.
  113067. */
  113068. readonly rootMesh: Mesh;
  113069. private _skybox;
  113070. /**
  113071. * Gets the skybox created by the helper.
  113072. */
  113073. readonly skybox: Nullable<Mesh>;
  113074. private _skyboxTexture;
  113075. /**
  113076. * Gets the skybox texture created by the helper.
  113077. */
  113078. readonly skyboxTexture: Nullable<BaseTexture>;
  113079. private _skyboxMaterial;
  113080. /**
  113081. * Gets the skybox material created by the helper.
  113082. */
  113083. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  113084. private _ground;
  113085. /**
  113086. * Gets the ground mesh created by the helper.
  113087. */
  113088. readonly ground: Nullable<Mesh>;
  113089. private _groundTexture;
  113090. /**
  113091. * Gets the ground texture created by the helper.
  113092. */
  113093. readonly groundTexture: Nullable<BaseTexture>;
  113094. private _groundMirror;
  113095. /**
  113096. * Gets the ground mirror created by the helper.
  113097. */
  113098. readonly groundMirror: Nullable<MirrorTexture>;
  113099. /**
  113100. * Gets the ground mirror render list to helps pushing the meshes
  113101. * you wish in the ground reflection.
  113102. */
  113103. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  113104. private _groundMaterial;
  113105. /**
  113106. * Gets the ground material created by the helper.
  113107. */
  113108. readonly groundMaterial: Nullable<BackgroundMaterial>;
  113109. /**
  113110. * Stores the creation options.
  113111. */
  113112. private readonly _scene;
  113113. private _options;
  113114. /**
  113115. * This observable will be notified with any error during the creation of the environment,
  113116. * mainly texture creation errors.
  113117. */
  113118. onErrorObservable: Observable<{
  113119. message?: string;
  113120. exception?: any;
  113121. }>;
  113122. /**
  113123. * constructor
  113124. * @param options Defines the options we want to customize the helper
  113125. * @param scene The scene to add the material to
  113126. */
  113127. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  113128. /**
  113129. * Updates the background according to the new options
  113130. * @param options
  113131. */
  113132. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  113133. /**
  113134. * Sets the primary color of all the available elements.
  113135. * @param color the main color to affect to the ground and the background
  113136. */
  113137. setMainColor(color: Color3): void;
  113138. /**
  113139. * Setup the image processing according to the specified options.
  113140. */
  113141. private _setupImageProcessing;
  113142. /**
  113143. * Setup the environment texture according to the specified options.
  113144. */
  113145. private _setupEnvironmentTexture;
  113146. /**
  113147. * Setup the background according to the specified options.
  113148. */
  113149. private _setupBackground;
  113150. /**
  113151. * Get the scene sizes according to the setup.
  113152. */
  113153. private _getSceneSize;
  113154. /**
  113155. * Setup the ground according to the specified options.
  113156. */
  113157. private _setupGround;
  113158. /**
  113159. * Setup the ground material according to the specified options.
  113160. */
  113161. private _setupGroundMaterial;
  113162. /**
  113163. * Setup the ground diffuse texture according to the specified options.
  113164. */
  113165. private _setupGroundDiffuseTexture;
  113166. /**
  113167. * Setup the ground mirror texture according to the specified options.
  113168. */
  113169. private _setupGroundMirrorTexture;
  113170. /**
  113171. * Setup the ground to receive the mirror texture.
  113172. */
  113173. private _setupMirrorInGroundMaterial;
  113174. /**
  113175. * Setup the skybox according to the specified options.
  113176. */
  113177. private _setupSkybox;
  113178. /**
  113179. * Setup the skybox material according to the specified options.
  113180. */
  113181. private _setupSkyboxMaterial;
  113182. /**
  113183. * Setup the skybox reflection texture according to the specified options.
  113184. */
  113185. private _setupSkyboxReflectionTexture;
  113186. private _errorHandler;
  113187. /**
  113188. * Dispose all the elements created by the Helper.
  113189. */
  113190. dispose(): void;
  113191. }
  113192. }
  113193. declare module BABYLON {
  113194. /**
  113195. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  113196. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  113197. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  113198. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  113199. */
  113200. export class PhotoDome extends TransformNode {
  113201. /**
  113202. * Define the image as a Monoscopic panoramic 360 image.
  113203. */
  113204. static readonly MODE_MONOSCOPIC: number;
  113205. /**
  113206. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113207. */
  113208. static readonly MODE_TOPBOTTOM: number;
  113209. /**
  113210. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113211. */
  113212. static readonly MODE_SIDEBYSIDE: number;
  113213. private _useDirectMapping;
  113214. /**
  113215. * The texture being displayed on the sphere
  113216. */
  113217. protected _photoTexture: Texture;
  113218. /**
  113219. * Gets or sets the texture being displayed on the sphere
  113220. */
  113221. photoTexture: Texture;
  113222. /**
  113223. * Observable raised when an error occured while loading the 360 image
  113224. */
  113225. onLoadErrorObservable: Observable<string>;
  113226. /**
  113227. * The skybox material
  113228. */
  113229. protected _material: BackgroundMaterial;
  113230. /**
  113231. * The surface used for the skybox
  113232. */
  113233. protected _mesh: Mesh;
  113234. /**
  113235. * Gets the mesh used for the skybox.
  113236. */
  113237. readonly mesh: Mesh;
  113238. /**
  113239. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113240. * Also see the options.resolution property.
  113241. */
  113242. fovMultiplier: number;
  113243. private _imageMode;
  113244. /**
  113245. * Gets or set the current video mode for the video. It can be:
  113246. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  113247. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113248. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113249. */
  113250. imageMode: number;
  113251. /**
  113252. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  113253. * @param name Element's name, child elements will append suffixes for their own names.
  113254. * @param urlsOfPhoto defines the url of the photo to display
  113255. * @param options defines an object containing optional or exposed sub element properties
  113256. * @param onError defines a callback called when an error occured while loading the texture
  113257. */
  113258. constructor(name: string, urlOfPhoto: string, options: {
  113259. resolution?: number;
  113260. size?: number;
  113261. useDirectMapping?: boolean;
  113262. faceForward?: boolean;
  113263. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  113264. private _onBeforeCameraRenderObserver;
  113265. private _changeImageMode;
  113266. /**
  113267. * Releases resources associated with this node.
  113268. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113269. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113270. */
  113271. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113272. }
  113273. }
  113274. declare module BABYLON {
  113275. /**
  113276. * Class used to host RGBD texture specific utilities
  113277. */
  113278. export class RGBDTextureTools {
  113279. /**
  113280. * Expand the RGBD Texture from RGBD to Half Float if possible.
  113281. * @param texture the texture to expand.
  113282. */
  113283. static ExpandRGBDTexture(texture: Texture): void;
  113284. }
  113285. }
  113286. declare module BABYLON {
  113287. /**
  113288. * Class used to host texture specific utilities
  113289. */
  113290. export class BRDFTextureTools {
  113291. /**
  113292. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  113293. * @param scene defines the hosting scene
  113294. * @returns the environment BRDF texture
  113295. */
  113296. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  113297. private static _environmentBRDFBase64Texture;
  113298. }
  113299. }
  113300. declare module BABYLON {
  113301. /**
  113302. * @hidden
  113303. */
  113304. export interface IMaterialClearCoatDefines {
  113305. CLEARCOAT: boolean;
  113306. CLEARCOAT_DEFAULTIOR: boolean;
  113307. CLEARCOAT_TEXTURE: boolean;
  113308. CLEARCOAT_TEXTUREDIRECTUV: number;
  113309. CLEARCOAT_BUMP: boolean;
  113310. CLEARCOAT_BUMPDIRECTUV: number;
  113311. CLEARCOAT_TINT: boolean;
  113312. CLEARCOAT_TINT_TEXTURE: boolean;
  113313. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  113314. /** @hidden */
  113315. _areTexturesDirty: boolean;
  113316. }
  113317. /**
  113318. * Define the code related to the clear coat parameters of the pbr material.
  113319. */
  113320. export class PBRClearCoatConfiguration {
  113321. /**
  113322. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113323. * The default fits with a polyurethane material.
  113324. */
  113325. private static readonly _DefaultIndexOfRefraction;
  113326. private _isEnabled;
  113327. /**
  113328. * Defines if the clear coat is enabled in the material.
  113329. */
  113330. isEnabled: boolean;
  113331. /**
  113332. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  113333. */
  113334. intensity: number;
  113335. /**
  113336. * Defines the clear coat layer roughness.
  113337. */
  113338. roughness: number;
  113339. private _indexOfRefraction;
  113340. /**
  113341. * Defines the index of refraction of the clear coat.
  113342. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113343. * The default fits with a polyurethane material.
  113344. * Changing the default value is more performance intensive.
  113345. */
  113346. indexOfRefraction: number;
  113347. private _texture;
  113348. /**
  113349. * Stores the clear coat values in a texture.
  113350. */
  113351. texture: Nullable<BaseTexture>;
  113352. private _bumpTexture;
  113353. /**
  113354. * Define the clear coat specific bump texture.
  113355. */
  113356. bumpTexture: Nullable<BaseTexture>;
  113357. private _isTintEnabled;
  113358. /**
  113359. * Defines if the clear coat tint is enabled in the material.
  113360. */
  113361. isTintEnabled: boolean;
  113362. /**
  113363. * Defines the clear coat tint of the material.
  113364. * This is only use if tint is enabled
  113365. */
  113366. tintColor: Color3;
  113367. /**
  113368. * Defines the distance at which the tint color should be found in the
  113369. * clear coat media.
  113370. * This is only use if tint is enabled
  113371. */
  113372. tintColorAtDistance: number;
  113373. /**
  113374. * Defines the clear coat layer thickness.
  113375. * This is only use if tint is enabled
  113376. */
  113377. tintThickness: number;
  113378. private _tintTexture;
  113379. /**
  113380. * Stores the clear tint values in a texture.
  113381. * rgb is tint
  113382. * a is a thickness factor
  113383. */
  113384. tintTexture: Nullable<BaseTexture>;
  113385. /** @hidden */
  113386. private _internalMarkAllSubMeshesAsTexturesDirty;
  113387. /** @hidden */
  113388. _markAllSubMeshesAsTexturesDirty(): void;
  113389. /**
  113390. * Instantiate a new istance of clear coat configuration.
  113391. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113392. */
  113393. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113394. /**
  113395. * Gets wehter the submesh is ready to be used or not.
  113396. * @param defines the list of "defines" to update.
  113397. * @param scene defines the scene the material belongs to.
  113398. * @param engine defines the engine the material belongs to.
  113399. * @param disableBumpMap defines wether the material disables bump or not.
  113400. * @returns - boolean indicating that the submesh is ready or not.
  113401. */
  113402. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  113403. /**
  113404. * Checks to see if a texture is used in the material.
  113405. * @param defines the list of "defines" to update.
  113406. * @param scene defines the scene to the material belongs to.
  113407. */
  113408. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  113409. /**
  113410. * Binds the material data.
  113411. * @param uniformBuffer defines the Uniform buffer to fill in.
  113412. * @param scene defines the scene the material belongs to.
  113413. * @param engine defines the engine the material belongs to.
  113414. * @param disableBumpMap defines wether the material disables bump or not.
  113415. * @param isFrozen defines wether the material is frozen or not.
  113416. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113417. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113418. */
  113419. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  113420. /**
  113421. * Checks to see if a texture is used in the material.
  113422. * @param texture - Base texture to use.
  113423. * @returns - Boolean specifying if a texture is used in the material.
  113424. */
  113425. hasTexture(texture: BaseTexture): boolean;
  113426. /**
  113427. * Returns an array of the actively used textures.
  113428. * @param activeTextures Array of BaseTextures
  113429. */
  113430. getActiveTextures(activeTextures: BaseTexture[]): void;
  113431. /**
  113432. * Returns the animatable textures.
  113433. * @param animatables Array of animatable textures.
  113434. */
  113435. getAnimatables(animatables: IAnimatable[]): void;
  113436. /**
  113437. * Disposes the resources of the material.
  113438. * @param forceDisposeTextures - Forces the disposal of all textures.
  113439. */
  113440. dispose(forceDisposeTextures?: boolean): void;
  113441. /**
  113442. * Get the current class name of the texture useful for serialization or dynamic coding.
  113443. * @returns "PBRClearCoatConfiguration"
  113444. */
  113445. getClassName(): string;
  113446. /**
  113447. * Add fallbacks to the effect fallbacks list.
  113448. * @param defines defines the Base texture to use.
  113449. * @param fallbacks defines the current fallback list.
  113450. * @param currentRank defines the current fallback rank.
  113451. * @returns the new fallback rank.
  113452. */
  113453. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113454. /**
  113455. * Add the required uniforms to the current list.
  113456. * @param uniforms defines the current uniform list.
  113457. */
  113458. static AddUniforms(uniforms: string[]): void;
  113459. /**
  113460. * Add the required samplers to the current list.
  113461. * @param samplers defines the current sampler list.
  113462. */
  113463. static AddSamplers(samplers: string[]): void;
  113464. /**
  113465. * Add the required uniforms to the current buffer.
  113466. * @param uniformBuffer defines the current uniform buffer.
  113467. */
  113468. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113469. /**
  113470. * Makes a duplicate of the current configuration into another one.
  113471. * @param clearCoatConfiguration define the config where to copy the info
  113472. */
  113473. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  113474. /**
  113475. * Serializes this clear coat configuration.
  113476. * @returns - An object with the serialized config.
  113477. */
  113478. serialize(): any;
  113479. /**
  113480. * Parses a anisotropy Configuration from a serialized object.
  113481. * @param source - Serialized object.
  113482. * @param scene Defines the scene we are parsing for
  113483. * @param rootUrl Defines the rootUrl to load from
  113484. */
  113485. parse(source: any, scene: Scene, rootUrl: string): void;
  113486. }
  113487. }
  113488. declare module BABYLON {
  113489. /**
  113490. * @hidden
  113491. */
  113492. export interface IMaterialAnisotropicDefines {
  113493. ANISOTROPIC: boolean;
  113494. ANISOTROPIC_TEXTURE: boolean;
  113495. ANISOTROPIC_TEXTUREDIRECTUV: number;
  113496. MAINUV1: boolean;
  113497. _areTexturesDirty: boolean;
  113498. _needUVs: boolean;
  113499. }
  113500. /**
  113501. * Define the code related to the anisotropic parameters of the pbr material.
  113502. */
  113503. export class PBRAnisotropicConfiguration {
  113504. private _isEnabled;
  113505. /**
  113506. * Defines if the anisotropy is enabled in the material.
  113507. */
  113508. isEnabled: boolean;
  113509. /**
  113510. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  113511. */
  113512. intensity: number;
  113513. /**
  113514. * Defines if the effect is along the tangents, bitangents or in between.
  113515. * By default, the effect is "strectching" the highlights along the tangents.
  113516. */
  113517. direction: Vector2;
  113518. private _texture;
  113519. /**
  113520. * Stores the anisotropy values in a texture.
  113521. * rg is direction (like normal from -1 to 1)
  113522. * b is a intensity
  113523. */
  113524. texture: Nullable<BaseTexture>;
  113525. /** @hidden */
  113526. private _internalMarkAllSubMeshesAsTexturesDirty;
  113527. /** @hidden */
  113528. _markAllSubMeshesAsTexturesDirty(): void;
  113529. /**
  113530. * Instantiate a new istance of anisotropy configuration.
  113531. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113532. */
  113533. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113534. /**
  113535. * Specifies that the submesh is ready to be used.
  113536. * @param defines the list of "defines" to update.
  113537. * @param scene defines the scene the material belongs to.
  113538. * @returns - boolean indicating that the submesh is ready or not.
  113539. */
  113540. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  113541. /**
  113542. * Checks to see if a texture is used in the material.
  113543. * @param defines the list of "defines" to update.
  113544. * @param mesh the mesh we are preparing the defines for.
  113545. * @param scene defines the scene the material belongs to.
  113546. */
  113547. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  113548. /**
  113549. * Binds the material data.
  113550. * @param uniformBuffer defines the Uniform buffer to fill in.
  113551. * @param scene defines the scene the material belongs to.
  113552. * @param isFrozen defines wether the material is frozen or not.
  113553. */
  113554. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113555. /**
  113556. * Checks to see if a texture is used in the material.
  113557. * @param texture - Base texture to use.
  113558. * @returns - Boolean specifying if a texture is used in the material.
  113559. */
  113560. hasTexture(texture: BaseTexture): boolean;
  113561. /**
  113562. * Returns an array of the actively used textures.
  113563. * @param activeTextures Array of BaseTextures
  113564. */
  113565. getActiveTextures(activeTextures: BaseTexture[]): void;
  113566. /**
  113567. * Returns the animatable textures.
  113568. * @param animatables Array of animatable textures.
  113569. */
  113570. getAnimatables(animatables: IAnimatable[]): void;
  113571. /**
  113572. * Disposes the resources of the material.
  113573. * @param forceDisposeTextures - Forces the disposal of all textures.
  113574. */
  113575. dispose(forceDisposeTextures?: boolean): void;
  113576. /**
  113577. * Get the current class name of the texture useful for serialization or dynamic coding.
  113578. * @returns "PBRAnisotropicConfiguration"
  113579. */
  113580. getClassName(): string;
  113581. /**
  113582. * Add fallbacks to the effect fallbacks list.
  113583. * @param defines defines the Base texture to use.
  113584. * @param fallbacks defines the current fallback list.
  113585. * @param currentRank defines the current fallback rank.
  113586. * @returns the new fallback rank.
  113587. */
  113588. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113589. /**
  113590. * Add the required uniforms to the current list.
  113591. * @param uniforms defines the current uniform list.
  113592. */
  113593. static AddUniforms(uniforms: string[]): void;
  113594. /**
  113595. * Add the required uniforms to the current buffer.
  113596. * @param uniformBuffer defines the current uniform buffer.
  113597. */
  113598. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113599. /**
  113600. * Add the required samplers to the current list.
  113601. * @param samplers defines the current sampler list.
  113602. */
  113603. static AddSamplers(samplers: string[]): void;
  113604. /**
  113605. * Makes a duplicate of the current configuration into another one.
  113606. * @param anisotropicConfiguration define the config where to copy the info
  113607. */
  113608. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  113609. /**
  113610. * Serializes this anisotropy configuration.
  113611. * @returns - An object with the serialized config.
  113612. */
  113613. serialize(): any;
  113614. /**
  113615. * Parses a anisotropy Configuration from a serialized object.
  113616. * @param source - Serialized object.
  113617. * @param scene Defines the scene we are parsing for
  113618. * @param rootUrl Defines the rootUrl to load from
  113619. */
  113620. parse(source: any, scene: Scene, rootUrl: string): void;
  113621. }
  113622. }
  113623. declare module BABYLON {
  113624. /**
  113625. * @hidden
  113626. */
  113627. export interface IMaterialBRDFDefines {
  113628. BRDF_V_HEIGHT_CORRELATED: boolean;
  113629. MS_BRDF_ENERGY_CONSERVATION: boolean;
  113630. SPHERICAL_HARMONICS: boolean;
  113631. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  113632. /** @hidden */
  113633. _areMiscDirty: boolean;
  113634. }
  113635. /**
  113636. * Define the code related to the BRDF parameters of the pbr material.
  113637. */
  113638. export class PBRBRDFConfiguration {
  113639. /**
  113640. * Default value used for the energy conservation.
  113641. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113642. */
  113643. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  113644. /**
  113645. * Default value used for the Smith Visibility Height Correlated mode.
  113646. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113647. */
  113648. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  113649. /**
  113650. * Default value used for the IBL diffuse part.
  113651. * This can help switching back to the polynomials mode globally which is a tiny bit
  113652. * less GPU intensive at the drawback of a lower quality.
  113653. */
  113654. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  113655. /**
  113656. * Default value used for activating energy conservation for the specular workflow.
  113657. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113658. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113659. */
  113660. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  113661. private _useEnergyConservation;
  113662. /**
  113663. * Defines if the material uses energy conservation.
  113664. */
  113665. useEnergyConservation: boolean;
  113666. private _useSmithVisibilityHeightCorrelated;
  113667. /**
  113668. * LEGACY Mode set to false
  113669. * Defines if the material uses height smith correlated visibility term.
  113670. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  113671. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  113672. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  113673. * Not relying on height correlated will also disable energy conservation.
  113674. */
  113675. useSmithVisibilityHeightCorrelated: boolean;
  113676. private _useSphericalHarmonics;
  113677. /**
  113678. * LEGACY Mode set to false
  113679. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  113680. * diffuse part of the IBL.
  113681. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  113682. * to the ground truth.
  113683. */
  113684. useSphericalHarmonics: boolean;
  113685. private _useSpecularGlossinessInputEnergyConservation;
  113686. /**
  113687. * Defines if the material uses energy conservation, when the specular workflow is active.
  113688. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113689. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113690. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  113691. */
  113692. useSpecularGlossinessInputEnergyConservation: boolean;
  113693. /** @hidden */
  113694. private _internalMarkAllSubMeshesAsMiscDirty;
  113695. /** @hidden */
  113696. _markAllSubMeshesAsMiscDirty(): void;
  113697. /**
  113698. * Instantiate a new istance of clear coat configuration.
  113699. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  113700. */
  113701. constructor(markAllSubMeshesAsMiscDirty: () => void);
  113702. /**
  113703. * Checks to see if a texture is used in the material.
  113704. * @param defines the list of "defines" to update.
  113705. */
  113706. prepareDefines(defines: IMaterialBRDFDefines): void;
  113707. /**
  113708. * Get the current class name of the texture useful for serialization or dynamic coding.
  113709. * @returns "PBRClearCoatConfiguration"
  113710. */
  113711. getClassName(): string;
  113712. /**
  113713. * Makes a duplicate of the current configuration into another one.
  113714. * @param brdfConfiguration define the config where to copy the info
  113715. */
  113716. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  113717. /**
  113718. * Serializes this BRDF configuration.
  113719. * @returns - An object with the serialized config.
  113720. */
  113721. serialize(): any;
  113722. /**
  113723. * Parses a anisotropy Configuration from a serialized object.
  113724. * @param source - Serialized object.
  113725. * @param scene Defines the scene we are parsing for
  113726. * @param rootUrl Defines the rootUrl to load from
  113727. */
  113728. parse(source: any, scene: Scene, rootUrl: string): void;
  113729. }
  113730. }
  113731. declare module BABYLON {
  113732. /**
  113733. * @hidden
  113734. */
  113735. export interface IMaterialSheenDefines {
  113736. SHEEN: boolean;
  113737. SHEEN_TEXTURE: boolean;
  113738. SHEEN_TEXTUREDIRECTUV: number;
  113739. SHEEN_LINKWITHALBEDO: boolean;
  113740. /** @hidden */
  113741. _areTexturesDirty: boolean;
  113742. }
  113743. /**
  113744. * Define the code related to the Sheen parameters of the pbr material.
  113745. */
  113746. export class PBRSheenConfiguration {
  113747. private _isEnabled;
  113748. /**
  113749. * Defines if the material uses sheen.
  113750. */
  113751. isEnabled: boolean;
  113752. private _linkSheenWithAlbedo;
  113753. /**
  113754. * Defines if the sheen is linked to the sheen color.
  113755. */
  113756. linkSheenWithAlbedo: boolean;
  113757. /**
  113758. * Defines the sheen intensity.
  113759. */
  113760. intensity: number;
  113761. /**
  113762. * Defines the sheen color.
  113763. */
  113764. color: Color3;
  113765. private _texture;
  113766. /**
  113767. * Stores the sheen tint values in a texture.
  113768. * rgb is tint
  113769. * a is a intensity
  113770. */
  113771. texture: Nullable<BaseTexture>;
  113772. /** @hidden */
  113773. private _internalMarkAllSubMeshesAsTexturesDirty;
  113774. /** @hidden */
  113775. _markAllSubMeshesAsTexturesDirty(): void;
  113776. /**
  113777. * Instantiate a new istance of clear coat configuration.
  113778. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113779. */
  113780. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113781. /**
  113782. * Specifies that the submesh is ready to be used.
  113783. * @param defines the list of "defines" to update.
  113784. * @param scene defines the scene the material belongs to.
  113785. * @returns - boolean indicating that the submesh is ready or not.
  113786. */
  113787. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  113788. /**
  113789. * Checks to see if a texture is used in the material.
  113790. * @param defines the list of "defines" to update.
  113791. * @param scene defines the scene the material belongs to.
  113792. */
  113793. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  113794. /**
  113795. * Binds the material data.
  113796. * @param uniformBuffer defines the Uniform buffer to fill in.
  113797. * @param scene defines the scene the material belongs to.
  113798. * @param isFrozen defines wether the material is frozen or not.
  113799. */
  113800. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113801. /**
  113802. * Checks to see if a texture is used in the material.
  113803. * @param texture - Base texture to use.
  113804. * @returns - Boolean specifying if a texture is used in the material.
  113805. */
  113806. hasTexture(texture: BaseTexture): boolean;
  113807. /**
  113808. * Returns an array of the actively used textures.
  113809. * @param activeTextures Array of BaseTextures
  113810. */
  113811. getActiveTextures(activeTextures: BaseTexture[]): void;
  113812. /**
  113813. * Returns the animatable textures.
  113814. * @param animatables Array of animatable textures.
  113815. */
  113816. getAnimatables(animatables: IAnimatable[]): void;
  113817. /**
  113818. * Disposes the resources of the material.
  113819. * @param forceDisposeTextures - Forces the disposal of all textures.
  113820. */
  113821. dispose(forceDisposeTextures?: boolean): void;
  113822. /**
  113823. * Get the current class name of the texture useful for serialization or dynamic coding.
  113824. * @returns "PBRSheenConfiguration"
  113825. */
  113826. getClassName(): string;
  113827. /**
  113828. * Add fallbacks to the effect fallbacks list.
  113829. * @param defines defines the Base texture to use.
  113830. * @param fallbacks defines the current fallback list.
  113831. * @param currentRank defines the current fallback rank.
  113832. * @returns the new fallback rank.
  113833. */
  113834. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113835. /**
  113836. * Add the required uniforms to the current list.
  113837. * @param uniforms defines the current uniform list.
  113838. */
  113839. static AddUniforms(uniforms: string[]): void;
  113840. /**
  113841. * Add the required uniforms to the current buffer.
  113842. * @param uniformBuffer defines the current uniform buffer.
  113843. */
  113844. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113845. /**
  113846. * Add the required samplers to the current list.
  113847. * @param samplers defines the current sampler list.
  113848. */
  113849. static AddSamplers(samplers: string[]): void;
  113850. /**
  113851. * Makes a duplicate of the current configuration into another one.
  113852. * @param sheenConfiguration define the config where to copy the info
  113853. */
  113854. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  113855. /**
  113856. * Serializes this BRDF configuration.
  113857. * @returns - An object with the serialized config.
  113858. */
  113859. serialize(): any;
  113860. /**
  113861. * Parses a anisotropy Configuration from a serialized object.
  113862. * @param source - Serialized object.
  113863. * @param scene Defines the scene we are parsing for
  113864. * @param rootUrl Defines the rootUrl to load from
  113865. */
  113866. parse(source: any, scene: Scene, rootUrl: string): void;
  113867. }
  113868. }
  113869. declare module BABYLON {
  113870. /**
  113871. * @hidden
  113872. */
  113873. export interface IMaterialSubSurfaceDefines {
  113874. SUBSURFACE: boolean;
  113875. SS_REFRACTION: boolean;
  113876. SS_TRANSLUCENCY: boolean;
  113877. SS_SCATERRING: boolean;
  113878. SS_THICKNESSANDMASK_TEXTURE: boolean;
  113879. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  113880. SS_REFRACTIONMAP_3D: boolean;
  113881. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  113882. SS_LODINREFRACTIONALPHA: boolean;
  113883. SS_GAMMAREFRACTION: boolean;
  113884. SS_RGBDREFRACTION: boolean;
  113885. SS_LINEARSPECULARREFRACTION: boolean;
  113886. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  113887. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  113888. /** @hidden */
  113889. _areTexturesDirty: boolean;
  113890. }
  113891. /**
  113892. * Define the code related to the sub surface parameters of the pbr material.
  113893. */
  113894. export class PBRSubSurfaceConfiguration {
  113895. private _isRefractionEnabled;
  113896. /**
  113897. * Defines if the refraction is enabled in the material.
  113898. */
  113899. isRefractionEnabled: boolean;
  113900. private _isTranslucencyEnabled;
  113901. /**
  113902. * Defines if the translucency is enabled in the material.
  113903. */
  113904. isTranslucencyEnabled: boolean;
  113905. private _isScatteringEnabled;
  113906. /**
  113907. * Defines the refraction intensity of the material.
  113908. * The refraction when enabled replaces the Diffuse part of the material.
  113909. * The intensity helps transitionning between diffuse and refraction.
  113910. */
  113911. refractionIntensity: number;
  113912. /**
  113913. * Defines the translucency intensity of the material.
  113914. * When translucency has been enabled, this defines how much of the "translucency"
  113915. * is addded to the diffuse part of the material.
  113916. */
  113917. translucencyIntensity: number;
  113918. /**
  113919. * Defines the scattering intensity of the material.
  113920. * When scattering has been enabled, this defines how much of the "scattered light"
  113921. * is addded to the diffuse part of the material.
  113922. */
  113923. scatteringIntensity: number;
  113924. private _thicknessTexture;
  113925. /**
  113926. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  113927. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  113928. * 0 would mean minimumThickness
  113929. * 1 would mean maximumThickness
  113930. * The other channels might be use as a mask to vary the different effects intensity.
  113931. */
  113932. thicknessTexture: Nullable<BaseTexture>;
  113933. private _refractionTexture;
  113934. /**
  113935. * Defines the texture to use for refraction.
  113936. */
  113937. refractionTexture: Nullable<BaseTexture>;
  113938. private _indexOfRefraction;
  113939. /**
  113940. * Defines the index of refraction used in the material.
  113941. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  113942. */
  113943. indexOfRefraction: number;
  113944. private _invertRefractionY;
  113945. /**
  113946. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113947. */
  113948. invertRefractionY: boolean;
  113949. private _linkRefractionWithTransparency;
  113950. /**
  113951. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113952. * Materials half opaque for instance using refraction could benefit from this control.
  113953. */
  113954. linkRefractionWithTransparency: boolean;
  113955. /**
  113956. * Defines the minimum thickness stored in the thickness map.
  113957. * If no thickness map is defined, this value will be used to simulate thickness.
  113958. */
  113959. minimumThickness: number;
  113960. /**
  113961. * Defines the maximum thickness stored in the thickness map.
  113962. */
  113963. maximumThickness: number;
  113964. /**
  113965. * Defines the volume tint of the material.
  113966. * This is used for both translucency and scattering.
  113967. */
  113968. tintColor: Color3;
  113969. /**
  113970. * Defines the distance at which the tint color should be found in the media.
  113971. * This is used for refraction only.
  113972. */
  113973. tintColorAtDistance: number;
  113974. /**
  113975. * Defines how far each channel transmit through the media.
  113976. * It is defined as a color to simplify it selection.
  113977. */
  113978. diffusionDistance: Color3;
  113979. private _useMaskFromThicknessTexture;
  113980. /**
  113981. * Stores the intensity of the different subsurface effects in the thickness texture.
  113982. * * the green channel is the translucency intensity.
  113983. * * the blue channel is the scattering intensity.
  113984. * * the alpha channel is the refraction intensity.
  113985. */
  113986. useMaskFromThicknessTexture: boolean;
  113987. /** @hidden */
  113988. private _internalMarkAllSubMeshesAsTexturesDirty;
  113989. /** @hidden */
  113990. _markAllSubMeshesAsTexturesDirty(): void;
  113991. /**
  113992. * Instantiate a new istance of sub surface configuration.
  113993. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113994. */
  113995. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113996. /**
  113997. * Gets wehter the submesh is ready to be used or not.
  113998. * @param defines the list of "defines" to update.
  113999. * @param scene defines the scene the material belongs to.
  114000. * @returns - boolean indicating that the submesh is ready or not.
  114001. */
  114002. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  114003. /**
  114004. * Checks to see if a texture is used in the material.
  114005. * @param defines the list of "defines" to update.
  114006. * @param scene defines the scene to the material belongs to.
  114007. */
  114008. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  114009. /**
  114010. * Binds the material data.
  114011. * @param uniformBuffer defines the Uniform buffer to fill in.
  114012. * @param scene defines the scene the material belongs to.
  114013. * @param engine defines the engine the material belongs to.
  114014. * @param isFrozen defines wether the material is frozen or not.
  114015. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  114016. */
  114017. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  114018. /**
  114019. * Unbinds the material from the mesh.
  114020. * @param activeEffect defines the effect that should be unbound from.
  114021. * @returns true if unbound, otherwise false
  114022. */
  114023. unbind(activeEffect: Effect): boolean;
  114024. /**
  114025. * Returns the texture used for refraction or null if none is used.
  114026. * @param scene defines the scene the material belongs to.
  114027. * @returns - Refraction texture if present. If no refraction texture and refraction
  114028. * is linked with transparency, returns environment texture. Otherwise, returns null.
  114029. */
  114030. private _getRefractionTexture;
  114031. /**
  114032. * Returns true if alpha blending should be disabled.
  114033. */
  114034. readonly disableAlphaBlending: boolean;
  114035. /**
  114036. * Fills the list of render target textures.
  114037. * @param renderTargets the list of render targets to update
  114038. */
  114039. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  114040. /**
  114041. * Checks to see if a texture is used in the material.
  114042. * @param texture - Base texture to use.
  114043. * @returns - Boolean specifying if a texture is used in the material.
  114044. */
  114045. hasTexture(texture: BaseTexture): boolean;
  114046. /**
  114047. * Gets a boolean indicating that current material needs to register RTT
  114048. * @returns true if this uses a render target otherwise false.
  114049. */
  114050. hasRenderTargetTextures(): boolean;
  114051. /**
  114052. * Returns an array of the actively used textures.
  114053. * @param activeTextures Array of BaseTextures
  114054. */
  114055. getActiveTextures(activeTextures: BaseTexture[]): void;
  114056. /**
  114057. * Returns the animatable textures.
  114058. * @param animatables Array of animatable textures.
  114059. */
  114060. getAnimatables(animatables: IAnimatable[]): void;
  114061. /**
  114062. * Disposes the resources of the material.
  114063. * @param forceDisposeTextures - Forces the disposal of all textures.
  114064. */
  114065. dispose(forceDisposeTextures?: boolean): void;
  114066. /**
  114067. * Get the current class name of the texture useful for serialization or dynamic coding.
  114068. * @returns "PBRSubSurfaceConfiguration"
  114069. */
  114070. getClassName(): string;
  114071. /**
  114072. * Add fallbacks to the effect fallbacks list.
  114073. * @param defines defines the Base texture to use.
  114074. * @param fallbacks defines the current fallback list.
  114075. * @param currentRank defines the current fallback rank.
  114076. * @returns the new fallback rank.
  114077. */
  114078. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114079. /**
  114080. * Add the required uniforms to the current list.
  114081. * @param uniforms defines the current uniform list.
  114082. */
  114083. static AddUniforms(uniforms: string[]): void;
  114084. /**
  114085. * Add the required samplers to the current list.
  114086. * @param samplers defines the current sampler list.
  114087. */
  114088. static AddSamplers(samplers: string[]): void;
  114089. /**
  114090. * Add the required uniforms to the current buffer.
  114091. * @param uniformBuffer defines the current uniform buffer.
  114092. */
  114093. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114094. /**
  114095. * Makes a duplicate of the current configuration into another one.
  114096. * @param configuration define the config where to copy the info
  114097. */
  114098. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  114099. /**
  114100. * Serializes this Sub Surface configuration.
  114101. * @returns - An object with the serialized config.
  114102. */
  114103. serialize(): any;
  114104. /**
  114105. * Parses a anisotropy Configuration from a serialized object.
  114106. * @param source - Serialized object.
  114107. * @param scene Defines the scene we are parsing for
  114108. * @param rootUrl Defines the rootUrl to load from
  114109. */
  114110. parse(source: any, scene: Scene, rootUrl: string): void;
  114111. }
  114112. }
  114113. declare module BABYLON {
  114114. /** @hidden */
  114115. export var pbrFragmentDeclaration: {
  114116. name: string;
  114117. shader: string;
  114118. };
  114119. }
  114120. declare module BABYLON {
  114121. /** @hidden */
  114122. export var pbrUboDeclaration: {
  114123. name: string;
  114124. shader: string;
  114125. };
  114126. }
  114127. declare module BABYLON {
  114128. /** @hidden */
  114129. export var pbrFragmentExtraDeclaration: {
  114130. name: string;
  114131. shader: string;
  114132. };
  114133. }
  114134. declare module BABYLON {
  114135. /** @hidden */
  114136. export var pbrFragmentSamplersDeclaration: {
  114137. name: string;
  114138. shader: string;
  114139. };
  114140. }
  114141. declare module BABYLON {
  114142. /** @hidden */
  114143. export var pbrHelperFunctions: {
  114144. name: string;
  114145. shader: string;
  114146. };
  114147. }
  114148. declare module BABYLON {
  114149. /** @hidden */
  114150. export var harmonicsFunctions: {
  114151. name: string;
  114152. shader: string;
  114153. };
  114154. }
  114155. declare module BABYLON {
  114156. /** @hidden */
  114157. export var pbrDirectLightingSetupFunctions: {
  114158. name: string;
  114159. shader: string;
  114160. };
  114161. }
  114162. declare module BABYLON {
  114163. /** @hidden */
  114164. export var pbrDirectLightingFalloffFunctions: {
  114165. name: string;
  114166. shader: string;
  114167. };
  114168. }
  114169. declare module BABYLON {
  114170. /** @hidden */
  114171. export var pbrBRDFFunctions: {
  114172. name: string;
  114173. shader: string;
  114174. };
  114175. }
  114176. declare module BABYLON {
  114177. /** @hidden */
  114178. export var pbrDirectLightingFunctions: {
  114179. name: string;
  114180. shader: string;
  114181. };
  114182. }
  114183. declare module BABYLON {
  114184. /** @hidden */
  114185. export var pbrIBLFunctions: {
  114186. name: string;
  114187. shader: string;
  114188. };
  114189. }
  114190. declare module BABYLON {
  114191. /** @hidden */
  114192. export var pbrDebug: {
  114193. name: string;
  114194. shader: string;
  114195. };
  114196. }
  114197. declare module BABYLON {
  114198. /** @hidden */
  114199. export var pbrPixelShader: {
  114200. name: string;
  114201. shader: string;
  114202. };
  114203. }
  114204. declare module BABYLON {
  114205. /** @hidden */
  114206. export var pbrVertexDeclaration: {
  114207. name: string;
  114208. shader: string;
  114209. };
  114210. }
  114211. declare module BABYLON {
  114212. /** @hidden */
  114213. export var pbrVertexShader: {
  114214. name: string;
  114215. shader: string;
  114216. };
  114217. }
  114218. declare module BABYLON {
  114219. /**
  114220. * Manages the defines for the PBR Material.
  114221. * @hidden
  114222. */
  114223. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  114224. PBR: boolean;
  114225. MAINUV1: boolean;
  114226. MAINUV2: boolean;
  114227. UV1: boolean;
  114228. UV2: boolean;
  114229. ALBEDO: boolean;
  114230. ALBEDODIRECTUV: number;
  114231. VERTEXCOLOR: boolean;
  114232. AMBIENT: boolean;
  114233. AMBIENTDIRECTUV: number;
  114234. AMBIENTINGRAYSCALE: boolean;
  114235. OPACITY: boolean;
  114236. VERTEXALPHA: boolean;
  114237. OPACITYDIRECTUV: number;
  114238. OPACITYRGB: boolean;
  114239. ALPHATEST: boolean;
  114240. DEPTHPREPASS: boolean;
  114241. ALPHABLEND: boolean;
  114242. ALPHAFROMALBEDO: boolean;
  114243. ALPHATESTVALUE: string;
  114244. SPECULAROVERALPHA: boolean;
  114245. RADIANCEOVERALPHA: boolean;
  114246. ALPHAFRESNEL: boolean;
  114247. LINEARALPHAFRESNEL: boolean;
  114248. PREMULTIPLYALPHA: boolean;
  114249. EMISSIVE: boolean;
  114250. EMISSIVEDIRECTUV: number;
  114251. REFLECTIVITY: boolean;
  114252. REFLECTIVITYDIRECTUV: number;
  114253. SPECULARTERM: boolean;
  114254. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  114255. MICROSURFACEAUTOMATIC: boolean;
  114256. LODBASEDMICROSFURACE: boolean;
  114257. MICROSURFACEMAP: boolean;
  114258. MICROSURFACEMAPDIRECTUV: number;
  114259. METALLICWORKFLOW: boolean;
  114260. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  114261. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  114262. METALLNESSSTOREINMETALMAPBLUE: boolean;
  114263. AOSTOREINMETALMAPRED: boolean;
  114264. ENVIRONMENTBRDF: boolean;
  114265. ENVIRONMENTBRDF_RGBD: boolean;
  114266. NORMAL: boolean;
  114267. TANGENT: boolean;
  114268. BUMP: boolean;
  114269. BUMPDIRECTUV: number;
  114270. OBJECTSPACE_NORMALMAP: boolean;
  114271. PARALLAX: boolean;
  114272. PARALLAXOCCLUSION: boolean;
  114273. NORMALXYSCALE: boolean;
  114274. LIGHTMAP: boolean;
  114275. LIGHTMAPDIRECTUV: number;
  114276. USELIGHTMAPASSHADOWMAP: boolean;
  114277. GAMMALIGHTMAP: boolean;
  114278. RGBDLIGHTMAP: boolean;
  114279. REFLECTION: boolean;
  114280. REFLECTIONMAP_3D: boolean;
  114281. REFLECTIONMAP_SPHERICAL: boolean;
  114282. REFLECTIONMAP_PLANAR: boolean;
  114283. REFLECTIONMAP_CUBIC: boolean;
  114284. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  114285. REFLECTIONMAP_PROJECTION: boolean;
  114286. REFLECTIONMAP_SKYBOX: boolean;
  114287. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  114288. REFLECTIONMAP_EXPLICIT: boolean;
  114289. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  114290. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  114291. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  114292. INVERTCUBICMAP: boolean;
  114293. USESPHERICALFROMREFLECTIONMAP: boolean;
  114294. USEIRRADIANCEMAP: boolean;
  114295. SPHERICAL_HARMONICS: boolean;
  114296. USESPHERICALINVERTEX: boolean;
  114297. REFLECTIONMAP_OPPOSITEZ: boolean;
  114298. LODINREFLECTIONALPHA: boolean;
  114299. GAMMAREFLECTION: boolean;
  114300. RGBDREFLECTION: boolean;
  114301. LINEARSPECULARREFLECTION: boolean;
  114302. RADIANCEOCCLUSION: boolean;
  114303. HORIZONOCCLUSION: boolean;
  114304. INSTANCES: boolean;
  114305. NUM_BONE_INFLUENCERS: number;
  114306. BonesPerMesh: number;
  114307. BONETEXTURE: boolean;
  114308. NONUNIFORMSCALING: boolean;
  114309. MORPHTARGETS: boolean;
  114310. MORPHTARGETS_NORMAL: boolean;
  114311. MORPHTARGETS_TANGENT: boolean;
  114312. MORPHTARGETS_UV: boolean;
  114313. NUM_MORPH_INFLUENCERS: number;
  114314. IMAGEPROCESSING: boolean;
  114315. VIGNETTE: boolean;
  114316. VIGNETTEBLENDMODEMULTIPLY: boolean;
  114317. VIGNETTEBLENDMODEOPAQUE: boolean;
  114318. TONEMAPPING: boolean;
  114319. TONEMAPPING_ACES: boolean;
  114320. CONTRAST: boolean;
  114321. COLORCURVES: boolean;
  114322. COLORGRADING: boolean;
  114323. COLORGRADING3D: boolean;
  114324. SAMPLER3DGREENDEPTH: boolean;
  114325. SAMPLER3DBGRMAP: boolean;
  114326. IMAGEPROCESSINGPOSTPROCESS: boolean;
  114327. EXPOSURE: boolean;
  114328. MULTIVIEW: boolean;
  114329. USEPHYSICALLIGHTFALLOFF: boolean;
  114330. USEGLTFLIGHTFALLOFF: boolean;
  114331. TWOSIDEDLIGHTING: boolean;
  114332. SHADOWFLOAT: boolean;
  114333. CLIPPLANE: boolean;
  114334. CLIPPLANE2: boolean;
  114335. CLIPPLANE3: boolean;
  114336. CLIPPLANE4: boolean;
  114337. POINTSIZE: boolean;
  114338. FOG: boolean;
  114339. LOGARITHMICDEPTH: boolean;
  114340. FORCENORMALFORWARD: boolean;
  114341. SPECULARAA: boolean;
  114342. CLEARCOAT: boolean;
  114343. CLEARCOAT_DEFAULTIOR: boolean;
  114344. CLEARCOAT_TEXTURE: boolean;
  114345. CLEARCOAT_TEXTUREDIRECTUV: number;
  114346. CLEARCOAT_BUMP: boolean;
  114347. CLEARCOAT_BUMPDIRECTUV: number;
  114348. CLEARCOAT_TINT: boolean;
  114349. CLEARCOAT_TINT_TEXTURE: boolean;
  114350. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114351. ANISOTROPIC: boolean;
  114352. ANISOTROPIC_TEXTURE: boolean;
  114353. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114354. BRDF_V_HEIGHT_CORRELATED: boolean;
  114355. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114356. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114357. SHEEN: boolean;
  114358. SHEEN_TEXTURE: boolean;
  114359. SHEEN_TEXTUREDIRECTUV: number;
  114360. SHEEN_LINKWITHALBEDO: boolean;
  114361. SUBSURFACE: boolean;
  114362. SS_REFRACTION: boolean;
  114363. SS_TRANSLUCENCY: boolean;
  114364. SS_SCATERRING: boolean;
  114365. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114366. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114367. SS_REFRACTIONMAP_3D: boolean;
  114368. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114369. SS_LODINREFRACTIONALPHA: boolean;
  114370. SS_GAMMAREFRACTION: boolean;
  114371. SS_RGBDREFRACTION: boolean;
  114372. SS_LINEARSPECULARREFRACTION: boolean;
  114373. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114374. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114375. UNLIT: boolean;
  114376. DEBUGMODE: number;
  114377. /**
  114378. * Initializes the PBR Material defines.
  114379. */
  114380. constructor();
  114381. /**
  114382. * Resets the PBR Material defines.
  114383. */
  114384. reset(): void;
  114385. }
  114386. /**
  114387. * The Physically based material base class of BJS.
  114388. *
  114389. * This offers the main features of a standard PBR material.
  114390. * For more information, please refer to the documentation :
  114391. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114392. */
  114393. export abstract class PBRBaseMaterial extends PushMaterial {
  114394. /**
  114395. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114396. */
  114397. static readonly PBRMATERIAL_OPAQUE: number;
  114398. /**
  114399. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114400. */
  114401. static readonly PBRMATERIAL_ALPHATEST: number;
  114402. /**
  114403. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114404. */
  114405. static readonly PBRMATERIAL_ALPHABLEND: number;
  114406. /**
  114407. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114408. * They are also discarded below the alpha cutoff threshold to improve performances.
  114409. */
  114410. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114411. /**
  114412. * Defines the default value of how much AO map is occluding the analytical lights
  114413. * (point spot...).
  114414. */
  114415. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114416. /**
  114417. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  114418. */
  114419. static readonly LIGHTFALLOFF_PHYSICAL: number;
  114420. /**
  114421. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  114422. * to enhance interoperability with other engines.
  114423. */
  114424. static readonly LIGHTFALLOFF_GLTF: number;
  114425. /**
  114426. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  114427. * to enhance interoperability with other materials.
  114428. */
  114429. static readonly LIGHTFALLOFF_STANDARD: number;
  114430. /**
  114431. * Intensity of the direct lights e.g. the four lights available in your scene.
  114432. * This impacts both the direct diffuse and specular highlights.
  114433. */
  114434. protected _directIntensity: number;
  114435. /**
  114436. * Intensity of the emissive part of the material.
  114437. * This helps controlling the emissive effect without modifying the emissive color.
  114438. */
  114439. protected _emissiveIntensity: number;
  114440. /**
  114441. * Intensity of the environment e.g. how much the environment will light the object
  114442. * either through harmonics for rough material or through the refelction for shiny ones.
  114443. */
  114444. protected _environmentIntensity: number;
  114445. /**
  114446. * This is a special control allowing the reduction of the specular highlights coming from the
  114447. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114448. */
  114449. protected _specularIntensity: number;
  114450. /**
  114451. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  114452. */
  114453. private _lightingInfos;
  114454. /**
  114455. * Debug Control allowing disabling the bump map on this material.
  114456. */
  114457. protected _disableBumpMap: boolean;
  114458. /**
  114459. * AKA Diffuse Texture in standard nomenclature.
  114460. */
  114461. protected _albedoTexture: Nullable<BaseTexture>;
  114462. /**
  114463. * AKA Occlusion Texture in other nomenclature.
  114464. */
  114465. protected _ambientTexture: Nullable<BaseTexture>;
  114466. /**
  114467. * AKA Occlusion Texture Intensity in other nomenclature.
  114468. */
  114469. protected _ambientTextureStrength: number;
  114470. /**
  114471. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114472. * 1 means it completely occludes it
  114473. * 0 mean it has no impact
  114474. */
  114475. protected _ambientTextureImpactOnAnalyticalLights: number;
  114476. /**
  114477. * Stores the alpha values in a texture.
  114478. */
  114479. protected _opacityTexture: Nullable<BaseTexture>;
  114480. /**
  114481. * Stores the reflection values in a texture.
  114482. */
  114483. protected _reflectionTexture: Nullable<BaseTexture>;
  114484. /**
  114485. * Stores the emissive values in a texture.
  114486. */
  114487. protected _emissiveTexture: Nullable<BaseTexture>;
  114488. /**
  114489. * AKA Specular texture in other nomenclature.
  114490. */
  114491. protected _reflectivityTexture: Nullable<BaseTexture>;
  114492. /**
  114493. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114494. */
  114495. protected _metallicTexture: Nullable<BaseTexture>;
  114496. /**
  114497. * Specifies the metallic scalar of the metallic/roughness workflow.
  114498. * Can also be used to scale the metalness values of the metallic texture.
  114499. */
  114500. protected _metallic: Nullable<number>;
  114501. /**
  114502. * Specifies the roughness scalar of the metallic/roughness workflow.
  114503. * Can also be used to scale the roughness values of the metallic texture.
  114504. */
  114505. protected _roughness: Nullable<number>;
  114506. /**
  114507. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114508. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114509. */
  114510. protected _microSurfaceTexture: Nullable<BaseTexture>;
  114511. /**
  114512. * Stores surface normal data used to displace a mesh in a texture.
  114513. */
  114514. protected _bumpTexture: Nullable<BaseTexture>;
  114515. /**
  114516. * Stores the pre-calculated light information of a mesh in a texture.
  114517. */
  114518. protected _lightmapTexture: Nullable<BaseTexture>;
  114519. /**
  114520. * The color of a material in ambient lighting.
  114521. */
  114522. protected _ambientColor: Color3;
  114523. /**
  114524. * AKA Diffuse Color in other nomenclature.
  114525. */
  114526. protected _albedoColor: Color3;
  114527. /**
  114528. * AKA Specular Color in other nomenclature.
  114529. */
  114530. protected _reflectivityColor: Color3;
  114531. /**
  114532. * The color applied when light is reflected from a material.
  114533. */
  114534. protected _reflectionColor: Color3;
  114535. /**
  114536. * The color applied when light is emitted from a material.
  114537. */
  114538. protected _emissiveColor: Color3;
  114539. /**
  114540. * AKA Glossiness in other nomenclature.
  114541. */
  114542. protected _microSurface: number;
  114543. /**
  114544. * Specifies that the material will use the light map as a show map.
  114545. */
  114546. protected _useLightmapAsShadowmap: boolean;
  114547. /**
  114548. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  114549. * makes the reflect vector face the model (under horizon).
  114550. */
  114551. protected _useHorizonOcclusion: boolean;
  114552. /**
  114553. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  114554. * too much the area relying on ambient texture to define their ambient occlusion.
  114555. */
  114556. protected _useRadianceOcclusion: boolean;
  114557. /**
  114558. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114559. */
  114560. protected _useAlphaFromAlbedoTexture: boolean;
  114561. /**
  114562. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  114563. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114564. */
  114565. protected _useSpecularOverAlpha: boolean;
  114566. /**
  114567. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114568. */
  114569. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114570. /**
  114571. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114572. */
  114573. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  114574. /**
  114575. * Specifies if the metallic texture contains the roughness information in its green channel.
  114576. */
  114577. protected _useRoughnessFromMetallicTextureGreen: boolean;
  114578. /**
  114579. * Specifies if the metallic texture contains the metallness information in its blue channel.
  114580. */
  114581. protected _useMetallnessFromMetallicTextureBlue: boolean;
  114582. /**
  114583. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  114584. */
  114585. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  114586. /**
  114587. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  114588. */
  114589. protected _useAmbientInGrayScale: boolean;
  114590. /**
  114591. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  114592. * The material will try to infer what glossiness each pixel should be.
  114593. */
  114594. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  114595. /**
  114596. * Defines the falloff type used in this material.
  114597. * It by default is Physical.
  114598. */
  114599. protected _lightFalloff: number;
  114600. /**
  114601. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  114602. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  114603. */
  114604. protected _useRadianceOverAlpha: boolean;
  114605. /**
  114606. * Allows using an object space normal map (instead of tangent space).
  114607. */
  114608. protected _useObjectSpaceNormalMap: boolean;
  114609. /**
  114610. * Allows using the bump map in parallax mode.
  114611. */
  114612. protected _useParallax: boolean;
  114613. /**
  114614. * Allows using the bump map in parallax occlusion mode.
  114615. */
  114616. protected _useParallaxOcclusion: boolean;
  114617. /**
  114618. * Controls the scale bias of the parallax mode.
  114619. */
  114620. protected _parallaxScaleBias: number;
  114621. /**
  114622. * If sets to true, disables all the lights affecting the material.
  114623. */
  114624. protected _disableLighting: boolean;
  114625. /**
  114626. * Number of Simultaneous lights allowed on the material.
  114627. */
  114628. protected _maxSimultaneousLights: number;
  114629. /**
  114630. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114631. */
  114632. protected _invertNormalMapX: boolean;
  114633. /**
  114634. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114635. */
  114636. protected _invertNormalMapY: boolean;
  114637. /**
  114638. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114639. */
  114640. protected _twoSidedLighting: boolean;
  114641. /**
  114642. * Defines the alpha limits in alpha test mode.
  114643. */
  114644. protected _alphaCutOff: number;
  114645. /**
  114646. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114647. */
  114648. protected _forceAlphaTest: boolean;
  114649. /**
  114650. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114651. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  114652. */
  114653. protected _useAlphaFresnel: boolean;
  114654. /**
  114655. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114656. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  114657. */
  114658. protected _useLinearAlphaFresnel: boolean;
  114659. /**
  114660. * The transparency mode of the material.
  114661. */
  114662. protected _transparencyMode: Nullable<number>;
  114663. /**
  114664. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  114665. * from cos thetav and roughness:
  114666. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  114667. */
  114668. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  114669. /**
  114670. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  114671. */
  114672. protected _forceIrradianceInFragment: boolean;
  114673. /**
  114674. * Force normal to face away from face.
  114675. */
  114676. protected _forceNormalForward: boolean;
  114677. /**
  114678. * Enables specular anti aliasing in the PBR shader.
  114679. * It will both interacts on the Geometry for analytical and IBL lighting.
  114680. * It also prefilter the roughness map based on the bump values.
  114681. */
  114682. protected _enableSpecularAntiAliasing: boolean;
  114683. /**
  114684. * Default configuration related to image processing available in the PBR Material.
  114685. */
  114686. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114687. /**
  114688. * Keep track of the image processing observer to allow dispose and replace.
  114689. */
  114690. private _imageProcessingObserver;
  114691. /**
  114692. * Attaches a new image processing configuration to the PBR Material.
  114693. * @param configuration
  114694. */
  114695. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114696. /**
  114697. * Stores the available render targets.
  114698. */
  114699. private _renderTargets;
  114700. /**
  114701. * Sets the global ambient color for the material used in lighting calculations.
  114702. */
  114703. private _globalAmbientColor;
  114704. /**
  114705. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  114706. */
  114707. private _useLogarithmicDepth;
  114708. /**
  114709. * If set to true, no lighting calculations will be applied.
  114710. */
  114711. private _unlit;
  114712. private _debugMode;
  114713. /**
  114714. * @hidden
  114715. * This is reserved for the inspector.
  114716. * Defines the material debug mode.
  114717. * It helps seeing only some components of the material while troubleshooting.
  114718. */
  114719. debugMode: number;
  114720. /**
  114721. * @hidden
  114722. * This is reserved for the inspector.
  114723. * Specify from where on screen the debug mode should start.
  114724. * The value goes from -1 (full screen) to 1 (not visible)
  114725. * It helps with side by side comparison against the final render
  114726. * This defaults to -1
  114727. */
  114728. private debugLimit;
  114729. /**
  114730. * @hidden
  114731. * This is reserved for the inspector.
  114732. * As the default viewing range might not be enough (if the ambient is really small for instance)
  114733. * You can use the factor to better multiply the final value.
  114734. */
  114735. private debugFactor;
  114736. /**
  114737. * Defines the clear coat layer parameters for the material.
  114738. */
  114739. readonly clearCoat: PBRClearCoatConfiguration;
  114740. /**
  114741. * Defines the anisotropic parameters for the material.
  114742. */
  114743. readonly anisotropy: PBRAnisotropicConfiguration;
  114744. /**
  114745. * Defines the BRDF parameters for the material.
  114746. */
  114747. readonly brdf: PBRBRDFConfiguration;
  114748. /**
  114749. * Defines the Sheen parameters for the material.
  114750. */
  114751. readonly sheen: PBRSheenConfiguration;
  114752. /**
  114753. * Defines the SubSurface parameters for the material.
  114754. */
  114755. readonly subSurface: PBRSubSurfaceConfiguration;
  114756. /**
  114757. * Custom callback helping to override the default shader used in the material.
  114758. */
  114759. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  114760. protected _rebuildInParallel: boolean;
  114761. /**
  114762. * Instantiates a new PBRMaterial instance.
  114763. *
  114764. * @param name The material name
  114765. * @param scene The scene the material will be use in.
  114766. */
  114767. constructor(name: string, scene: Scene);
  114768. /**
  114769. * Gets a boolean indicating that current material needs to register RTT
  114770. */
  114771. readonly hasRenderTargetTextures: boolean;
  114772. /**
  114773. * Gets the name of the material class.
  114774. */
  114775. getClassName(): string;
  114776. /**
  114777. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114778. */
  114779. /**
  114780. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114781. */
  114782. useLogarithmicDepth: boolean;
  114783. /**
  114784. * Gets the current transparency mode.
  114785. */
  114786. /**
  114787. * Sets the transparency mode of the material.
  114788. *
  114789. * | Value | Type | Description |
  114790. * | ----- | ----------------------------------- | ----------- |
  114791. * | 0 | OPAQUE | |
  114792. * | 1 | ALPHATEST | |
  114793. * | 2 | ALPHABLEND | |
  114794. * | 3 | ALPHATESTANDBLEND | |
  114795. *
  114796. */
  114797. transparencyMode: Nullable<number>;
  114798. /**
  114799. * Returns true if alpha blending should be disabled.
  114800. */
  114801. private readonly _disableAlphaBlending;
  114802. /**
  114803. * Specifies whether or not this material should be rendered in alpha blend mode.
  114804. */
  114805. needAlphaBlending(): boolean;
  114806. /**
  114807. * Specifies if the mesh will require alpha blending.
  114808. * @param mesh - BJS mesh.
  114809. */
  114810. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  114811. /**
  114812. * Specifies whether or not this material should be rendered in alpha test mode.
  114813. */
  114814. needAlphaTesting(): boolean;
  114815. /**
  114816. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  114817. */
  114818. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  114819. /**
  114820. * Gets the texture used for the alpha test.
  114821. */
  114822. getAlphaTestTexture(): Nullable<BaseTexture>;
  114823. /**
  114824. * Specifies that the submesh is ready to be used.
  114825. * @param mesh - BJS mesh.
  114826. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  114827. * @param useInstances - Specifies that instances should be used.
  114828. * @returns - boolean indicating that the submesh is ready or not.
  114829. */
  114830. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114831. /**
  114832. * Specifies if the material uses metallic roughness workflow.
  114833. * @returns boolean specifiying if the material uses metallic roughness workflow.
  114834. */
  114835. isMetallicWorkflow(): boolean;
  114836. private _prepareEffect;
  114837. private _prepareDefines;
  114838. /**
  114839. * Force shader compilation
  114840. */
  114841. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  114842. clipPlane: boolean;
  114843. }>): void;
  114844. /**
  114845. * Initializes the uniform buffer layout for the shader.
  114846. */
  114847. buildUniformLayout(): void;
  114848. /**
  114849. * Unbinds the material from the mesh
  114850. */
  114851. unbind(): void;
  114852. /**
  114853. * Binds the submesh data.
  114854. * @param world - The world matrix.
  114855. * @param mesh - The BJS mesh.
  114856. * @param subMesh - A submesh of the BJS mesh.
  114857. */
  114858. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114859. /**
  114860. * Returns the animatable textures.
  114861. * @returns - Array of animatable textures.
  114862. */
  114863. getAnimatables(): IAnimatable[];
  114864. /**
  114865. * Returns the texture used for reflections.
  114866. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  114867. */
  114868. private _getReflectionTexture;
  114869. /**
  114870. * Returns an array of the actively used textures.
  114871. * @returns - Array of BaseTextures
  114872. */
  114873. getActiveTextures(): BaseTexture[];
  114874. /**
  114875. * Checks to see if a texture is used in the material.
  114876. * @param texture - Base texture to use.
  114877. * @returns - Boolean specifying if a texture is used in the material.
  114878. */
  114879. hasTexture(texture: BaseTexture): boolean;
  114880. /**
  114881. * Disposes the resources of the material.
  114882. * @param forceDisposeEffect - Forces the disposal of effects.
  114883. * @param forceDisposeTextures - Forces the disposal of all textures.
  114884. */
  114885. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114886. }
  114887. }
  114888. declare module BABYLON {
  114889. /**
  114890. * The Physically based material of BJS.
  114891. *
  114892. * This offers the main features of a standard PBR material.
  114893. * For more information, please refer to the documentation :
  114894. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114895. */
  114896. export class PBRMaterial extends PBRBaseMaterial {
  114897. /**
  114898. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114899. */
  114900. static readonly PBRMATERIAL_OPAQUE: number;
  114901. /**
  114902. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114903. */
  114904. static readonly PBRMATERIAL_ALPHATEST: number;
  114905. /**
  114906. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114907. */
  114908. static readonly PBRMATERIAL_ALPHABLEND: number;
  114909. /**
  114910. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114911. * They are also discarded below the alpha cutoff threshold to improve performances.
  114912. */
  114913. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114914. /**
  114915. * Defines the default value of how much AO map is occluding the analytical lights
  114916. * (point spot...).
  114917. */
  114918. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114919. /**
  114920. * Intensity of the direct lights e.g. the four lights available in your scene.
  114921. * This impacts both the direct diffuse and specular highlights.
  114922. */
  114923. directIntensity: number;
  114924. /**
  114925. * Intensity of the emissive part of the material.
  114926. * This helps controlling the emissive effect without modifying the emissive color.
  114927. */
  114928. emissiveIntensity: number;
  114929. /**
  114930. * Intensity of the environment e.g. how much the environment will light the object
  114931. * either through harmonics for rough material or through the refelction for shiny ones.
  114932. */
  114933. environmentIntensity: number;
  114934. /**
  114935. * This is a special control allowing the reduction of the specular highlights coming from the
  114936. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114937. */
  114938. specularIntensity: number;
  114939. /**
  114940. * Debug Control allowing disabling the bump map on this material.
  114941. */
  114942. disableBumpMap: boolean;
  114943. /**
  114944. * AKA Diffuse Texture in standard nomenclature.
  114945. */
  114946. albedoTexture: BaseTexture;
  114947. /**
  114948. * AKA Occlusion Texture in other nomenclature.
  114949. */
  114950. ambientTexture: BaseTexture;
  114951. /**
  114952. * AKA Occlusion Texture Intensity in other nomenclature.
  114953. */
  114954. ambientTextureStrength: number;
  114955. /**
  114956. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114957. * 1 means it completely occludes it
  114958. * 0 mean it has no impact
  114959. */
  114960. ambientTextureImpactOnAnalyticalLights: number;
  114961. /**
  114962. * Stores the alpha values in a texture.
  114963. */
  114964. opacityTexture: BaseTexture;
  114965. /**
  114966. * Stores the reflection values in a texture.
  114967. */
  114968. reflectionTexture: Nullable<BaseTexture>;
  114969. /**
  114970. * Stores the emissive values in a texture.
  114971. */
  114972. emissiveTexture: BaseTexture;
  114973. /**
  114974. * AKA Specular texture in other nomenclature.
  114975. */
  114976. reflectivityTexture: BaseTexture;
  114977. /**
  114978. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114979. */
  114980. metallicTexture: BaseTexture;
  114981. /**
  114982. * Specifies the metallic scalar of the metallic/roughness workflow.
  114983. * Can also be used to scale the metalness values of the metallic texture.
  114984. */
  114985. metallic: Nullable<number>;
  114986. /**
  114987. * Specifies the roughness scalar of the metallic/roughness workflow.
  114988. * Can also be used to scale the roughness values of the metallic texture.
  114989. */
  114990. roughness: Nullable<number>;
  114991. /**
  114992. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114993. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114994. */
  114995. microSurfaceTexture: BaseTexture;
  114996. /**
  114997. * Stores surface normal data used to displace a mesh in a texture.
  114998. */
  114999. bumpTexture: BaseTexture;
  115000. /**
  115001. * Stores the pre-calculated light information of a mesh in a texture.
  115002. */
  115003. lightmapTexture: BaseTexture;
  115004. /**
  115005. * Stores the refracted light information in a texture.
  115006. */
  115007. refractionTexture: Nullable<BaseTexture>;
  115008. /**
  115009. * The color of a material in ambient lighting.
  115010. */
  115011. ambientColor: Color3;
  115012. /**
  115013. * AKA Diffuse Color in other nomenclature.
  115014. */
  115015. albedoColor: Color3;
  115016. /**
  115017. * AKA Specular Color in other nomenclature.
  115018. */
  115019. reflectivityColor: Color3;
  115020. /**
  115021. * The color reflected from the material.
  115022. */
  115023. reflectionColor: Color3;
  115024. /**
  115025. * The color emitted from the material.
  115026. */
  115027. emissiveColor: Color3;
  115028. /**
  115029. * AKA Glossiness in other nomenclature.
  115030. */
  115031. microSurface: number;
  115032. /**
  115033. * source material index of refraction (IOR)' / 'destination material IOR.
  115034. */
  115035. indexOfRefraction: number;
  115036. /**
  115037. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  115038. */
  115039. invertRefractionY: boolean;
  115040. /**
  115041. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  115042. * Materials half opaque for instance using refraction could benefit from this control.
  115043. */
  115044. linkRefractionWithTransparency: boolean;
  115045. /**
  115046. * If true, the light map contains occlusion information instead of lighting info.
  115047. */
  115048. useLightmapAsShadowmap: boolean;
  115049. /**
  115050. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  115051. */
  115052. useAlphaFromAlbedoTexture: boolean;
  115053. /**
  115054. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115055. */
  115056. forceAlphaTest: boolean;
  115057. /**
  115058. * Defines the alpha limits in alpha test mode.
  115059. */
  115060. alphaCutOff: number;
  115061. /**
  115062. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  115063. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  115064. */
  115065. useSpecularOverAlpha: boolean;
  115066. /**
  115067. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  115068. */
  115069. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  115070. /**
  115071. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115072. */
  115073. useRoughnessFromMetallicTextureAlpha: boolean;
  115074. /**
  115075. * Specifies if the metallic texture contains the roughness information in its green channel.
  115076. */
  115077. useRoughnessFromMetallicTextureGreen: boolean;
  115078. /**
  115079. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115080. */
  115081. useMetallnessFromMetallicTextureBlue: boolean;
  115082. /**
  115083. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115084. */
  115085. useAmbientOcclusionFromMetallicTextureRed: boolean;
  115086. /**
  115087. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115088. */
  115089. useAmbientInGrayScale: boolean;
  115090. /**
  115091. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115092. * The material will try to infer what glossiness each pixel should be.
  115093. */
  115094. useAutoMicroSurfaceFromReflectivityMap: boolean;
  115095. /**
  115096. * BJS is using an harcoded light falloff based on a manually sets up range.
  115097. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115098. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115099. */
  115100. /**
  115101. * BJS is using an harcoded light falloff based on a manually sets up range.
  115102. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115103. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115104. */
  115105. usePhysicalLightFalloff: boolean;
  115106. /**
  115107. * In order to support the falloff compatibility with gltf, a special mode has been added
  115108. * to reproduce the gltf light falloff.
  115109. */
  115110. /**
  115111. * In order to support the falloff compatibility with gltf, a special mode has been added
  115112. * to reproduce the gltf light falloff.
  115113. */
  115114. useGLTFLightFalloff: boolean;
  115115. /**
  115116. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115117. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115118. */
  115119. useRadianceOverAlpha: boolean;
  115120. /**
  115121. * Allows using an object space normal map (instead of tangent space).
  115122. */
  115123. useObjectSpaceNormalMap: boolean;
  115124. /**
  115125. * Allows using the bump map in parallax mode.
  115126. */
  115127. useParallax: boolean;
  115128. /**
  115129. * Allows using the bump map in parallax occlusion mode.
  115130. */
  115131. useParallaxOcclusion: boolean;
  115132. /**
  115133. * Controls the scale bias of the parallax mode.
  115134. */
  115135. parallaxScaleBias: number;
  115136. /**
  115137. * If sets to true, disables all the lights affecting the material.
  115138. */
  115139. disableLighting: boolean;
  115140. /**
  115141. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115142. */
  115143. forceIrradianceInFragment: boolean;
  115144. /**
  115145. * Number of Simultaneous lights allowed on the material.
  115146. */
  115147. maxSimultaneousLights: number;
  115148. /**
  115149. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115150. */
  115151. invertNormalMapX: boolean;
  115152. /**
  115153. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115154. */
  115155. invertNormalMapY: boolean;
  115156. /**
  115157. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115158. */
  115159. twoSidedLighting: boolean;
  115160. /**
  115161. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115162. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115163. */
  115164. useAlphaFresnel: boolean;
  115165. /**
  115166. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115167. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115168. */
  115169. useLinearAlphaFresnel: boolean;
  115170. /**
  115171. * Let user defines the brdf lookup texture used for IBL.
  115172. * A default 8bit version is embedded but you could point at :
  115173. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  115174. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115175. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  115176. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115177. */
  115178. environmentBRDFTexture: Nullable<BaseTexture>;
  115179. /**
  115180. * Force normal to face away from face.
  115181. */
  115182. forceNormalForward: boolean;
  115183. /**
  115184. * Enables specular anti aliasing in the PBR shader.
  115185. * It will both interacts on the Geometry for analytical and IBL lighting.
  115186. * It also prefilter the roughness map based on the bump values.
  115187. */
  115188. enableSpecularAntiAliasing: boolean;
  115189. /**
  115190. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115191. * makes the reflect vector face the model (under horizon).
  115192. */
  115193. useHorizonOcclusion: boolean;
  115194. /**
  115195. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115196. * too much the area relying on ambient texture to define their ambient occlusion.
  115197. */
  115198. useRadianceOcclusion: boolean;
  115199. /**
  115200. * If set to true, no lighting calculations will be applied.
  115201. */
  115202. unlit: boolean;
  115203. /**
  115204. * Gets the image processing configuration used either in this material.
  115205. */
  115206. /**
  115207. * Sets the Default image processing configuration used either in the this material.
  115208. *
  115209. * If sets to null, the scene one is in use.
  115210. */
  115211. imageProcessingConfiguration: ImageProcessingConfiguration;
  115212. /**
  115213. * Gets wether the color curves effect is enabled.
  115214. */
  115215. /**
  115216. * Sets wether the color curves effect is enabled.
  115217. */
  115218. cameraColorCurvesEnabled: boolean;
  115219. /**
  115220. * Gets wether the color grading effect is enabled.
  115221. */
  115222. /**
  115223. * Gets wether the color grading effect is enabled.
  115224. */
  115225. cameraColorGradingEnabled: boolean;
  115226. /**
  115227. * Gets wether tonemapping is enabled or not.
  115228. */
  115229. /**
  115230. * Sets wether tonemapping is enabled or not
  115231. */
  115232. cameraToneMappingEnabled: boolean;
  115233. /**
  115234. * The camera exposure used on this material.
  115235. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115236. * This corresponds to a photographic exposure.
  115237. */
  115238. /**
  115239. * The camera exposure used on this material.
  115240. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115241. * This corresponds to a photographic exposure.
  115242. */
  115243. cameraExposure: number;
  115244. /**
  115245. * Gets The camera contrast used on this material.
  115246. */
  115247. /**
  115248. * Sets The camera contrast used on this material.
  115249. */
  115250. cameraContrast: number;
  115251. /**
  115252. * Gets the Color Grading 2D Lookup Texture.
  115253. */
  115254. /**
  115255. * Sets the Color Grading 2D Lookup Texture.
  115256. */
  115257. cameraColorGradingTexture: Nullable<BaseTexture>;
  115258. /**
  115259. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115260. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115261. * 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;
  115262. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115263. */
  115264. /**
  115265. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115266. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115267. * 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;
  115268. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115269. */
  115270. cameraColorCurves: Nullable<ColorCurves>;
  115271. /**
  115272. * Instantiates a new PBRMaterial instance.
  115273. *
  115274. * @param name The material name
  115275. * @param scene The scene the material will be use in.
  115276. */
  115277. constructor(name: string, scene: Scene);
  115278. /**
  115279. * Returns the name of this material class.
  115280. */
  115281. getClassName(): string;
  115282. /**
  115283. * Makes a duplicate of the current material.
  115284. * @param name - name to use for the new material.
  115285. */
  115286. clone(name: string): PBRMaterial;
  115287. /**
  115288. * Serializes this PBR Material.
  115289. * @returns - An object with the serialized material.
  115290. */
  115291. serialize(): any;
  115292. /**
  115293. * Parses a PBR Material from a serialized object.
  115294. * @param source - Serialized object.
  115295. * @param scene - BJS scene instance.
  115296. * @param rootUrl - url for the scene object
  115297. * @returns - PBRMaterial
  115298. */
  115299. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  115300. }
  115301. }
  115302. declare module BABYLON {
  115303. /**
  115304. * Direct draw surface info
  115305. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  115306. */
  115307. export interface DDSInfo {
  115308. /**
  115309. * Width of the texture
  115310. */
  115311. width: number;
  115312. /**
  115313. * Width of the texture
  115314. */
  115315. height: number;
  115316. /**
  115317. * Number of Mipmaps for the texture
  115318. * @see https://en.wikipedia.org/wiki/Mipmap
  115319. */
  115320. mipmapCount: number;
  115321. /**
  115322. * If the textures format is a known fourCC format
  115323. * @see https://www.fourcc.org/
  115324. */
  115325. isFourCC: boolean;
  115326. /**
  115327. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  115328. */
  115329. isRGB: boolean;
  115330. /**
  115331. * If the texture is a lumincance format
  115332. */
  115333. isLuminance: boolean;
  115334. /**
  115335. * If this is a cube texture
  115336. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  115337. */
  115338. isCube: boolean;
  115339. /**
  115340. * If the texture is a compressed format eg. FOURCC_DXT1
  115341. */
  115342. isCompressed: boolean;
  115343. /**
  115344. * The dxgiFormat of the texture
  115345. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  115346. */
  115347. dxgiFormat: number;
  115348. /**
  115349. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  115350. */
  115351. textureType: number;
  115352. /**
  115353. * Sphericle polynomial created for the dds texture
  115354. */
  115355. sphericalPolynomial?: SphericalPolynomial;
  115356. }
  115357. /**
  115358. * Class used to provide DDS decompression tools
  115359. */
  115360. export class DDSTools {
  115361. /**
  115362. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  115363. */
  115364. static StoreLODInAlphaChannel: boolean;
  115365. /**
  115366. * Gets DDS information from an array buffer
  115367. * @param arrayBuffer defines the array buffer to read data from
  115368. * @returns the DDS information
  115369. */
  115370. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  115371. private static _FloatView;
  115372. private static _Int32View;
  115373. private static _ToHalfFloat;
  115374. private static _FromHalfFloat;
  115375. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  115376. private static _GetHalfFloatRGBAArrayBuffer;
  115377. private static _GetFloatRGBAArrayBuffer;
  115378. private static _GetFloatAsUIntRGBAArrayBuffer;
  115379. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  115380. private static _GetRGBAArrayBuffer;
  115381. private static _ExtractLongWordOrder;
  115382. private static _GetRGBArrayBuffer;
  115383. private static _GetLuminanceArrayBuffer;
  115384. /**
  115385. * Uploads DDS Levels to a Babylon Texture
  115386. * @hidden
  115387. */
  115388. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  115389. }
  115390. interface ThinEngine {
  115391. /**
  115392. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  115393. * @param rootUrl defines the url where the file to load is located
  115394. * @param scene defines the current scene
  115395. * @param lodScale defines scale to apply to the mip map selection
  115396. * @param lodOffset defines offset to apply to the mip map selection
  115397. * @param onLoad defines an optional callback raised when the texture is loaded
  115398. * @param onError defines an optional callback raised if there is an issue to load the texture
  115399. * @param format defines the format of the data
  115400. * @param forcedExtension defines the extension to use to pick the right loader
  115401. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  115402. * @returns the cube texture as an InternalTexture
  115403. */
  115404. 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;
  115405. }
  115406. }
  115407. declare module BABYLON {
  115408. /**
  115409. * Implementation of the DDS Texture Loader.
  115410. * @hidden
  115411. */
  115412. export class _DDSTextureLoader implements IInternalTextureLoader {
  115413. /**
  115414. * Defines wether the loader supports cascade loading the different faces.
  115415. */
  115416. readonly supportCascades: boolean;
  115417. /**
  115418. * This returns if the loader support the current file information.
  115419. * @param extension defines the file extension of the file being loaded
  115420. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115421. * @param fallback defines the fallback internal texture if any
  115422. * @param isBase64 defines whether the texture is encoded as a base64
  115423. * @param isBuffer defines whether the texture data are stored as a buffer
  115424. * @returns true if the loader can load the specified file
  115425. */
  115426. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115427. /**
  115428. * Transform the url before loading if required.
  115429. * @param rootUrl the url of the texture
  115430. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115431. * @returns the transformed texture
  115432. */
  115433. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115434. /**
  115435. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115436. * @param rootUrl the url of the texture
  115437. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115438. * @returns the fallback texture
  115439. */
  115440. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115441. /**
  115442. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115443. * @param data contains the texture data
  115444. * @param texture defines the BabylonJS internal texture
  115445. * @param createPolynomials will be true if polynomials have been requested
  115446. * @param onLoad defines the callback to trigger once the texture is ready
  115447. * @param onError defines the callback to trigger in case of error
  115448. */
  115449. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115450. /**
  115451. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115452. * @param data contains the texture data
  115453. * @param texture defines the BabylonJS internal texture
  115454. * @param callback defines the method to call once ready to upload
  115455. */
  115456. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115457. }
  115458. }
  115459. declare module BABYLON {
  115460. /**
  115461. * Implementation of the ENV Texture Loader.
  115462. * @hidden
  115463. */
  115464. export class _ENVTextureLoader implements IInternalTextureLoader {
  115465. /**
  115466. * Defines wether the loader supports cascade loading the different faces.
  115467. */
  115468. readonly supportCascades: boolean;
  115469. /**
  115470. * This returns if the loader support the current file information.
  115471. * @param extension defines the file extension of the file being loaded
  115472. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115473. * @param fallback defines the fallback internal texture if any
  115474. * @param isBase64 defines whether the texture is encoded as a base64
  115475. * @param isBuffer defines whether the texture data are stored as a buffer
  115476. * @returns true if the loader can load the specified file
  115477. */
  115478. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115479. /**
  115480. * Transform the url before loading if required.
  115481. * @param rootUrl the url of the texture
  115482. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115483. * @returns the transformed texture
  115484. */
  115485. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115486. /**
  115487. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115488. * @param rootUrl the url of the texture
  115489. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115490. * @returns the fallback texture
  115491. */
  115492. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115493. /**
  115494. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115495. * @param data contains the texture data
  115496. * @param texture defines the BabylonJS internal texture
  115497. * @param createPolynomials will be true if polynomials have been requested
  115498. * @param onLoad defines the callback to trigger once the texture is ready
  115499. * @param onError defines the callback to trigger in case of error
  115500. */
  115501. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115502. /**
  115503. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115504. * @param data contains the texture data
  115505. * @param texture defines the BabylonJS internal texture
  115506. * @param callback defines the method to call once ready to upload
  115507. */
  115508. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115509. }
  115510. }
  115511. declare module BABYLON {
  115512. /**
  115513. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  115514. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  115515. */
  115516. export class KhronosTextureContainer {
  115517. /** contents of the KTX container file */
  115518. arrayBuffer: any;
  115519. private static HEADER_LEN;
  115520. private static COMPRESSED_2D;
  115521. private static COMPRESSED_3D;
  115522. private static TEX_2D;
  115523. private static TEX_3D;
  115524. /**
  115525. * Gets the openGL type
  115526. */
  115527. glType: number;
  115528. /**
  115529. * Gets the openGL type size
  115530. */
  115531. glTypeSize: number;
  115532. /**
  115533. * Gets the openGL format
  115534. */
  115535. glFormat: number;
  115536. /**
  115537. * Gets the openGL internal format
  115538. */
  115539. glInternalFormat: number;
  115540. /**
  115541. * Gets the base internal format
  115542. */
  115543. glBaseInternalFormat: number;
  115544. /**
  115545. * Gets image width in pixel
  115546. */
  115547. pixelWidth: number;
  115548. /**
  115549. * Gets image height in pixel
  115550. */
  115551. pixelHeight: number;
  115552. /**
  115553. * Gets image depth in pixels
  115554. */
  115555. pixelDepth: number;
  115556. /**
  115557. * Gets the number of array elements
  115558. */
  115559. numberOfArrayElements: number;
  115560. /**
  115561. * Gets the number of faces
  115562. */
  115563. numberOfFaces: number;
  115564. /**
  115565. * Gets the number of mipmap levels
  115566. */
  115567. numberOfMipmapLevels: number;
  115568. /**
  115569. * Gets the bytes of key value data
  115570. */
  115571. bytesOfKeyValueData: number;
  115572. /**
  115573. * Gets the load type
  115574. */
  115575. loadType: number;
  115576. /**
  115577. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  115578. */
  115579. isInvalid: boolean;
  115580. /**
  115581. * Creates a new KhronosTextureContainer
  115582. * @param arrayBuffer contents of the KTX container file
  115583. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  115584. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  115585. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  115586. */
  115587. constructor(
  115588. /** contents of the KTX container file */
  115589. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  115590. /**
  115591. * Uploads KTX content to a Babylon Texture.
  115592. * It is assumed that the texture has already been created & is currently bound
  115593. * @hidden
  115594. */
  115595. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  115596. private _upload2DCompressedLevels;
  115597. }
  115598. }
  115599. declare module BABYLON {
  115600. /**
  115601. * Implementation of the KTX Texture Loader.
  115602. * @hidden
  115603. */
  115604. export class _KTXTextureLoader implements IInternalTextureLoader {
  115605. /**
  115606. * Defines wether the loader supports cascade loading the different faces.
  115607. */
  115608. readonly supportCascades: boolean;
  115609. /**
  115610. * This returns if the loader support the current file information.
  115611. * @param extension defines the file extension of the file being loaded
  115612. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115613. * @param fallback defines the fallback internal texture if any
  115614. * @param isBase64 defines whether the texture is encoded as a base64
  115615. * @param isBuffer defines whether the texture data are stored as a buffer
  115616. * @returns true if the loader can load the specified file
  115617. */
  115618. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115619. /**
  115620. * Transform the url before loading if required.
  115621. * @param rootUrl the url of the texture
  115622. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115623. * @returns the transformed texture
  115624. */
  115625. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115626. /**
  115627. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115628. * @param rootUrl the url of the texture
  115629. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115630. * @returns the fallback texture
  115631. */
  115632. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115633. /**
  115634. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115635. * @param data contains the texture data
  115636. * @param texture defines the BabylonJS internal texture
  115637. * @param createPolynomials will be true if polynomials have been requested
  115638. * @param onLoad defines the callback to trigger once the texture is ready
  115639. * @param onError defines the callback to trigger in case of error
  115640. */
  115641. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115642. /**
  115643. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115644. * @param data contains the texture data
  115645. * @param texture defines the BabylonJS internal texture
  115646. * @param callback defines the method to call once ready to upload
  115647. */
  115648. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  115649. }
  115650. }
  115651. declare module BABYLON {
  115652. /**
  115653. * Options for the default xr helper
  115654. */
  115655. export class WebXRDefaultExperienceOptions {
  115656. /**
  115657. * Floor meshes that should be used for teleporting
  115658. */
  115659. floorMeshes: Array<AbstractMesh>;
  115660. }
  115661. /**
  115662. * Default experience which provides a similar setup to the previous webVRExperience
  115663. */
  115664. export class WebXRDefaultExperience {
  115665. /**
  115666. * Base experience
  115667. */
  115668. baseExperience: WebXRExperienceHelper;
  115669. /**
  115670. * Input experience extension
  115671. */
  115672. input: WebXRInput;
  115673. /**
  115674. * Loads the controller models
  115675. */
  115676. controllerModelLoader: WebXRControllerModelLoader;
  115677. /**
  115678. * Enables laser pointer and selection
  115679. */
  115680. pointerSelection: WebXRControllerPointerSelection;
  115681. /**
  115682. * Enables teleportation
  115683. */
  115684. teleportation: WebXRControllerTeleportation;
  115685. /**
  115686. * Enables ui for enetering/exiting xr
  115687. */
  115688. enterExitUI: WebXREnterExitUI;
  115689. /**
  115690. * Default output canvas xr should render to
  115691. */
  115692. outputCanvas: WebXRManagedOutputCanvas;
  115693. /**
  115694. * Creates the default xr experience
  115695. * @param scene scene
  115696. * @param options options for basic configuration
  115697. * @returns resulting WebXRDefaultExperience
  115698. */
  115699. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115700. private constructor();
  115701. /**
  115702. * DIsposes of the experience helper
  115703. */
  115704. dispose(): void;
  115705. }
  115706. }
  115707. declare module BABYLON {
  115708. /** @hidden */
  115709. export var _forceSceneHelpersToBundle: boolean;
  115710. interface Scene {
  115711. /**
  115712. * Creates a default light for the scene.
  115713. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  115714. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  115715. */
  115716. createDefaultLight(replace?: boolean): void;
  115717. /**
  115718. * Creates a default camera for the scene.
  115719. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  115720. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115721. * @param replace has default false, when true replaces the active camera in the scene
  115722. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  115723. */
  115724. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115725. /**
  115726. * Creates a default camera and a default light.
  115727. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  115728. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115729. * @param replace has the default false, when true replaces the active camera/light in the scene
  115730. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  115731. */
  115732. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115733. /**
  115734. * Creates a new sky box
  115735. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  115736. * @param environmentTexture defines the texture to use as environment texture
  115737. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  115738. * @param scale defines the overall scale of the skybox
  115739. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  115740. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  115741. * @returns a new mesh holding the sky box
  115742. */
  115743. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  115744. /**
  115745. * Creates a new environment
  115746. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  115747. * @param options defines the options you can use to configure the environment
  115748. * @returns the new EnvironmentHelper
  115749. */
  115750. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  115751. /**
  115752. * Creates a new VREXperienceHelper
  115753. * @see http://doc.babylonjs.com/how_to/webvr_helper
  115754. * @param webVROptions defines the options used to create the new VREXperienceHelper
  115755. * @returns a new VREXperienceHelper
  115756. */
  115757. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  115758. /**
  115759. * Creates a new WebXRDefaultExperience
  115760. * @see http://doc.babylonjs.com/how_to/webxr
  115761. * @param options experience options
  115762. * @returns a promise for a new WebXRDefaultExperience
  115763. */
  115764. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115765. }
  115766. }
  115767. declare module BABYLON {
  115768. /**
  115769. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  115770. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  115771. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  115772. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115773. */
  115774. export class VideoDome extends TransformNode {
  115775. /**
  115776. * Define the video source as a Monoscopic panoramic 360 video.
  115777. */
  115778. static readonly MODE_MONOSCOPIC: number;
  115779. /**
  115780. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115781. */
  115782. static readonly MODE_TOPBOTTOM: number;
  115783. /**
  115784. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115785. */
  115786. static readonly MODE_SIDEBYSIDE: number;
  115787. private _halfDome;
  115788. private _useDirectMapping;
  115789. /**
  115790. * The video texture being displayed on the sphere
  115791. */
  115792. protected _videoTexture: VideoTexture;
  115793. /**
  115794. * Gets the video texture being displayed on the sphere
  115795. */
  115796. readonly videoTexture: VideoTexture;
  115797. /**
  115798. * The skybox material
  115799. */
  115800. protected _material: BackgroundMaterial;
  115801. /**
  115802. * The surface used for the skybox
  115803. */
  115804. protected _mesh: Mesh;
  115805. /**
  115806. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  115807. */
  115808. private _halfDomeMask;
  115809. /**
  115810. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115811. * Also see the options.resolution property.
  115812. */
  115813. fovMultiplier: number;
  115814. private _videoMode;
  115815. /**
  115816. * Gets or set the current video mode for the video. It can be:
  115817. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  115818. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115819. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115820. */
  115821. videoMode: number;
  115822. /**
  115823. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  115824. *
  115825. */
  115826. /**
  115827. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  115828. */
  115829. halfDome: boolean;
  115830. /**
  115831. * Oberserver used in Stereoscopic VR Mode.
  115832. */
  115833. private _onBeforeCameraRenderObserver;
  115834. /**
  115835. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  115836. * @param name Element's name, child elements will append suffixes for their own names.
  115837. * @param urlsOrVideo defines the url(s) or the video element to use
  115838. * @param options An object containing optional or exposed sub element properties
  115839. */
  115840. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  115841. resolution?: number;
  115842. clickToPlay?: boolean;
  115843. autoPlay?: boolean;
  115844. loop?: boolean;
  115845. size?: number;
  115846. poster?: string;
  115847. faceForward?: boolean;
  115848. useDirectMapping?: boolean;
  115849. halfDomeMode?: boolean;
  115850. }, scene: Scene);
  115851. private _changeVideoMode;
  115852. /**
  115853. * Releases resources associated with this node.
  115854. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115855. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115856. */
  115857. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115858. }
  115859. }
  115860. declare module BABYLON {
  115861. /**
  115862. * This class can be used to get instrumentation data from a Babylon engine
  115863. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115864. */
  115865. export class EngineInstrumentation implements IDisposable {
  115866. /**
  115867. * Define the instrumented engine.
  115868. */
  115869. engine: Engine;
  115870. private _captureGPUFrameTime;
  115871. private _gpuFrameTimeToken;
  115872. private _gpuFrameTime;
  115873. private _captureShaderCompilationTime;
  115874. private _shaderCompilationTime;
  115875. private _onBeginFrameObserver;
  115876. private _onEndFrameObserver;
  115877. private _onBeforeShaderCompilationObserver;
  115878. private _onAfterShaderCompilationObserver;
  115879. /**
  115880. * Gets the perf counter used for GPU frame time
  115881. */
  115882. readonly gpuFrameTimeCounter: PerfCounter;
  115883. /**
  115884. * Gets the GPU frame time capture status
  115885. */
  115886. /**
  115887. * Enable or disable the GPU frame time capture
  115888. */
  115889. captureGPUFrameTime: boolean;
  115890. /**
  115891. * Gets the perf counter used for shader compilation time
  115892. */
  115893. readonly shaderCompilationTimeCounter: PerfCounter;
  115894. /**
  115895. * Gets the shader compilation time capture status
  115896. */
  115897. /**
  115898. * Enable or disable the shader compilation time capture
  115899. */
  115900. captureShaderCompilationTime: boolean;
  115901. /**
  115902. * Instantiates a new engine instrumentation.
  115903. * This class can be used to get instrumentation data from a Babylon engine
  115904. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115905. * @param engine Defines the engine to instrument
  115906. */
  115907. constructor(
  115908. /**
  115909. * Define the instrumented engine.
  115910. */
  115911. engine: Engine);
  115912. /**
  115913. * Dispose and release associated resources.
  115914. */
  115915. dispose(): void;
  115916. }
  115917. }
  115918. declare module BABYLON {
  115919. /**
  115920. * This class can be used to get instrumentation data from a Babylon engine
  115921. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  115922. */
  115923. export class SceneInstrumentation implements IDisposable {
  115924. /**
  115925. * Defines the scene to instrument
  115926. */
  115927. scene: Scene;
  115928. private _captureActiveMeshesEvaluationTime;
  115929. private _activeMeshesEvaluationTime;
  115930. private _captureRenderTargetsRenderTime;
  115931. private _renderTargetsRenderTime;
  115932. private _captureFrameTime;
  115933. private _frameTime;
  115934. private _captureRenderTime;
  115935. private _renderTime;
  115936. private _captureInterFrameTime;
  115937. private _interFrameTime;
  115938. private _captureParticlesRenderTime;
  115939. private _particlesRenderTime;
  115940. private _captureSpritesRenderTime;
  115941. private _spritesRenderTime;
  115942. private _capturePhysicsTime;
  115943. private _physicsTime;
  115944. private _captureAnimationsTime;
  115945. private _animationsTime;
  115946. private _captureCameraRenderTime;
  115947. private _cameraRenderTime;
  115948. private _onBeforeActiveMeshesEvaluationObserver;
  115949. private _onAfterActiveMeshesEvaluationObserver;
  115950. private _onBeforeRenderTargetsRenderObserver;
  115951. private _onAfterRenderTargetsRenderObserver;
  115952. private _onAfterRenderObserver;
  115953. private _onBeforeDrawPhaseObserver;
  115954. private _onAfterDrawPhaseObserver;
  115955. private _onBeforeAnimationsObserver;
  115956. private _onBeforeParticlesRenderingObserver;
  115957. private _onAfterParticlesRenderingObserver;
  115958. private _onBeforeSpritesRenderingObserver;
  115959. private _onAfterSpritesRenderingObserver;
  115960. private _onBeforePhysicsObserver;
  115961. private _onAfterPhysicsObserver;
  115962. private _onAfterAnimationsObserver;
  115963. private _onBeforeCameraRenderObserver;
  115964. private _onAfterCameraRenderObserver;
  115965. /**
  115966. * Gets the perf counter used for active meshes evaluation time
  115967. */
  115968. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  115969. /**
  115970. * Gets the active meshes evaluation time capture status
  115971. */
  115972. /**
  115973. * Enable or disable the active meshes evaluation time capture
  115974. */
  115975. captureActiveMeshesEvaluationTime: boolean;
  115976. /**
  115977. * Gets the perf counter used for render targets render time
  115978. */
  115979. readonly renderTargetsRenderTimeCounter: PerfCounter;
  115980. /**
  115981. * Gets the render targets render time capture status
  115982. */
  115983. /**
  115984. * Enable or disable the render targets render time capture
  115985. */
  115986. captureRenderTargetsRenderTime: boolean;
  115987. /**
  115988. * Gets the perf counter used for particles render time
  115989. */
  115990. readonly particlesRenderTimeCounter: PerfCounter;
  115991. /**
  115992. * Gets the particles render time capture status
  115993. */
  115994. /**
  115995. * Enable or disable the particles render time capture
  115996. */
  115997. captureParticlesRenderTime: boolean;
  115998. /**
  115999. * Gets the perf counter used for sprites render time
  116000. */
  116001. readonly spritesRenderTimeCounter: PerfCounter;
  116002. /**
  116003. * Gets the sprites render time capture status
  116004. */
  116005. /**
  116006. * Enable or disable the sprites render time capture
  116007. */
  116008. captureSpritesRenderTime: boolean;
  116009. /**
  116010. * Gets the perf counter used for physics time
  116011. */
  116012. readonly physicsTimeCounter: PerfCounter;
  116013. /**
  116014. * Gets the physics time capture status
  116015. */
  116016. /**
  116017. * Enable or disable the physics time capture
  116018. */
  116019. capturePhysicsTime: boolean;
  116020. /**
  116021. * Gets the perf counter used for animations time
  116022. */
  116023. readonly animationsTimeCounter: PerfCounter;
  116024. /**
  116025. * Gets the animations time capture status
  116026. */
  116027. /**
  116028. * Enable or disable the animations time capture
  116029. */
  116030. captureAnimationsTime: boolean;
  116031. /**
  116032. * Gets the perf counter used for frame time capture
  116033. */
  116034. readonly frameTimeCounter: PerfCounter;
  116035. /**
  116036. * Gets the frame time capture status
  116037. */
  116038. /**
  116039. * Enable or disable the frame time capture
  116040. */
  116041. captureFrameTime: boolean;
  116042. /**
  116043. * Gets the perf counter used for inter-frames time capture
  116044. */
  116045. readonly interFrameTimeCounter: PerfCounter;
  116046. /**
  116047. * Gets the inter-frames time capture status
  116048. */
  116049. /**
  116050. * Enable or disable the inter-frames time capture
  116051. */
  116052. captureInterFrameTime: boolean;
  116053. /**
  116054. * Gets the perf counter used for render time capture
  116055. */
  116056. readonly renderTimeCounter: PerfCounter;
  116057. /**
  116058. * Gets the render time capture status
  116059. */
  116060. /**
  116061. * Enable or disable the render time capture
  116062. */
  116063. captureRenderTime: boolean;
  116064. /**
  116065. * Gets the perf counter used for camera render time capture
  116066. */
  116067. readonly cameraRenderTimeCounter: PerfCounter;
  116068. /**
  116069. * Gets the camera render time capture status
  116070. */
  116071. /**
  116072. * Enable or disable the camera render time capture
  116073. */
  116074. captureCameraRenderTime: boolean;
  116075. /**
  116076. * Gets the perf counter used for draw calls
  116077. */
  116078. readonly drawCallsCounter: PerfCounter;
  116079. /**
  116080. * Instantiates a new scene instrumentation.
  116081. * This class can be used to get instrumentation data from a Babylon engine
  116082. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  116083. * @param scene Defines the scene to instrument
  116084. */
  116085. constructor(
  116086. /**
  116087. * Defines the scene to instrument
  116088. */
  116089. scene: Scene);
  116090. /**
  116091. * Dispose and release associated resources.
  116092. */
  116093. dispose(): void;
  116094. }
  116095. }
  116096. declare module BABYLON {
  116097. /** @hidden */
  116098. export var glowMapGenerationPixelShader: {
  116099. name: string;
  116100. shader: string;
  116101. };
  116102. }
  116103. declare module BABYLON {
  116104. /** @hidden */
  116105. export var glowMapGenerationVertexShader: {
  116106. name: string;
  116107. shader: string;
  116108. };
  116109. }
  116110. declare module BABYLON {
  116111. /**
  116112. * Effect layer options. This helps customizing the behaviour
  116113. * of the effect layer.
  116114. */
  116115. export interface IEffectLayerOptions {
  116116. /**
  116117. * Multiplication factor apply to the canvas size to compute the render target size
  116118. * used to generated the objects (the smaller the faster).
  116119. */
  116120. mainTextureRatio: number;
  116121. /**
  116122. * Enforces a fixed size texture to ensure effect stability across devices.
  116123. */
  116124. mainTextureFixedSize?: number;
  116125. /**
  116126. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  116127. */
  116128. alphaBlendingMode: number;
  116129. /**
  116130. * The camera attached to the layer.
  116131. */
  116132. camera: Nullable<Camera>;
  116133. /**
  116134. * The rendering group to draw the layer in.
  116135. */
  116136. renderingGroupId: number;
  116137. }
  116138. /**
  116139. * The effect layer Helps adding post process effect blended with the main pass.
  116140. *
  116141. * This can be for instance use to generate glow or higlight effects on the scene.
  116142. *
  116143. * The effect layer class can not be used directly and is intented to inherited from to be
  116144. * customized per effects.
  116145. */
  116146. export abstract class EffectLayer {
  116147. private _vertexBuffers;
  116148. private _indexBuffer;
  116149. private _cachedDefines;
  116150. private _effectLayerMapGenerationEffect;
  116151. private _effectLayerOptions;
  116152. private _mergeEffect;
  116153. protected _scene: Scene;
  116154. protected _engine: Engine;
  116155. protected _maxSize: number;
  116156. protected _mainTextureDesiredSize: ISize;
  116157. protected _mainTexture: RenderTargetTexture;
  116158. protected _shouldRender: boolean;
  116159. protected _postProcesses: PostProcess[];
  116160. protected _textures: BaseTexture[];
  116161. protected _emissiveTextureAndColor: {
  116162. texture: Nullable<BaseTexture>;
  116163. color: Color4;
  116164. };
  116165. /**
  116166. * The name of the layer
  116167. */
  116168. name: string;
  116169. /**
  116170. * The clear color of the texture used to generate the glow map.
  116171. */
  116172. neutralColor: Color4;
  116173. /**
  116174. * Specifies wether the highlight layer is enabled or not.
  116175. */
  116176. isEnabled: boolean;
  116177. /**
  116178. * Gets the camera attached to the layer.
  116179. */
  116180. readonly camera: Nullable<Camera>;
  116181. /**
  116182. * Gets the rendering group id the layer should render in.
  116183. */
  116184. renderingGroupId: number;
  116185. /**
  116186. * An event triggered when the effect layer has been disposed.
  116187. */
  116188. onDisposeObservable: Observable<EffectLayer>;
  116189. /**
  116190. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  116191. */
  116192. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  116193. /**
  116194. * An event triggered when the generated texture is being merged in the scene.
  116195. */
  116196. onBeforeComposeObservable: Observable<EffectLayer>;
  116197. /**
  116198. * An event triggered when the generated texture has been merged in the scene.
  116199. */
  116200. onAfterComposeObservable: Observable<EffectLayer>;
  116201. /**
  116202. * An event triggered when the efffect layer changes its size.
  116203. */
  116204. onSizeChangedObservable: Observable<EffectLayer>;
  116205. /** @hidden */
  116206. static _SceneComponentInitialization: (scene: Scene) => void;
  116207. /**
  116208. * Instantiates a new effect Layer and references it in the scene.
  116209. * @param name The name of the layer
  116210. * @param scene The scene to use the layer in
  116211. */
  116212. constructor(
  116213. /** The Friendly of the effect in the scene */
  116214. name: string, scene: Scene);
  116215. /**
  116216. * Get the effect name of the layer.
  116217. * @return The effect name
  116218. */
  116219. abstract getEffectName(): string;
  116220. /**
  116221. * Checks for the readiness of the element composing the layer.
  116222. * @param subMesh the mesh to check for
  116223. * @param useInstances specify wether or not to use instances to render the mesh
  116224. * @return true if ready otherwise, false
  116225. */
  116226. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116227. /**
  116228. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116229. * @returns true if the effect requires stencil during the main canvas render pass.
  116230. */
  116231. abstract needStencil(): boolean;
  116232. /**
  116233. * Create the merge effect. This is the shader use to blit the information back
  116234. * to the main canvas at the end of the scene rendering.
  116235. * @returns The effect containing the shader used to merge the effect on the main canvas
  116236. */
  116237. protected abstract _createMergeEffect(): Effect;
  116238. /**
  116239. * Creates the render target textures and post processes used in the effect layer.
  116240. */
  116241. protected abstract _createTextureAndPostProcesses(): void;
  116242. /**
  116243. * Implementation specific of rendering the generating effect on the main canvas.
  116244. * @param effect The effect used to render through
  116245. */
  116246. protected abstract _internalRender(effect: Effect): void;
  116247. /**
  116248. * Sets the required values for both the emissive texture and and the main color.
  116249. */
  116250. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116251. /**
  116252. * Free any resources and references associated to a mesh.
  116253. * Internal use
  116254. * @param mesh The mesh to free.
  116255. */
  116256. abstract _disposeMesh(mesh: Mesh): void;
  116257. /**
  116258. * Serializes this layer (Glow or Highlight for example)
  116259. * @returns a serialized layer object
  116260. */
  116261. abstract serialize?(): any;
  116262. /**
  116263. * Initializes the effect layer with the required options.
  116264. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  116265. */
  116266. protected _init(options: Partial<IEffectLayerOptions>): void;
  116267. /**
  116268. * Generates the index buffer of the full screen quad blending to the main canvas.
  116269. */
  116270. private _generateIndexBuffer;
  116271. /**
  116272. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  116273. */
  116274. private _generateVertexBuffer;
  116275. /**
  116276. * Sets the main texture desired size which is the closest power of two
  116277. * of the engine canvas size.
  116278. */
  116279. private _setMainTextureSize;
  116280. /**
  116281. * Creates the main texture for the effect layer.
  116282. */
  116283. protected _createMainTexture(): void;
  116284. /**
  116285. * Adds specific effects defines.
  116286. * @param defines The defines to add specifics to.
  116287. */
  116288. protected _addCustomEffectDefines(defines: string[]): void;
  116289. /**
  116290. * Checks for the readiness of the element composing the layer.
  116291. * @param subMesh the mesh to check for
  116292. * @param useInstances specify wether or not to use instances to render the mesh
  116293. * @param emissiveTexture the associated emissive texture used to generate the glow
  116294. * @return true if ready otherwise, false
  116295. */
  116296. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  116297. /**
  116298. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  116299. */
  116300. render(): void;
  116301. /**
  116302. * Determine if a given mesh will be used in the current effect.
  116303. * @param mesh mesh to test
  116304. * @returns true if the mesh will be used
  116305. */
  116306. hasMesh(mesh: AbstractMesh): boolean;
  116307. /**
  116308. * Returns true if the layer contains information to display, otherwise false.
  116309. * @returns true if the glow layer should be rendered
  116310. */
  116311. shouldRender(): boolean;
  116312. /**
  116313. * Returns true if the mesh should render, otherwise false.
  116314. * @param mesh The mesh to render
  116315. * @returns true if it should render otherwise false
  116316. */
  116317. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  116318. /**
  116319. * Returns true if the mesh can be rendered, otherwise false.
  116320. * @param mesh The mesh to render
  116321. * @param material The material used on the mesh
  116322. * @returns true if it can be rendered otherwise false
  116323. */
  116324. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116325. /**
  116326. * Returns true if the mesh should render, otherwise false.
  116327. * @param mesh The mesh to render
  116328. * @returns true if it should render otherwise false
  116329. */
  116330. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  116331. /**
  116332. * Renders the submesh passed in parameter to the generation map.
  116333. */
  116334. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  116335. /**
  116336. * Rebuild the required buffers.
  116337. * @hidden Internal use only.
  116338. */
  116339. _rebuild(): void;
  116340. /**
  116341. * Dispose only the render target textures and post process.
  116342. */
  116343. private _disposeTextureAndPostProcesses;
  116344. /**
  116345. * Dispose the highlight layer and free resources.
  116346. */
  116347. dispose(): void;
  116348. /**
  116349. * Gets the class name of the effect layer
  116350. * @returns the string with the class name of the effect layer
  116351. */
  116352. getClassName(): string;
  116353. /**
  116354. * Creates an effect layer from parsed effect layer data
  116355. * @param parsedEffectLayer defines effect layer data
  116356. * @param scene defines the current scene
  116357. * @param rootUrl defines the root URL containing the effect layer information
  116358. * @returns a parsed effect Layer
  116359. */
  116360. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  116361. }
  116362. }
  116363. declare module BABYLON {
  116364. interface AbstractScene {
  116365. /**
  116366. * The list of effect layers (highlights/glow) added to the scene
  116367. * @see http://doc.babylonjs.com/how_to/highlight_layer
  116368. * @see http://doc.babylonjs.com/how_to/glow_layer
  116369. */
  116370. effectLayers: Array<EffectLayer>;
  116371. /**
  116372. * Removes the given effect layer from this scene.
  116373. * @param toRemove defines the effect layer to remove
  116374. * @returns the index of the removed effect layer
  116375. */
  116376. removeEffectLayer(toRemove: EffectLayer): number;
  116377. /**
  116378. * Adds the given effect layer to this scene
  116379. * @param newEffectLayer defines the effect layer to add
  116380. */
  116381. addEffectLayer(newEffectLayer: EffectLayer): void;
  116382. }
  116383. /**
  116384. * Defines the layer scene component responsible to manage any effect layers
  116385. * in a given scene.
  116386. */
  116387. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  116388. /**
  116389. * The component name helpfull to identify the component in the list of scene components.
  116390. */
  116391. readonly name: string;
  116392. /**
  116393. * The scene the component belongs to.
  116394. */
  116395. scene: Scene;
  116396. private _engine;
  116397. private _renderEffects;
  116398. private _needStencil;
  116399. private _previousStencilState;
  116400. /**
  116401. * Creates a new instance of the component for the given scene
  116402. * @param scene Defines the scene to register the component in
  116403. */
  116404. constructor(scene: Scene);
  116405. /**
  116406. * Registers the component in a given scene
  116407. */
  116408. register(): void;
  116409. /**
  116410. * Rebuilds the elements related to this component in case of
  116411. * context lost for instance.
  116412. */
  116413. rebuild(): void;
  116414. /**
  116415. * Serializes the component data to the specified json object
  116416. * @param serializationObject The object to serialize to
  116417. */
  116418. serialize(serializationObject: any): void;
  116419. /**
  116420. * Adds all the elements from the container to the scene
  116421. * @param container the container holding the elements
  116422. */
  116423. addFromContainer(container: AbstractScene): void;
  116424. /**
  116425. * Removes all the elements in the container from the scene
  116426. * @param container contains the elements to remove
  116427. * @param dispose if the removed element should be disposed (default: false)
  116428. */
  116429. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116430. /**
  116431. * Disposes the component and the associated ressources.
  116432. */
  116433. dispose(): void;
  116434. private _isReadyForMesh;
  116435. private _renderMainTexture;
  116436. private _setStencil;
  116437. private _setStencilBack;
  116438. private _draw;
  116439. private _drawCamera;
  116440. private _drawRenderingGroup;
  116441. }
  116442. }
  116443. declare module BABYLON {
  116444. /** @hidden */
  116445. export var glowMapMergePixelShader: {
  116446. name: string;
  116447. shader: string;
  116448. };
  116449. }
  116450. declare module BABYLON {
  116451. /** @hidden */
  116452. export var glowMapMergeVertexShader: {
  116453. name: string;
  116454. shader: string;
  116455. };
  116456. }
  116457. declare module BABYLON {
  116458. interface AbstractScene {
  116459. /**
  116460. * Return a the first highlight layer of the scene with a given name.
  116461. * @param name The name of the highlight layer to look for.
  116462. * @return The highlight layer if found otherwise null.
  116463. */
  116464. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  116465. }
  116466. /**
  116467. * Glow layer options. This helps customizing the behaviour
  116468. * of the glow layer.
  116469. */
  116470. export interface IGlowLayerOptions {
  116471. /**
  116472. * Multiplication factor apply to the canvas size to compute the render target size
  116473. * used to generated the glowing objects (the smaller the faster).
  116474. */
  116475. mainTextureRatio: number;
  116476. /**
  116477. * Enforces a fixed size texture to ensure resize independant blur.
  116478. */
  116479. mainTextureFixedSize?: number;
  116480. /**
  116481. * How big is the kernel of the blur texture.
  116482. */
  116483. blurKernelSize: number;
  116484. /**
  116485. * The camera attached to the layer.
  116486. */
  116487. camera: Nullable<Camera>;
  116488. /**
  116489. * Enable MSAA by chosing the number of samples.
  116490. */
  116491. mainTextureSamples?: number;
  116492. /**
  116493. * The rendering group to draw the layer in.
  116494. */
  116495. renderingGroupId: number;
  116496. }
  116497. /**
  116498. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  116499. *
  116500. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116501. * glowy meshes to your scene.
  116502. *
  116503. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  116504. */
  116505. export class GlowLayer extends EffectLayer {
  116506. /**
  116507. * Effect Name of the layer.
  116508. */
  116509. static readonly EffectName: string;
  116510. /**
  116511. * The default blur kernel size used for the glow.
  116512. */
  116513. static DefaultBlurKernelSize: number;
  116514. /**
  116515. * The default texture size ratio used for the glow.
  116516. */
  116517. static DefaultTextureRatio: number;
  116518. /**
  116519. * Sets the kernel size of the blur.
  116520. */
  116521. /**
  116522. * Gets the kernel size of the blur.
  116523. */
  116524. blurKernelSize: number;
  116525. /**
  116526. * Sets the glow intensity.
  116527. */
  116528. /**
  116529. * Gets the glow intensity.
  116530. */
  116531. intensity: number;
  116532. private _options;
  116533. private _intensity;
  116534. private _horizontalBlurPostprocess1;
  116535. private _verticalBlurPostprocess1;
  116536. private _horizontalBlurPostprocess2;
  116537. private _verticalBlurPostprocess2;
  116538. private _blurTexture1;
  116539. private _blurTexture2;
  116540. private _postProcesses1;
  116541. private _postProcesses2;
  116542. private _includedOnlyMeshes;
  116543. private _excludedMeshes;
  116544. /**
  116545. * Callback used to let the user override the color selection on a per mesh basis
  116546. */
  116547. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  116548. /**
  116549. * Callback used to let the user override the texture selection on a per mesh basis
  116550. */
  116551. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  116552. /**
  116553. * Instantiates a new glow Layer and references it to the scene.
  116554. * @param name The name of the layer
  116555. * @param scene The scene to use the layer in
  116556. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  116557. */
  116558. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  116559. /**
  116560. * Get the effect name of the layer.
  116561. * @return The effect name
  116562. */
  116563. getEffectName(): string;
  116564. /**
  116565. * Create the merge effect. This is the shader use to blit the information back
  116566. * to the main canvas at the end of the scene rendering.
  116567. */
  116568. protected _createMergeEffect(): Effect;
  116569. /**
  116570. * Creates the render target textures and post processes used in the glow layer.
  116571. */
  116572. protected _createTextureAndPostProcesses(): void;
  116573. /**
  116574. * Checks for the readiness of the element composing the layer.
  116575. * @param subMesh the mesh to check for
  116576. * @param useInstances specify wether or not to use instances to render the mesh
  116577. * @param emissiveTexture the associated emissive texture used to generate the glow
  116578. * @return true if ready otherwise, false
  116579. */
  116580. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116581. /**
  116582. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116583. */
  116584. needStencil(): boolean;
  116585. /**
  116586. * Returns true if the mesh can be rendered, otherwise false.
  116587. * @param mesh The mesh to render
  116588. * @param material The material used on the mesh
  116589. * @returns true if it can be rendered otherwise false
  116590. */
  116591. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116592. /**
  116593. * Implementation specific of rendering the generating effect on the main canvas.
  116594. * @param effect The effect used to render through
  116595. */
  116596. protected _internalRender(effect: Effect): void;
  116597. /**
  116598. * Sets the required values for both the emissive texture and and the main color.
  116599. */
  116600. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116601. /**
  116602. * Returns true if the mesh should render, otherwise false.
  116603. * @param mesh The mesh to render
  116604. * @returns true if it should render otherwise false
  116605. */
  116606. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116607. /**
  116608. * Adds specific effects defines.
  116609. * @param defines The defines to add specifics to.
  116610. */
  116611. protected _addCustomEffectDefines(defines: string[]): void;
  116612. /**
  116613. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  116614. * @param mesh The mesh to exclude from the glow layer
  116615. */
  116616. addExcludedMesh(mesh: Mesh): void;
  116617. /**
  116618. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  116619. * @param mesh The mesh to remove
  116620. */
  116621. removeExcludedMesh(mesh: Mesh): void;
  116622. /**
  116623. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  116624. * @param mesh The mesh to include in the glow layer
  116625. */
  116626. addIncludedOnlyMesh(mesh: Mesh): void;
  116627. /**
  116628. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  116629. * @param mesh The mesh to remove
  116630. */
  116631. removeIncludedOnlyMesh(mesh: Mesh): void;
  116632. /**
  116633. * Determine if a given mesh will be used in the glow layer
  116634. * @param mesh The mesh to test
  116635. * @returns true if the mesh will be highlighted by the current glow layer
  116636. */
  116637. hasMesh(mesh: AbstractMesh): boolean;
  116638. /**
  116639. * Free any resources and references associated to a mesh.
  116640. * Internal use
  116641. * @param mesh The mesh to free.
  116642. * @hidden
  116643. */
  116644. _disposeMesh(mesh: Mesh): void;
  116645. /**
  116646. * Gets the class name of the effect layer
  116647. * @returns the string with the class name of the effect layer
  116648. */
  116649. getClassName(): string;
  116650. /**
  116651. * Serializes this glow layer
  116652. * @returns a serialized glow layer object
  116653. */
  116654. serialize(): any;
  116655. /**
  116656. * Creates a Glow Layer from parsed glow layer data
  116657. * @param parsedGlowLayer defines glow layer data
  116658. * @param scene defines the current scene
  116659. * @param rootUrl defines the root URL containing the glow layer information
  116660. * @returns a parsed Glow Layer
  116661. */
  116662. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  116663. }
  116664. }
  116665. declare module BABYLON {
  116666. /** @hidden */
  116667. export var glowBlurPostProcessPixelShader: {
  116668. name: string;
  116669. shader: string;
  116670. };
  116671. }
  116672. declare module BABYLON {
  116673. interface AbstractScene {
  116674. /**
  116675. * Return a the first highlight layer of the scene with a given name.
  116676. * @param name The name of the highlight layer to look for.
  116677. * @return The highlight layer if found otherwise null.
  116678. */
  116679. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  116680. }
  116681. /**
  116682. * Highlight layer options. This helps customizing the behaviour
  116683. * of the highlight layer.
  116684. */
  116685. export interface IHighlightLayerOptions {
  116686. /**
  116687. * Multiplication factor apply to the canvas size to compute the render target size
  116688. * used to generated the glowing objects (the smaller the faster).
  116689. */
  116690. mainTextureRatio: number;
  116691. /**
  116692. * Enforces a fixed size texture to ensure resize independant blur.
  116693. */
  116694. mainTextureFixedSize?: number;
  116695. /**
  116696. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  116697. * of the picture to blur (the smaller the faster).
  116698. */
  116699. blurTextureSizeRatio: number;
  116700. /**
  116701. * How big in texel of the blur texture is the vertical blur.
  116702. */
  116703. blurVerticalSize: number;
  116704. /**
  116705. * How big in texel of the blur texture is the horizontal blur.
  116706. */
  116707. blurHorizontalSize: number;
  116708. /**
  116709. * Alpha blending mode used to apply the blur. Default is combine.
  116710. */
  116711. alphaBlendingMode: number;
  116712. /**
  116713. * The camera attached to the layer.
  116714. */
  116715. camera: Nullable<Camera>;
  116716. /**
  116717. * Should we display highlight as a solid stroke?
  116718. */
  116719. isStroke?: boolean;
  116720. /**
  116721. * The rendering group to draw the layer in.
  116722. */
  116723. renderingGroupId: number;
  116724. }
  116725. /**
  116726. * The highlight layer Helps adding a glow effect around a mesh.
  116727. *
  116728. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116729. * glowy meshes to your scene.
  116730. *
  116731. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  116732. */
  116733. export class HighlightLayer extends EffectLayer {
  116734. name: string;
  116735. /**
  116736. * Effect Name of the highlight layer.
  116737. */
  116738. static readonly EffectName: string;
  116739. /**
  116740. * The neutral color used during the preparation of the glow effect.
  116741. * This is black by default as the blend operation is a blend operation.
  116742. */
  116743. static NeutralColor: Color4;
  116744. /**
  116745. * Stencil value used for glowing meshes.
  116746. */
  116747. static GlowingMeshStencilReference: number;
  116748. /**
  116749. * Stencil value used for the other meshes in the scene.
  116750. */
  116751. static NormalMeshStencilReference: number;
  116752. /**
  116753. * Specifies whether or not the inner glow is ACTIVE in the layer.
  116754. */
  116755. innerGlow: boolean;
  116756. /**
  116757. * Specifies whether or not the outer glow is ACTIVE in the layer.
  116758. */
  116759. outerGlow: boolean;
  116760. /**
  116761. * Specifies the horizontal size of the blur.
  116762. */
  116763. /**
  116764. * Gets the horizontal size of the blur.
  116765. */
  116766. blurHorizontalSize: number;
  116767. /**
  116768. * Specifies the vertical size of the blur.
  116769. */
  116770. /**
  116771. * Gets the vertical size of the blur.
  116772. */
  116773. blurVerticalSize: number;
  116774. /**
  116775. * An event triggered when the highlight layer is being blurred.
  116776. */
  116777. onBeforeBlurObservable: Observable<HighlightLayer>;
  116778. /**
  116779. * An event triggered when the highlight layer has been blurred.
  116780. */
  116781. onAfterBlurObservable: Observable<HighlightLayer>;
  116782. private _instanceGlowingMeshStencilReference;
  116783. private _options;
  116784. private _downSamplePostprocess;
  116785. private _horizontalBlurPostprocess;
  116786. private _verticalBlurPostprocess;
  116787. private _blurTexture;
  116788. private _meshes;
  116789. private _excludedMeshes;
  116790. /**
  116791. * Instantiates a new highlight Layer and references it to the scene..
  116792. * @param name The name of the layer
  116793. * @param scene The scene to use the layer in
  116794. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  116795. */
  116796. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  116797. /**
  116798. * Get the effect name of the layer.
  116799. * @return The effect name
  116800. */
  116801. getEffectName(): string;
  116802. /**
  116803. * Create the merge effect. This is the shader use to blit the information back
  116804. * to the main canvas at the end of the scene rendering.
  116805. */
  116806. protected _createMergeEffect(): Effect;
  116807. /**
  116808. * Creates the render target textures and post processes used in the highlight layer.
  116809. */
  116810. protected _createTextureAndPostProcesses(): void;
  116811. /**
  116812. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116813. */
  116814. needStencil(): boolean;
  116815. /**
  116816. * Checks for the readiness of the element composing the layer.
  116817. * @param subMesh the mesh to check for
  116818. * @param useInstances specify wether or not to use instances to render the mesh
  116819. * @param emissiveTexture the associated emissive texture used to generate the glow
  116820. * @return true if ready otherwise, false
  116821. */
  116822. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116823. /**
  116824. * Implementation specific of rendering the generating effect on the main canvas.
  116825. * @param effect The effect used to render through
  116826. */
  116827. protected _internalRender(effect: Effect): void;
  116828. /**
  116829. * Returns true if the layer contains information to display, otherwise false.
  116830. */
  116831. shouldRender(): boolean;
  116832. /**
  116833. * Returns true if the mesh should render, otherwise false.
  116834. * @param mesh The mesh to render
  116835. * @returns true if it should render otherwise false
  116836. */
  116837. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116838. /**
  116839. * Sets the required values for both the emissive texture and and the main color.
  116840. */
  116841. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116842. /**
  116843. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  116844. * @param mesh The mesh to exclude from the highlight layer
  116845. */
  116846. addExcludedMesh(mesh: Mesh): void;
  116847. /**
  116848. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  116849. * @param mesh The mesh to highlight
  116850. */
  116851. removeExcludedMesh(mesh: Mesh): void;
  116852. /**
  116853. * Determine if a given mesh will be highlighted by the current HighlightLayer
  116854. * @param mesh mesh to test
  116855. * @returns true if the mesh will be highlighted by the current HighlightLayer
  116856. */
  116857. hasMesh(mesh: AbstractMesh): boolean;
  116858. /**
  116859. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  116860. * @param mesh The mesh to highlight
  116861. * @param color The color of the highlight
  116862. * @param glowEmissiveOnly Extract the glow from the emissive texture
  116863. */
  116864. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  116865. /**
  116866. * Remove a mesh from the highlight layer in order to make it stop glowing.
  116867. * @param mesh The mesh to highlight
  116868. */
  116869. removeMesh(mesh: Mesh): void;
  116870. /**
  116871. * Force the stencil to the normal expected value for none glowing parts
  116872. */
  116873. private _defaultStencilReference;
  116874. /**
  116875. * Free any resources and references associated to a mesh.
  116876. * Internal use
  116877. * @param mesh The mesh to free.
  116878. * @hidden
  116879. */
  116880. _disposeMesh(mesh: Mesh): void;
  116881. /**
  116882. * Dispose the highlight layer and free resources.
  116883. */
  116884. dispose(): void;
  116885. /**
  116886. * Gets the class name of the effect layer
  116887. * @returns the string with the class name of the effect layer
  116888. */
  116889. getClassName(): string;
  116890. /**
  116891. * Serializes this Highlight layer
  116892. * @returns a serialized Highlight layer object
  116893. */
  116894. serialize(): any;
  116895. /**
  116896. * Creates a Highlight layer from parsed Highlight layer data
  116897. * @param parsedHightlightLayer defines the Highlight layer data
  116898. * @param scene defines the current scene
  116899. * @param rootUrl defines the root URL containing the Highlight layer information
  116900. * @returns a parsed Highlight layer
  116901. */
  116902. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  116903. }
  116904. }
  116905. declare module BABYLON {
  116906. interface AbstractScene {
  116907. /**
  116908. * The list of layers (background and foreground) of the scene
  116909. */
  116910. layers: Array<Layer>;
  116911. }
  116912. /**
  116913. * Defines the layer scene component responsible to manage any layers
  116914. * in a given scene.
  116915. */
  116916. export class LayerSceneComponent implements ISceneComponent {
  116917. /**
  116918. * The component name helpfull to identify the component in the list of scene components.
  116919. */
  116920. readonly name: string;
  116921. /**
  116922. * The scene the component belongs to.
  116923. */
  116924. scene: Scene;
  116925. private _engine;
  116926. /**
  116927. * Creates a new instance of the component for the given scene
  116928. * @param scene Defines the scene to register the component in
  116929. */
  116930. constructor(scene: Scene);
  116931. /**
  116932. * Registers the component in a given scene
  116933. */
  116934. register(): void;
  116935. /**
  116936. * Rebuilds the elements related to this component in case of
  116937. * context lost for instance.
  116938. */
  116939. rebuild(): void;
  116940. /**
  116941. * Disposes the component and the associated ressources.
  116942. */
  116943. dispose(): void;
  116944. private _draw;
  116945. private _drawCameraPredicate;
  116946. private _drawCameraBackground;
  116947. private _drawCameraForeground;
  116948. private _drawRenderTargetPredicate;
  116949. private _drawRenderTargetBackground;
  116950. private _drawRenderTargetForeground;
  116951. /**
  116952. * Adds all the elements from the container to the scene
  116953. * @param container the container holding the elements
  116954. */
  116955. addFromContainer(container: AbstractScene): void;
  116956. /**
  116957. * Removes all the elements in the container from the scene
  116958. * @param container contains the elements to remove
  116959. * @param dispose if the removed element should be disposed (default: false)
  116960. */
  116961. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116962. }
  116963. }
  116964. declare module BABYLON {
  116965. /** @hidden */
  116966. export var layerPixelShader: {
  116967. name: string;
  116968. shader: string;
  116969. };
  116970. }
  116971. declare module BABYLON {
  116972. /** @hidden */
  116973. export var layerVertexShader: {
  116974. name: string;
  116975. shader: string;
  116976. };
  116977. }
  116978. declare module BABYLON {
  116979. /**
  116980. * This represents a full screen 2d layer.
  116981. * This can be useful to display a picture in the background of your scene for instance.
  116982. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116983. */
  116984. export class Layer {
  116985. /**
  116986. * Define the name of the layer.
  116987. */
  116988. name: string;
  116989. /**
  116990. * Define the texture the layer should display.
  116991. */
  116992. texture: Nullable<Texture>;
  116993. /**
  116994. * Is the layer in background or foreground.
  116995. */
  116996. isBackground: boolean;
  116997. /**
  116998. * Define the color of the layer (instead of texture).
  116999. */
  117000. color: Color4;
  117001. /**
  117002. * Define the scale of the layer in order to zoom in out of the texture.
  117003. */
  117004. scale: Vector2;
  117005. /**
  117006. * Define an offset for the layer in order to shift the texture.
  117007. */
  117008. offset: Vector2;
  117009. /**
  117010. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  117011. */
  117012. alphaBlendingMode: number;
  117013. /**
  117014. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  117015. * Alpha test will not mix with the background color in case of transparency.
  117016. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  117017. */
  117018. alphaTest: boolean;
  117019. /**
  117020. * Define a mask to restrict the layer to only some of the scene cameras.
  117021. */
  117022. layerMask: number;
  117023. /**
  117024. * Define the list of render target the layer is visible into.
  117025. */
  117026. renderTargetTextures: RenderTargetTexture[];
  117027. /**
  117028. * Define if the layer is only used in renderTarget or if it also
  117029. * renders in the main frame buffer of the canvas.
  117030. */
  117031. renderOnlyInRenderTargetTextures: boolean;
  117032. private _scene;
  117033. private _vertexBuffers;
  117034. private _indexBuffer;
  117035. private _effect;
  117036. private _alphaTestEffect;
  117037. /**
  117038. * An event triggered when the layer is disposed.
  117039. */
  117040. onDisposeObservable: Observable<Layer>;
  117041. private _onDisposeObserver;
  117042. /**
  117043. * Back compatibility with callback before the onDisposeObservable existed.
  117044. * The set callback will be triggered when the layer has been disposed.
  117045. */
  117046. onDispose: () => void;
  117047. /**
  117048. * An event triggered before rendering the scene
  117049. */
  117050. onBeforeRenderObservable: Observable<Layer>;
  117051. private _onBeforeRenderObserver;
  117052. /**
  117053. * Back compatibility with callback before the onBeforeRenderObservable existed.
  117054. * The set callback will be triggered just before rendering the layer.
  117055. */
  117056. onBeforeRender: () => void;
  117057. /**
  117058. * An event triggered after rendering the scene
  117059. */
  117060. onAfterRenderObservable: Observable<Layer>;
  117061. private _onAfterRenderObserver;
  117062. /**
  117063. * Back compatibility with callback before the onAfterRenderObservable existed.
  117064. * The set callback will be triggered just after rendering the layer.
  117065. */
  117066. onAfterRender: () => void;
  117067. /**
  117068. * Instantiates a new layer.
  117069. * This represents a full screen 2d layer.
  117070. * This can be useful to display a picture in the background of your scene for instance.
  117071. * @see https://www.babylonjs-playground.com/#08A2BS#1
  117072. * @param name Define the name of the layer in the scene
  117073. * @param imgUrl Define the url of the texture to display in the layer
  117074. * @param scene Define the scene the layer belongs to
  117075. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  117076. * @param color Defines a color for the layer
  117077. */
  117078. constructor(
  117079. /**
  117080. * Define the name of the layer.
  117081. */
  117082. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  117083. private _createIndexBuffer;
  117084. /** @hidden */
  117085. _rebuild(): void;
  117086. /**
  117087. * Renders the layer in the scene.
  117088. */
  117089. render(): void;
  117090. /**
  117091. * Disposes and releases the associated ressources.
  117092. */
  117093. dispose(): void;
  117094. }
  117095. }
  117096. declare module BABYLON {
  117097. /** @hidden */
  117098. export var lensFlarePixelShader: {
  117099. name: string;
  117100. shader: string;
  117101. };
  117102. }
  117103. declare module BABYLON {
  117104. /** @hidden */
  117105. export var lensFlareVertexShader: {
  117106. name: string;
  117107. shader: string;
  117108. };
  117109. }
  117110. declare module BABYLON {
  117111. /**
  117112. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117113. * It is usually composed of several `lensFlare`.
  117114. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117115. */
  117116. export class LensFlareSystem {
  117117. /**
  117118. * Define the name of the lens flare system
  117119. */
  117120. name: string;
  117121. /**
  117122. * List of lens flares used in this system.
  117123. */
  117124. lensFlares: LensFlare[];
  117125. /**
  117126. * Define a limit from the border the lens flare can be visible.
  117127. */
  117128. borderLimit: number;
  117129. /**
  117130. * Define a viewport border we do not want to see the lens flare in.
  117131. */
  117132. viewportBorder: number;
  117133. /**
  117134. * Define a predicate which could limit the list of meshes able to occlude the effect.
  117135. */
  117136. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  117137. /**
  117138. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  117139. */
  117140. layerMask: number;
  117141. /**
  117142. * Define the id of the lens flare system in the scene.
  117143. * (equal to name by default)
  117144. */
  117145. id: string;
  117146. private _scene;
  117147. private _emitter;
  117148. private _vertexBuffers;
  117149. private _indexBuffer;
  117150. private _effect;
  117151. private _positionX;
  117152. private _positionY;
  117153. private _isEnabled;
  117154. /** @hidden */
  117155. static _SceneComponentInitialization: (scene: Scene) => void;
  117156. /**
  117157. * Instantiates a lens flare system.
  117158. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117159. * It is usually composed of several `lensFlare`.
  117160. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117161. * @param name Define the name of the lens flare system in the scene
  117162. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  117163. * @param scene Define the scene the lens flare system belongs to
  117164. */
  117165. constructor(
  117166. /**
  117167. * Define the name of the lens flare system
  117168. */
  117169. name: string, emitter: any, scene: Scene);
  117170. /**
  117171. * Define if the lens flare system is enabled.
  117172. */
  117173. isEnabled: boolean;
  117174. /**
  117175. * Get the scene the effects belongs to.
  117176. * @returns the scene holding the lens flare system
  117177. */
  117178. getScene(): Scene;
  117179. /**
  117180. * Get the emitter of the lens flare system.
  117181. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117182. * @returns the emitter of the lens flare system
  117183. */
  117184. getEmitter(): any;
  117185. /**
  117186. * Set the emitter of the lens flare system.
  117187. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117188. * @param newEmitter Define the new emitter of the system
  117189. */
  117190. setEmitter(newEmitter: any): void;
  117191. /**
  117192. * Get the lens flare system emitter position.
  117193. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  117194. * @returns the position
  117195. */
  117196. getEmitterPosition(): Vector3;
  117197. /**
  117198. * @hidden
  117199. */
  117200. computeEffectivePosition(globalViewport: Viewport): boolean;
  117201. /** @hidden */
  117202. _isVisible(): boolean;
  117203. /**
  117204. * @hidden
  117205. */
  117206. render(): boolean;
  117207. /**
  117208. * Dispose and release the lens flare with its associated resources.
  117209. */
  117210. dispose(): void;
  117211. /**
  117212. * Parse a lens flare system from a JSON repressentation
  117213. * @param parsedLensFlareSystem Define the JSON to parse
  117214. * @param scene Define the scene the parsed system should be instantiated in
  117215. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  117216. * @returns the parsed system
  117217. */
  117218. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  117219. /**
  117220. * Serialize the current Lens Flare System into a JSON representation.
  117221. * @returns the serialized JSON
  117222. */
  117223. serialize(): any;
  117224. }
  117225. }
  117226. declare module BABYLON {
  117227. /**
  117228. * This represents one of the lens effect in a `lensFlareSystem`.
  117229. * It controls one of the indiviual texture used in the effect.
  117230. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117231. */
  117232. export class LensFlare {
  117233. /**
  117234. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117235. */
  117236. size: number;
  117237. /**
  117238. * 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.
  117239. */
  117240. position: number;
  117241. /**
  117242. * Define the lens color.
  117243. */
  117244. color: Color3;
  117245. /**
  117246. * Define the lens texture.
  117247. */
  117248. texture: Nullable<Texture>;
  117249. /**
  117250. * Define the alpha mode to render this particular lens.
  117251. */
  117252. alphaMode: number;
  117253. private _system;
  117254. /**
  117255. * Creates a new Lens Flare.
  117256. * This represents one of the lens effect in a `lensFlareSystem`.
  117257. * It controls one of the indiviual texture used in the effect.
  117258. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117259. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  117260. * @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.
  117261. * @param color Define the lens color
  117262. * @param imgUrl Define the lens texture url
  117263. * @param system Define the `lensFlareSystem` this flare is part of
  117264. * @returns The newly created Lens Flare
  117265. */
  117266. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  117267. /**
  117268. * Instantiates a new Lens Flare.
  117269. * This represents one of the lens effect in a `lensFlareSystem`.
  117270. * It controls one of the indiviual texture used in the effect.
  117271. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117272. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  117273. * @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.
  117274. * @param color Define the lens color
  117275. * @param imgUrl Define the lens texture url
  117276. * @param system Define the `lensFlareSystem` this flare is part of
  117277. */
  117278. constructor(
  117279. /**
  117280. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117281. */
  117282. size: number,
  117283. /**
  117284. * 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.
  117285. */
  117286. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  117287. /**
  117288. * Dispose and release the lens flare with its associated resources.
  117289. */
  117290. dispose(): void;
  117291. }
  117292. }
  117293. declare module BABYLON {
  117294. interface AbstractScene {
  117295. /**
  117296. * The list of lens flare system added to the scene
  117297. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117298. */
  117299. lensFlareSystems: Array<LensFlareSystem>;
  117300. /**
  117301. * Removes the given lens flare system from this scene.
  117302. * @param toRemove The lens flare system to remove
  117303. * @returns The index of the removed lens flare system
  117304. */
  117305. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  117306. /**
  117307. * Adds the given lens flare system to this scene
  117308. * @param newLensFlareSystem The lens flare system to add
  117309. */
  117310. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  117311. /**
  117312. * Gets a lens flare system using its name
  117313. * @param name defines the name to look for
  117314. * @returns the lens flare system or null if not found
  117315. */
  117316. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  117317. /**
  117318. * Gets a lens flare system using its id
  117319. * @param id defines the id to look for
  117320. * @returns the lens flare system or null if not found
  117321. */
  117322. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  117323. }
  117324. /**
  117325. * Defines the lens flare scene component responsible to manage any lens flares
  117326. * in a given scene.
  117327. */
  117328. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  117329. /**
  117330. * The component name helpfull to identify the component in the list of scene components.
  117331. */
  117332. readonly name: string;
  117333. /**
  117334. * The scene the component belongs to.
  117335. */
  117336. scene: Scene;
  117337. /**
  117338. * Creates a new instance of the component for the given scene
  117339. * @param scene Defines the scene to register the component in
  117340. */
  117341. constructor(scene: Scene);
  117342. /**
  117343. * Registers the component in a given scene
  117344. */
  117345. register(): void;
  117346. /**
  117347. * Rebuilds the elements related to this component in case of
  117348. * context lost for instance.
  117349. */
  117350. rebuild(): void;
  117351. /**
  117352. * Adds all the elements from the container to the scene
  117353. * @param container the container holding the elements
  117354. */
  117355. addFromContainer(container: AbstractScene): void;
  117356. /**
  117357. * Removes all the elements in the container from the scene
  117358. * @param container contains the elements to remove
  117359. * @param dispose if the removed element should be disposed (default: false)
  117360. */
  117361. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117362. /**
  117363. * Serializes the component data to the specified json object
  117364. * @param serializationObject The object to serialize to
  117365. */
  117366. serialize(serializationObject: any): void;
  117367. /**
  117368. * Disposes the component and the associated ressources.
  117369. */
  117370. dispose(): void;
  117371. private _draw;
  117372. }
  117373. }
  117374. declare module BABYLON {
  117375. /**
  117376. * Defines the shadow generator component responsible to manage any shadow generators
  117377. * in a given scene.
  117378. */
  117379. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  117380. /**
  117381. * The component name helpfull to identify the component in the list of scene components.
  117382. */
  117383. readonly name: string;
  117384. /**
  117385. * The scene the component belongs to.
  117386. */
  117387. scene: Scene;
  117388. /**
  117389. * Creates a new instance of the component for the given scene
  117390. * @param scene Defines the scene to register the component in
  117391. */
  117392. constructor(scene: Scene);
  117393. /**
  117394. * Registers the component in a given scene
  117395. */
  117396. register(): void;
  117397. /**
  117398. * Rebuilds the elements related to this component in case of
  117399. * context lost for instance.
  117400. */
  117401. rebuild(): void;
  117402. /**
  117403. * Serializes the component data to the specified json object
  117404. * @param serializationObject The object to serialize to
  117405. */
  117406. serialize(serializationObject: any): void;
  117407. /**
  117408. * Adds all the elements from the container to the scene
  117409. * @param container the container holding the elements
  117410. */
  117411. addFromContainer(container: AbstractScene): void;
  117412. /**
  117413. * Removes all the elements in the container from the scene
  117414. * @param container contains the elements to remove
  117415. * @param dispose if the removed element should be disposed (default: false)
  117416. */
  117417. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117418. /**
  117419. * Rebuilds the elements related to this component in case of
  117420. * context lost for instance.
  117421. */
  117422. dispose(): void;
  117423. private _gatherRenderTargets;
  117424. }
  117425. }
  117426. declare module BABYLON {
  117427. /**
  117428. * A point light is a light defined by an unique point in world space.
  117429. * The light is emitted in every direction from this point.
  117430. * A good example of a point light is a standard light bulb.
  117431. * Documentation: https://doc.babylonjs.com/babylon101/lights
  117432. */
  117433. export class PointLight extends ShadowLight {
  117434. private _shadowAngle;
  117435. /**
  117436. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117437. * This specifies what angle the shadow will use to be created.
  117438. *
  117439. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117440. */
  117441. /**
  117442. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117443. * This specifies what angle the shadow will use to be created.
  117444. *
  117445. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117446. */
  117447. shadowAngle: number;
  117448. /**
  117449. * Gets the direction if it has been set.
  117450. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117451. */
  117452. /**
  117453. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117454. */
  117455. direction: Vector3;
  117456. /**
  117457. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  117458. * A PointLight emits the light in every direction.
  117459. * It can cast shadows.
  117460. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  117461. * ```javascript
  117462. * var pointLight = new PointLight("pl", camera.position, scene);
  117463. * ```
  117464. * Documentation : https://doc.babylonjs.com/babylon101/lights
  117465. * @param name The light friendly name
  117466. * @param position The position of the point light in the scene
  117467. * @param scene The scene the lights belongs to
  117468. */
  117469. constructor(name: string, position: Vector3, scene: Scene);
  117470. /**
  117471. * Returns the string "PointLight"
  117472. * @returns the class name
  117473. */
  117474. getClassName(): string;
  117475. /**
  117476. * Returns the integer 0.
  117477. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  117478. */
  117479. getTypeID(): number;
  117480. /**
  117481. * Specifies wether or not the shadowmap should be a cube texture.
  117482. * @returns true if the shadowmap needs to be a cube texture.
  117483. */
  117484. needCube(): boolean;
  117485. /**
  117486. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  117487. * @param faceIndex The index of the face we are computed the direction to generate shadow
  117488. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  117489. */
  117490. getShadowDirection(faceIndex?: number): Vector3;
  117491. /**
  117492. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  117493. * - fov = PI / 2
  117494. * - aspect ratio : 1.0
  117495. * - z-near and far equal to the active camera minZ and maxZ.
  117496. * Returns the PointLight.
  117497. */
  117498. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  117499. protected _buildUniformLayout(): void;
  117500. /**
  117501. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  117502. * @param effect The effect to update
  117503. * @param lightIndex The index of the light in the effect to update
  117504. * @returns The point light
  117505. */
  117506. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  117507. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  117508. /**
  117509. * Prepares the list of defines specific to the light type.
  117510. * @param defines the list of defines
  117511. * @param lightIndex defines the index of the light for the effect
  117512. */
  117513. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  117514. }
  117515. }
  117516. declare module BABYLON {
  117517. /**
  117518. * Header information of HDR texture files.
  117519. */
  117520. export interface HDRInfo {
  117521. /**
  117522. * The height of the texture in pixels.
  117523. */
  117524. height: number;
  117525. /**
  117526. * The width of the texture in pixels.
  117527. */
  117528. width: number;
  117529. /**
  117530. * The index of the beginning of the data in the binary file.
  117531. */
  117532. dataPosition: number;
  117533. }
  117534. /**
  117535. * This groups tools to convert HDR texture to native colors array.
  117536. */
  117537. export class HDRTools {
  117538. private static Ldexp;
  117539. private static Rgbe2float;
  117540. private static readStringLine;
  117541. /**
  117542. * Reads header information from an RGBE texture stored in a native array.
  117543. * More information on this format are available here:
  117544. * https://en.wikipedia.org/wiki/RGBE_image_format
  117545. *
  117546. * @param uint8array The binary file stored in native array.
  117547. * @return The header information.
  117548. */
  117549. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  117550. /**
  117551. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  117552. * This RGBE texture needs to store the information as a panorama.
  117553. *
  117554. * More information on this format are available here:
  117555. * https://en.wikipedia.org/wiki/RGBE_image_format
  117556. *
  117557. * @param buffer The binary file stored in an array buffer.
  117558. * @param size The expected size of the extracted cubemap.
  117559. * @return The Cube Map information.
  117560. */
  117561. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  117562. /**
  117563. * Returns the pixels data extracted from an RGBE texture.
  117564. * This pixels will be stored left to right up to down in the R G B order in one array.
  117565. *
  117566. * More information on this format are available here:
  117567. * https://en.wikipedia.org/wiki/RGBE_image_format
  117568. *
  117569. * @param uint8array The binary file stored in an array buffer.
  117570. * @param hdrInfo The header information of the file.
  117571. * @return The pixels data in RGB right to left up to down order.
  117572. */
  117573. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  117574. private static RGBE_ReadPixels_RLE;
  117575. }
  117576. }
  117577. declare module BABYLON {
  117578. /**
  117579. * This represents a texture coming from an HDR input.
  117580. *
  117581. * The only supported format is currently panorama picture stored in RGBE format.
  117582. * Example of such files can be found on HDRLib: http://hdrlib.com/
  117583. */
  117584. export class HDRCubeTexture extends BaseTexture {
  117585. private static _facesMapping;
  117586. private _generateHarmonics;
  117587. private _noMipmap;
  117588. private _textureMatrix;
  117589. private _size;
  117590. private _onLoad;
  117591. private _onError;
  117592. /**
  117593. * The texture URL.
  117594. */
  117595. url: string;
  117596. /**
  117597. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  117598. */
  117599. coordinatesMode: number;
  117600. protected _isBlocking: boolean;
  117601. /**
  117602. * Sets wether or not the texture is blocking during loading.
  117603. */
  117604. /**
  117605. * Gets wether or not the texture is blocking during loading.
  117606. */
  117607. isBlocking: boolean;
  117608. protected _rotationY: number;
  117609. /**
  117610. * Sets texture matrix rotation angle around Y axis in radians.
  117611. */
  117612. /**
  117613. * Gets texture matrix rotation angle around Y axis radians.
  117614. */
  117615. rotationY: number;
  117616. /**
  117617. * Gets or sets the center of the bounding box associated with the cube texture
  117618. * It must define where the camera used to render the texture was set
  117619. */
  117620. boundingBoxPosition: Vector3;
  117621. private _boundingBoxSize;
  117622. /**
  117623. * Gets or sets the size of the bounding box associated with the cube texture
  117624. * When defined, the cubemap will switch to local mode
  117625. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  117626. * @example https://www.babylonjs-playground.com/#RNASML
  117627. */
  117628. boundingBoxSize: Vector3;
  117629. /**
  117630. * Instantiates an HDRTexture from the following parameters.
  117631. *
  117632. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  117633. * @param scene The scene the texture will be used in
  117634. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117635. * @param noMipmap Forces to not generate the mipmap if true
  117636. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  117637. * @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)
  117638. * @param reserved Reserved flag for internal use.
  117639. */
  117640. 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>);
  117641. /**
  117642. * Get the current class name of the texture useful for serialization or dynamic coding.
  117643. * @returns "HDRCubeTexture"
  117644. */
  117645. getClassName(): string;
  117646. /**
  117647. * Occurs when the file is raw .hdr file.
  117648. */
  117649. private loadTexture;
  117650. clone(): HDRCubeTexture;
  117651. delayLoad(): void;
  117652. /**
  117653. * Get the texture reflection matrix used to rotate/transform the reflection.
  117654. * @returns the reflection matrix
  117655. */
  117656. getReflectionTextureMatrix(): Matrix;
  117657. /**
  117658. * Set the texture reflection matrix used to rotate/transform the reflection.
  117659. * @param value Define the reflection matrix to set
  117660. */
  117661. setReflectionTextureMatrix(value: Matrix): void;
  117662. /**
  117663. * Parses a JSON representation of an HDR Texture in order to create the texture
  117664. * @param parsedTexture Define the JSON representation
  117665. * @param scene Define the scene the texture should be created in
  117666. * @param rootUrl Define the root url in case we need to load relative dependencies
  117667. * @returns the newly created texture after parsing
  117668. */
  117669. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  117670. serialize(): any;
  117671. }
  117672. }
  117673. declare module BABYLON {
  117674. /**
  117675. * Class used to control physics engine
  117676. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117677. */
  117678. export class PhysicsEngine implements IPhysicsEngine {
  117679. private _physicsPlugin;
  117680. /**
  117681. * Global value used to control the smallest number supported by the simulation
  117682. */
  117683. static Epsilon: number;
  117684. private _impostors;
  117685. private _joints;
  117686. /**
  117687. * Gets the gravity vector used by the simulation
  117688. */
  117689. gravity: Vector3;
  117690. /**
  117691. * Factory used to create the default physics plugin.
  117692. * @returns The default physics plugin
  117693. */
  117694. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  117695. /**
  117696. * Creates a new Physics Engine
  117697. * @param gravity defines the gravity vector used by the simulation
  117698. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  117699. */
  117700. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  117701. /**
  117702. * Sets the gravity vector used by the simulation
  117703. * @param gravity defines the gravity vector to use
  117704. */
  117705. setGravity(gravity: Vector3): void;
  117706. /**
  117707. * Set the time step of the physics engine.
  117708. * Default is 1/60.
  117709. * To slow it down, enter 1/600 for example.
  117710. * To speed it up, 1/30
  117711. * @param newTimeStep defines the new timestep to apply to this world.
  117712. */
  117713. setTimeStep(newTimeStep?: number): void;
  117714. /**
  117715. * Get the time step of the physics engine.
  117716. * @returns the current time step
  117717. */
  117718. getTimeStep(): number;
  117719. /**
  117720. * Release all resources
  117721. */
  117722. dispose(): void;
  117723. /**
  117724. * Gets the name of the current physics plugin
  117725. * @returns the name of the plugin
  117726. */
  117727. getPhysicsPluginName(): string;
  117728. /**
  117729. * Adding a new impostor for the impostor tracking.
  117730. * This will be done by the impostor itself.
  117731. * @param impostor the impostor to add
  117732. */
  117733. addImpostor(impostor: PhysicsImpostor): void;
  117734. /**
  117735. * Remove an impostor from the engine.
  117736. * This impostor and its mesh will not longer be updated by the physics engine.
  117737. * @param impostor the impostor to remove
  117738. */
  117739. removeImpostor(impostor: PhysicsImpostor): void;
  117740. /**
  117741. * Add a joint to the physics engine
  117742. * @param mainImpostor defines the main impostor to which the joint is added.
  117743. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  117744. * @param joint defines the joint that will connect both impostors.
  117745. */
  117746. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117747. /**
  117748. * Removes a joint from the simulation
  117749. * @param mainImpostor defines the impostor used with the joint
  117750. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  117751. * @param joint defines the joint to remove
  117752. */
  117753. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117754. /**
  117755. * Called by the scene. No need to call it.
  117756. * @param delta defines the timespam between frames
  117757. */
  117758. _step(delta: number): void;
  117759. /**
  117760. * Gets the current plugin used to run the simulation
  117761. * @returns current plugin
  117762. */
  117763. getPhysicsPlugin(): IPhysicsEnginePlugin;
  117764. /**
  117765. * Gets the list of physic impostors
  117766. * @returns an array of PhysicsImpostor
  117767. */
  117768. getImpostors(): Array<PhysicsImpostor>;
  117769. /**
  117770. * Gets the impostor for a physics enabled object
  117771. * @param object defines the object impersonated by the impostor
  117772. * @returns the PhysicsImpostor or null if not found
  117773. */
  117774. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  117775. /**
  117776. * Gets the impostor for a physics body object
  117777. * @param body defines physics body used by the impostor
  117778. * @returns the PhysicsImpostor or null if not found
  117779. */
  117780. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  117781. /**
  117782. * Does a raycast in the physics world
  117783. * @param from when should the ray start?
  117784. * @param to when should the ray end?
  117785. * @returns PhysicsRaycastResult
  117786. */
  117787. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117788. }
  117789. }
  117790. declare module BABYLON {
  117791. /** @hidden */
  117792. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  117793. private _useDeltaForWorldStep;
  117794. world: any;
  117795. name: string;
  117796. private _physicsMaterials;
  117797. private _fixedTimeStep;
  117798. private _cannonRaycastResult;
  117799. private _raycastResult;
  117800. private _physicsBodysToRemoveAfterStep;
  117801. BJSCANNON: any;
  117802. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  117803. setGravity(gravity: Vector3): void;
  117804. setTimeStep(timeStep: number): void;
  117805. getTimeStep(): number;
  117806. executeStep(delta: number): void;
  117807. private _removeMarkedPhysicsBodiesFromWorld;
  117808. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117809. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117810. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117811. private _processChildMeshes;
  117812. removePhysicsBody(impostor: PhysicsImpostor): void;
  117813. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117814. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117815. private _addMaterial;
  117816. private _checkWithEpsilon;
  117817. private _createShape;
  117818. private _createHeightmap;
  117819. private _minus90X;
  117820. private _plus90X;
  117821. private _tmpPosition;
  117822. private _tmpDeltaPosition;
  117823. private _tmpUnityRotation;
  117824. private _updatePhysicsBodyTransformation;
  117825. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117826. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117827. isSupported(): boolean;
  117828. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117829. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117830. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117831. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117832. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117833. getBodyMass(impostor: PhysicsImpostor): number;
  117834. getBodyFriction(impostor: PhysicsImpostor): number;
  117835. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117836. getBodyRestitution(impostor: PhysicsImpostor): number;
  117837. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117838. sleepBody(impostor: PhysicsImpostor): void;
  117839. wakeUpBody(impostor: PhysicsImpostor): void;
  117840. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  117841. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  117842. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  117843. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117844. getRadius(impostor: PhysicsImpostor): number;
  117845. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117846. dispose(): void;
  117847. private _extendNamespace;
  117848. /**
  117849. * Does a raycast in the physics world
  117850. * @param from when should the ray start?
  117851. * @param to when should the ray end?
  117852. * @returns PhysicsRaycastResult
  117853. */
  117854. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117855. }
  117856. }
  117857. declare module BABYLON {
  117858. /** @hidden */
  117859. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  117860. world: any;
  117861. name: string;
  117862. BJSOIMO: any;
  117863. private _raycastResult;
  117864. constructor(iterations?: number, oimoInjection?: any);
  117865. setGravity(gravity: Vector3): void;
  117866. setTimeStep(timeStep: number): void;
  117867. getTimeStep(): number;
  117868. private _tmpImpostorsArray;
  117869. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117870. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117871. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117872. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117873. private _tmpPositionVector;
  117874. removePhysicsBody(impostor: PhysicsImpostor): void;
  117875. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117876. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117877. isSupported(): boolean;
  117878. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117879. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117880. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117881. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117882. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117883. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117884. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117885. getBodyMass(impostor: PhysicsImpostor): number;
  117886. getBodyFriction(impostor: PhysicsImpostor): number;
  117887. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117888. getBodyRestitution(impostor: PhysicsImpostor): number;
  117889. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117890. sleepBody(impostor: PhysicsImpostor): void;
  117891. wakeUpBody(impostor: PhysicsImpostor): void;
  117892. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  117893. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  117894. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  117895. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117896. getRadius(impostor: PhysicsImpostor): number;
  117897. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117898. dispose(): void;
  117899. /**
  117900. * Does a raycast in the physics world
  117901. * @param from when should the ray start?
  117902. * @param to when should the ray end?
  117903. * @returns PhysicsRaycastResult
  117904. */
  117905. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117906. }
  117907. }
  117908. declare module BABYLON {
  117909. /**
  117910. * Class containing static functions to help procedurally build meshes
  117911. */
  117912. export class RibbonBuilder {
  117913. /**
  117914. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117915. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  117916. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  117917. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  117918. * * 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
  117919. * * 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
  117920. * * 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
  117921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117922. * * 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
  117923. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117924. * * 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
  117925. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  117926. * * 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
  117927. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  117928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117929. * @param name defines the name of the mesh
  117930. * @param options defines the options used to create the mesh
  117931. * @param scene defines the hosting scene
  117932. * @returns the ribbon mesh
  117933. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  117934. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117935. */
  117936. static CreateRibbon(name: string, options: {
  117937. pathArray: Vector3[][];
  117938. closeArray?: boolean;
  117939. closePath?: boolean;
  117940. offset?: number;
  117941. updatable?: boolean;
  117942. sideOrientation?: number;
  117943. frontUVs?: Vector4;
  117944. backUVs?: Vector4;
  117945. instance?: Mesh;
  117946. invertUV?: boolean;
  117947. uvs?: Vector2[];
  117948. colors?: Color4[];
  117949. }, scene?: Nullable<Scene>): Mesh;
  117950. }
  117951. }
  117952. declare module BABYLON {
  117953. /**
  117954. * Class containing static functions to help procedurally build meshes
  117955. */
  117956. export class ShapeBuilder {
  117957. /**
  117958. * 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.
  117959. * * 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.
  117960. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117961. * * 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.
  117962. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  117963. * * 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
  117964. * * 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
  117965. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  117966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117967. * * 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
  117968. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  117969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117970. * @param name defines the name of the mesh
  117971. * @param options defines the options used to create the mesh
  117972. * @param scene defines the hosting scene
  117973. * @returns the extruded shape mesh
  117974. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117975. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117976. */
  117977. static ExtrudeShape(name: string, options: {
  117978. shape: Vector3[];
  117979. path: Vector3[];
  117980. scale?: number;
  117981. rotation?: number;
  117982. cap?: number;
  117983. updatable?: boolean;
  117984. sideOrientation?: number;
  117985. frontUVs?: Vector4;
  117986. backUVs?: Vector4;
  117987. instance?: Mesh;
  117988. invertUV?: boolean;
  117989. }, scene?: Nullable<Scene>): Mesh;
  117990. /**
  117991. * Creates an custom extruded shape mesh.
  117992. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  117993. * * 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.
  117994. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117995. * * 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
  117996. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  117997. * * 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
  117998. * * It must returns a float value that will be the scale value applied to the shape on each path point
  117999. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  118000. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  118001. * * 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
  118002. * * 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
  118003. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  118004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118005. * * 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
  118006. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118008. * @param name defines the name of the mesh
  118009. * @param options defines the options used to create the mesh
  118010. * @param scene defines the hosting scene
  118011. * @returns the custom extruded shape mesh
  118012. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  118013. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118014. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118015. */
  118016. static ExtrudeShapeCustom(name: string, options: {
  118017. shape: Vector3[];
  118018. path: Vector3[];
  118019. scaleFunction?: any;
  118020. rotationFunction?: any;
  118021. ribbonCloseArray?: boolean;
  118022. ribbonClosePath?: boolean;
  118023. cap?: number;
  118024. updatable?: boolean;
  118025. sideOrientation?: number;
  118026. frontUVs?: Vector4;
  118027. backUVs?: Vector4;
  118028. instance?: Mesh;
  118029. invertUV?: boolean;
  118030. }, scene?: Nullable<Scene>): Mesh;
  118031. private static _ExtrudeShapeGeneric;
  118032. }
  118033. }
  118034. declare module BABYLON {
  118035. /**
  118036. * AmmoJS Physics plugin
  118037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118038. * @see https://github.com/kripken/ammo.js/
  118039. */
  118040. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  118041. private _useDeltaForWorldStep;
  118042. /**
  118043. * Reference to the Ammo library
  118044. */
  118045. bjsAMMO: any;
  118046. /**
  118047. * Created ammoJS world which physics bodies are added to
  118048. */
  118049. world: any;
  118050. /**
  118051. * Name of the plugin
  118052. */
  118053. name: string;
  118054. private _timeStep;
  118055. private _fixedTimeStep;
  118056. private _maxSteps;
  118057. private _tmpQuaternion;
  118058. private _tmpAmmoTransform;
  118059. private _tmpAmmoQuaternion;
  118060. private _tmpAmmoConcreteContactResultCallback;
  118061. private _collisionConfiguration;
  118062. private _dispatcher;
  118063. private _overlappingPairCache;
  118064. private _solver;
  118065. private _softBodySolver;
  118066. private _tmpAmmoVectorA;
  118067. private _tmpAmmoVectorB;
  118068. private _tmpAmmoVectorC;
  118069. private _tmpAmmoVectorD;
  118070. private _tmpContactCallbackResult;
  118071. private _tmpAmmoVectorRCA;
  118072. private _tmpAmmoVectorRCB;
  118073. private _raycastResult;
  118074. private static readonly DISABLE_COLLISION_FLAG;
  118075. private static readonly KINEMATIC_FLAG;
  118076. private static readonly DISABLE_DEACTIVATION_FLAG;
  118077. /**
  118078. * Initializes the ammoJS plugin
  118079. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  118080. * @param ammoInjection can be used to inject your own ammo reference
  118081. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  118082. */
  118083. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  118084. /**
  118085. * Sets the gravity of the physics world (m/(s^2))
  118086. * @param gravity Gravity to set
  118087. */
  118088. setGravity(gravity: Vector3): void;
  118089. /**
  118090. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  118091. * @param timeStep timestep to use in seconds
  118092. */
  118093. setTimeStep(timeStep: number): void;
  118094. /**
  118095. * 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)
  118096. * @param fixedTimeStep fixedTimeStep to use in seconds
  118097. */
  118098. setFixedTimeStep(fixedTimeStep: number): void;
  118099. /**
  118100. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  118101. * @param maxSteps the maximum number of steps by the physics engine per frame
  118102. */
  118103. setMaxSteps(maxSteps: number): void;
  118104. /**
  118105. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  118106. * @returns the current timestep in seconds
  118107. */
  118108. getTimeStep(): number;
  118109. private _isImpostorInContact;
  118110. private _isImpostorPairInContact;
  118111. private _stepSimulation;
  118112. /**
  118113. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  118114. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  118115. * After the step the babylon meshes are set to the position of the physics imposters
  118116. * @param delta amount of time to step forward
  118117. * @param impostors array of imposters to update before/after the step
  118118. */
  118119. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  118120. /**
  118121. * Update babylon mesh to match physics world object
  118122. * @param impostor imposter to match
  118123. */
  118124. private _afterSoftStep;
  118125. /**
  118126. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118127. * @param impostor imposter to match
  118128. */
  118129. private _ropeStep;
  118130. /**
  118131. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118132. * @param impostor imposter to match
  118133. */
  118134. private _softbodyOrClothStep;
  118135. private _tmpVector;
  118136. private _tmpMatrix;
  118137. /**
  118138. * Applies an impulse on the imposter
  118139. * @param impostor imposter to apply impulse to
  118140. * @param force amount of force to be applied to the imposter
  118141. * @param contactPoint the location to apply the impulse on the imposter
  118142. */
  118143. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118144. /**
  118145. * Applies a force on the imposter
  118146. * @param impostor imposter to apply force
  118147. * @param force amount of force to be applied to the imposter
  118148. * @param contactPoint the location to apply the force on the imposter
  118149. */
  118150. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118151. /**
  118152. * Creates a physics body using the plugin
  118153. * @param impostor the imposter to create the physics body on
  118154. */
  118155. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118156. /**
  118157. * Removes the physics body from the imposter and disposes of the body's memory
  118158. * @param impostor imposter to remove the physics body from
  118159. */
  118160. removePhysicsBody(impostor: PhysicsImpostor): void;
  118161. /**
  118162. * Generates a joint
  118163. * @param impostorJoint the imposter joint to create the joint with
  118164. */
  118165. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118166. /**
  118167. * Removes a joint
  118168. * @param impostorJoint the imposter joint to remove the joint from
  118169. */
  118170. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118171. private _addMeshVerts;
  118172. /**
  118173. * Initialise the soft body vertices to match its object's (mesh) vertices
  118174. * Softbody vertices (nodes) are in world space and to match this
  118175. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  118176. * @param impostor to create the softbody for
  118177. */
  118178. private _softVertexData;
  118179. /**
  118180. * Create an impostor's soft body
  118181. * @param impostor to create the softbody for
  118182. */
  118183. private _createSoftbody;
  118184. /**
  118185. * Create cloth for an impostor
  118186. * @param impostor to create the softbody for
  118187. */
  118188. private _createCloth;
  118189. /**
  118190. * Create rope for an impostor
  118191. * @param impostor to create the softbody for
  118192. */
  118193. private _createRope;
  118194. private _addHullVerts;
  118195. private _createShape;
  118196. /**
  118197. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  118198. * @param impostor imposter containing the physics body and babylon object
  118199. */
  118200. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118201. /**
  118202. * Sets the babylon object's position/rotation from the physics body's position/rotation
  118203. * @param impostor imposter containing the physics body and babylon object
  118204. * @param newPosition new position
  118205. * @param newRotation new rotation
  118206. */
  118207. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118208. /**
  118209. * If this plugin is supported
  118210. * @returns true if its supported
  118211. */
  118212. isSupported(): boolean;
  118213. /**
  118214. * Sets the linear velocity of the physics body
  118215. * @param impostor imposter to set the velocity on
  118216. * @param velocity velocity to set
  118217. */
  118218. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118219. /**
  118220. * Sets the angular velocity of the physics body
  118221. * @param impostor imposter to set the velocity on
  118222. * @param velocity velocity to set
  118223. */
  118224. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118225. /**
  118226. * gets the linear velocity
  118227. * @param impostor imposter to get linear velocity from
  118228. * @returns linear velocity
  118229. */
  118230. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118231. /**
  118232. * gets the angular velocity
  118233. * @param impostor imposter to get angular velocity from
  118234. * @returns angular velocity
  118235. */
  118236. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118237. /**
  118238. * Sets the mass of physics body
  118239. * @param impostor imposter to set the mass on
  118240. * @param mass mass to set
  118241. */
  118242. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118243. /**
  118244. * Gets the mass of the physics body
  118245. * @param impostor imposter to get the mass from
  118246. * @returns mass
  118247. */
  118248. getBodyMass(impostor: PhysicsImpostor): number;
  118249. /**
  118250. * Gets friction of the impostor
  118251. * @param impostor impostor to get friction from
  118252. * @returns friction value
  118253. */
  118254. getBodyFriction(impostor: PhysicsImpostor): number;
  118255. /**
  118256. * Sets friction of the impostor
  118257. * @param impostor impostor to set friction on
  118258. * @param friction friction value
  118259. */
  118260. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118261. /**
  118262. * Gets restitution of the impostor
  118263. * @param impostor impostor to get restitution from
  118264. * @returns restitution value
  118265. */
  118266. getBodyRestitution(impostor: PhysicsImpostor): number;
  118267. /**
  118268. * Sets resitution of the impostor
  118269. * @param impostor impostor to set resitution on
  118270. * @param restitution resitution value
  118271. */
  118272. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118273. /**
  118274. * Gets pressure inside the impostor
  118275. * @param impostor impostor to get pressure from
  118276. * @returns pressure value
  118277. */
  118278. getBodyPressure(impostor: PhysicsImpostor): number;
  118279. /**
  118280. * Sets pressure inside a soft body impostor
  118281. * Cloth and rope must remain 0 pressure
  118282. * @param impostor impostor to set pressure on
  118283. * @param pressure pressure value
  118284. */
  118285. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  118286. /**
  118287. * Gets stiffness of the impostor
  118288. * @param impostor impostor to get stiffness from
  118289. * @returns pressure value
  118290. */
  118291. getBodyStiffness(impostor: PhysicsImpostor): number;
  118292. /**
  118293. * Sets stiffness of the impostor
  118294. * @param impostor impostor to set stiffness on
  118295. * @param stiffness stiffness value from 0 to 1
  118296. */
  118297. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  118298. /**
  118299. * Gets velocityIterations of the impostor
  118300. * @param impostor impostor to get velocity iterations from
  118301. * @returns velocityIterations value
  118302. */
  118303. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  118304. /**
  118305. * Sets velocityIterations of the impostor
  118306. * @param impostor impostor to set velocity iterations on
  118307. * @param velocityIterations velocityIterations value
  118308. */
  118309. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  118310. /**
  118311. * Gets positionIterations of the impostor
  118312. * @param impostor impostor to get position iterations from
  118313. * @returns positionIterations value
  118314. */
  118315. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  118316. /**
  118317. * Sets positionIterations of the impostor
  118318. * @param impostor impostor to set position on
  118319. * @param positionIterations positionIterations value
  118320. */
  118321. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  118322. /**
  118323. * Append an anchor to a cloth object
  118324. * @param impostor is the cloth impostor to add anchor to
  118325. * @param otherImpostor is the rigid impostor to anchor to
  118326. * @param width ratio across width from 0 to 1
  118327. * @param height ratio up height from 0 to 1
  118328. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  118329. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118330. */
  118331. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118332. /**
  118333. * Append an hook to a rope object
  118334. * @param impostor is the rope impostor to add hook to
  118335. * @param otherImpostor is the rigid impostor to hook to
  118336. * @param length ratio along the rope from 0 to 1
  118337. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  118338. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118339. */
  118340. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118341. /**
  118342. * Sleeps the physics body and stops it from being active
  118343. * @param impostor impostor to sleep
  118344. */
  118345. sleepBody(impostor: PhysicsImpostor): void;
  118346. /**
  118347. * Activates the physics body
  118348. * @param impostor impostor to activate
  118349. */
  118350. wakeUpBody(impostor: PhysicsImpostor): void;
  118351. /**
  118352. * Updates the distance parameters of the joint
  118353. * @param joint joint to update
  118354. * @param maxDistance maximum distance of the joint
  118355. * @param minDistance minimum distance of the joint
  118356. */
  118357. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118358. /**
  118359. * Sets a motor on the joint
  118360. * @param joint joint to set motor on
  118361. * @param speed speed of the motor
  118362. * @param maxForce maximum force of the motor
  118363. * @param motorIndex index of the motor
  118364. */
  118365. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118366. /**
  118367. * Sets the motors limit
  118368. * @param joint joint to set limit on
  118369. * @param upperLimit upper limit
  118370. * @param lowerLimit lower limit
  118371. */
  118372. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118373. /**
  118374. * Syncs the position and rotation of a mesh with the impostor
  118375. * @param mesh mesh to sync
  118376. * @param impostor impostor to update the mesh with
  118377. */
  118378. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118379. /**
  118380. * Gets the radius of the impostor
  118381. * @param impostor impostor to get radius from
  118382. * @returns the radius
  118383. */
  118384. getRadius(impostor: PhysicsImpostor): number;
  118385. /**
  118386. * Gets the box size of the impostor
  118387. * @param impostor impostor to get box size from
  118388. * @param result the resulting box size
  118389. */
  118390. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118391. /**
  118392. * Disposes of the impostor
  118393. */
  118394. dispose(): void;
  118395. /**
  118396. * Does a raycast in the physics world
  118397. * @param from when should the ray start?
  118398. * @param to when should the ray end?
  118399. * @returns PhysicsRaycastResult
  118400. */
  118401. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118402. }
  118403. }
  118404. declare module BABYLON {
  118405. interface AbstractScene {
  118406. /**
  118407. * The list of reflection probes added to the scene
  118408. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118409. */
  118410. reflectionProbes: Array<ReflectionProbe>;
  118411. /**
  118412. * Removes the given reflection probe from this scene.
  118413. * @param toRemove The reflection probe to remove
  118414. * @returns The index of the removed reflection probe
  118415. */
  118416. removeReflectionProbe(toRemove: ReflectionProbe): number;
  118417. /**
  118418. * Adds the given reflection probe to this scene.
  118419. * @param newReflectionProbe The reflection probe to add
  118420. */
  118421. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  118422. }
  118423. /**
  118424. * Class used to generate realtime reflection / refraction cube textures
  118425. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118426. */
  118427. export class ReflectionProbe {
  118428. /** defines the name of the probe */
  118429. name: string;
  118430. private _scene;
  118431. private _renderTargetTexture;
  118432. private _projectionMatrix;
  118433. private _viewMatrix;
  118434. private _target;
  118435. private _add;
  118436. private _attachedMesh;
  118437. private _invertYAxis;
  118438. /** Gets or sets probe position (center of the cube map) */
  118439. position: Vector3;
  118440. /**
  118441. * Creates a new reflection probe
  118442. * @param name defines the name of the probe
  118443. * @param size defines the texture resolution (for each face)
  118444. * @param scene defines the hosting scene
  118445. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  118446. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  118447. */
  118448. constructor(
  118449. /** defines the name of the probe */
  118450. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  118451. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  118452. samples: number;
  118453. /** Gets or sets the refresh rate to use (on every frame by default) */
  118454. refreshRate: number;
  118455. /**
  118456. * Gets the hosting scene
  118457. * @returns a Scene
  118458. */
  118459. getScene(): Scene;
  118460. /** Gets the internal CubeTexture used to render to */
  118461. readonly cubeTexture: RenderTargetTexture;
  118462. /** Gets the list of meshes to render */
  118463. readonly renderList: Nullable<AbstractMesh[]>;
  118464. /**
  118465. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  118466. * @param mesh defines the mesh to attach to
  118467. */
  118468. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118469. /**
  118470. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  118471. * @param renderingGroupId The rendering group id corresponding to its index
  118472. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118473. */
  118474. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  118475. /**
  118476. * Clean all associated resources
  118477. */
  118478. dispose(): void;
  118479. /**
  118480. * Converts the reflection probe information to a readable string for debug purpose.
  118481. * @param fullDetails Supports for multiple levels of logging within scene loading
  118482. * @returns the human readable reflection probe info
  118483. */
  118484. toString(fullDetails?: boolean): string;
  118485. /**
  118486. * Get the class name of the relfection probe.
  118487. * @returns "ReflectionProbe"
  118488. */
  118489. getClassName(): string;
  118490. /**
  118491. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  118492. * @returns The JSON representation of the texture
  118493. */
  118494. serialize(): any;
  118495. /**
  118496. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  118497. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  118498. * @param scene Define the scene the parsed reflection probe should be instantiated in
  118499. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  118500. * @returns The parsed reflection probe if successful
  118501. */
  118502. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  118503. }
  118504. }
  118505. declare module BABYLON {
  118506. /** @hidden */
  118507. export var _BabylonLoaderRegistered: boolean;
  118508. }
  118509. declare module BABYLON {
  118510. /**
  118511. * The Physically based simple base material of BJS.
  118512. *
  118513. * This enables better naming and convention enforcements on top of the pbrMaterial.
  118514. * It is used as the base class for both the specGloss and metalRough conventions.
  118515. */
  118516. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  118517. /**
  118518. * Number of Simultaneous lights allowed on the material.
  118519. */
  118520. maxSimultaneousLights: number;
  118521. /**
  118522. * If sets to true, disables all the lights affecting the material.
  118523. */
  118524. disableLighting: boolean;
  118525. /**
  118526. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  118527. */
  118528. environmentTexture: BaseTexture;
  118529. /**
  118530. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118531. */
  118532. invertNormalMapX: boolean;
  118533. /**
  118534. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118535. */
  118536. invertNormalMapY: boolean;
  118537. /**
  118538. * Normal map used in the model.
  118539. */
  118540. normalTexture: BaseTexture;
  118541. /**
  118542. * Emissivie color used to self-illuminate the model.
  118543. */
  118544. emissiveColor: Color3;
  118545. /**
  118546. * Emissivie texture used to self-illuminate the model.
  118547. */
  118548. emissiveTexture: BaseTexture;
  118549. /**
  118550. * Occlusion Channel Strenght.
  118551. */
  118552. occlusionStrength: number;
  118553. /**
  118554. * Occlusion Texture of the material (adding extra occlusion effects).
  118555. */
  118556. occlusionTexture: BaseTexture;
  118557. /**
  118558. * Defines the alpha limits in alpha test mode.
  118559. */
  118560. alphaCutOff: number;
  118561. /**
  118562. * Gets the current double sided mode.
  118563. */
  118564. /**
  118565. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118566. */
  118567. doubleSided: boolean;
  118568. /**
  118569. * Stores the pre-calculated light information of a mesh in a texture.
  118570. */
  118571. lightmapTexture: BaseTexture;
  118572. /**
  118573. * If true, the light map contains occlusion information instead of lighting info.
  118574. */
  118575. useLightmapAsShadowmap: boolean;
  118576. /**
  118577. * Instantiates a new PBRMaterial instance.
  118578. *
  118579. * @param name The material name
  118580. * @param scene The scene the material will be use in.
  118581. */
  118582. constructor(name: string, scene: Scene);
  118583. getClassName(): string;
  118584. }
  118585. }
  118586. declare module BABYLON {
  118587. /**
  118588. * The PBR material of BJS following the metal roughness convention.
  118589. *
  118590. * This fits to the PBR convention in the GLTF definition:
  118591. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  118592. */
  118593. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  118594. /**
  118595. * The base color has two different interpretations depending on the value of metalness.
  118596. * When the material is a metal, the base color is the specific measured reflectance value
  118597. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  118598. * of the material.
  118599. */
  118600. baseColor: Color3;
  118601. /**
  118602. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  118603. * well as opacity information in the alpha channel.
  118604. */
  118605. baseTexture: BaseTexture;
  118606. /**
  118607. * Specifies the metallic scalar value of the material.
  118608. * Can also be used to scale the metalness values of the metallic texture.
  118609. */
  118610. metallic: number;
  118611. /**
  118612. * Specifies the roughness scalar value of the material.
  118613. * Can also be used to scale the roughness values of the metallic texture.
  118614. */
  118615. roughness: number;
  118616. /**
  118617. * Texture containing both the metallic value in the B channel and the
  118618. * roughness value in the G channel to keep better precision.
  118619. */
  118620. metallicRoughnessTexture: BaseTexture;
  118621. /**
  118622. * Instantiates a new PBRMetalRoughnessMaterial instance.
  118623. *
  118624. * @param name The material name
  118625. * @param scene The scene the material will be use in.
  118626. */
  118627. constructor(name: string, scene: Scene);
  118628. /**
  118629. * Return the currrent class name of the material.
  118630. */
  118631. getClassName(): string;
  118632. /**
  118633. * Makes a duplicate of the current material.
  118634. * @param name - name to use for the new material.
  118635. */
  118636. clone(name: string): PBRMetallicRoughnessMaterial;
  118637. /**
  118638. * Serialize the material to a parsable JSON object.
  118639. */
  118640. serialize(): any;
  118641. /**
  118642. * Parses a JSON object correponding to the serialize function.
  118643. */
  118644. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  118645. }
  118646. }
  118647. declare module BABYLON {
  118648. /**
  118649. * The PBR material of BJS following the specular glossiness convention.
  118650. *
  118651. * This fits to the PBR convention in the GLTF definition:
  118652. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  118653. */
  118654. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  118655. /**
  118656. * Specifies the diffuse color of the material.
  118657. */
  118658. diffuseColor: Color3;
  118659. /**
  118660. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  118661. * channel.
  118662. */
  118663. diffuseTexture: BaseTexture;
  118664. /**
  118665. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  118666. */
  118667. specularColor: Color3;
  118668. /**
  118669. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  118670. */
  118671. glossiness: number;
  118672. /**
  118673. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  118674. */
  118675. specularGlossinessTexture: BaseTexture;
  118676. /**
  118677. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  118678. *
  118679. * @param name The material name
  118680. * @param scene The scene the material will be use in.
  118681. */
  118682. constructor(name: string, scene: Scene);
  118683. /**
  118684. * Return the currrent class name of the material.
  118685. */
  118686. getClassName(): string;
  118687. /**
  118688. * Makes a duplicate of the current material.
  118689. * @param name - name to use for the new material.
  118690. */
  118691. clone(name: string): PBRSpecularGlossinessMaterial;
  118692. /**
  118693. * Serialize the material to a parsable JSON object.
  118694. */
  118695. serialize(): any;
  118696. /**
  118697. * Parses a JSON object correponding to the serialize function.
  118698. */
  118699. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  118700. }
  118701. }
  118702. declare module BABYLON {
  118703. /**
  118704. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  118705. * It can help converting any input color in a desired output one. This can then be used to create effects
  118706. * from sepia, black and white to sixties or futuristic rendering...
  118707. *
  118708. * The only supported format is currently 3dl.
  118709. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  118710. */
  118711. export class ColorGradingTexture extends BaseTexture {
  118712. /**
  118713. * The current texture matrix. (will always be identity in color grading texture)
  118714. */
  118715. private _textureMatrix;
  118716. /**
  118717. * The texture URL.
  118718. */
  118719. url: string;
  118720. /**
  118721. * Empty line regex stored for GC.
  118722. */
  118723. private static _noneEmptyLineRegex;
  118724. private _engine;
  118725. /**
  118726. * Instantiates a ColorGradingTexture from the following parameters.
  118727. *
  118728. * @param url The location of the color gradind data (currently only supporting 3dl)
  118729. * @param scene The scene the texture will be used in
  118730. */
  118731. constructor(url: string, scene: Scene);
  118732. /**
  118733. * Returns the texture matrix used in most of the material.
  118734. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  118735. */
  118736. getTextureMatrix(): Matrix;
  118737. /**
  118738. * Occurs when the file being loaded is a .3dl LUT file.
  118739. */
  118740. private load3dlTexture;
  118741. /**
  118742. * Starts the loading process of the texture.
  118743. */
  118744. private loadTexture;
  118745. /**
  118746. * Clones the color gradind texture.
  118747. */
  118748. clone(): ColorGradingTexture;
  118749. /**
  118750. * Called during delayed load for textures.
  118751. */
  118752. delayLoad(): void;
  118753. /**
  118754. * Parses a color grading texture serialized by Babylon.
  118755. * @param parsedTexture The texture information being parsedTexture
  118756. * @param scene The scene to load the texture in
  118757. * @param rootUrl The root url of the data assets to load
  118758. * @return A color gradind texture
  118759. */
  118760. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  118761. /**
  118762. * Serializes the LUT texture to json format.
  118763. */
  118764. serialize(): any;
  118765. }
  118766. }
  118767. declare module BABYLON {
  118768. /**
  118769. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  118770. */
  118771. export class EquiRectangularCubeTexture extends BaseTexture {
  118772. /** The six faces of the cube. */
  118773. private static _FacesMapping;
  118774. private _noMipmap;
  118775. private _onLoad;
  118776. private _onError;
  118777. /** The size of the cubemap. */
  118778. private _size;
  118779. /** The buffer of the image. */
  118780. private _buffer;
  118781. /** The width of the input image. */
  118782. private _width;
  118783. /** The height of the input image. */
  118784. private _height;
  118785. /** The URL to the image. */
  118786. url: string;
  118787. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  118788. coordinatesMode: number;
  118789. /**
  118790. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  118791. * @param url The location of the image
  118792. * @param scene The scene the texture will be used in
  118793. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118794. * @param noMipmap Forces to not generate the mipmap if true
  118795. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  118796. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  118797. * @param onLoad — defines a callback called when texture is loaded
  118798. * @param onError — defines a callback called if there is an error
  118799. */
  118800. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  118801. /**
  118802. * Load the image data, by putting the image on a canvas and extracting its buffer.
  118803. */
  118804. private loadImage;
  118805. /**
  118806. * Convert the image buffer into a cubemap and create a CubeTexture.
  118807. */
  118808. private loadTexture;
  118809. /**
  118810. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  118811. * @param buffer The ArrayBuffer that should be converted.
  118812. * @returns The buffer as Float32Array.
  118813. */
  118814. private getFloat32ArrayFromArrayBuffer;
  118815. /**
  118816. * Get the current class name of the texture useful for serialization or dynamic coding.
  118817. * @returns "EquiRectangularCubeTexture"
  118818. */
  118819. getClassName(): string;
  118820. /**
  118821. * Create a clone of the current EquiRectangularCubeTexture and return it.
  118822. * @returns A clone of the current EquiRectangularCubeTexture.
  118823. */
  118824. clone(): EquiRectangularCubeTexture;
  118825. }
  118826. }
  118827. declare module BABYLON {
  118828. /**
  118829. * Based on jsTGALoader - Javascript loader for TGA file
  118830. * By Vincent Thibault
  118831. * @see http://blog.robrowser.com/javascript-tga-loader.html
  118832. */
  118833. export class TGATools {
  118834. private static _TYPE_INDEXED;
  118835. private static _TYPE_RGB;
  118836. private static _TYPE_GREY;
  118837. private static _TYPE_RLE_INDEXED;
  118838. private static _TYPE_RLE_RGB;
  118839. private static _TYPE_RLE_GREY;
  118840. private static _ORIGIN_MASK;
  118841. private static _ORIGIN_SHIFT;
  118842. private static _ORIGIN_BL;
  118843. private static _ORIGIN_BR;
  118844. private static _ORIGIN_UL;
  118845. private static _ORIGIN_UR;
  118846. /**
  118847. * Gets the header of a TGA file
  118848. * @param data defines the TGA data
  118849. * @returns the header
  118850. */
  118851. static GetTGAHeader(data: Uint8Array): any;
  118852. /**
  118853. * Uploads TGA content to a Babylon Texture
  118854. * @hidden
  118855. */
  118856. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  118857. /** @hidden */
  118858. 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;
  118859. /** @hidden */
  118860. 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;
  118861. /** @hidden */
  118862. 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;
  118863. /** @hidden */
  118864. 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;
  118865. /** @hidden */
  118866. 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;
  118867. /** @hidden */
  118868. 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;
  118869. }
  118870. }
  118871. declare module BABYLON {
  118872. /**
  118873. * Implementation of the TGA Texture Loader.
  118874. * @hidden
  118875. */
  118876. export class _TGATextureLoader implements IInternalTextureLoader {
  118877. /**
  118878. * Defines wether the loader supports cascade loading the different faces.
  118879. */
  118880. readonly supportCascades: boolean;
  118881. /**
  118882. * This returns if the loader support the current file information.
  118883. * @param extension defines the file extension of the file being loaded
  118884. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118885. * @param fallback defines the fallback internal texture if any
  118886. * @param isBase64 defines whether the texture is encoded as a base64
  118887. * @param isBuffer defines whether the texture data are stored as a buffer
  118888. * @returns true if the loader can load the specified file
  118889. */
  118890. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118891. /**
  118892. * Transform the url before loading if required.
  118893. * @param rootUrl the url of the texture
  118894. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118895. * @returns the transformed texture
  118896. */
  118897. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118898. /**
  118899. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118900. * @param rootUrl the url of the texture
  118901. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118902. * @returns the fallback texture
  118903. */
  118904. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118905. /**
  118906. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118907. * @param data contains the texture data
  118908. * @param texture defines the BabylonJS internal texture
  118909. * @param createPolynomials will be true if polynomials have been requested
  118910. * @param onLoad defines the callback to trigger once the texture is ready
  118911. * @param onError defines the callback to trigger in case of error
  118912. */
  118913. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118914. /**
  118915. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118916. * @param data contains the texture data
  118917. * @param texture defines the BabylonJS internal texture
  118918. * @param callback defines the method to call once ready to upload
  118919. */
  118920. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118921. }
  118922. }
  118923. declare module BABYLON {
  118924. /**
  118925. * Info about the .basis files
  118926. */
  118927. class BasisFileInfo {
  118928. /**
  118929. * If the file has alpha
  118930. */
  118931. hasAlpha: boolean;
  118932. /**
  118933. * Info about each image of the basis file
  118934. */
  118935. images: Array<{
  118936. levels: Array<{
  118937. width: number;
  118938. height: number;
  118939. transcodedPixels: ArrayBufferView;
  118940. }>;
  118941. }>;
  118942. }
  118943. /**
  118944. * Result of transcoding a basis file
  118945. */
  118946. class TranscodeResult {
  118947. /**
  118948. * Info about the .basis file
  118949. */
  118950. fileInfo: BasisFileInfo;
  118951. /**
  118952. * Format to use when loading the file
  118953. */
  118954. format: number;
  118955. }
  118956. /**
  118957. * Configuration options for the Basis transcoder
  118958. */
  118959. export class BasisTranscodeConfiguration {
  118960. /**
  118961. * Supported compression formats used to determine the supported output format of the transcoder
  118962. */
  118963. supportedCompressionFormats?: {
  118964. /**
  118965. * etc1 compression format
  118966. */
  118967. etc1?: boolean;
  118968. /**
  118969. * s3tc compression format
  118970. */
  118971. s3tc?: boolean;
  118972. /**
  118973. * pvrtc compression format
  118974. */
  118975. pvrtc?: boolean;
  118976. /**
  118977. * etc2 compression format
  118978. */
  118979. etc2?: boolean;
  118980. };
  118981. /**
  118982. * If mipmap levels should be loaded for transcoded images (Default: true)
  118983. */
  118984. loadMipmapLevels?: boolean;
  118985. /**
  118986. * Index of a single image to load (Default: all images)
  118987. */
  118988. loadSingleImage?: number;
  118989. }
  118990. /**
  118991. * Used to load .Basis files
  118992. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  118993. */
  118994. export class BasisTools {
  118995. private static _IgnoreSupportedFormats;
  118996. /**
  118997. * URL to use when loading the basis transcoder
  118998. */
  118999. static JSModuleURL: string;
  119000. /**
  119001. * URL to use when loading the wasm module for the transcoder
  119002. */
  119003. static WasmModuleURL: string;
  119004. /**
  119005. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  119006. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  119007. * @returns internal format corresponding to the Basis format
  119008. */
  119009. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  119010. private static _WorkerPromise;
  119011. private static _Worker;
  119012. private static _actionId;
  119013. private static _CreateWorkerAsync;
  119014. /**
  119015. * Transcodes a loaded image file to compressed pixel data
  119016. * @param imageData image data to transcode
  119017. * @param config configuration options for the transcoding
  119018. * @returns a promise resulting in the transcoded image
  119019. */
  119020. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  119021. /**
  119022. * Loads a texture from the transcode result
  119023. * @param texture texture load to
  119024. * @param transcodeResult the result of transcoding the basis file to load from
  119025. */
  119026. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  119027. }
  119028. }
  119029. declare module BABYLON {
  119030. /**
  119031. * Loader for .basis file format
  119032. */
  119033. export class _BasisTextureLoader implements IInternalTextureLoader {
  119034. /**
  119035. * Defines whether the loader supports cascade loading the different faces.
  119036. */
  119037. readonly supportCascades: boolean;
  119038. /**
  119039. * This returns if the loader support the current file information.
  119040. * @param extension defines the file extension of the file being loaded
  119041. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119042. * @param fallback defines the fallback internal texture if any
  119043. * @param isBase64 defines whether the texture is encoded as a base64
  119044. * @param isBuffer defines whether the texture data are stored as a buffer
  119045. * @returns true if the loader can load the specified file
  119046. */
  119047. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119048. /**
  119049. * Transform the url before loading if required.
  119050. * @param rootUrl the url of the texture
  119051. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119052. * @returns the transformed texture
  119053. */
  119054. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119055. /**
  119056. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119057. * @param rootUrl the url of the texture
  119058. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119059. * @returns the fallback texture
  119060. */
  119061. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119062. /**
  119063. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  119064. * @param data contains the texture data
  119065. * @param texture defines the BabylonJS internal texture
  119066. * @param createPolynomials will be true if polynomials have been requested
  119067. * @param onLoad defines the callback to trigger once the texture is ready
  119068. * @param onError defines the callback to trigger in case of error
  119069. */
  119070. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119071. /**
  119072. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119073. * @param data contains the texture data
  119074. * @param texture defines the BabylonJS internal texture
  119075. * @param callback defines the method to call once ready to upload
  119076. */
  119077. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119078. }
  119079. }
  119080. declare module BABYLON {
  119081. /**
  119082. * 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.
  119083. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119084. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119085. */
  119086. export class CustomProceduralTexture extends ProceduralTexture {
  119087. private _animate;
  119088. private _time;
  119089. private _config;
  119090. private _texturePath;
  119091. /**
  119092. * Instantiates a new Custom Procedural Texture.
  119093. * 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.
  119094. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119095. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119096. * @param name Define the name of the texture
  119097. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  119098. * @param size Define the size of the texture to create
  119099. * @param scene Define the scene the texture belongs to
  119100. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  119101. * @param generateMipMaps Define if the texture should creates mip maps or not
  119102. */
  119103. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119104. private _loadJson;
  119105. /**
  119106. * Is the texture ready to be used ? (rendered at least once)
  119107. * @returns true if ready, otherwise, false.
  119108. */
  119109. isReady(): boolean;
  119110. /**
  119111. * Render the texture to its associated render target.
  119112. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  119113. */
  119114. render(useCameraPostProcess?: boolean): void;
  119115. /**
  119116. * Update the list of dependant textures samplers in the shader.
  119117. */
  119118. updateTextures(): void;
  119119. /**
  119120. * Update the uniform values of the procedural texture in the shader.
  119121. */
  119122. updateShaderUniforms(): void;
  119123. /**
  119124. * Define if the texture animates or not.
  119125. */
  119126. animate: boolean;
  119127. }
  119128. }
  119129. declare module BABYLON {
  119130. /** @hidden */
  119131. export var noisePixelShader: {
  119132. name: string;
  119133. shader: string;
  119134. };
  119135. }
  119136. declare module BABYLON {
  119137. /**
  119138. * Class used to generate noise procedural textures
  119139. */
  119140. export class NoiseProceduralTexture extends ProceduralTexture {
  119141. private _time;
  119142. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  119143. brightness: number;
  119144. /** Defines the number of octaves to process */
  119145. octaves: number;
  119146. /** Defines the level of persistence (0.8 by default) */
  119147. persistence: number;
  119148. /** Gets or sets animation speed factor (default is 1) */
  119149. animationSpeedFactor: number;
  119150. /**
  119151. * Creates a new NoiseProceduralTexture
  119152. * @param name defines the name fo the texture
  119153. * @param size defines the size of the texture (default is 256)
  119154. * @param scene defines the hosting scene
  119155. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  119156. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  119157. */
  119158. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119159. private _updateShaderUniforms;
  119160. protected _getDefines(): string;
  119161. /** Generate the current state of the procedural texture */
  119162. render(useCameraPostProcess?: boolean): void;
  119163. /**
  119164. * Serializes this noise procedural texture
  119165. * @returns a serialized noise procedural texture object
  119166. */
  119167. serialize(): any;
  119168. /**
  119169. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  119170. * @param parsedTexture defines parsed texture data
  119171. * @param scene defines the current scene
  119172. * @param rootUrl defines the root URL containing noise procedural texture information
  119173. * @returns a parsed NoiseProceduralTexture
  119174. */
  119175. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  119176. }
  119177. }
  119178. declare module BABYLON {
  119179. /**
  119180. * Raw cube texture where the raw buffers are passed in
  119181. */
  119182. export class RawCubeTexture extends CubeTexture {
  119183. /**
  119184. * Creates a cube texture where the raw buffers are passed in.
  119185. * @param scene defines the scene the texture is attached to
  119186. * @param data defines the array of data to use to create each face
  119187. * @param size defines the size of the textures
  119188. * @param format defines the format of the data
  119189. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  119190. * @param generateMipMaps defines if the engine should generate the mip levels
  119191. * @param invertY defines if data must be stored with Y axis inverted
  119192. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  119193. * @param compression defines the compression used (null by default)
  119194. */
  119195. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  119196. /**
  119197. * Updates the raw cube texture.
  119198. * @param data defines the data to store
  119199. * @param format defines the data format
  119200. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119201. * @param invertY defines if data must be stored with Y axis inverted
  119202. * @param compression defines the compression used (null by default)
  119203. * @param level defines which level of the texture to update
  119204. */
  119205. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  119206. /**
  119207. * Updates a raw cube texture with RGBD encoded data.
  119208. * @param data defines the array of data [mipmap][face] to use to create each face
  119209. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  119210. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  119211. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  119212. * @returns a promsie that resolves when the operation is complete
  119213. */
  119214. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  119215. /**
  119216. * Clones the raw cube texture.
  119217. * @return a new cube texture
  119218. */
  119219. clone(): CubeTexture;
  119220. /** @hidden */
  119221. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  119222. }
  119223. }
  119224. declare module BABYLON {
  119225. /**
  119226. * Class used to store 3D textures containing user data
  119227. */
  119228. export class RawTexture3D extends Texture {
  119229. /** Gets or sets the texture format to use */
  119230. format: number;
  119231. private _engine;
  119232. /**
  119233. * Create a new RawTexture3D
  119234. * @param data defines the data of the texture
  119235. * @param width defines the width of the texture
  119236. * @param height defines the height of the texture
  119237. * @param depth defines the depth of the texture
  119238. * @param format defines the texture format to use
  119239. * @param scene defines the hosting scene
  119240. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  119241. * @param invertY defines if texture must be stored with Y axis inverted
  119242. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  119243. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  119244. */
  119245. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  119246. /** Gets or sets the texture format to use */
  119247. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  119248. /**
  119249. * Update the texture with new data
  119250. * @param data defines the data to store in the texture
  119251. */
  119252. update(data: ArrayBufferView): void;
  119253. }
  119254. }
  119255. declare module BABYLON {
  119256. /**
  119257. * Creates a refraction texture used by refraction channel of the standard material.
  119258. * It is like a mirror but to see through a material.
  119259. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119260. */
  119261. export class RefractionTexture extends RenderTargetTexture {
  119262. /**
  119263. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  119264. * 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.
  119265. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119266. */
  119267. refractionPlane: Plane;
  119268. /**
  119269. * Define how deep under the surface we should see.
  119270. */
  119271. depth: number;
  119272. /**
  119273. * Creates a refraction texture used by refraction channel of the standard material.
  119274. * It is like a mirror but to see through a material.
  119275. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119276. * @param name Define the texture name
  119277. * @param size Define the size of the underlying texture
  119278. * @param scene Define the scene the refraction belongs to
  119279. * @param generateMipMaps Define if we need to generate mips level for the refraction
  119280. */
  119281. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  119282. /**
  119283. * Clone the refraction texture.
  119284. * @returns the cloned texture
  119285. */
  119286. clone(): RefractionTexture;
  119287. /**
  119288. * Serialize the texture to a JSON representation you could use in Parse later on
  119289. * @returns the serialized JSON representation
  119290. */
  119291. serialize(): any;
  119292. }
  119293. }
  119294. declare module BABYLON {
  119295. /**
  119296. * Defines the options related to the creation of an HtmlElementTexture
  119297. */
  119298. export interface IHtmlElementTextureOptions {
  119299. /**
  119300. * Defines wether mip maps should be created or not.
  119301. */
  119302. generateMipMaps?: boolean;
  119303. /**
  119304. * Defines the sampling mode of the texture.
  119305. */
  119306. samplingMode?: number;
  119307. /**
  119308. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  119309. */
  119310. engine: Nullable<ThinEngine>;
  119311. /**
  119312. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  119313. */
  119314. scene: Nullable<Scene>;
  119315. }
  119316. /**
  119317. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  119318. * To be as efficient as possible depending on your constraints nothing aside the first upload
  119319. * is automatically managed.
  119320. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  119321. * in your application.
  119322. *
  119323. * As the update is not automatic, you need to call them manually.
  119324. */
  119325. export class HtmlElementTexture extends BaseTexture {
  119326. /**
  119327. * The texture URL.
  119328. */
  119329. element: HTMLVideoElement | HTMLCanvasElement;
  119330. private static readonly DefaultOptions;
  119331. private _textureMatrix;
  119332. private _engine;
  119333. private _isVideo;
  119334. private _generateMipMaps;
  119335. private _samplingMode;
  119336. /**
  119337. * Instantiates a HtmlElementTexture from the following parameters.
  119338. *
  119339. * @param name Defines the name of the texture
  119340. * @param element Defines the video or canvas the texture is filled with
  119341. * @param options Defines the other none mandatory texture creation options
  119342. */
  119343. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  119344. private _createInternalTexture;
  119345. /**
  119346. * Returns the texture matrix used in most of the material.
  119347. */
  119348. getTextureMatrix(): Matrix;
  119349. /**
  119350. * Updates the content of the texture.
  119351. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  119352. */
  119353. update(invertY?: Nullable<boolean>): void;
  119354. }
  119355. }
  119356. declare module BABYLON {
  119357. /**
  119358. * Enum used to define the target of a block
  119359. */
  119360. export enum NodeMaterialBlockTargets {
  119361. /** Vertex shader */
  119362. Vertex = 1,
  119363. /** Fragment shader */
  119364. Fragment = 2,
  119365. /** Neutral */
  119366. Neutral = 4,
  119367. /** Vertex and Fragment */
  119368. VertexAndFragment = 3
  119369. }
  119370. }
  119371. declare module BABYLON {
  119372. /**
  119373. * Defines the kind of connection point for node based material
  119374. */
  119375. export enum NodeMaterialBlockConnectionPointTypes {
  119376. /** Float */
  119377. Float = 1,
  119378. /** Int */
  119379. Int = 2,
  119380. /** Vector2 */
  119381. Vector2 = 4,
  119382. /** Vector3 */
  119383. Vector3 = 8,
  119384. /** Vector4 */
  119385. Vector4 = 16,
  119386. /** Color3 */
  119387. Color3 = 32,
  119388. /** Color4 */
  119389. Color4 = 64,
  119390. /** Matrix */
  119391. Matrix = 128,
  119392. /** Detect type based on connection */
  119393. AutoDetect = 1024,
  119394. /** Output type that will be defined by input type */
  119395. BasedOnInput = 2048
  119396. }
  119397. }
  119398. declare module BABYLON {
  119399. /**
  119400. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  119401. */
  119402. export enum NodeMaterialBlockConnectionPointMode {
  119403. /** Value is an uniform */
  119404. Uniform = 0,
  119405. /** Value is a mesh attribute */
  119406. Attribute = 1,
  119407. /** Value is a varying between vertex and fragment shaders */
  119408. Varying = 2,
  119409. /** Mode is undefined */
  119410. Undefined = 3
  119411. }
  119412. }
  119413. declare module BABYLON {
  119414. /**
  119415. * Enum used to define system values e.g. values automatically provided by the system
  119416. */
  119417. export enum NodeMaterialSystemValues {
  119418. /** World */
  119419. World = 1,
  119420. /** View */
  119421. View = 2,
  119422. /** Projection */
  119423. Projection = 3,
  119424. /** ViewProjection */
  119425. ViewProjection = 4,
  119426. /** WorldView */
  119427. WorldView = 5,
  119428. /** WorldViewProjection */
  119429. WorldViewProjection = 6,
  119430. /** CameraPosition */
  119431. CameraPosition = 7,
  119432. /** Fog Color */
  119433. FogColor = 8,
  119434. /** Delta time */
  119435. DeltaTime = 9
  119436. }
  119437. }
  119438. declare module BABYLON {
  119439. /**
  119440. * Root class for all node material optimizers
  119441. */
  119442. export class NodeMaterialOptimizer {
  119443. /**
  119444. * Function used to optimize a NodeMaterial graph
  119445. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  119446. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  119447. */
  119448. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  119449. }
  119450. }
  119451. declare module BABYLON {
  119452. /**
  119453. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  119454. */
  119455. export class TransformBlock extends NodeMaterialBlock {
  119456. /**
  119457. * Defines the value to use to complement W value to transform it to a Vector4
  119458. */
  119459. complementW: number;
  119460. /**
  119461. * Defines the value to use to complement z value to transform it to a Vector4
  119462. */
  119463. complementZ: number;
  119464. /**
  119465. * Creates a new TransformBlock
  119466. * @param name defines the block name
  119467. */
  119468. constructor(name: string);
  119469. /**
  119470. * Gets the current class name
  119471. * @returns the class name
  119472. */
  119473. getClassName(): string;
  119474. /**
  119475. * Gets the vector input
  119476. */
  119477. readonly vector: NodeMaterialConnectionPoint;
  119478. /**
  119479. * Gets the output component
  119480. */
  119481. readonly output: NodeMaterialConnectionPoint;
  119482. /**
  119483. * Gets the matrix transform input
  119484. */
  119485. readonly transform: NodeMaterialConnectionPoint;
  119486. protected _buildBlock(state: NodeMaterialBuildState): this;
  119487. serialize(): any;
  119488. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119489. protected _dumpPropertiesCode(): string;
  119490. }
  119491. }
  119492. declare module BABYLON {
  119493. /**
  119494. * Block used to output the vertex position
  119495. */
  119496. export class VertexOutputBlock extends NodeMaterialBlock {
  119497. /**
  119498. * Creates a new VertexOutputBlock
  119499. * @param name defines the block name
  119500. */
  119501. constructor(name: string);
  119502. /**
  119503. * Gets the current class name
  119504. * @returns the class name
  119505. */
  119506. getClassName(): string;
  119507. /**
  119508. * Gets the vector input component
  119509. */
  119510. readonly vector: NodeMaterialConnectionPoint;
  119511. protected _buildBlock(state: NodeMaterialBuildState): this;
  119512. }
  119513. }
  119514. declare module BABYLON {
  119515. /**
  119516. * Block used to output the final color
  119517. */
  119518. export class FragmentOutputBlock extends NodeMaterialBlock {
  119519. /**
  119520. * Create a new FragmentOutputBlock
  119521. * @param name defines the block name
  119522. */
  119523. constructor(name: string);
  119524. /**
  119525. * Gets the current class name
  119526. * @returns the class name
  119527. */
  119528. getClassName(): string;
  119529. /**
  119530. * Gets the rgba input component
  119531. */
  119532. readonly rgba: NodeMaterialConnectionPoint;
  119533. /**
  119534. * Gets the rgb input component
  119535. */
  119536. readonly rgb: NodeMaterialConnectionPoint;
  119537. /**
  119538. * Gets the a input component
  119539. */
  119540. readonly a: NodeMaterialConnectionPoint;
  119541. protected _buildBlock(state: NodeMaterialBuildState): this;
  119542. }
  119543. }
  119544. declare module BABYLON {
  119545. /**
  119546. * Block used to read a reflection texture from a sampler
  119547. */
  119548. export class ReflectionTextureBlock extends NodeMaterialBlock {
  119549. private _define3DName;
  119550. private _defineCubicName;
  119551. private _defineExplicitName;
  119552. private _defineProjectionName;
  119553. private _defineLocalCubicName;
  119554. private _defineSphericalName;
  119555. private _definePlanarName;
  119556. private _defineEquirectangularName;
  119557. private _defineMirroredEquirectangularFixedName;
  119558. private _defineEquirectangularFixedName;
  119559. private _defineSkyboxName;
  119560. private _cubeSamplerName;
  119561. private _2DSamplerName;
  119562. private _positionUVWName;
  119563. private _directionWName;
  119564. private _reflectionCoordsName;
  119565. private _reflection2DCoordsName;
  119566. private _reflectionColorName;
  119567. private _reflectionMatrixName;
  119568. /**
  119569. * Gets or sets the texture associated with the node
  119570. */
  119571. texture: Nullable<BaseTexture>;
  119572. /**
  119573. * Create a new TextureBlock
  119574. * @param name defines the block name
  119575. */
  119576. constructor(name: string);
  119577. /**
  119578. * Gets the current class name
  119579. * @returns the class name
  119580. */
  119581. getClassName(): string;
  119582. /**
  119583. * Gets the world position input component
  119584. */
  119585. readonly position: NodeMaterialConnectionPoint;
  119586. /**
  119587. * Gets the world position input component
  119588. */
  119589. readonly worldPosition: NodeMaterialConnectionPoint;
  119590. /**
  119591. * Gets the world normal input component
  119592. */
  119593. readonly worldNormal: NodeMaterialConnectionPoint;
  119594. /**
  119595. * Gets the world input component
  119596. */
  119597. readonly world: NodeMaterialConnectionPoint;
  119598. /**
  119599. * Gets the camera (or eye) position component
  119600. */
  119601. readonly cameraPosition: NodeMaterialConnectionPoint;
  119602. /**
  119603. * Gets the view input component
  119604. */
  119605. readonly view: NodeMaterialConnectionPoint;
  119606. /**
  119607. * Gets the rgb output component
  119608. */
  119609. readonly rgb: NodeMaterialConnectionPoint;
  119610. /**
  119611. * Gets the r output component
  119612. */
  119613. readonly r: NodeMaterialConnectionPoint;
  119614. /**
  119615. * Gets the g output component
  119616. */
  119617. readonly g: NodeMaterialConnectionPoint;
  119618. /**
  119619. * Gets the b output component
  119620. */
  119621. readonly b: NodeMaterialConnectionPoint;
  119622. autoConfigure(material: NodeMaterial): void;
  119623. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119624. isReady(): boolean;
  119625. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119626. private _injectVertexCode;
  119627. private _writeOutput;
  119628. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119629. serialize(): any;
  119630. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119631. }
  119632. }
  119633. declare module BABYLON {
  119634. /**
  119635. * Interface used to configure the node material editor
  119636. */
  119637. export interface INodeMaterialEditorOptions {
  119638. /** Define the URl to load node editor script */
  119639. editorURL?: string;
  119640. }
  119641. /** @hidden */
  119642. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  119643. /** BONES */
  119644. NUM_BONE_INFLUENCERS: number;
  119645. BonesPerMesh: number;
  119646. BONETEXTURE: boolean;
  119647. /** MORPH TARGETS */
  119648. MORPHTARGETS: boolean;
  119649. MORPHTARGETS_NORMAL: boolean;
  119650. MORPHTARGETS_TANGENT: boolean;
  119651. MORPHTARGETS_UV: boolean;
  119652. NUM_MORPH_INFLUENCERS: number;
  119653. /** IMAGE PROCESSING */
  119654. IMAGEPROCESSING: boolean;
  119655. VIGNETTE: boolean;
  119656. VIGNETTEBLENDMODEMULTIPLY: boolean;
  119657. VIGNETTEBLENDMODEOPAQUE: boolean;
  119658. TONEMAPPING: boolean;
  119659. TONEMAPPING_ACES: boolean;
  119660. CONTRAST: boolean;
  119661. EXPOSURE: boolean;
  119662. COLORCURVES: boolean;
  119663. COLORGRADING: boolean;
  119664. COLORGRADING3D: boolean;
  119665. SAMPLER3DGREENDEPTH: boolean;
  119666. SAMPLER3DBGRMAP: boolean;
  119667. IMAGEPROCESSINGPOSTPROCESS: boolean;
  119668. /** MISC. */
  119669. BUMPDIRECTUV: number;
  119670. constructor();
  119671. setValue(name: string, value: boolean): void;
  119672. }
  119673. /**
  119674. * Class used to configure NodeMaterial
  119675. */
  119676. export interface INodeMaterialOptions {
  119677. /**
  119678. * Defines if blocks should emit comments
  119679. */
  119680. emitComments: boolean;
  119681. }
  119682. /**
  119683. * Class used to create a node based material built by assembling shader blocks
  119684. */
  119685. export class NodeMaterial extends PushMaterial {
  119686. private static _BuildIdGenerator;
  119687. private _options;
  119688. private _vertexCompilationState;
  119689. private _fragmentCompilationState;
  119690. private _sharedData;
  119691. private _buildId;
  119692. private _buildWasSuccessful;
  119693. private _cachedWorldViewMatrix;
  119694. private _cachedWorldViewProjectionMatrix;
  119695. private _optimizers;
  119696. private _animationFrame;
  119697. /** Define the URl to load node editor script */
  119698. static EditorURL: string;
  119699. private BJSNODEMATERIALEDITOR;
  119700. /** Get the inspector from bundle or global */
  119701. private _getGlobalNodeMaterialEditor;
  119702. /**
  119703. * 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)
  119704. */
  119705. ignoreAlpha: boolean;
  119706. /**
  119707. * Defines the maximum number of lights that can be used in the material
  119708. */
  119709. maxSimultaneousLights: number;
  119710. /**
  119711. * Observable raised when the material is built
  119712. */
  119713. onBuildObservable: Observable<NodeMaterial>;
  119714. /**
  119715. * Gets or sets the root nodes of the material vertex shader
  119716. */
  119717. _vertexOutputNodes: NodeMaterialBlock[];
  119718. /**
  119719. * Gets or sets the root nodes of the material fragment (pixel) shader
  119720. */
  119721. _fragmentOutputNodes: NodeMaterialBlock[];
  119722. /** Gets or sets options to control the node material overall behavior */
  119723. options: INodeMaterialOptions;
  119724. /**
  119725. * Default configuration related to image processing available in the standard Material.
  119726. */
  119727. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119728. /**
  119729. * Gets the image processing configuration used either in this material.
  119730. */
  119731. /**
  119732. * Sets the Default image processing configuration used either in the this material.
  119733. *
  119734. * If sets to null, the scene one is in use.
  119735. */
  119736. imageProcessingConfiguration: ImageProcessingConfiguration;
  119737. /**
  119738. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  119739. */
  119740. attachedBlocks: NodeMaterialBlock[];
  119741. /**
  119742. * Create a new node based material
  119743. * @param name defines the material name
  119744. * @param scene defines the hosting scene
  119745. * @param options defines creation option
  119746. */
  119747. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  119748. /**
  119749. * Gets the current class name of the material e.g. "NodeMaterial"
  119750. * @returns the class name
  119751. */
  119752. getClassName(): string;
  119753. /**
  119754. * Keep track of the image processing observer to allow dispose and replace.
  119755. */
  119756. private _imageProcessingObserver;
  119757. /**
  119758. * Attaches a new image processing configuration to the Standard Material.
  119759. * @param configuration
  119760. */
  119761. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  119762. /**
  119763. * Get a block by its name
  119764. * @param name defines the name of the block to retrieve
  119765. * @returns the required block or null if not found
  119766. */
  119767. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  119768. /**
  119769. * Get a block by its name
  119770. * @param predicate defines the predicate used to find the good candidate
  119771. * @returns the required block or null if not found
  119772. */
  119773. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  119774. /**
  119775. * Get an input block by its name
  119776. * @param predicate defines the predicate used to find the good candidate
  119777. * @returns the required input block or null if not found
  119778. */
  119779. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  119780. /**
  119781. * Gets the list of input blocks attached to this material
  119782. * @returns an array of InputBlocks
  119783. */
  119784. getInputBlocks(): InputBlock[];
  119785. /**
  119786. * Adds a new optimizer to the list of optimizers
  119787. * @param optimizer defines the optimizers to add
  119788. * @returns the current material
  119789. */
  119790. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119791. /**
  119792. * Remove an optimizer from the list of optimizers
  119793. * @param optimizer defines the optimizers to remove
  119794. * @returns the current material
  119795. */
  119796. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119797. /**
  119798. * Add a new block to the list of output nodes
  119799. * @param node defines the node to add
  119800. * @returns the current material
  119801. */
  119802. addOutputNode(node: NodeMaterialBlock): this;
  119803. /**
  119804. * Remove a block from the list of root nodes
  119805. * @param node defines the node to remove
  119806. * @returns the current material
  119807. */
  119808. removeOutputNode(node: NodeMaterialBlock): this;
  119809. private _addVertexOutputNode;
  119810. private _removeVertexOutputNode;
  119811. private _addFragmentOutputNode;
  119812. private _removeFragmentOutputNode;
  119813. /**
  119814. * Specifies if the material will require alpha blending
  119815. * @returns a boolean specifying if alpha blending is needed
  119816. */
  119817. needAlphaBlending(): boolean;
  119818. /**
  119819. * Specifies if this material should be rendered in alpha test mode
  119820. * @returns a boolean specifying if an alpha test is needed.
  119821. */
  119822. needAlphaTesting(): boolean;
  119823. private _initializeBlock;
  119824. private _resetDualBlocks;
  119825. /**
  119826. * Build the material and generates the inner effect
  119827. * @param verbose defines if the build should log activity
  119828. */
  119829. build(verbose?: boolean): void;
  119830. /**
  119831. * Runs an otpimization phase to try to improve the shader code
  119832. */
  119833. optimize(): void;
  119834. private _prepareDefinesForAttributes;
  119835. /**
  119836. * Get if the submesh is ready to be used and all its information available.
  119837. * Child classes can use it to update shaders
  119838. * @param mesh defines the mesh to check
  119839. * @param subMesh defines which submesh to check
  119840. * @param useInstances specifies that instances should be used
  119841. * @returns a boolean indicating that the submesh is ready or not
  119842. */
  119843. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  119844. /**
  119845. * Get a string representing the shaders built by the current node graph
  119846. */
  119847. readonly compiledShaders: string;
  119848. /**
  119849. * Binds the world matrix to the material
  119850. * @param world defines the world transformation matrix
  119851. */
  119852. bindOnlyWorldMatrix(world: Matrix): void;
  119853. /**
  119854. * Binds the submesh to this material by preparing the effect and shader to draw
  119855. * @param world defines the world transformation matrix
  119856. * @param mesh defines the mesh containing the submesh
  119857. * @param subMesh defines the submesh to bind the material to
  119858. */
  119859. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  119860. /**
  119861. * Gets the active textures from the material
  119862. * @returns an array of textures
  119863. */
  119864. getActiveTextures(): BaseTexture[];
  119865. /**
  119866. * Gets the list of texture blocks
  119867. * @returns an array of texture blocks
  119868. */
  119869. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  119870. /**
  119871. * Specifies if the material uses a texture
  119872. * @param texture defines the texture to check against the material
  119873. * @returns a boolean specifying if the material uses the texture
  119874. */
  119875. hasTexture(texture: BaseTexture): boolean;
  119876. /**
  119877. * Disposes the material
  119878. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  119879. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  119880. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  119881. */
  119882. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  119883. /** Creates the node editor window. */
  119884. private _createNodeEditor;
  119885. /**
  119886. * Launch the node material editor
  119887. * @param config Define the configuration of the editor
  119888. * @return a promise fulfilled when the node editor is visible
  119889. */
  119890. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  119891. /**
  119892. * Clear the current material
  119893. */
  119894. clear(): void;
  119895. /**
  119896. * Clear the current material and set it to a default state
  119897. */
  119898. setToDefault(): void;
  119899. /**
  119900. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  119901. * @param url defines the url to load from
  119902. * @returns a promise that will fullfil when the material is fully loaded
  119903. */
  119904. loadAsync(url: string): Promise<unknown>;
  119905. private _gatherBlocks;
  119906. /**
  119907. * Generate a string containing the code declaration required to create an equivalent of this material
  119908. * @returns a string
  119909. */
  119910. generateCode(): string;
  119911. /**
  119912. * Serializes this material in a JSON representation
  119913. * @returns the serialized material object
  119914. */
  119915. serialize(): any;
  119916. private _restoreConnections;
  119917. /**
  119918. * Clear the current graph and load a new one from a serialization object
  119919. * @param source defines the JSON representation of the material
  119920. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119921. */
  119922. loadFromSerialization(source: any, rootUrl?: string): void;
  119923. /**
  119924. * Creates a node material from parsed material data
  119925. * @param source defines the JSON representation of the material
  119926. * @param scene defines the hosting scene
  119927. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119928. * @returns a new node material
  119929. */
  119930. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  119931. /**
  119932. * Creates a new node material set to default basic configuration
  119933. * @param name defines the name of the material
  119934. * @param scene defines the hosting scene
  119935. * @returns a new NodeMaterial
  119936. */
  119937. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  119938. }
  119939. }
  119940. declare module BABYLON {
  119941. /**
  119942. * Block used to read a texture from a sampler
  119943. */
  119944. export class TextureBlock extends NodeMaterialBlock {
  119945. private _defineName;
  119946. private _linearDefineName;
  119947. private _samplerName;
  119948. private _transformedUVName;
  119949. private _textureTransformName;
  119950. private _textureInfoName;
  119951. private _mainUVName;
  119952. private _mainUVDefineName;
  119953. /**
  119954. * Gets or sets the texture associated with the node
  119955. */
  119956. texture: Nullable<Texture>;
  119957. /**
  119958. * Create a new TextureBlock
  119959. * @param name defines the block name
  119960. */
  119961. constructor(name: string);
  119962. /**
  119963. * Gets the current class name
  119964. * @returns the class name
  119965. */
  119966. getClassName(): string;
  119967. /**
  119968. * Gets the uv input component
  119969. */
  119970. readonly uv: NodeMaterialConnectionPoint;
  119971. /**
  119972. * Gets the rgba output component
  119973. */
  119974. readonly rgba: NodeMaterialConnectionPoint;
  119975. /**
  119976. * Gets the rgb output component
  119977. */
  119978. readonly rgb: NodeMaterialConnectionPoint;
  119979. /**
  119980. * Gets the r output component
  119981. */
  119982. readonly r: NodeMaterialConnectionPoint;
  119983. /**
  119984. * Gets the g output component
  119985. */
  119986. readonly g: NodeMaterialConnectionPoint;
  119987. /**
  119988. * Gets the b output component
  119989. */
  119990. readonly b: NodeMaterialConnectionPoint;
  119991. /**
  119992. * Gets the a output component
  119993. */
  119994. readonly a: NodeMaterialConnectionPoint;
  119995. readonly target: NodeMaterialBlockTargets;
  119996. autoConfigure(material: NodeMaterial): void;
  119997. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119998. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119999. isReady(): boolean;
  120000. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120001. private readonly _isMixed;
  120002. private _injectVertexCode;
  120003. private _writeOutput;
  120004. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120005. protected _dumpPropertiesCode(): string;
  120006. serialize(): any;
  120007. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120008. }
  120009. }
  120010. declare module BABYLON {
  120011. /**
  120012. * Class used to store shared data between 2 NodeMaterialBuildState
  120013. */
  120014. export class NodeMaterialBuildStateSharedData {
  120015. /**
  120016. * Gets the list of emitted varyings
  120017. */
  120018. temps: string[];
  120019. /**
  120020. * Gets the list of emitted varyings
  120021. */
  120022. varyings: string[];
  120023. /**
  120024. * Gets the varying declaration string
  120025. */
  120026. varyingDeclaration: string;
  120027. /**
  120028. * Input blocks
  120029. */
  120030. inputBlocks: InputBlock[];
  120031. /**
  120032. * Input blocks
  120033. */
  120034. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  120035. /**
  120036. * Bindable blocks (Blocks that need to set data to the effect)
  120037. */
  120038. bindableBlocks: NodeMaterialBlock[];
  120039. /**
  120040. * List of blocks that can provide a compilation fallback
  120041. */
  120042. blocksWithFallbacks: NodeMaterialBlock[];
  120043. /**
  120044. * List of blocks that can provide a define update
  120045. */
  120046. blocksWithDefines: NodeMaterialBlock[];
  120047. /**
  120048. * List of blocks that can provide a repeatable content
  120049. */
  120050. repeatableContentBlocks: NodeMaterialBlock[];
  120051. /**
  120052. * List of blocks that can provide a dynamic list of uniforms
  120053. */
  120054. dynamicUniformBlocks: NodeMaterialBlock[];
  120055. /**
  120056. * List of blocks that can block the isReady function for the material
  120057. */
  120058. blockingBlocks: NodeMaterialBlock[];
  120059. /**
  120060. * Gets the list of animated inputs
  120061. */
  120062. animatedInputs: InputBlock[];
  120063. /**
  120064. * Build Id used to avoid multiple recompilations
  120065. */
  120066. buildId: number;
  120067. /** List of emitted variables */
  120068. variableNames: {
  120069. [key: string]: number;
  120070. };
  120071. /** List of emitted defines */
  120072. defineNames: {
  120073. [key: string]: number;
  120074. };
  120075. /** Should emit comments? */
  120076. emitComments: boolean;
  120077. /** Emit build activity */
  120078. verbose: boolean;
  120079. /** Gets or sets the hosting scene */
  120080. scene: Scene;
  120081. /**
  120082. * Gets the compilation hints emitted at compilation time
  120083. */
  120084. hints: {
  120085. needWorldViewMatrix: boolean;
  120086. needWorldViewProjectionMatrix: boolean;
  120087. needAlphaBlending: boolean;
  120088. needAlphaTesting: boolean;
  120089. };
  120090. /**
  120091. * List of compilation checks
  120092. */
  120093. checks: {
  120094. emitVertex: boolean;
  120095. emitFragment: boolean;
  120096. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  120097. };
  120098. /** Creates a new shared data */
  120099. constructor();
  120100. /**
  120101. * Emits console errors and exceptions if there is a failing check
  120102. */
  120103. emitErrors(): void;
  120104. }
  120105. }
  120106. declare module BABYLON {
  120107. /**
  120108. * Class used to store node based material build state
  120109. */
  120110. export class NodeMaterialBuildState {
  120111. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  120112. supportUniformBuffers: boolean;
  120113. /**
  120114. * Gets the list of emitted attributes
  120115. */
  120116. attributes: string[];
  120117. /**
  120118. * Gets the list of emitted uniforms
  120119. */
  120120. uniforms: string[];
  120121. /**
  120122. * Gets the list of emitted constants
  120123. */
  120124. constants: string[];
  120125. /**
  120126. * Gets the list of emitted uniform buffers
  120127. */
  120128. uniformBuffers: string[];
  120129. /**
  120130. * Gets the list of emitted samplers
  120131. */
  120132. samplers: string[];
  120133. /**
  120134. * Gets the list of emitted functions
  120135. */
  120136. functions: {
  120137. [key: string]: string;
  120138. };
  120139. /**
  120140. * Gets the list of emitted extensions
  120141. */
  120142. extensions: {
  120143. [key: string]: string;
  120144. };
  120145. /**
  120146. * Gets the target of the compilation state
  120147. */
  120148. target: NodeMaterialBlockTargets;
  120149. /**
  120150. * Gets the list of emitted counters
  120151. */
  120152. counters: {
  120153. [key: string]: number;
  120154. };
  120155. /**
  120156. * Shared data between multiple NodeMaterialBuildState instances
  120157. */
  120158. sharedData: NodeMaterialBuildStateSharedData;
  120159. /** @hidden */
  120160. _vertexState: NodeMaterialBuildState;
  120161. /** @hidden */
  120162. _attributeDeclaration: string;
  120163. /** @hidden */
  120164. _uniformDeclaration: string;
  120165. /** @hidden */
  120166. _constantDeclaration: string;
  120167. /** @hidden */
  120168. _samplerDeclaration: string;
  120169. /** @hidden */
  120170. _varyingTransfer: string;
  120171. private _repeatableContentAnchorIndex;
  120172. /** @hidden */
  120173. _builtCompilationString: string;
  120174. /**
  120175. * Gets the emitted compilation strings
  120176. */
  120177. compilationString: string;
  120178. /**
  120179. * Finalize the compilation strings
  120180. * @param state defines the current compilation state
  120181. */
  120182. finalize(state: NodeMaterialBuildState): void;
  120183. /** @hidden */
  120184. readonly _repeatableContentAnchor: string;
  120185. /** @hidden */
  120186. _getFreeVariableName(prefix: string): string;
  120187. /** @hidden */
  120188. _getFreeDefineName(prefix: string): string;
  120189. /** @hidden */
  120190. _excludeVariableName(name: string): void;
  120191. /** @hidden */
  120192. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  120193. /** @hidden */
  120194. _emitExtension(name: string, extension: string): void;
  120195. /** @hidden */
  120196. _emitFunction(name: string, code: string, comments: string): void;
  120197. /** @hidden */
  120198. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  120199. replaceStrings?: {
  120200. search: RegExp;
  120201. replace: string;
  120202. }[];
  120203. repeatKey?: string;
  120204. }): string;
  120205. /** @hidden */
  120206. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  120207. repeatKey?: string;
  120208. removeAttributes?: boolean;
  120209. removeUniforms?: boolean;
  120210. removeVaryings?: boolean;
  120211. removeIfDef?: boolean;
  120212. replaceStrings?: {
  120213. search: RegExp;
  120214. replace: string;
  120215. }[];
  120216. }, storeKey?: string): void;
  120217. /** @hidden */
  120218. _registerTempVariable(name: string): boolean;
  120219. /** @hidden */
  120220. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  120221. /** @hidden */
  120222. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  120223. /** @hidden */
  120224. _emitFloat(value: number): string;
  120225. }
  120226. }
  120227. declare module BABYLON {
  120228. /**
  120229. * Defines a block that can be used inside a node based material
  120230. */
  120231. export class NodeMaterialBlock {
  120232. private _buildId;
  120233. private _buildTarget;
  120234. private _target;
  120235. private _isFinalMerger;
  120236. private _isInput;
  120237. /** @hidden */
  120238. _codeVariableName: string;
  120239. /** @hidden */
  120240. _inputs: NodeMaterialConnectionPoint[];
  120241. /** @hidden */
  120242. _outputs: NodeMaterialConnectionPoint[];
  120243. /** @hidden */
  120244. _preparationId: number;
  120245. /**
  120246. * Gets or sets the name of the block
  120247. */
  120248. name: string;
  120249. /**
  120250. * Gets or sets the unique id of the node
  120251. */
  120252. uniqueId: number;
  120253. /**
  120254. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  120255. */
  120256. readonly isFinalMerger: boolean;
  120257. /**
  120258. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  120259. */
  120260. readonly isInput: boolean;
  120261. /**
  120262. * Gets or sets the build Id
  120263. */
  120264. buildId: number;
  120265. /**
  120266. * Gets or sets the target of the block
  120267. */
  120268. target: NodeMaterialBlockTargets;
  120269. /**
  120270. * Gets the list of input points
  120271. */
  120272. readonly inputs: NodeMaterialConnectionPoint[];
  120273. /** Gets the list of output points */
  120274. readonly outputs: NodeMaterialConnectionPoint[];
  120275. /**
  120276. * Find an input by its name
  120277. * @param name defines the name of the input to look for
  120278. * @returns the input or null if not found
  120279. */
  120280. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120281. /**
  120282. * Find an output by its name
  120283. * @param name defines the name of the outputto look for
  120284. * @returns the output or null if not found
  120285. */
  120286. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120287. /**
  120288. * Creates a new NodeMaterialBlock
  120289. * @param name defines the block name
  120290. * @param target defines the target of that block (Vertex by default)
  120291. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  120292. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  120293. */
  120294. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  120295. /**
  120296. * Initialize the block and prepare the context for build
  120297. * @param state defines the state that will be used for the build
  120298. */
  120299. initialize(state: NodeMaterialBuildState): void;
  120300. /**
  120301. * Bind data to effect. Will only be called for blocks with isBindable === true
  120302. * @param effect defines the effect to bind data to
  120303. * @param nodeMaterial defines the hosting NodeMaterial
  120304. * @param mesh defines the mesh that will be rendered
  120305. */
  120306. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120307. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  120308. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  120309. protected _writeFloat(value: number): string;
  120310. /**
  120311. * Gets the current class name e.g. "NodeMaterialBlock"
  120312. * @returns the class name
  120313. */
  120314. getClassName(): string;
  120315. /**
  120316. * Register a new input. Must be called inside a block constructor
  120317. * @param name defines the connection point name
  120318. * @param type defines the connection point type
  120319. * @param isOptional defines a boolean indicating that this input can be omitted
  120320. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120321. * @returns the current block
  120322. */
  120323. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  120324. /**
  120325. * Register a new output. Must be called inside a block constructor
  120326. * @param name defines the connection point name
  120327. * @param type defines the connection point type
  120328. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120329. * @returns the current block
  120330. */
  120331. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  120332. /**
  120333. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  120334. * @param forOutput defines an optional connection point to check compatibility with
  120335. * @returns the first available input or null
  120336. */
  120337. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  120338. /**
  120339. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  120340. * @param forBlock defines an optional block to check compatibility with
  120341. * @returns the first available input or null
  120342. */
  120343. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  120344. /**
  120345. * Gets the sibling of the given output
  120346. * @param current defines the current output
  120347. * @returns the next output in the list or null
  120348. */
  120349. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  120350. /**
  120351. * Connect current block with another block
  120352. * @param other defines the block to connect with
  120353. * @param options define the various options to help pick the right connections
  120354. * @returns the current block
  120355. */
  120356. connectTo(other: NodeMaterialBlock, options?: {
  120357. input?: string;
  120358. output?: string;
  120359. outputSwizzle?: string;
  120360. }): this | undefined;
  120361. protected _buildBlock(state: NodeMaterialBuildState): void;
  120362. /**
  120363. * Add uniforms, samplers and uniform buffers at compilation time
  120364. * @param state defines the state to update
  120365. * @param nodeMaterial defines the node material requesting the update
  120366. * @param defines defines the material defines to update
  120367. */
  120368. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120369. /**
  120370. * Add potential fallbacks if shader compilation fails
  120371. * @param mesh defines the mesh to be rendered
  120372. * @param fallbacks defines the current prioritized list of fallbacks
  120373. */
  120374. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120375. /**
  120376. * Initialize defines for shader compilation
  120377. * @param mesh defines the mesh to be rendered
  120378. * @param nodeMaterial defines the node material requesting the update
  120379. * @param defines defines the material defines to update
  120380. * @param useInstances specifies that instances should be used
  120381. */
  120382. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120383. /**
  120384. * Update defines for shader compilation
  120385. * @param mesh defines the mesh to be rendered
  120386. * @param nodeMaterial defines the node material requesting the update
  120387. * @param defines defines the material defines to update
  120388. * @param useInstances specifies that instances should be used
  120389. */
  120390. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120391. /**
  120392. * Lets the block try to connect some inputs automatically
  120393. * @param material defines the hosting NodeMaterial
  120394. */
  120395. autoConfigure(material: NodeMaterial): void;
  120396. /**
  120397. * Function called when a block is declared as repeatable content generator
  120398. * @param vertexShaderState defines the current compilation state for the vertex shader
  120399. * @param fragmentShaderState defines the current compilation state for the fragment shader
  120400. * @param mesh defines the mesh to be rendered
  120401. * @param defines defines the material defines to update
  120402. */
  120403. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120404. /**
  120405. * Checks if the block is ready
  120406. * @param mesh defines the mesh to be rendered
  120407. * @param nodeMaterial defines the node material requesting the update
  120408. * @param defines defines the material defines to update
  120409. * @param useInstances specifies that instances should be used
  120410. * @returns true if the block is ready
  120411. */
  120412. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  120413. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  120414. private _processBuild;
  120415. /**
  120416. * Compile the current node and generate the shader code
  120417. * @param state defines the current compilation state (uniforms, samplers, current string)
  120418. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  120419. * @returns true if already built
  120420. */
  120421. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  120422. protected _inputRename(name: string): string;
  120423. protected _outputRename(name: string): string;
  120424. protected _dumpPropertiesCode(): string;
  120425. /** @hidden */
  120426. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  120427. /**
  120428. * Clone the current block to a new identical block
  120429. * @param scene defines the hosting scene
  120430. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120431. * @returns a copy of the current block
  120432. */
  120433. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  120434. /**
  120435. * Serializes this block in a JSON representation
  120436. * @returns the serialized block object
  120437. */
  120438. serialize(): any;
  120439. /** @hidden */
  120440. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120441. }
  120442. }
  120443. declare module BABYLON {
  120444. /**
  120445. * Enum defining the type of animations supported by InputBlock
  120446. */
  120447. export enum AnimatedInputBlockTypes {
  120448. /** No animation */
  120449. None = 0,
  120450. /** Time based animation. Will only work for floats */
  120451. Time = 1
  120452. }
  120453. }
  120454. declare module BABYLON {
  120455. /**
  120456. * Block used to expose an input value
  120457. */
  120458. export class InputBlock extends NodeMaterialBlock {
  120459. private _mode;
  120460. private _associatedVariableName;
  120461. private _storedValue;
  120462. private _valueCallback;
  120463. private _type;
  120464. private _animationType;
  120465. /** Gets or set a value used to limit the range of float values */
  120466. min: number;
  120467. /** Gets or set a value used to limit the range of float values */
  120468. max: number;
  120469. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  120470. matrixMode: number;
  120471. /** @hidden */
  120472. _systemValue: Nullable<NodeMaterialSystemValues>;
  120473. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  120474. visibleInInspector: boolean;
  120475. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  120476. isConstant: boolean;
  120477. /**
  120478. * Gets or sets the connection point type (default is float)
  120479. */
  120480. readonly type: NodeMaterialBlockConnectionPointTypes;
  120481. /**
  120482. * Creates a new InputBlock
  120483. * @param name defines the block name
  120484. * @param target defines the target of that block (Vertex by default)
  120485. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  120486. */
  120487. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  120488. /**
  120489. * Gets the output component
  120490. */
  120491. readonly output: NodeMaterialConnectionPoint;
  120492. /**
  120493. * Set the source of this connection point to a vertex attribute
  120494. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  120495. * @returns the current connection point
  120496. */
  120497. setAsAttribute(attributeName?: string): InputBlock;
  120498. /**
  120499. * Set the source of this connection point to a system value
  120500. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  120501. * @returns the current connection point
  120502. */
  120503. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  120504. /**
  120505. * Gets or sets the value of that point.
  120506. * Please note that this value will be ignored if valueCallback is defined
  120507. */
  120508. value: any;
  120509. /**
  120510. * Gets or sets a callback used to get the value of that point.
  120511. * Please note that setting this value will force the connection point to ignore the value property
  120512. */
  120513. valueCallback: () => any;
  120514. /**
  120515. * Gets or sets the associated variable name in the shader
  120516. */
  120517. associatedVariableName: string;
  120518. /** Gets or sets the type of animation applied to the input */
  120519. animationType: AnimatedInputBlockTypes;
  120520. /**
  120521. * Gets a boolean indicating that this connection point not defined yet
  120522. */
  120523. readonly isUndefined: boolean;
  120524. /**
  120525. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  120526. * In this case the connection point name must be the name of the uniform to use.
  120527. * Can only be set on inputs
  120528. */
  120529. isUniform: boolean;
  120530. /**
  120531. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  120532. * In this case the connection point name must be the name of the attribute to use
  120533. * Can only be set on inputs
  120534. */
  120535. isAttribute: boolean;
  120536. /**
  120537. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  120538. * Can only be set on exit points
  120539. */
  120540. isVarying: boolean;
  120541. /**
  120542. * Gets a boolean indicating that the current connection point is a system value
  120543. */
  120544. readonly isSystemValue: boolean;
  120545. /**
  120546. * Gets or sets the current well known value or null if not defined as a system value
  120547. */
  120548. systemValue: Nullable<NodeMaterialSystemValues>;
  120549. /**
  120550. * Gets the current class name
  120551. * @returns the class name
  120552. */
  120553. getClassName(): string;
  120554. /**
  120555. * Animate the input if animationType !== None
  120556. * @param scene defines the rendering scene
  120557. */
  120558. animate(scene: Scene): void;
  120559. private _emitDefine;
  120560. initialize(state: NodeMaterialBuildState): void;
  120561. /**
  120562. * Set the input block to its default value (based on its type)
  120563. */
  120564. setDefaultValue(): void;
  120565. private _emitConstant;
  120566. private _emit;
  120567. /** @hidden */
  120568. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  120569. /** @hidden */
  120570. _transmit(effect: Effect, scene: Scene): void;
  120571. protected _buildBlock(state: NodeMaterialBuildState): void;
  120572. protected _dumpPropertiesCode(): string;
  120573. serialize(): any;
  120574. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120575. }
  120576. }
  120577. declare module BABYLON {
  120578. /**
  120579. * Defines a connection point for a block
  120580. */
  120581. export class NodeMaterialConnectionPoint {
  120582. /** @hidden */
  120583. _ownerBlock: NodeMaterialBlock;
  120584. /** @hidden */
  120585. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120586. private _endpoints;
  120587. private _associatedVariableName;
  120588. /** @hidden */
  120589. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120590. /** @hidden */
  120591. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120592. private _type;
  120593. /** @hidden */
  120594. _enforceAssociatedVariableName: boolean;
  120595. /**
  120596. * Gets or sets the additional types supported by this connection point
  120597. */
  120598. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120599. /**
  120600. * Gets or sets the additional types excluded by this connection point
  120601. */
  120602. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120603. /**
  120604. * Gets or sets the associated variable name in the shader
  120605. */
  120606. associatedVariableName: string;
  120607. /**
  120608. * Gets or sets the connection point type (default is float)
  120609. */
  120610. type: NodeMaterialBlockConnectionPointTypes;
  120611. /**
  120612. * Gets or sets the connection point name
  120613. */
  120614. name: string;
  120615. /**
  120616. * Gets or sets a boolean indicating that this connection point can be omitted
  120617. */
  120618. isOptional: boolean;
  120619. /**
  120620. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  120621. */
  120622. define: string;
  120623. /** Gets or sets the target of that connection point */
  120624. target: NodeMaterialBlockTargets;
  120625. /**
  120626. * Gets a boolean indicating that the current point is connected
  120627. */
  120628. readonly isConnected: boolean;
  120629. /**
  120630. * Gets a boolean indicating that the current point is connected to an input block
  120631. */
  120632. readonly isConnectedToInputBlock: boolean;
  120633. /**
  120634. * Gets a the connected input block (if any)
  120635. */
  120636. readonly connectInputBlock: Nullable<InputBlock>;
  120637. /** Get the other side of the connection (if any) */
  120638. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120639. /** Get the block that owns this connection point */
  120640. readonly ownerBlock: NodeMaterialBlock;
  120641. /** Get the block connected on the other side of this connection (if any) */
  120642. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  120643. /** Get the block connected on the endpoints of this connection (if any) */
  120644. readonly connectedBlocks: Array<NodeMaterialBlock>;
  120645. /** Gets the list of connected endpoints */
  120646. readonly endpoints: NodeMaterialConnectionPoint[];
  120647. /** Gets a boolean indicating if that output point is connected to at least one input */
  120648. readonly hasEndpoints: boolean;
  120649. /**
  120650. * Creates a new connection point
  120651. * @param name defines the connection point name
  120652. * @param ownerBlock defines the block hosting this connection point
  120653. */
  120654. constructor(name: string, ownerBlock: NodeMaterialBlock);
  120655. /**
  120656. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  120657. * @returns the class name
  120658. */
  120659. getClassName(): string;
  120660. /**
  120661. * Gets an boolean indicating if the current point can be connected to another point
  120662. * @param connectionPoint defines the other connection point
  120663. * @returns true if the connection is possible
  120664. */
  120665. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  120666. /**
  120667. * Connect this point to another connection point
  120668. * @param connectionPoint defines the other connection point
  120669. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  120670. * @returns the current connection point
  120671. */
  120672. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  120673. /**
  120674. * Disconnect this point from one of his endpoint
  120675. * @param endpoint defines the other connection point
  120676. * @returns the current connection point
  120677. */
  120678. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  120679. /**
  120680. * Serializes this point in a JSON representation
  120681. * @returns the serialized point object
  120682. */
  120683. serialize(): any;
  120684. }
  120685. }
  120686. declare module BABYLON {
  120687. /**
  120688. * Block used to add support for vertex skinning (bones)
  120689. */
  120690. export class BonesBlock extends NodeMaterialBlock {
  120691. /**
  120692. * Creates a new BonesBlock
  120693. * @param name defines the block name
  120694. */
  120695. constructor(name: string);
  120696. /**
  120697. * Initialize the block and prepare the context for build
  120698. * @param state defines the state that will be used for the build
  120699. */
  120700. initialize(state: NodeMaterialBuildState): void;
  120701. /**
  120702. * Gets the current class name
  120703. * @returns the class name
  120704. */
  120705. getClassName(): string;
  120706. /**
  120707. * Gets the matrix indices input component
  120708. */
  120709. readonly matricesIndices: NodeMaterialConnectionPoint;
  120710. /**
  120711. * Gets the matrix weights input component
  120712. */
  120713. readonly matricesWeights: NodeMaterialConnectionPoint;
  120714. /**
  120715. * Gets the extra matrix indices input component
  120716. */
  120717. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  120718. /**
  120719. * Gets the extra matrix weights input component
  120720. */
  120721. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  120722. /**
  120723. * Gets the world input component
  120724. */
  120725. readonly world: NodeMaterialConnectionPoint;
  120726. /**
  120727. * Gets the output component
  120728. */
  120729. readonly output: NodeMaterialConnectionPoint;
  120730. autoConfigure(material: NodeMaterial): void;
  120731. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120732. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120733. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120734. protected _buildBlock(state: NodeMaterialBuildState): this;
  120735. }
  120736. }
  120737. declare module BABYLON {
  120738. /**
  120739. * Block used to add support for instances
  120740. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  120741. */
  120742. export class InstancesBlock extends NodeMaterialBlock {
  120743. /**
  120744. * Creates a new InstancesBlock
  120745. * @param name defines the block name
  120746. */
  120747. constructor(name: string);
  120748. /**
  120749. * Gets the current class name
  120750. * @returns the class name
  120751. */
  120752. getClassName(): string;
  120753. /**
  120754. * Gets the first world row input component
  120755. */
  120756. readonly world0: NodeMaterialConnectionPoint;
  120757. /**
  120758. * Gets the second world row input component
  120759. */
  120760. readonly world1: NodeMaterialConnectionPoint;
  120761. /**
  120762. * Gets the third world row input component
  120763. */
  120764. readonly world2: NodeMaterialConnectionPoint;
  120765. /**
  120766. * Gets the forth world row input component
  120767. */
  120768. readonly world3: NodeMaterialConnectionPoint;
  120769. /**
  120770. * Gets the world input component
  120771. */
  120772. readonly world: NodeMaterialConnectionPoint;
  120773. /**
  120774. * Gets the output component
  120775. */
  120776. readonly output: NodeMaterialConnectionPoint;
  120777. autoConfigure(material: NodeMaterial): void;
  120778. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120779. protected _buildBlock(state: NodeMaterialBuildState): this;
  120780. }
  120781. }
  120782. declare module BABYLON {
  120783. /**
  120784. * Block used to add morph targets support to vertex shader
  120785. */
  120786. export class MorphTargetsBlock extends NodeMaterialBlock {
  120787. private _repeatableContentAnchor;
  120788. private _repeatebleContentGenerated;
  120789. /**
  120790. * Create a new MorphTargetsBlock
  120791. * @param name defines the block name
  120792. */
  120793. constructor(name: string);
  120794. /**
  120795. * Gets the current class name
  120796. * @returns the class name
  120797. */
  120798. getClassName(): string;
  120799. /**
  120800. * Gets the position input component
  120801. */
  120802. readonly position: NodeMaterialConnectionPoint;
  120803. /**
  120804. * Gets the normal input component
  120805. */
  120806. readonly normal: NodeMaterialConnectionPoint;
  120807. /**
  120808. * Gets the tangent input component
  120809. */
  120810. readonly tangent: NodeMaterialConnectionPoint;
  120811. /**
  120812. * Gets the tangent input component
  120813. */
  120814. readonly uv: NodeMaterialConnectionPoint;
  120815. /**
  120816. * Gets the position output component
  120817. */
  120818. readonly positionOutput: NodeMaterialConnectionPoint;
  120819. /**
  120820. * Gets the normal output component
  120821. */
  120822. readonly normalOutput: NodeMaterialConnectionPoint;
  120823. /**
  120824. * Gets the tangent output component
  120825. */
  120826. readonly tangentOutput: NodeMaterialConnectionPoint;
  120827. /**
  120828. * Gets the tangent output component
  120829. */
  120830. readonly uvOutput: NodeMaterialConnectionPoint;
  120831. initialize(state: NodeMaterialBuildState): void;
  120832. autoConfigure(material: NodeMaterial): void;
  120833. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120834. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120835. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120836. protected _buildBlock(state: NodeMaterialBuildState): this;
  120837. }
  120838. }
  120839. declare module BABYLON {
  120840. /**
  120841. * Block used to get data information from a light
  120842. */
  120843. export class LightInformationBlock extends NodeMaterialBlock {
  120844. private _lightDataUniformName;
  120845. private _lightColorUniformName;
  120846. private _lightTypeDefineName;
  120847. /**
  120848. * Gets or sets the light associated with this block
  120849. */
  120850. light: Nullable<Light>;
  120851. /**
  120852. * Creates a new LightInformationBlock
  120853. * @param name defines the block name
  120854. */
  120855. constructor(name: string);
  120856. /**
  120857. * Gets the current class name
  120858. * @returns the class name
  120859. */
  120860. getClassName(): string;
  120861. /**
  120862. * Gets the world position input component
  120863. */
  120864. readonly worldPosition: NodeMaterialConnectionPoint;
  120865. /**
  120866. * Gets the direction output component
  120867. */
  120868. readonly direction: NodeMaterialConnectionPoint;
  120869. /**
  120870. * Gets the direction output component
  120871. */
  120872. readonly color: NodeMaterialConnectionPoint;
  120873. /**
  120874. * Gets the direction output component
  120875. */
  120876. readonly intensity: NodeMaterialConnectionPoint;
  120877. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120878. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120879. protected _buildBlock(state: NodeMaterialBuildState): this;
  120880. serialize(): any;
  120881. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120882. }
  120883. }
  120884. declare module BABYLON {
  120885. /**
  120886. * Block used to add image processing support to fragment shader
  120887. */
  120888. export class ImageProcessingBlock extends NodeMaterialBlock {
  120889. /**
  120890. * Create a new ImageProcessingBlock
  120891. * @param name defines the block name
  120892. */
  120893. constructor(name: string);
  120894. /**
  120895. * Gets the current class name
  120896. * @returns the class name
  120897. */
  120898. getClassName(): string;
  120899. /**
  120900. * Gets the color input component
  120901. */
  120902. readonly color: NodeMaterialConnectionPoint;
  120903. /**
  120904. * Gets the output component
  120905. */
  120906. readonly output: NodeMaterialConnectionPoint;
  120907. /**
  120908. * Initialize the block and prepare the context for build
  120909. * @param state defines the state that will be used for the build
  120910. */
  120911. initialize(state: NodeMaterialBuildState): void;
  120912. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  120913. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120914. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120915. protected _buildBlock(state: NodeMaterialBuildState): this;
  120916. }
  120917. }
  120918. declare module BABYLON {
  120919. /**
  120920. * Block used to pertub normals based on a normal map
  120921. */
  120922. export class PerturbNormalBlock extends NodeMaterialBlock {
  120923. private _tangentSpaceParameterName;
  120924. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  120925. invertX: boolean;
  120926. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  120927. invertY: boolean;
  120928. /**
  120929. * Create a new PerturbNormalBlock
  120930. * @param name defines the block name
  120931. */
  120932. constructor(name: string);
  120933. /**
  120934. * Gets the current class name
  120935. * @returns the class name
  120936. */
  120937. getClassName(): string;
  120938. /**
  120939. * Gets the world position input component
  120940. */
  120941. readonly worldPosition: NodeMaterialConnectionPoint;
  120942. /**
  120943. * Gets the world normal input component
  120944. */
  120945. readonly worldNormal: NodeMaterialConnectionPoint;
  120946. /**
  120947. * Gets the uv input component
  120948. */
  120949. readonly uv: NodeMaterialConnectionPoint;
  120950. /**
  120951. * Gets the normal map color input component
  120952. */
  120953. readonly normalMapColor: NodeMaterialConnectionPoint;
  120954. /**
  120955. * Gets the strength input component
  120956. */
  120957. readonly strength: NodeMaterialConnectionPoint;
  120958. /**
  120959. * Gets the output component
  120960. */
  120961. readonly output: NodeMaterialConnectionPoint;
  120962. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120963. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120964. autoConfigure(material: NodeMaterial): void;
  120965. protected _buildBlock(state: NodeMaterialBuildState): this;
  120966. protected _dumpPropertiesCode(): string;
  120967. serialize(): any;
  120968. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120969. }
  120970. }
  120971. declare module BABYLON {
  120972. /**
  120973. * Block used to discard a pixel if a value is smaller than a cutoff
  120974. */
  120975. export class DiscardBlock extends NodeMaterialBlock {
  120976. /**
  120977. * Create a new DiscardBlock
  120978. * @param name defines the block name
  120979. */
  120980. constructor(name: string);
  120981. /**
  120982. * Gets the current class name
  120983. * @returns the class name
  120984. */
  120985. getClassName(): string;
  120986. /**
  120987. * Gets the color input component
  120988. */
  120989. readonly value: NodeMaterialConnectionPoint;
  120990. /**
  120991. * Gets the cutoff input component
  120992. */
  120993. readonly cutoff: NodeMaterialConnectionPoint;
  120994. protected _buildBlock(state: NodeMaterialBuildState): this;
  120995. }
  120996. }
  120997. declare module BABYLON {
  120998. /**
  120999. * Block used to add support for scene fog
  121000. */
  121001. export class FogBlock extends NodeMaterialBlock {
  121002. private _fogDistanceName;
  121003. private _fogParameters;
  121004. /**
  121005. * Create a new FogBlock
  121006. * @param name defines the block name
  121007. */
  121008. constructor(name: string);
  121009. /**
  121010. * Gets the current class name
  121011. * @returns the class name
  121012. */
  121013. getClassName(): string;
  121014. /**
  121015. * Gets the world position input component
  121016. */
  121017. readonly worldPosition: NodeMaterialConnectionPoint;
  121018. /**
  121019. * Gets the view input component
  121020. */
  121021. readonly view: NodeMaterialConnectionPoint;
  121022. /**
  121023. * Gets the color input component
  121024. */
  121025. readonly input: NodeMaterialConnectionPoint;
  121026. /**
  121027. * Gets the fog color input component
  121028. */
  121029. readonly fogColor: NodeMaterialConnectionPoint;
  121030. /**
  121031. * Gets the output component
  121032. */
  121033. readonly output: NodeMaterialConnectionPoint;
  121034. autoConfigure(material: NodeMaterial): void;
  121035. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121036. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121037. protected _buildBlock(state: NodeMaterialBuildState): this;
  121038. }
  121039. }
  121040. declare module BABYLON {
  121041. /**
  121042. * Block used to add light in the fragment shader
  121043. */
  121044. export class LightBlock extends NodeMaterialBlock {
  121045. private _lightId;
  121046. /**
  121047. * Gets or sets the light associated with this block
  121048. */
  121049. light: Nullable<Light>;
  121050. /**
  121051. * Create a new LightBlock
  121052. * @param name defines the block name
  121053. */
  121054. constructor(name: string);
  121055. /**
  121056. * Gets the current class name
  121057. * @returns the class name
  121058. */
  121059. getClassName(): string;
  121060. /**
  121061. * Gets the world position input component
  121062. */
  121063. readonly worldPosition: NodeMaterialConnectionPoint;
  121064. /**
  121065. * Gets the world normal input component
  121066. */
  121067. readonly worldNormal: NodeMaterialConnectionPoint;
  121068. /**
  121069. * Gets the camera (or eye) position component
  121070. */
  121071. readonly cameraPosition: NodeMaterialConnectionPoint;
  121072. /**
  121073. * Gets the glossiness component
  121074. */
  121075. readonly glossiness: NodeMaterialConnectionPoint;
  121076. /**
  121077. * Gets the glossinness power component
  121078. */
  121079. readonly glossPower: NodeMaterialConnectionPoint;
  121080. /**
  121081. * Gets the diffuse color component
  121082. */
  121083. readonly diffuseColor: NodeMaterialConnectionPoint;
  121084. /**
  121085. * Gets the specular color component
  121086. */
  121087. readonly specularColor: NodeMaterialConnectionPoint;
  121088. /**
  121089. * Gets the diffuse output component
  121090. */
  121091. readonly diffuseOutput: NodeMaterialConnectionPoint;
  121092. /**
  121093. * Gets the specular output component
  121094. */
  121095. readonly specularOutput: NodeMaterialConnectionPoint;
  121096. autoConfigure(material: NodeMaterial): void;
  121097. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121098. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121099. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121100. private _injectVertexCode;
  121101. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121102. serialize(): any;
  121103. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121104. }
  121105. }
  121106. declare module BABYLON {
  121107. /**
  121108. * Block used to multiply 2 values
  121109. */
  121110. export class MultiplyBlock extends NodeMaterialBlock {
  121111. /**
  121112. * Creates a new MultiplyBlock
  121113. * @param name defines the block name
  121114. */
  121115. constructor(name: string);
  121116. /**
  121117. * Gets the current class name
  121118. * @returns the class name
  121119. */
  121120. getClassName(): string;
  121121. /**
  121122. * Gets the left operand input component
  121123. */
  121124. readonly left: NodeMaterialConnectionPoint;
  121125. /**
  121126. * Gets the right operand input component
  121127. */
  121128. readonly right: NodeMaterialConnectionPoint;
  121129. /**
  121130. * Gets the output component
  121131. */
  121132. readonly output: NodeMaterialConnectionPoint;
  121133. protected _buildBlock(state: NodeMaterialBuildState): this;
  121134. }
  121135. }
  121136. declare module BABYLON {
  121137. /**
  121138. * Block used to add 2 vectors
  121139. */
  121140. export class AddBlock extends NodeMaterialBlock {
  121141. /**
  121142. * Creates a new AddBlock
  121143. * @param name defines the block name
  121144. */
  121145. constructor(name: string);
  121146. /**
  121147. * Gets the current class name
  121148. * @returns the class name
  121149. */
  121150. getClassName(): string;
  121151. /**
  121152. * Gets the left operand input component
  121153. */
  121154. readonly left: NodeMaterialConnectionPoint;
  121155. /**
  121156. * Gets the right operand input component
  121157. */
  121158. readonly right: NodeMaterialConnectionPoint;
  121159. /**
  121160. * Gets the output component
  121161. */
  121162. readonly output: NodeMaterialConnectionPoint;
  121163. protected _buildBlock(state: NodeMaterialBuildState): this;
  121164. }
  121165. }
  121166. declare module BABYLON {
  121167. /**
  121168. * Block used to scale a vector by a float
  121169. */
  121170. export class ScaleBlock extends NodeMaterialBlock {
  121171. /**
  121172. * Creates a new ScaleBlock
  121173. * @param name defines the block name
  121174. */
  121175. constructor(name: string);
  121176. /**
  121177. * Gets the current class name
  121178. * @returns the class name
  121179. */
  121180. getClassName(): string;
  121181. /**
  121182. * Gets the input component
  121183. */
  121184. readonly input: NodeMaterialConnectionPoint;
  121185. /**
  121186. * Gets the factor input component
  121187. */
  121188. readonly factor: NodeMaterialConnectionPoint;
  121189. /**
  121190. * Gets the output component
  121191. */
  121192. readonly output: NodeMaterialConnectionPoint;
  121193. protected _buildBlock(state: NodeMaterialBuildState): this;
  121194. }
  121195. }
  121196. declare module BABYLON {
  121197. /**
  121198. * Block used to clamp a float
  121199. */
  121200. export class ClampBlock extends NodeMaterialBlock {
  121201. /** Gets or sets the minimum range */
  121202. minimum: number;
  121203. /** Gets or sets the maximum range */
  121204. maximum: number;
  121205. /**
  121206. * Creates a new ClampBlock
  121207. * @param name defines the block name
  121208. */
  121209. constructor(name: string);
  121210. /**
  121211. * Gets the current class name
  121212. * @returns the class name
  121213. */
  121214. getClassName(): string;
  121215. /**
  121216. * Gets the value input component
  121217. */
  121218. readonly value: NodeMaterialConnectionPoint;
  121219. /**
  121220. * Gets the output component
  121221. */
  121222. readonly output: NodeMaterialConnectionPoint;
  121223. protected _buildBlock(state: NodeMaterialBuildState): this;
  121224. protected _dumpPropertiesCode(): string;
  121225. serialize(): any;
  121226. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121227. }
  121228. }
  121229. declare module BABYLON {
  121230. /**
  121231. * Block used to apply a cross product between 2 vectors
  121232. */
  121233. export class CrossBlock extends NodeMaterialBlock {
  121234. /**
  121235. * Creates a new CrossBlock
  121236. * @param name defines the block name
  121237. */
  121238. constructor(name: string);
  121239. /**
  121240. * Gets the current class name
  121241. * @returns the class name
  121242. */
  121243. getClassName(): string;
  121244. /**
  121245. * Gets the left operand input component
  121246. */
  121247. readonly left: NodeMaterialConnectionPoint;
  121248. /**
  121249. * Gets the right operand input component
  121250. */
  121251. readonly right: NodeMaterialConnectionPoint;
  121252. /**
  121253. * Gets the output component
  121254. */
  121255. readonly output: NodeMaterialConnectionPoint;
  121256. protected _buildBlock(state: NodeMaterialBuildState): this;
  121257. }
  121258. }
  121259. declare module BABYLON {
  121260. /**
  121261. * Block used to apply a dot product between 2 vectors
  121262. */
  121263. export class DotBlock extends NodeMaterialBlock {
  121264. /**
  121265. * Creates a new DotBlock
  121266. * @param name defines the block name
  121267. */
  121268. constructor(name: string);
  121269. /**
  121270. * Gets the current class name
  121271. * @returns the class name
  121272. */
  121273. getClassName(): string;
  121274. /**
  121275. * Gets the left operand input component
  121276. */
  121277. readonly left: NodeMaterialConnectionPoint;
  121278. /**
  121279. * Gets the right operand input component
  121280. */
  121281. readonly right: NodeMaterialConnectionPoint;
  121282. /**
  121283. * Gets the output component
  121284. */
  121285. readonly output: NodeMaterialConnectionPoint;
  121286. protected _buildBlock(state: NodeMaterialBuildState): this;
  121287. }
  121288. }
  121289. declare module BABYLON {
  121290. /**
  121291. * Block used to remap a float from a range to a new one
  121292. */
  121293. export class RemapBlock extends NodeMaterialBlock {
  121294. /**
  121295. * Gets or sets the source range
  121296. */
  121297. sourceRange: Vector2;
  121298. /**
  121299. * Gets or sets the target range
  121300. */
  121301. targetRange: Vector2;
  121302. /**
  121303. * Creates a new RemapBlock
  121304. * @param name defines the block name
  121305. */
  121306. constructor(name: string);
  121307. /**
  121308. * Gets the current class name
  121309. * @returns the class name
  121310. */
  121311. getClassName(): string;
  121312. /**
  121313. * Gets the input component
  121314. */
  121315. readonly input: NodeMaterialConnectionPoint;
  121316. /**
  121317. * Gets the source min input component
  121318. */
  121319. readonly sourceMin: NodeMaterialConnectionPoint;
  121320. /**
  121321. * Gets the source max input component
  121322. */
  121323. readonly sourceMax: NodeMaterialConnectionPoint;
  121324. /**
  121325. * Gets the target min input component
  121326. */
  121327. readonly targetMin: NodeMaterialConnectionPoint;
  121328. /**
  121329. * Gets the target max input component
  121330. */
  121331. readonly targetMax: NodeMaterialConnectionPoint;
  121332. /**
  121333. * Gets the output component
  121334. */
  121335. readonly output: NodeMaterialConnectionPoint;
  121336. protected _buildBlock(state: NodeMaterialBuildState): this;
  121337. protected _dumpPropertiesCode(): string;
  121338. serialize(): any;
  121339. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121340. }
  121341. }
  121342. declare module BABYLON {
  121343. /**
  121344. * Block used to normalize a vector
  121345. */
  121346. export class NormalizeBlock extends NodeMaterialBlock {
  121347. /**
  121348. * Creates a new NormalizeBlock
  121349. * @param name defines the block name
  121350. */
  121351. constructor(name: string);
  121352. /**
  121353. * Gets the current class name
  121354. * @returns the class name
  121355. */
  121356. getClassName(): string;
  121357. /**
  121358. * Gets the input component
  121359. */
  121360. readonly input: NodeMaterialConnectionPoint;
  121361. /**
  121362. * Gets the output component
  121363. */
  121364. readonly output: NodeMaterialConnectionPoint;
  121365. protected _buildBlock(state: NodeMaterialBuildState): this;
  121366. }
  121367. }
  121368. declare module BABYLON {
  121369. /**
  121370. * Operations supported by the Trigonometry block
  121371. */
  121372. export enum TrigonometryBlockOperations {
  121373. /** Cos */
  121374. Cos = 0,
  121375. /** Sin */
  121376. Sin = 1,
  121377. /** Abs */
  121378. Abs = 2,
  121379. /** Exp */
  121380. Exp = 3,
  121381. /** Exp2 */
  121382. Exp2 = 4,
  121383. /** Round */
  121384. Round = 5,
  121385. /** Floor */
  121386. Floor = 6,
  121387. /** Ceiling */
  121388. Ceiling = 7,
  121389. /** Square root */
  121390. Sqrt = 8,
  121391. /** Log */
  121392. Log = 9,
  121393. /** Tangent */
  121394. Tan = 10,
  121395. /** Arc tangent */
  121396. ArcTan = 11,
  121397. /** Arc cosinus */
  121398. ArcCos = 12,
  121399. /** Arc sinus */
  121400. ArcSin = 13,
  121401. /** Fraction */
  121402. Fract = 14,
  121403. /** Sign */
  121404. Sign = 15,
  121405. /** To radians (from degrees) */
  121406. Radians = 16,
  121407. /** To degrees (from radians) */
  121408. Degrees = 17
  121409. }
  121410. /**
  121411. * Block used to apply trigonometry operation to floats
  121412. */
  121413. export class TrigonometryBlock extends NodeMaterialBlock {
  121414. /**
  121415. * Gets or sets the operation applied by the block
  121416. */
  121417. operation: TrigonometryBlockOperations;
  121418. /**
  121419. * Creates a new TrigonometryBlock
  121420. * @param name defines the block name
  121421. */
  121422. constructor(name: string);
  121423. /**
  121424. * Gets the current class name
  121425. * @returns the class name
  121426. */
  121427. getClassName(): string;
  121428. /**
  121429. * Gets the input component
  121430. */
  121431. readonly input: NodeMaterialConnectionPoint;
  121432. /**
  121433. * Gets the output component
  121434. */
  121435. readonly output: NodeMaterialConnectionPoint;
  121436. protected _buildBlock(state: NodeMaterialBuildState): this;
  121437. serialize(): any;
  121438. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121439. }
  121440. }
  121441. declare module BABYLON {
  121442. /**
  121443. * Block used to create a Color3/4 out of individual inputs (one for each component)
  121444. */
  121445. export class ColorMergerBlock extends NodeMaterialBlock {
  121446. /**
  121447. * Create a new ColorMergerBlock
  121448. * @param name defines the block name
  121449. */
  121450. constructor(name: string);
  121451. /**
  121452. * Gets the current class name
  121453. * @returns the class name
  121454. */
  121455. getClassName(): string;
  121456. /**
  121457. * Gets the r component (input)
  121458. */
  121459. readonly r: NodeMaterialConnectionPoint;
  121460. /**
  121461. * Gets the g component (input)
  121462. */
  121463. readonly g: NodeMaterialConnectionPoint;
  121464. /**
  121465. * Gets the b component (input)
  121466. */
  121467. readonly b: NodeMaterialConnectionPoint;
  121468. /**
  121469. * Gets the a component (input)
  121470. */
  121471. readonly a: NodeMaterialConnectionPoint;
  121472. /**
  121473. * Gets the rgba component (output)
  121474. */
  121475. readonly rgba: NodeMaterialConnectionPoint;
  121476. /**
  121477. * Gets the rgb component (output)
  121478. */
  121479. readonly rgb: NodeMaterialConnectionPoint;
  121480. protected _buildBlock(state: NodeMaterialBuildState): this;
  121481. }
  121482. }
  121483. declare module BABYLON {
  121484. /**
  121485. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  121486. */
  121487. export class VectorMergerBlock extends NodeMaterialBlock {
  121488. /**
  121489. * Create a new VectorMergerBlock
  121490. * @param name defines the block name
  121491. */
  121492. constructor(name: string);
  121493. /**
  121494. * Gets the current class name
  121495. * @returns the class name
  121496. */
  121497. getClassName(): string;
  121498. /**
  121499. * Gets the x component (input)
  121500. */
  121501. readonly x: NodeMaterialConnectionPoint;
  121502. /**
  121503. * Gets the y component (input)
  121504. */
  121505. readonly y: NodeMaterialConnectionPoint;
  121506. /**
  121507. * Gets the z component (input)
  121508. */
  121509. readonly z: NodeMaterialConnectionPoint;
  121510. /**
  121511. * Gets the w component (input)
  121512. */
  121513. readonly w: NodeMaterialConnectionPoint;
  121514. /**
  121515. * Gets the xyzw component (output)
  121516. */
  121517. readonly xyzw: NodeMaterialConnectionPoint;
  121518. /**
  121519. * Gets the xyz component (output)
  121520. */
  121521. readonly xyz: NodeMaterialConnectionPoint;
  121522. /**
  121523. * Gets the xy component (output)
  121524. */
  121525. readonly xy: NodeMaterialConnectionPoint;
  121526. protected _buildBlock(state: NodeMaterialBuildState): this;
  121527. }
  121528. }
  121529. declare module BABYLON {
  121530. /**
  121531. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  121532. */
  121533. export class ColorSplitterBlock extends NodeMaterialBlock {
  121534. /**
  121535. * Create a new ColorSplitterBlock
  121536. * @param name defines the block name
  121537. */
  121538. constructor(name: string);
  121539. /**
  121540. * Gets the current class name
  121541. * @returns the class name
  121542. */
  121543. getClassName(): string;
  121544. /**
  121545. * Gets the rgba component (input)
  121546. */
  121547. readonly rgba: NodeMaterialConnectionPoint;
  121548. /**
  121549. * Gets the rgb component (input)
  121550. */
  121551. readonly rgbIn: NodeMaterialConnectionPoint;
  121552. /**
  121553. * Gets the rgb component (output)
  121554. */
  121555. readonly rgbOut: NodeMaterialConnectionPoint;
  121556. /**
  121557. * Gets the r component (output)
  121558. */
  121559. readonly r: NodeMaterialConnectionPoint;
  121560. /**
  121561. * Gets the g component (output)
  121562. */
  121563. readonly g: NodeMaterialConnectionPoint;
  121564. /**
  121565. * Gets the b component (output)
  121566. */
  121567. readonly b: NodeMaterialConnectionPoint;
  121568. /**
  121569. * Gets the a component (output)
  121570. */
  121571. readonly a: NodeMaterialConnectionPoint;
  121572. protected _inputRename(name: string): string;
  121573. protected _outputRename(name: string): string;
  121574. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121575. }
  121576. }
  121577. declare module BABYLON {
  121578. /**
  121579. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  121580. */
  121581. export class VectorSplitterBlock extends NodeMaterialBlock {
  121582. /**
  121583. * Create a new VectorSplitterBlock
  121584. * @param name defines the block name
  121585. */
  121586. constructor(name: string);
  121587. /**
  121588. * Gets the current class name
  121589. * @returns the class name
  121590. */
  121591. getClassName(): string;
  121592. /**
  121593. * Gets the xyzw component (input)
  121594. */
  121595. readonly xyzw: NodeMaterialConnectionPoint;
  121596. /**
  121597. * Gets the xyz component (input)
  121598. */
  121599. readonly xyzIn: NodeMaterialConnectionPoint;
  121600. /**
  121601. * Gets the xy component (input)
  121602. */
  121603. readonly xyIn: NodeMaterialConnectionPoint;
  121604. /**
  121605. * Gets the xyz component (output)
  121606. */
  121607. readonly xyzOut: NodeMaterialConnectionPoint;
  121608. /**
  121609. * Gets the xy component (output)
  121610. */
  121611. readonly xyOut: NodeMaterialConnectionPoint;
  121612. /**
  121613. * Gets the x component (output)
  121614. */
  121615. readonly x: NodeMaterialConnectionPoint;
  121616. /**
  121617. * Gets the y component (output)
  121618. */
  121619. readonly y: NodeMaterialConnectionPoint;
  121620. /**
  121621. * Gets the z component (output)
  121622. */
  121623. readonly z: NodeMaterialConnectionPoint;
  121624. /**
  121625. * Gets the w component (output)
  121626. */
  121627. readonly w: NodeMaterialConnectionPoint;
  121628. protected _inputRename(name: string): string;
  121629. protected _outputRename(name: string): string;
  121630. protected _buildBlock(state: NodeMaterialBuildState): this;
  121631. }
  121632. }
  121633. declare module BABYLON {
  121634. /**
  121635. * Block used to lerp between 2 values
  121636. */
  121637. export class LerpBlock extends NodeMaterialBlock {
  121638. /**
  121639. * Creates a new LerpBlock
  121640. * @param name defines the block name
  121641. */
  121642. constructor(name: string);
  121643. /**
  121644. * Gets the current class name
  121645. * @returns the class name
  121646. */
  121647. getClassName(): string;
  121648. /**
  121649. * Gets the left operand input component
  121650. */
  121651. readonly left: NodeMaterialConnectionPoint;
  121652. /**
  121653. * Gets the right operand input component
  121654. */
  121655. readonly right: NodeMaterialConnectionPoint;
  121656. /**
  121657. * Gets the gradient operand input component
  121658. */
  121659. readonly gradient: NodeMaterialConnectionPoint;
  121660. /**
  121661. * Gets the output component
  121662. */
  121663. readonly output: NodeMaterialConnectionPoint;
  121664. protected _buildBlock(state: NodeMaterialBuildState): this;
  121665. }
  121666. }
  121667. declare module BABYLON {
  121668. /**
  121669. * Block used to divide 2 vectors
  121670. */
  121671. export class DivideBlock extends NodeMaterialBlock {
  121672. /**
  121673. * Creates a new DivideBlock
  121674. * @param name defines the block name
  121675. */
  121676. constructor(name: string);
  121677. /**
  121678. * Gets the current class name
  121679. * @returns the class name
  121680. */
  121681. getClassName(): string;
  121682. /**
  121683. * Gets the left operand input component
  121684. */
  121685. readonly left: NodeMaterialConnectionPoint;
  121686. /**
  121687. * Gets the right operand input component
  121688. */
  121689. readonly right: NodeMaterialConnectionPoint;
  121690. /**
  121691. * Gets the output component
  121692. */
  121693. readonly output: NodeMaterialConnectionPoint;
  121694. protected _buildBlock(state: NodeMaterialBuildState): this;
  121695. }
  121696. }
  121697. declare module BABYLON {
  121698. /**
  121699. * Block used to subtract 2 vectors
  121700. */
  121701. export class SubtractBlock extends NodeMaterialBlock {
  121702. /**
  121703. * Creates a new SubtractBlock
  121704. * @param name defines the block name
  121705. */
  121706. constructor(name: string);
  121707. /**
  121708. * Gets the current class name
  121709. * @returns the class name
  121710. */
  121711. getClassName(): string;
  121712. /**
  121713. * Gets the left operand input component
  121714. */
  121715. readonly left: NodeMaterialConnectionPoint;
  121716. /**
  121717. * Gets the right operand input component
  121718. */
  121719. readonly right: NodeMaterialConnectionPoint;
  121720. /**
  121721. * Gets the output component
  121722. */
  121723. readonly output: NodeMaterialConnectionPoint;
  121724. protected _buildBlock(state: NodeMaterialBuildState): this;
  121725. }
  121726. }
  121727. declare module BABYLON {
  121728. /**
  121729. * Block used to step a value
  121730. */
  121731. export class StepBlock extends NodeMaterialBlock {
  121732. /**
  121733. * Creates a new StepBlock
  121734. * @param name defines the block name
  121735. */
  121736. constructor(name: string);
  121737. /**
  121738. * Gets the current class name
  121739. * @returns the class name
  121740. */
  121741. getClassName(): string;
  121742. /**
  121743. * Gets the value operand input component
  121744. */
  121745. readonly value: NodeMaterialConnectionPoint;
  121746. /**
  121747. * Gets the edge operand input component
  121748. */
  121749. readonly edge: NodeMaterialConnectionPoint;
  121750. /**
  121751. * Gets the output component
  121752. */
  121753. readonly output: NodeMaterialConnectionPoint;
  121754. protected _buildBlock(state: NodeMaterialBuildState): this;
  121755. }
  121756. }
  121757. declare module BABYLON {
  121758. /**
  121759. * Block used to get the opposite (1 - x) of a value
  121760. */
  121761. export class OneMinusBlock extends NodeMaterialBlock {
  121762. /**
  121763. * Creates a new OneMinusBlock
  121764. * @param name defines the block name
  121765. */
  121766. constructor(name: string);
  121767. /**
  121768. * Gets the current class name
  121769. * @returns the class name
  121770. */
  121771. getClassName(): string;
  121772. /**
  121773. * Gets the input component
  121774. */
  121775. readonly input: NodeMaterialConnectionPoint;
  121776. /**
  121777. * Gets the output component
  121778. */
  121779. readonly output: NodeMaterialConnectionPoint;
  121780. protected _buildBlock(state: NodeMaterialBuildState): this;
  121781. }
  121782. }
  121783. declare module BABYLON {
  121784. /**
  121785. * Block used to get the view direction
  121786. */
  121787. export class ViewDirectionBlock extends NodeMaterialBlock {
  121788. /**
  121789. * Creates a new ViewDirectionBlock
  121790. * @param name defines the block name
  121791. */
  121792. constructor(name: string);
  121793. /**
  121794. * Gets the current class name
  121795. * @returns the class name
  121796. */
  121797. getClassName(): string;
  121798. /**
  121799. * Gets the world position component
  121800. */
  121801. readonly worldPosition: NodeMaterialConnectionPoint;
  121802. /**
  121803. * Gets the camera position component
  121804. */
  121805. readonly cameraPosition: NodeMaterialConnectionPoint;
  121806. /**
  121807. * Gets the output component
  121808. */
  121809. readonly output: NodeMaterialConnectionPoint;
  121810. autoConfigure(material: NodeMaterial): void;
  121811. protected _buildBlock(state: NodeMaterialBuildState): this;
  121812. }
  121813. }
  121814. declare module BABYLON {
  121815. /**
  121816. * Block used to compute fresnel value
  121817. */
  121818. export class FresnelBlock extends NodeMaterialBlock {
  121819. /**
  121820. * Create a new FresnelBlock
  121821. * @param name defines the block name
  121822. */
  121823. constructor(name: string);
  121824. /**
  121825. * Gets the current class name
  121826. * @returns the class name
  121827. */
  121828. getClassName(): string;
  121829. /**
  121830. * Gets the world normal input component
  121831. */
  121832. readonly worldNormal: NodeMaterialConnectionPoint;
  121833. /**
  121834. * Gets the view direction input component
  121835. */
  121836. readonly viewDirection: NodeMaterialConnectionPoint;
  121837. /**
  121838. * Gets the bias input component
  121839. */
  121840. readonly bias: NodeMaterialConnectionPoint;
  121841. /**
  121842. * Gets the camera (or eye) position component
  121843. */
  121844. readonly power: NodeMaterialConnectionPoint;
  121845. /**
  121846. * Gets the fresnel output component
  121847. */
  121848. readonly fresnel: NodeMaterialConnectionPoint;
  121849. autoConfigure(material: NodeMaterial): void;
  121850. protected _buildBlock(state: NodeMaterialBuildState): this;
  121851. }
  121852. }
  121853. declare module BABYLON {
  121854. /**
  121855. * Block used to get the max of 2 values
  121856. */
  121857. export class MaxBlock extends NodeMaterialBlock {
  121858. /**
  121859. * Creates a new MaxBlock
  121860. * @param name defines the block name
  121861. */
  121862. constructor(name: string);
  121863. /**
  121864. * Gets the current class name
  121865. * @returns the class name
  121866. */
  121867. getClassName(): string;
  121868. /**
  121869. * Gets the left operand input component
  121870. */
  121871. readonly left: NodeMaterialConnectionPoint;
  121872. /**
  121873. * Gets the right operand input component
  121874. */
  121875. readonly right: NodeMaterialConnectionPoint;
  121876. /**
  121877. * Gets the output component
  121878. */
  121879. readonly output: NodeMaterialConnectionPoint;
  121880. protected _buildBlock(state: NodeMaterialBuildState): this;
  121881. }
  121882. }
  121883. declare module BABYLON {
  121884. /**
  121885. * Block used to get the min of 2 values
  121886. */
  121887. export class MinBlock extends NodeMaterialBlock {
  121888. /**
  121889. * Creates a new MinBlock
  121890. * @param name defines the block name
  121891. */
  121892. constructor(name: string);
  121893. /**
  121894. * Gets the current class name
  121895. * @returns the class name
  121896. */
  121897. getClassName(): string;
  121898. /**
  121899. * Gets the left operand input component
  121900. */
  121901. readonly left: NodeMaterialConnectionPoint;
  121902. /**
  121903. * Gets the right operand input component
  121904. */
  121905. readonly right: NodeMaterialConnectionPoint;
  121906. /**
  121907. * Gets the output component
  121908. */
  121909. readonly output: NodeMaterialConnectionPoint;
  121910. protected _buildBlock(state: NodeMaterialBuildState): this;
  121911. }
  121912. }
  121913. declare module BABYLON {
  121914. /**
  121915. * Block used to get the distance between 2 values
  121916. */
  121917. export class DistanceBlock extends NodeMaterialBlock {
  121918. /**
  121919. * Creates a new DistanceBlock
  121920. * @param name defines the block name
  121921. */
  121922. constructor(name: string);
  121923. /**
  121924. * Gets the current class name
  121925. * @returns the class name
  121926. */
  121927. getClassName(): string;
  121928. /**
  121929. * Gets the left operand input component
  121930. */
  121931. readonly left: NodeMaterialConnectionPoint;
  121932. /**
  121933. * Gets the right operand input component
  121934. */
  121935. readonly right: NodeMaterialConnectionPoint;
  121936. /**
  121937. * Gets the output component
  121938. */
  121939. readonly output: NodeMaterialConnectionPoint;
  121940. protected _buildBlock(state: NodeMaterialBuildState): this;
  121941. }
  121942. }
  121943. declare module BABYLON {
  121944. /**
  121945. * Block used to get the length of a vector
  121946. */
  121947. export class LengthBlock extends NodeMaterialBlock {
  121948. /**
  121949. * Creates a new LengthBlock
  121950. * @param name defines the block name
  121951. */
  121952. constructor(name: string);
  121953. /**
  121954. * Gets the current class name
  121955. * @returns the class name
  121956. */
  121957. getClassName(): string;
  121958. /**
  121959. * Gets the value input component
  121960. */
  121961. readonly value: NodeMaterialConnectionPoint;
  121962. /**
  121963. * Gets the output component
  121964. */
  121965. readonly output: NodeMaterialConnectionPoint;
  121966. protected _buildBlock(state: NodeMaterialBuildState): this;
  121967. }
  121968. }
  121969. declare module BABYLON {
  121970. /**
  121971. * Block used to get negative version of a value (i.e. x * -1)
  121972. */
  121973. export class NegateBlock extends NodeMaterialBlock {
  121974. /**
  121975. * Creates a new NegateBlock
  121976. * @param name defines the block name
  121977. */
  121978. constructor(name: string);
  121979. /**
  121980. * Gets the current class name
  121981. * @returns the class name
  121982. */
  121983. getClassName(): string;
  121984. /**
  121985. * Gets the value input component
  121986. */
  121987. readonly value: NodeMaterialConnectionPoint;
  121988. /**
  121989. * Gets the output component
  121990. */
  121991. readonly output: NodeMaterialConnectionPoint;
  121992. protected _buildBlock(state: NodeMaterialBuildState): this;
  121993. }
  121994. }
  121995. declare module BABYLON {
  121996. /**
  121997. * Block used to get the value of the first parameter raised to the power of the second
  121998. */
  121999. export class PowBlock extends NodeMaterialBlock {
  122000. /**
  122001. * Creates a new PowBlock
  122002. * @param name defines the block name
  122003. */
  122004. constructor(name: string);
  122005. /**
  122006. * Gets the current class name
  122007. * @returns the class name
  122008. */
  122009. getClassName(): string;
  122010. /**
  122011. * Gets the value operand input component
  122012. */
  122013. readonly value: NodeMaterialConnectionPoint;
  122014. /**
  122015. * Gets the power operand input component
  122016. */
  122017. readonly power: NodeMaterialConnectionPoint;
  122018. /**
  122019. * Gets the output component
  122020. */
  122021. readonly output: NodeMaterialConnectionPoint;
  122022. protected _buildBlock(state: NodeMaterialBuildState): this;
  122023. }
  122024. }
  122025. declare module BABYLON {
  122026. /**
  122027. * Block used to get a random number
  122028. */
  122029. export class RandomNumberBlock extends NodeMaterialBlock {
  122030. /**
  122031. * Creates a new RandomNumberBlock
  122032. * @param name defines the block name
  122033. */
  122034. constructor(name: string);
  122035. /**
  122036. * Gets the current class name
  122037. * @returns the class name
  122038. */
  122039. getClassName(): string;
  122040. /**
  122041. * Gets the seed input component
  122042. */
  122043. readonly seed: NodeMaterialConnectionPoint;
  122044. /**
  122045. * Gets the output component
  122046. */
  122047. readonly output: NodeMaterialConnectionPoint;
  122048. protected _buildBlock(state: NodeMaterialBuildState): this;
  122049. }
  122050. }
  122051. declare module BABYLON {
  122052. /**
  122053. * Block used to compute arc tangent of 2 values
  122054. */
  122055. export class ArcTan2Block extends NodeMaterialBlock {
  122056. /**
  122057. * Creates a new ArcTan2Block
  122058. * @param name defines the block name
  122059. */
  122060. constructor(name: string);
  122061. /**
  122062. * Gets the current class name
  122063. * @returns the class name
  122064. */
  122065. getClassName(): string;
  122066. /**
  122067. * Gets the x operand input component
  122068. */
  122069. readonly x: NodeMaterialConnectionPoint;
  122070. /**
  122071. * Gets the y operand input component
  122072. */
  122073. readonly y: NodeMaterialConnectionPoint;
  122074. /**
  122075. * Gets the output component
  122076. */
  122077. readonly output: NodeMaterialConnectionPoint;
  122078. protected _buildBlock(state: NodeMaterialBuildState): this;
  122079. }
  122080. }
  122081. declare module BABYLON {
  122082. /**
  122083. * Block used to smooth step a value
  122084. */
  122085. export class SmoothStepBlock extends NodeMaterialBlock {
  122086. /**
  122087. * Creates a new SmoothStepBlock
  122088. * @param name defines the block name
  122089. */
  122090. constructor(name: string);
  122091. /**
  122092. * Gets the current class name
  122093. * @returns the class name
  122094. */
  122095. getClassName(): string;
  122096. /**
  122097. * Gets the value operand input component
  122098. */
  122099. readonly value: NodeMaterialConnectionPoint;
  122100. /**
  122101. * Gets the first edge operand input component
  122102. */
  122103. readonly edge0: NodeMaterialConnectionPoint;
  122104. /**
  122105. * Gets the second edge operand input component
  122106. */
  122107. readonly edge1: NodeMaterialConnectionPoint;
  122108. /**
  122109. * Gets the output component
  122110. */
  122111. readonly output: NodeMaterialConnectionPoint;
  122112. protected _buildBlock(state: NodeMaterialBuildState): this;
  122113. }
  122114. }
  122115. declare module BABYLON {
  122116. /**
  122117. * Block used to get the reciprocal (1 / x) of a value
  122118. */
  122119. export class ReciprocalBlock extends NodeMaterialBlock {
  122120. /**
  122121. * Creates a new ReciprocalBlock
  122122. * @param name defines the block name
  122123. */
  122124. constructor(name: string);
  122125. /**
  122126. * Gets the current class name
  122127. * @returns the class name
  122128. */
  122129. getClassName(): string;
  122130. /**
  122131. * Gets the input component
  122132. */
  122133. readonly input: NodeMaterialConnectionPoint;
  122134. /**
  122135. * Gets the output component
  122136. */
  122137. readonly output: NodeMaterialConnectionPoint;
  122138. protected _buildBlock(state: NodeMaterialBuildState): this;
  122139. }
  122140. }
  122141. declare module BABYLON {
  122142. /**
  122143. * Block used to replace a color by another one
  122144. */
  122145. export class ReplaceColorBlock extends NodeMaterialBlock {
  122146. /**
  122147. * Creates a new ReplaceColorBlock
  122148. * @param name defines the block name
  122149. */
  122150. constructor(name: string);
  122151. /**
  122152. * Gets the current class name
  122153. * @returns the class name
  122154. */
  122155. getClassName(): string;
  122156. /**
  122157. * Gets the value input component
  122158. */
  122159. readonly value: NodeMaterialConnectionPoint;
  122160. /**
  122161. * Gets the reference input component
  122162. */
  122163. readonly reference: NodeMaterialConnectionPoint;
  122164. /**
  122165. * Gets the distance input component
  122166. */
  122167. readonly distance: NodeMaterialConnectionPoint;
  122168. /**
  122169. * Gets the replacement input component
  122170. */
  122171. readonly replacement: NodeMaterialConnectionPoint;
  122172. /**
  122173. * Gets the output component
  122174. */
  122175. readonly output: NodeMaterialConnectionPoint;
  122176. protected _buildBlock(state: NodeMaterialBuildState): this;
  122177. }
  122178. }
  122179. declare module BABYLON {
  122180. /**
  122181. * Block used to posterize a value
  122182. * @see https://en.wikipedia.org/wiki/Posterization
  122183. */
  122184. export class PosterizeBlock extends NodeMaterialBlock {
  122185. /**
  122186. * Creates a new PosterizeBlock
  122187. * @param name defines the block name
  122188. */
  122189. constructor(name: string);
  122190. /**
  122191. * Gets the current class name
  122192. * @returns the class name
  122193. */
  122194. getClassName(): string;
  122195. /**
  122196. * Gets the value input component
  122197. */
  122198. readonly value: NodeMaterialConnectionPoint;
  122199. /**
  122200. * Gets the steps input component
  122201. */
  122202. readonly steps: NodeMaterialConnectionPoint;
  122203. /**
  122204. * Gets the output component
  122205. */
  122206. readonly output: NodeMaterialConnectionPoint;
  122207. protected _buildBlock(state: NodeMaterialBuildState): this;
  122208. }
  122209. }
  122210. declare module BABYLON {
  122211. /**
  122212. * Operations supported by the Wave block
  122213. */
  122214. export enum WaveBlockKind {
  122215. /** SawTooth */
  122216. SawTooth = 0,
  122217. /** Square */
  122218. Square = 1,
  122219. /** Triangle */
  122220. Triangle = 2
  122221. }
  122222. /**
  122223. * Block used to apply wave operation to floats
  122224. */
  122225. export class WaveBlock extends NodeMaterialBlock {
  122226. /**
  122227. * Gets or sets the kibnd of wave to be applied by the block
  122228. */
  122229. kind: WaveBlockKind;
  122230. /**
  122231. * Creates a new WaveBlock
  122232. * @param name defines the block name
  122233. */
  122234. constructor(name: string);
  122235. /**
  122236. * Gets the current class name
  122237. * @returns the class name
  122238. */
  122239. getClassName(): string;
  122240. /**
  122241. * Gets the input component
  122242. */
  122243. readonly input: NodeMaterialConnectionPoint;
  122244. /**
  122245. * Gets the output component
  122246. */
  122247. readonly output: NodeMaterialConnectionPoint;
  122248. protected _buildBlock(state: NodeMaterialBuildState): this;
  122249. serialize(): any;
  122250. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122251. }
  122252. }
  122253. declare module BABYLON {
  122254. /**
  122255. * Class used to store a color step for the GradientBlock
  122256. */
  122257. export class GradientBlockColorStep {
  122258. /**
  122259. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122260. */
  122261. step: number;
  122262. /**
  122263. * Gets or sets the color associated with this step
  122264. */
  122265. color: Color3;
  122266. /**
  122267. * Creates a new GradientBlockColorStep
  122268. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  122269. * @param color defines the color associated with this step
  122270. */
  122271. constructor(
  122272. /**
  122273. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122274. */
  122275. step: number,
  122276. /**
  122277. * Gets or sets the color associated with this step
  122278. */
  122279. color: Color3);
  122280. }
  122281. /**
  122282. * Block used to return a color from a gradient based on an input value between 0 and 1
  122283. */
  122284. export class GradientBlock extends NodeMaterialBlock {
  122285. /**
  122286. * Gets or sets the list of color steps
  122287. */
  122288. colorSteps: GradientBlockColorStep[];
  122289. /**
  122290. * Creates a new GradientBlock
  122291. * @param name defines the block name
  122292. */
  122293. constructor(name: string);
  122294. /**
  122295. * Gets the current class name
  122296. * @returns the class name
  122297. */
  122298. getClassName(): string;
  122299. /**
  122300. * Gets the gradient input component
  122301. */
  122302. readonly gradient: NodeMaterialConnectionPoint;
  122303. /**
  122304. * Gets the output component
  122305. */
  122306. readonly output: NodeMaterialConnectionPoint;
  122307. private _writeColorConstant;
  122308. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122309. serialize(): any;
  122310. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122311. protected _dumpPropertiesCode(): string;
  122312. }
  122313. }
  122314. declare module BABYLON {
  122315. /**
  122316. * Block used to normalize lerp between 2 values
  122317. */
  122318. export class NLerpBlock extends NodeMaterialBlock {
  122319. /**
  122320. * Creates a new NLerpBlock
  122321. * @param name defines the block name
  122322. */
  122323. constructor(name: string);
  122324. /**
  122325. * Gets the current class name
  122326. * @returns the class name
  122327. */
  122328. getClassName(): string;
  122329. /**
  122330. * Gets the left operand input component
  122331. */
  122332. readonly left: NodeMaterialConnectionPoint;
  122333. /**
  122334. * Gets the right operand input component
  122335. */
  122336. readonly right: NodeMaterialConnectionPoint;
  122337. /**
  122338. * Gets the gradient operand input component
  122339. */
  122340. readonly gradient: NodeMaterialConnectionPoint;
  122341. /**
  122342. * Gets the output component
  122343. */
  122344. readonly output: NodeMaterialConnectionPoint;
  122345. protected _buildBlock(state: NodeMaterialBuildState): this;
  122346. }
  122347. }
  122348. declare module BABYLON {
  122349. /**
  122350. * Effect Render Options
  122351. */
  122352. export interface IEffectRendererOptions {
  122353. /**
  122354. * Defines the vertices positions.
  122355. */
  122356. positions?: number[];
  122357. /**
  122358. * Defines the indices.
  122359. */
  122360. indices?: number[];
  122361. }
  122362. /**
  122363. * Helper class to render one or more effects
  122364. */
  122365. export class EffectRenderer {
  122366. private engine;
  122367. private static _DefaultOptions;
  122368. private _vertexBuffers;
  122369. private _indexBuffer;
  122370. private _ringBufferIndex;
  122371. private _ringScreenBuffer;
  122372. private _fullscreenViewport;
  122373. private _getNextFrameBuffer;
  122374. /**
  122375. * Creates an effect renderer
  122376. * @param engine the engine to use for rendering
  122377. * @param options defines the options of the effect renderer
  122378. */
  122379. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  122380. /**
  122381. * Sets the current viewport in normalized coordinates 0-1
  122382. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  122383. */
  122384. setViewport(viewport?: Viewport): void;
  122385. /**
  122386. * Binds the embedded attributes buffer to the effect.
  122387. * @param effect Defines the effect to bind the attributes for
  122388. */
  122389. bindBuffers(effect: Effect): void;
  122390. /**
  122391. * Sets the current effect wrapper to use during draw.
  122392. * The effect needs to be ready before calling this api.
  122393. * This also sets the default full screen position attribute.
  122394. * @param effectWrapper Defines the effect to draw with
  122395. */
  122396. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  122397. /**
  122398. * Draws a full screen quad.
  122399. */
  122400. draw(): void;
  122401. /**
  122402. * renders one or more effects to a specified texture
  122403. * @param effectWrappers list of effects to renderer
  122404. * @param outputTexture texture to draw to, if null it will render to the screen
  122405. */
  122406. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  122407. /**
  122408. * Disposes of the effect renderer
  122409. */
  122410. dispose(): void;
  122411. }
  122412. /**
  122413. * Options to create an EffectWrapper
  122414. */
  122415. interface EffectWrapperCreationOptions {
  122416. /**
  122417. * Engine to use to create the effect
  122418. */
  122419. engine: ThinEngine;
  122420. /**
  122421. * Fragment shader for the effect
  122422. */
  122423. fragmentShader: string;
  122424. /**
  122425. * Vertex shader for the effect
  122426. */
  122427. vertexShader?: string;
  122428. /**
  122429. * Attributes to use in the shader
  122430. */
  122431. attributeNames?: Array<string>;
  122432. /**
  122433. * Uniforms to use in the shader
  122434. */
  122435. uniformNames?: Array<string>;
  122436. /**
  122437. * Texture sampler names to use in the shader
  122438. */
  122439. samplerNames?: Array<string>;
  122440. /**
  122441. * The friendly name of the effect displayed in Spector.
  122442. */
  122443. name?: string;
  122444. }
  122445. /**
  122446. * Wraps an effect to be used for rendering
  122447. */
  122448. export class EffectWrapper {
  122449. /**
  122450. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  122451. */
  122452. onApplyObservable: Observable<{}>;
  122453. /**
  122454. * The underlying effect
  122455. */
  122456. effect: Effect;
  122457. /**
  122458. * Creates an effect to be renderer
  122459. * @param creationOptions options to create the effect
  122460. */
  122461. constructor(creationOptions: EffectWrapperCreationOptions);
  122462. /**
  122463. * Disposes of the effect wrapper
  122464. */
  122465. dispose(): void;
  122466. }
  122467. }
  122468. declare module BABYLON {
  122469. /**
  122470. * Helper class to push actions to a pool of workers.
  122471. */
  122472. export class WorkerPool implements IDisposable {
  122473. private _workerInfos;
  122474. private _pendingActions;
  122475. /**
  122476. * Constructor
  122477. * @param workers Array of workers to use for actions
  122478. */
  122479. constructor(workers: Array<Worker>);
  122480. /**
  122481. * Terminates all workers and clears any pending actions.
  122482. */
  122483. dispose(): void;
  122484. /**
  122485. * Pushes an action to the worker pool. If all the workers are active, the action will be
  122486. * pended until a worker has completed its action.
  122487. * @param action The action to perform. Call onComplete when the action is complete.
  122488. */
  122489. push(action: (worker: Worker, onComplete: () => void) => void): void;
  122490. private _execute;
  122491. }
  122492. }
  122493. declare module BABYLON {
  122494. /**
  122495. * Configuration for Draco compression
  122496. */
  122497. export interface IDracoCompressionConfiguration {
  122498. /**
  122499. * Configuration for the decoder.
  122500. */
  122501. decoder: {
  122502. /**
  122503. * The url to the WebAssembly module.
  122504. */
  122505. wasmUrl?: string;
  122506. /**
  122507. * The url to the WebAssembly binary.
  122508. */
  122509. wasmBinaryUrl?: string;
  122510. /**
  122511. * The url to the fallback JavaScript module.
  122512. */
  122513. fallbackUrl?: string;
  122514. };
  122515. }
  122516. /**
  122517. * Draco compression (https://google.github.io/draco/)
  122518. *
  122519. * This class wraps the Draco module.
  122520. *
  122521. * **Encoder**
  122522. *
  122523. * The encoder is not currently implemented.
  122524. *
  122525. * **Decoder**
  122526. *
  122527. * 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.
  122528. *
  122529. * To update the configuration, use the following code:
  122530. * ```javascript
  122531. * DracoCompression.Configuration = {
  122532. * decoder: {
  122533. * wasmUrl: "<url to the WebAssembly library>",
  122534. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  122535. * fallbackUrl: "<url to the fallback JavaScript library>",
  122536. * }
  122537. * };
  122538. * ```
  122539. *
  122540. * 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.
  122541. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  122542. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  122543. *
  122544. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  122545. * ```javascript
  122546. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  122547. * ```
  122548. *
  122549. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  122550. */
  122551. export class DracoCompression implements IDisposable {
  122552. private _workerPoolPromise?;
  122553. private _decoderModulePromise?;
  122554. /**
  122555. * The configuration. Defaults to the following urls:
  122556. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  122557. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  122558. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  122559. */
  122560. static Configuration: IDracoCompressionConfiguration;
  122561. /**
  122562. * Returns true if the decoder configuration is available.
  122563. */
  122564. static readonly DecoderAvailable: boolean;
  122565. /**
  122566. * Default number of workers to create when creating the draco compression object.
  122567. */
  122568. static DefaultNumWorkers: number;
  122569. private static GetDefaultNumWorkers;
  122570. private static _Default;
  122571. /**
  122572. * Default instance for the draco compression object.
  122573. */
  122574. static readonly Default: DracoCompression;
  122575. /**
  122576. * Constructor
  122577. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  122578. */
  122579. constructor(numWorkers?: number);
  122580. /**
  122581. * Stop all async operations and release resources.
  122582. */
  122583. dispose(): void;
  122584. /**
  122585. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  122586. * @returns a promise that resolves when ready
  122587. */
  122588. whenReadyAsync(): Promise<void>;
  122589. /**
  122590. * Decode Draco compressed mesh data to vertex data.
  122591. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  122592. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  122593. * @returns A promise that resolves with the decoded vertex data
  122594. */
  122595. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  122596. [kind: string]: number;
  122597. }): Promise<VertexData>;
  122598. }
  122599. }
  122600. declare module BABYLON {
  122601. /**
  122602. * Class for building Constructive Solid Geometry
  122603. */
  122604. export class CSG {
  122605. private polygons;
  122606. /**
  122607. * The world matrix
  122608. */
  122609. matrix: Matrix;
  122610. /**
  122611. * Stores the position
  122612. */
  122613. position: Vector3;
  122614. /**
  122615. * Stores the rotation
  122616. */
  122617. rotation: Vector3;
  122618. /**
  122619. * Stores the rotation quaternion
  122620. */
  122621. rotationQuaternion: Nullable<Quaternion>;
  122622. /**
  122623. * Stores the scaling vector
  122624. */
  122625. scaling: Vector3;
  122626. /**
  122627. * Convert the Mesh to CSG
  122628. * @param mesh The Mesh to convert to CSG
  122629. * @returns A new CSG from the Mesh
  122630. */
  122631. static FromMesh(mesh: Mesh): CSG;
  122632. /**
  122633. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  122634. * @param polygons Polygons used to construct a CSG solid
  122635. */
  122636. private static FromPolygons;
  122637. /**
  122638. * Clones, or makes a deep copy, of the CSG
  122639. * @returns A new CSG
  122640. */
  122641. clone(): CSG;
  122642. /**
  122643. * Unions this CSG with another CSG
  122644. * @param csg The CSG to union against this CSG
  122645. * @returns The unioned CSG
  122646. */
  122647. union(csg: CSG): CSG;
  122648. /**
  122649. * Unions this CSG with another CSG in place
  122650. * @param csg The CSG to union against this CSG
  122651. */
  122652. unionInPlace(csg: CSG): void;
  122653. /**
  122654. * Subtracts this CSG with another CSG
  122655. * @param csg The CSG to subtract against this CSG
  122656. * @returns A new CSG
  122657. */
  122658. subtract(csg: CSG): CSG;
  122659. /**
  122660. * Subtracts this CSG with another CSG in place
  122661. * @param csg The CSG to subtact against this CSG
  122662. */
  122663. subtractInPlace(csg: CSG): void;
  122664. /**
  122665. * Intersect this CSG with another CSG
  122666. * @param csg The CSG to intersect against this CSG
  122667. * @returns A new CSG
  122668. */
  122669. intersect(csg: CSG): CSG;
  122670. /**
  122671. * Intersects this CSG with another CSG in place
  122672. * @param csg The CSG to intersect against this CSG
  122673. */
  122674. intersectInPlace(csg: CSG): void;
  122675. /**
  122676. * Return a new CSG solid with solid and empty space switched. This solid is
  122677. * not modified.
  122678. * @returns A new CSG solid with solid and empty space switched
  122679. */
  122680. inverse(): CSG;
  122681. /**
  122682. * Inverses the CSG in place
  122683. */
  122684. inverseInPlace(): void;
  122685. /**
  122686. * This is used to keep meshes transformations so they can be restored
  122687. * when we build back a Babylon Mesh
  122688. * NB : All CSG operations are performed in world coordinates
  122689. * @param csg The CSG to copy the transform attributes from
  122690. * @returns This CSG
  122691. */
  122692. copyTransformAttributes(csg: CSG): CSG;
  122693. /**
  122694. * Build Raw mesh from CSG
  122695. * Coordinates here are in world space
  122696. * @param name The name of the mesh geometry
  122697. * @param scene The Scene
  122698. * @param keepSubMeshes Specifies if the submeshes should be kept
  122699. * @returns A new Mesh
  122700. */
  122701. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122702. /**
  122703. * Build Mesh from CSG taking material and transforms into account
  122704. * @param name The name of the Mesh
  122705. * @param material The material of the Mesh
  122706. * @param scene The Scene
  122707. * @param keepSubMeshes Specifies if submeshes should be kept
  122708. * @returns The new Mesh
  122709. */
  122710. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122711. }
  122712. }
  122713. declare module BABYLON {
  122714. /**
  122715. * Class used to create a trail following a mesh
  122716. */
  122717. export class TrailMesh extends Mesh {
  122718. private _generator;
  122719. private _autoStart;
  122720. private _running;
  122721. private _diameter;
  122722. private _length;
  122723. private _sectionPolygonPointsCount;
  122724. private _sectionVectors;
  122725. private _sectionNormalVectors;
  122726. private _beforeRenderObserver;
  122727. /**
  122728. * @constructor
  122729. * @param name The value used by scene.getMeshByName() to do a lookup.
  122730. * @param generator The mesh to generate a trail.
  122731. * @param scene The scene to add this mesh to.
  122732. * @param diameter Diameter of trailing mesh. Default is 1.
  122733. * @param length Length of trailing mesh. Default is 60.
  122734. * @param autoStart Automatically start trailing mesh. Default true.
  122735. */
  122736. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  122737. /**
  122738. * "TrailMesh"
  122739. * @returns "TrailMesh"
  122740. */
  122741. getClassName(): string;
  122742. private _createMesh;
  122743. /**
  122744. * Start trailing mesh.
  122745. */
  122746. start(): void;
  122747. /**
  122748. * Stop trailing mesh.
  122749. */
  122750. stop(): void;
  122751. /**
  122752. * Update trailing mesh geometry.
  122753. */
  122754. update(): void;
  122755. /**
  122756. * Returns a new TrailMesh object.
  122757. * @param name is a string, the name given to the new mesh
  122758. * @param newGenerator use new generator object for cloned trail mesh
  122759. * @returns a new mesh
  122760. */
  122761. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  122762. /**
  122763. * Serializes this trail mesh
  122764. * @param serializationObject object to write serialization to
  122765. */
  122766. serialize(serializationObject: any): void;
  122767. /**
  122768. * Parses a serialized trail mesh
  122769. * @param parsedMesh the serialized mesh
  122770. * @param scene the scene to create the trail mesh in
  122771. * @returns the created trail mesh
  122772. */
  122773. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  122774. }
  122775. }
  122776. declare module BABYLON {
  122777. /**
  122778. * Class containing static functions to help procedurally build meshes
  122779. */
  122780. export class TiledBoxBuilder {
  122781. /**
  122782. * Creates a box mesh
  122783. * 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)
  122784. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122786. * * 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
  122787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122788. * @param name defines the name of the mesh
  122789. * @param options defines the options used to create the mesh
  122790. * @param scene defines the hosting scene
  122791. * @returns the box mesh
  122792. */
  122793. static CreateTiledBox(name: string, options: {
  122794. pattern?: number;
  122795. width?: number;
  122796. height?: number;
  122797. depth?: number;
  122798. tileSize?: number;
  122799. tileWidth?: number;
  122800. tileHeight?: number;
  122801. alignHorizontal?: number;
  122802. alignVertical?: number;
  122803. faceUV?: Vector4[];
  122804. faceColors?: Color4[];
  122805. sideOrientation?: number;
  122806. updatable?: boolean;
  122807. }, scene?: Nullable<Scene>): Mesh;
  122808. }
  122809. }
  122810. declare module BABYLON {
  122811. /**
  122812. * Class containing static functions to help procedurally build meshes
  122813. */
  122814. export class TorusKnotBuilder {
  122815. /**
  122816. * Creates a torus knot mesh
  122817. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  122818. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  122819. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  122820. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  122821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122822. * * 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
  122823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122824. * @param name defines the name of the mesh
  122825. * @param options defines the options used to create the mesh
  122826. * @param scene defines the hosting scene
  122827. * @returns the torus knot mesh
  122828. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  122829. */
  122830. static CreateTorusKnot(name: string, options: {
  122831. radius?: number;
  122832. tube?: number;
  122833. radialSegments?: number;
  122834. tubularSegments?: number;
  122835. p?: number;
  122836. q?: number;
  122837. updatable?: boolean;
  122838. sideOrientation?: number;
  122839. frontUVs?: Vector4;
  122840. backUVs?: Vector4;
  122841. }, scene: any): Mesh;
  122842. }
  122843. }
  122844. declare module BABYLON {
  122845. /**
  122846. * Polygon
  122847. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  122848. */
  122849. export class Polygon {
  122850. /**
  122851. * Creates a rectangle
  122852. * @param xmin bottom X coord
  122853. * @param ymin bottom Y coord
  122854. * @param xmax top X coord
  122855. * @param ymax top Y coord
  122856. * @returns points that make the resulting rectation
  122857. */
  122858. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  122859. /**
  122860. * Creates a circle
  122861. * @param radius radius of circle
  122862. * @param cx scale in x
  122863. * @param cy scale in y
  122864. * @param numberOfSides number of sides that make up the circle
  122865. * @returns points that make the resulting circle
  122866. */
  122867. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  122868. /**
  122869. * Creates a polygon from input string
  122870. * @param input Input polygon data
  122871. * @returns the parsed points
  122872. */
  122873. static Parse(input: string): Vector2[];
  122874. /**
  122875. * Starts building a polygon from x and y coordinates
  122876. * @param x x coordinate
  122877. * @param y y coordinate
  122878. * @returns the started path2
  122879. */
  122880. static StartingAt(x: number, y: number): Path2;
  122881. }
  122882. /**
  122883. * Builds a polygon
  122884. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  122885. */
  122886. export class PolygonMeshBuilder {
  122887. private _points;
  122888. private _outlinepoints;
  122889. private _holes;
  122890. private _name;
  122891. private _scene;
  122892. private _epoints;
  122893. private _eholes;
  122894. private _addToepoint;
  122895. /**
  122896. * Babylon reference to the earcut plugin.
  122897. */
  122898. bjsEarcut: any;
  122899. /**
  122900. * Creates a PolygonMeshBuilder
  122901. * @param name name of the builder
  122902. * @param contours Path of the polygon
  122903. * @param scene scene to add to when creating the mesh
  122904. * @param earcutInjection can be used to inject your own earcut reference
  122905. */
  122906. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  122907. /**
  122908. * Adds a whole within the polygon
  122909. * @param hole Array of points defining the hole
  122910. * @returns this
  122911. */
  122912. addHole(hole: Vector2[]): PolygonMeshBuilder;
  122913. /**
  122914. * Creates the polygon
  122915. * @param updatable If the mesh should be updatable
  122916. * @param depth The depth of the mesh created
  122917. * @returns the created mesh
  122918. */
  122919. build(updatable?: boolean, depth?: number): Mesh;
  122920. /**
  122921. * Creates the polygon
  122922. * @param depth The depth of the mesh created
  122923. * @returns the created VertexData
  122924. */
  122925. buildVertexData(depth?: number): VertexData;
  122926. /**
  122927. * Adds a side to the polygon
  122928. * @param positions points that make the polygon
  122929. * @param normals normals of the polygon
  122930. * @param uvs uvs of the polygon
  122931. * @param indices indices of the polygon
  122932. * @param bounds bounds of the polygon
  122933. * @param points points of the polygon
  122934. * @param depth depth of the polygon
  122935. * @param flip flip of the polygon
  122936. */
  122937. private addSide;
  122938. }
  122939. }
  122940. declare module BABYLON {
  122941. /**
  122942. * Class containing static functions to help procedurally build meshes
  122943. */
  122944. export class PolygonBuilder {
  122945. /**
  122946. * Creates a polygon mesh
  122947. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  122948. * * 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
  122949. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122951. * * 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)
  122952. * * Remember you can only change the shape positions, not their number when updating a polygon
  122953. * @param name defines the name of the mesh
  122954. * @param options defines the options used to create the mesh
  122955. * @param scene defines the hosting scene
  122956. * @param earcutInjection can be used to inject your own earcut reference
  122957. * @returns the polygon mesh
  122958. */
  122959. static CreatePolygon(name: string, options: {
  122960. shape: Vector3[];
  122961. holes?: Vector3[][];
  122962. depth?: number;
  122963. faceUV?: Vector4[];
  122964. faceColors?: Color4[];
  122965. updatable?: boolean;
  122966. sideOrientation?: number;
  122967. frontUVs?: Vector4;
  122968. backUVs?: Vector4;
  122969. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122970. /**
  122971. * Creates an extruded polygon mesh, with depth in the Y direction.
  122972. * * 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)
  122973. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122974. * @param name defines the name of the mesh
  122975. * @param options defines the options used to create the mesh
  122976. * @param scene defines the hosting scene
  122977. * @param earcutInjection can be used to inject your own earcut reference
  122978. * @returns the polygon mesh
  122979. */
  122980. static ExtrudePolygon(name: string, options: {
  122981. shape: Vector3[];
  122982. holes?: Vector3[][];
  122983. depth?: number;
  122984. faceUV?: Vector4[];
  122985. faceColors?: Color4[];
  122986. updatable?: boolean;
  122987. sideOrientation?: number;
  122988. frontUVs?: Vector4;
  122989. backUVs?: Vector4;
  122990. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122991. }
  122992. }
  122993. declare module BABYLON {
  122994. /**
  122995. * Class containing static functions to help procedurally build meshes
  122996. */
  122997. export class LatheBuilder {
  122998. /**
  122999. * Creates lathe mesh.
  123000. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123001. * * 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
  123002. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123003. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123004. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123005. * * 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
  123006. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123007. * * 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
  123008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123009. * * 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
  123010. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123012. * @param name defines the name of the mesh
  123013. * @param options defines the options used to create the mesh
  123014. * @param scene defines the hosting scene
  123015. * @returns the lathe mesh
  123016. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123017. */
  123018. static CreateLathe(name: string, options: {
  123019. shape: Vector3[];
  123020. radius?: number;
  123021. tessellation?: number;
  123022. clip?: number;
  123023. arc?: number;
  123024. closed?: boolean;
  123025. updatable?: boolean;
  123026. sideOrientation?: number;
  123027. frontUVs?: Vector4;
  123028. backUVs?: Vector4;
  123029. cap?: number;
  123030. invertUV?: boolean;
  123031. }, scene?: Nullable<Scene>): Mesh;
  123032. }
  123033. }
  123034. declare module BABYLON {
  123035. /**
  123036. * Class containing static functions to help procedurally build meshes
  123037. */
  123038. export class TiledPlaneBuilder {
  123039. /**
  123040. * Creates a tiled plane mesh
  123041. * * The parameter `pattern` will, depending on value, do nothing or
  123042. * * * flip (reflect about central vertical) alternate tiles across and up
  123043. * * * flip every tile on alternate rows
  123044. * * * rotate (180 degs) alternate tiles across and up
  123045. * * * rotate every tile on alternate rows
  123046. * * * flip and rotate alternate tiles across and up
  123047. * * * flip and rotate every tile on alternate rows
  123048. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  123049. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  123050. * * 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
  123051. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123052. * * 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)
  123053. * * 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)
  123054. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123055. * @param name defines the name of the mesh
  123056. * @param options defines the options used to create the mesh
  123057. * @param scene defines the hosting scene
  123058. * @returns the box mesh
  123059. */
  123060. static CreateTiledPlane(name: string, options: {
  123061. pattern?: number;
  123062. tileSize?: number;
  123063. tileWidth?: number;
  123064. tileHeight?: number;
  123065. size?: number;
  123066. width?: number;
  123067. height?: number;
  123068. alignHorizontal?: number;
  123069. alignVertical?: number;
  123070. sideOrientation?: number;
  123071. frontUVs?: Vector4;
  123072. backUVs?: Vector4;
  123073. updatable?: boolean;
  123074. }, scene?: Nullable<Scene>): Mesh;
  123075. }
  123076. }
  123077. declare module BABYLON {
  123078. /**
  123079. * Class containing static functions to help procedurally build meshes
  123080. */
  123081. export class TubeBuilder {
  123082. /**
  123083. * Creates a tube mesh.
  123084. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123085. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123086. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123087. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123088. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123089. * * 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)
  123090. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123091. * * 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
  123092. * * 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
  123093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123094. * * 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
  123095. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123097. * @param name defines the name of the mesh
  123098. * @param options defines the options used to create the mesh
  123099. * @param scene defines the hosting scene
  123100. * @returns the tube mesh
  123101. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123102. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123103. */
  123104. static CreateTube(name: string, options: {
  123105. path: Vector3[];
  123106. radius?: number;
  123107. tessellation?: number;
  123108. radiusFunction?: {
  123109. (i: number, distance: number): number;
  123110. };
  123111. cap?: number;
  123112. arc?: number;
  123113. updatable?: boolean;
  123114. sideOrientation?: number;
  123115. frontUVs?: Vector4;
  123116. backUVs?: Vector4;
  123117. instance?: Mesh;
  123118. invertUV?: boolean;
  123119. }, scene?: Nullable<Scene>): Mesh;
  123120. }
  123121. }
  123122. declare module BABYLON {
  123123. /**
  123124. * Class containing static functions to help procedurally build meshes
  123125. */
  123126. export class IcoSphereBuilder {
  123127. /**
  123128. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123129. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123130. * * 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`)
  123131. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123132. * * 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
  123133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123134. * * 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
  123135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123136. * @param name defines the name of the mesh
  123137. * @param options defines the options used to create the mesh
  123138. * @param scene defines the hosting scene
  123139. * @returns the icosahedron mesh
  123140. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123141. */
  123142. static CreateIcoSphere(name: string, options: {
  123143. radius?: number;
  123144. radiusX?: number;
  123145. radiusY?: number;
  123146. radiusZ?: number;
  123147. flat?: boolean;
  123148. subdivisions?: number;
  123149. sideOrientation?: number;
  123150. frontUVs?: Vector4;
  123151. backUVs?: Vector4;
  123152. updatable?: boolean;
  123153. }, scene?: Nullable<Scene>): Mesh;
  123154. }
  123155. }
  123156. declare module BABYLON {
  123157. /**
  123158. * Class containing static functions to help procedurally build meshes
  123159. */
  123160. export class DecalBuilder {
  123161. /**
  123162. * Creates a decal mesh.
  123163. * 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
  123164. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123165. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123166. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123167. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123168. * @param name defines the name of the mesh
  123169. * @param sourceMesh defines the mesh where the decal must be applied
  123170. * @param options defines the options used to create the mesh
  123171. * @param scene defines the hosting scene
  123172. * @returns the decal mesh
  123173. * @see https://doc.babylonjs.com/how_to/decals
  123174. */
  123175. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123176. position?: Vector3;
  123177. normal?: Vector3;
  123178. size?: Vector3;
  123179. angle?: number;
  123180. }): Mesh;
  123181. }
  123182. }
  123183. declare module BABYLON {
  123184. /**
  123185. * Class containing static functions to help procedurally build meshes
  123186. */
  123187. export class MeshBuilder {
  123188. /**
  123189. * Creates a box mesh
  123190. * * The parameter `size` sets the size (float) of each box side (default 1)
  123191. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  123192. * * 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)
  123193. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123195. * * 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
  123196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123197. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123198. * @param name defines the name of the mesh
  123199. * @param options defines the options used to create the mesh
  123200. * @param scene defines the hosting scene
  123201. * @returns the box mesh
  123202. */
  123203. static CreateBox(name: string, options: {
  123204. size?: number;
  123205. width?: number;
  123206. height?: number;
  123207. depth?: number;
  123208. faceUV?: Vector4[];
  123209. faceColors?: Color4[];
  123210. sideOrientation?: number;
  123211. frontUVs?: Vector4;
  123212. backUVs?: Vector4;
  123213. updatable?: boolean;
  123214. }, scene?: Nullable<Scene>): Mesh;
  123215. /**
  123216. * Creates a tiled box mesh
  123217. * * faceTiles sets the pattern, tile size and number of tiles for a face
  123218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123219. * @param name defines the name of the mesh
  123220. * @param options defines the options used to create the mesh
  123221. * @param scene defines the hosting scene
  123222. * @returns the tiled box mesh
  123223. */
  123224. static CreateTiledBox(name: string, options: {
  123225. pattern?: number;
  123226. size?: number;
  123227. width?: number;
  123228. height?: number;
  123229. depth: number;
  123230. tileSize?: number;
  123231. tileWidth?: number;
  123232. tileHeight?: number;
  123233. faceUV?: Vector4[];
  123234. faceColors?: Color4[];
  123235. alignHorizontal?: number;
  123236. alignVertical?: number;
  123237. sideOrientation?: number;
  123238. updatable?: boolean;
  123239. }, scene?: Nullable<Scene>): Mesh;
  123240. /**
  123241. * Creates a sphere mesh
  123242. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  123243. * * 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`)
  123244. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  123245. * * 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
  123246. * * 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)
  123247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123248. * * 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
  123249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123250. * @param name defines the name of the mesh
  123251. * @param options defines the options used to create the mesh
  123252. * @param scene defines the hosting scene
  123253. * @returns the sphere mesh
  123254. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  123255. */
  123256. static CreateSphere(name: string, options: {
  123257. segments?: number;
  123258. diameter?: number;
  123259. diameterX?: number;
  123260. diameterY?: number;
  123261. diameterZ?: number;
  123262. arc?: number;
  123263. slice?: number;
  123264. sideOrientation?: number;
  123265. frontUVs?: Vector4;
  123266. backUVs?: Vector4;
  123267. updatable?: boolean;
  123268. }, scene?: Nullable<Scene>): Mesh;
  123269. /**
  123270. * Creates a plane polygonal mesh. By default, this is a disc
  123271. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  123272. * * 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
  123273. * * 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
  123274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123275. * * 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
  123276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123277. * @param name defines the name of the mesh
  123278. * @param options defines the options used to create the mesh
  123279. * @param scene defines the hosting scene
  123280. * @returns the plane polygonal mesh
  123281. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  123282. */
  123283. static CreateDisc(name: string, options: {
  123284. radius?: number;
  123285. tessellation?: number;
  123286. arc?: number;
  123287. updatable?: boolean;
  123288. sideOrientation?: number;
  123289. frontUVs?: Vector4;
  123290. backUVs?: Vector4;
  123291. }, scene?: Nullable<Scene>): Mesh;
  123292. /**
  123293. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123294. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123295. * * 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`)
  123296. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123297. * * 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
  123298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123299. * * 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
  123300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123301. * @param name defines the name of the mesh
  123302. * @param options defines the options used to create the mesh
  123303. * @param scene defines the hosting scene
  123304. * @returns the icosahedron mesh
  123305. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123306. */
  123307. static CreateIcoSphere(name: string, options: {
  123308. radius?: number;
  123309. radiusX?: number;
  123310. radiusY?: number;
  123311. radiusZ?: number;
  123312. flat?: boolean;
  123313. subdivisions?: number;
  123314. sideOrientation?: number;
  123315. frontUVs?: Vector4;
  123316. backUVs?: Vector4;
  123317. updatable?: boolean;
  123318. }, scene?: Nullable<Scene>): Mesh;
  123319. /**
  123320. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123321. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  123322. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  123323. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  123324. * * 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
  123325. * * 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
  123326. * * 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
  123327. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123328. * * 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
  123329. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123330. * * 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
  123331. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  123332. * * 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
  123333. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  123334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123335. * @param name defines the name of the mesh
  123336. * @param options defines the options used to create the mesh
  123337. * @param scene defines the hosting scene
  123338. * @returns the ribbon mesh
  123339. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  123340. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123341. */
  123342. static CreateRibbon(name: string, options: {
  123343. pathArray: Vector3[][];
  123344. closeArray?: boolean;
  123345. closePath?: boolean;
  123346. offset?: number;
  123347. updatable?: boolean;
  123348. sideOrientation?: number;
  123349. frontUVs?: Vector4;
  123350. backUVs?: Vector4;
  123351. instance?: Mesh;
  123352. invertUV?: boolean;
  123353. uvs?: Vector2[];
  123354. colors?: Color4[];
  123355. }, scene?: Nullable<Scene>): Mesh;
  123356. /**
  123357. * Creates a cylinder or a cone mesh
  123358. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  123359. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  123360. * * 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.
  123361. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  123362. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  123363. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  123364. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  123365. * * 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).
  123366. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  123367. * * 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).
  123368. * * 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
  123369. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  123370. * * 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
  123371. * * 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.
  123372. * * If `enclose` is false, a ring surface is one element.
  123373. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  123374. * * 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
  123375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123376. * * 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
  123377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123378. * @param name defines the name of the mesh
  123379. * @param options defines the options used to create the mesh
  123380. * @param scene defines the hosting scene
  123381. * @returns the cylinder mesh
  123382. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  123383. */
  123384. static CreateCylinder(name: string, options: {
  123385. height?: number;
  123386. diameterTop?: number;
  123387. diameterBottom?: number;
  123388. diameter?: number;
  123389. tessellation?: number;
  123390. subdivisions?: number;
  123391. arc?: number;
  123392. faceColors?: Color4[];
  123393. faceUV?: Vector4[];
  123394. updatable?: boolean;
  123395. hasRings?: boolean;
  123396. enclose?: boolean;
  123397. cap?: number;
  123398. sideOrientation?: number;
  123399. frontUVs?: Vector4;
  123400. backUVs?: Vector4;
  123401. }, scene?: Nullable<Scene>): Mesh;
  123402. /**
  123403. * Creates a torus mesh
  123404. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  123405. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  123406. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  123407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123408. * * 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
  123409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123410. * @param name defines the name of the mesh
  123411. * @param options defines the options used to create the mesh
  123412. * @param scene defines the hosting scene
  123413. * @returns the torus mesh
  123414. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  123415. */
  123416. static CreateTorus(name: string, options: {
  123417. diameter?: number;
  123418. thickness?: number;
  123419. tessellation?: number;
  123420. updatable?: boolean;
  123421. sideOrientation?: number;
  123422. frontUVs?: Vector4;
  123423. backUVs?: Vector4;
  123424. }, scene?: Nullable<Scene>): Mesh;
  123425. /**
  123426. * Creates a torus knot mesh
  123427. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  123428. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  123429. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  123430. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  123431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123432. * * 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
  123433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123434. * @param name defines the name of the mesh
  123435. * @param options defines the options used to create the mesh
  123436. * @param scene defines the hosting scene
  123437. * @returns the torus knot mesh
  123438. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  123439. */
  123440. static CreateTorusKnot(name: string, options: {
  123441. radius?: number;
  123442. tube?: number;
  123443. radialSegments?: number;
  123444. tubularSegments?: number;
  123445. p?: number;
  123446. q?: number;
  123447. updatable?: boolean;
  123448. sideOrientation?: number;
  123449. frontUVs?: Vector4;
  123450. backUVs?: Vector4;
  123451. }, scene?: Nullable<Scene>): Mesh;
  123452. /**
  123453. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  123454. * * 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
  123455. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  123456. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  123457. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  123458. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  123459. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  123460. * * 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
  123461. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  123462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123463. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  123464. * @param name defines the name of the new line system
  123465. * @param options defines the options used to create the line system
  123466. * @param scene defines the hosting scene
  123467. * @returns a new line system mesh
  123468. */
  123469. static CreateLineSystem(name: string, options: {
  123470. lines: Vector3[][];
  123471. updatable?: boolean;
  123472. instance?: Nullable<LinesMesh>;
  123473. colors?: Nullable<Color4[][]>;
  123474. useVertexAlpha?: boolean;
  123475. }, scene: Nullable<Scene>): LinesMesh;
  123476. /**
  123477. * Creates a line mesh
  123478. * 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
  123479. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123480. * * The parameter `points` is an array successive Vector3
  123481. * * 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
  123482. * * The optional parameter `colors` is an array of successive Color4, one per line point
  123483. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  123484. * * When updating an instance, remember that only point positions can change, not the number of points
  123485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123486. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  123487. * @param name defines the name of the new line system
  123488. * @param options defines the options used to create the line system
  123489. * @param scene defines the hosting scene
  123490. * @returns a new line mesh
  123491. */
  123492. static CreateLines(name: string, options: {
  123493. points: Vector3[];
  123494. updatable?: boolean;
  123495. instance?: Nullable<LinesMesh>;
  123496. colors?: Color4[];
  123497. useVertexAlpha?: boolean;
  123498. }, scene?: Nullable<Scene>): LinesMesh;
  123499. /**
  123500. * Creates a dashed line mesh
  123501. * * 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
  123502. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123503. * * The parameter `points` is an array successive Vector3
  123504. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  123505. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  123506. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  123507. * * 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
  123508. * * When updating an instance, remember that only point positions can change, not the number of points
  123509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123510. * @param name defines the name of the mesh
  123511. * @param options defines the options used to create the mesh
  123512. * @param scene defines the hosting scene
  123513. * @returns the dashed line mesh
  123514. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  123515. */
  123516. static CreateDashedLines(name: string, options: {
  123517. points: Vector3[];
  123518. dashSize?: number;
  123519. gapSize?: number;
  123520. dashNb?: number;
  123521. updatable?: boolean;
  123522. instance?: LinesMesh;
  123523. }, scene?: Nullable<Scene>): LinesMesh;
  123524. /**
  123525. * 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.
  123526. * * 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.
  123527. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123528. * * 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.
  123529. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  123530. * * 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
  123531. * * 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
  123532. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  123533. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123534. * * 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
  123535. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  123536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123537. * @param name defines the name of the mesh
  123538. * @param options defines the options used to create the mesh
  123539. * @param scene defines the hosting scene
  123540. * @returns the extruded shape mesh
  123541. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123542. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123543. */
  123544. static ExtrudeShape(name: string, options: {
  123545. shape: Vector3[];
  123546. path: Vector3[];
  123547. scale?: number;
  123548. rotation?: number;
  123549. cap?: number;
  123550. updatable?: boolean;
  123551. sideOrientation?: number;
  123552. frontUVs?: Vector4;
  123553. backUVs?: Vector4;
  123554. instance?: Mesh;
  123555. invertUV?: boolean;
  123556. }, scene?: Nullable<Scene>): Mesh;
  123557. /**
  123558. * Creates an custom extruded shape mesh.
  123559. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  123560. * * 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.
  123561. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123562. * * 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
  123563. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  123564. * * 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
  123565. * * It must returns a float value that will be the scale value applied to the shape on each path point
  123566. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  123567. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  123568. * * 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
  123569. * * 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
  123570. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  123571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123572. * * 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
  123573. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123575. * @param name defines the name of the mesh
  123576. * @param options defines the options used to create the mesh
  123577. * @param scene defines the hosting scene
  123578. * @returns the custom extruded shape mesh
  123579. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  123580. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123581. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123582. */
  123583. static ExtrudeShapeCustom(name: string, options: {
  123584. shape: Vector3[];
  123585. path: Vector3[];
  123586. scaleFunction?: any;
  123587. rotationFunction?: any;
  123588. ribbonCloseArray?: boolean;
  123589. ribbonClosePath?: boolean;
  123590. cap?: number;
  123591. updatable?: boolean;
  123592. sideOrientation?: number;
  123593. frontUVs?: Vector4;
  123594. backUVs?: Vector4;
  123595. instance?: Mesh;
  123596. invertUV?: boolean;
  123597. }, scene?: Nullable<Scene>): Mesh;
  123598. /**
  123599. * Creates lathe mesh.
  123600. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123601. * * 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
  123602. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123603. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123604. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123605. * * 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
  123606. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123607. * * 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
  123608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123609. * * 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
  123610. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123612. * @param name defines the name of the mesh
  123613. * @param options defines the options used to create the mesh
  123614. * @param scene defines the hosting scene
  123615. * @returns the lathe mesh
  123616. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123617. */
  123618. static CreateLathe(name: string, options: {
  123619. shape: Vector3[];
  123620. radius?: number;
  123621. tessellation?: number;
  123622. clip?: number;
  123623. arc?: number;
  123624. closed?: boolean;
  123625. updatable?: boolean;
  123626. sideOrientation?: number;
  123627. frontUVs?: Vector4;
  123628. backUVs?: Vector4;
  123629. cap?: number;
  123630. invertUV?: boolean;
  123631. }, scene?: Nullable<Scene>): Mesh;
  123632. /**
  123633. * Creates a tiled plane mesh
  123634. * * You can set a limited pattern arrangement with the tiles
  123635. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123636. * * 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
  123637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123638. * @param name defines the name of the mesh
  123639. * @param options defines the options used to create the mesh
  123640. * @param scene defines the hosting scene
  123641. * @returns the plane mesh
  123642. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123643. */
  123644. static CreateTiledPlane(name: string, options: {
  123645. pattern?: number;
  123646. tileSize?: number;
  123647. tileWidth?: number;
  123648. tileHeight?: number;
  123649. size?: number;
  123650. width?: number;
  123651. height?: number;
  123652. alignHorizontal?: number;
  123653. alignVertical?: number;
  123654. sideOrientation?: number;
  123655. frontUVs?: Vector4;
  123656. backUVs?: Vector4;
  123657. updatable?: boolean;
  123658. }, scene?: Nullable<Scene>): Mesh;
  123659. /**
  123660. * Creates a plane mesh
  123661. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123662. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123663. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123665. * * 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
  123666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123667. * @param name defines the name of the mesh
  123668. * @param options defines the options used to create the mesh
  123669. * @param scene defines the hosting scene
  123670. * @returns the plane mesh
  123671. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123672. */
  123673. static CreatePlane(name: string, options: {
  123674. size?: number;
  123675. width?: number;
  123676. height?: number;
  123677. sideOrientation?: number;
  123678. frontUVs?: Vector4;
  123679. backUVs?: Vector4;
  123680. updatable?: boolean;
  123681. sourcePlane?: Plane;
  123682. }, scene?: Nullable<Scene>): Mesh;
  123683. /**
  123684. * Creates a ground mesh
  123685. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  123686. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  123687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123688. * @param name defines the name of the mesh
  123689. * @param options defines the options used to create the mesh
  123690. * @param scene defines the hosting scene
  123691. * @returns the ground mesh
  123692. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  123693. */
  123694. static CreateGround(name: string, options: {
  123695. width?: number;
  123696. height?: number;
  123697. subdivisions?: number;
  123698. subdivisionsX?: number;
  123699. subdivisionsY?: number;
  123700. updatable?: boolean;
  123701. }, scene?: Nullable<Scene>): Mesh;
  123702. /**
  123703. * Creates a tiled ground mesh
  123704. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  123705. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  123706. * * 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
  123707. * * 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
  123708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123709. * @param name defines the name of the mesh
  123710. * @param options defines the options used to create the mesh
  123711. * @param scene defines the hosting scene
  123712. * @returns the tiled ground mesh
  123713. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  123714. */
  123715. static CreateTiledGround(name: string, options: {
  123716. xmin: number;
  123717. zmin: number;
  123718. xmax: number;
  123719. zmax: number;
  123720. subdivisions?: {
  123721. w: number;
  123722. h: number;
  123723. };
  123724. precision?: {
  123725. w: number;
  123726. h: number;
  123727. };
  123728. updatable?: boolean;
  123729. }, scene?: Nullable<Scene>): Mesh;
  123730. /**
  123731. * Creates a ground mesh from a height map
  123732. * * The parameter `url` sets the URL of the height map image resource.
  123733. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  123734. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  123735. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  123736. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  123737. * * 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.
  123738. * * 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).
  123739. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  123740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123741. * @param name defines the name of the mesh
  123742. * @param url defines the url to the height map
  123743. * @param options defines the options used to create the mesh
  123744. * @param scene defines the hosting scene
  123745. * @returns the ground mesh
  123746. * @see https://doc.babylonjs.com/babylon101/height_map
  123747. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  123748. */
  123749. static CreateGroundFromHeightMap(name: string, url: string, options: {
  123750. width?: number;
  123751. height?: number;
  123752. subdivisions?: number;
  123753. minHeight?: number;
  123754. maxHeight?: number;
  123755. colorFilter?: Color3;
  123756. alphaFilter?: number;
  123757. updatable?: boolean;
  123758. onReady?: (mesh: GroundMesh) => void;
  123759. }, scene?: Nullable<Scene>): GroundMesh;
  123760. /**
  123761. * Creates a polygon mesh
  123762. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  123763. * * 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
  123764. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123766. * * 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)
  123767. * * Remember you can only change the shape positions, not their number when updating a polygon
  123768. * @param name defines the name of the mesh
  123769. * @param options defines the options used to create the mesh
  123770. * @param scene defines the hosting scene
  123771. * @param earcutInjection can be used to inject your own earcut reference
  123772. * @returns the polygon mesh
  123773. */
  123774. static CreatePolygon(name: string, options: {
  123775. shape: Vector3[];
  123776. holes?: Vector3[][];
  123777. depth?: number;
  123778. faceUV?: Vector4[];
  123779. faceColors?: Color4[];
  123780. updatable?: boolean;
  123781. sideOrientation?: number;
  123782. frontUVs?: Vector4;
  123783. backUVs?: Vector4;
  123784. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123785. /**
  123786. * Creates an extruded polygon mesh, with depth in the Y direction.
  123787. * * 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)
  123788. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123789. * @param name defines the name of the mesh
  123790. * @param options defines the options used to create the mesh
  123791. * @param scene defines the hosting scene
  123792. * @param earcutInjection can be used to inject your own earcut reference
  123793. * @returns the polygon mesh
  123794. */
  123795. static ExtrudePolygon(name: string, options: {
  123796. shape: Vector3[];
  123797. holes?: Vector3[][];
  123798. depth?: number;
  123799. faceUV?: Vector4[];
  123800. faceColors?: Color4[];
  123801. updatable?: boolean;
  123802. sideOrientation?: number;
  123803. frontUVs?: Vector4;
  123804. backUVs?: Vector4;
  123805. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123806. /**
  123807. * Creates a tube mesh.
  123808. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123809. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123810. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123811. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123812. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123813. * * 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)
  123814. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123815. * * 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
  123816. * * 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
  123817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123818. * * 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
  123819. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123821. * @param name defines the name of the mesh
  123822. * @param options defines the options used to create the mesh
  123823. * @param scene defines the hosting scene
  123824. * @returns the tube mesh
  123825. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123826. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123827. */
  123828. static CreateTube(name: string, options: {
  123829. path: Vector3[];
  123830. radius?: number;
  123831. tessellation?: number;
  123832. radiusFunction?: {
  123833. (i: number, distance: number): number;
  123834. };
  123835. cap?: number;
  123836. arc?: number;
  123837. updatable?: boolean;
  123838. sideOrientation?: number;
  123839. frontUVs?: Vector4;
  123840. backUVs?: Vector4;
  123841. instance?: Mesh;
  123842. invertUV?: boolean;
  123843. }, scene?: Nullable<Scene>): Mesh;
  123844. /**
  123845. * Creates a polyhedron mesh
  123846. * * 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
  123847. * * The parameter `size` (positive float, default 1) sets the polygon size
  123848. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  123849. * * 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`
  123850. * * 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
  123851. * * 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)`)
  123852. * * 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
  123853. * * 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
  123854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123855. * * 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
  123856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123857. * @param name defines the name of the mesh
  123858. * @param options defines the options used to create the mesh
  123859. * @param scene defines the hosting scene
  123860. * @returns the polyhedron mesh
  123861. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  123862. */
  123863. static CreatePolyhedron(name: string, options: {
  123864. type?: number;
  123865. size?: number;
  123866. sizeX?: number;
  123867. sizeY?: number;
  123868. sizeZ?: number;
  123869. custom?: any;
  123870. faceUV?: Vector4[];
  123871. faceColors?: Color4[];
  123872. flat?: boolean;
  123873. updatable?: boolean;
  123874. sideOrientation?: number;
  123875. frontUVs?: Vector4;
  123876. backUVs?: Vector4;
  123877. }, scene?: Nullable<Scene>): Mesh;
  123878. /**
  123879. * Creates a decal mesh.
  123880. * 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
  123881. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123882. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123883. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123884. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123885. * @param name defines the name of the mesh
  123886. * @param sourceMesh defines the mesh where the decal must be applied
  123887. * @param options defines the options used to create the mesh
  123888. * @param scene defines the hosting scene
  123889. * @returns the decal mesh
  123890. * @see https://doc.babylonjs.com/how_to/decals
  123891. */
  123892. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123893. position?: Vector3;
  123894. normal?: Vector3;
  123895. size?: Vector3;
  123896. angle?: number;
  123897. }): Mesh;
  123898. }
  123899. }
  123900. declare module BABYLON {
  123901. /**
  123902. * A simplifier interface for future simplification implementations
  123903. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123904. */
  123905. export interface ISimplifier {
  123906. /**
  123907. * Simplification of a given mesh according to the given settings.
  123908. * Since this requires computation, it is assumed that the function runs async.
  123909. * @param settings The settings of the simplification, including quality and distance
  123910. * @param successCallback A callback that will be called after the mesh was simplified.
  123911. * @param errorCallback in case of an error, this callback will be called. optional.
  123912. */
  123913. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  123914. }
  123915. /**
  123916. * Expected simplification settings.
  123917. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  123918. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123919. */
  123920. export interface ISimplificationSettings {
  123921. /**
  123922. * Gets or sets the expected quality
  123923. */
  123924. quality: number;
  123925. /**
  123926. * Gets or sets the distance when this optimized version should be used
  123927. */
  123928. distance: number;
  123929. /**
  123930. * Gets an already optimized mesh
  123931. */
  123932. optimizeMesh?: boolean;
  123933. }
  123934. /**
  123935. * Class used to specify simplification options
  123936. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123937. */
  123938. export class SimplificationSettings implements ISimplificationSettings {
  123939. /** expected quality */
  123940. quality: number;
  123941. /** distance when this optimized version should be used */
  123942. distance: number;
  123943. /** already optimized mesh */
  123944. optimizeMesh?: boolean | undefined;
  123945. /**
  123946. * Creates a SimplificationSettings
  123947. * @param quality expected quality
  123948. * @param distance distance when this optimized version should be used
  123949. * @param optimizeMesh already optimized mesh
  123950. */
  123951. constructor(
  123952. /** expected quality */
  123953. quality: number,
  123954. /** distance when this optimized version should be used */
  123955. distance: number,
  123956. /** already optimized mesh */
  123957. optimizeMesh?: boolean | undefined);
  123958. }
  123959. /**
  123960. * Interface used to define a simplification task
  123961. */
  123962. export interface ISimplificationTask {
  123963. /**
  123964. * Array of settings
  123965. */
  123966. settings: Array<ISimplificationSettings>;
  123967. /**
  123968. * Simplification type
  123969. */
  123970. simplificationType: SimplificationType;
  123971. /**
  123972. * Mesh to simplify
  123973. */
  123974. mesh: Mesh;
  123975. /**
  123976. * Callback called on success
  123977. */
  123978. successCallback?: () => void;
  123979. /**
  123980. * Defines if parallel processing can be used
  123981. */
  123982. parallelProcessing: boolean;
  123983. }
  123984. /**
  123985. * Queue used to order the simplification tasks
  123986. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123987. */
  123988. export class SimplificationQueue {
  123989. private _simplificationArray;
  123990. /**
  123991. * Gets a boolean indicating that the process is still running
  123992. */
  123993. running: boolean;
  123994. /**
  123995. * Creates a new queue
  123996. */
  123997. constructor();
  123998. /**
  123999. * Adds a new simplification task
  124000. * @param task defines a task to add
  124001. */
  124002. addTask(task: ISimplificationTask): void;
  124003. /**
  124004. * Execute next task
  124005. */
  124006. executeNext(): void;
  124007. /**
  124008. * Execute a simplification task
  124009. * @param task defines the task to run
  124010. */
  124011. runSimplification(task: ISimplificationTask): void;
  124012. private getSimplifier;
  124013. }
  124014. /**
  124015. * The implemented types of simplification
  124016. * At the moment only Quadratic Error Decimation is implemented
  124017. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124018. */
  124019. export enum SimplificationType {
  124020. /** Quadratic error decimation */
  124021. QUADRATIC = 0
  124022. }
  124023. }
  124024. declare module BABYLON {
  124025. interface Scene {
  124026. /** @hidden (Backing field) */
  124027. _simplificationQueue: SimplificationQueue;
  124028. /**
  124029. * Gets or sets the simplification queue attached to the scene
  124030. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124031. */
  124032. simplificationQueue: SimplificationQueue;
  124033. }
  124034. interface Mesh {
  124035. /**
  124036. * Simplify the mesh according to the given array of settings.
  124037. * Function will return immediately and will simplify async
  124038. * @param settings a collection of simplification settings
  124039. * @param parallelProcessing should all levels calculate parallel or one after the other
  124040. * @param simplificationType the type of simplification to run
  124041. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  124042. * @returns the current mesh
  124043. */
  124044. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  124045. }
  124046. /**
  124047. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  124048. * created in a scene
  124049. */
  124050. export class SimplicationQueueSceneComponent implements ISceneComponent {
  124051. /**
  124052. * The component name helpfull to identify the component in the list of scene components.
  124053. */
  124054. readonly name: string;
  124055. /**
  124056. * The scene the component belongs to.
  124057. */
  124058. scene: Scene;
  124059. /**
  124060. * Creates a new instance of the component for the given scene
  124061. * @param scene Defines the scene to register the component in
  124062. */
  124063. constructor(scene: Scene);
  124064. /**
  124065. * Registers the component in a given scene
  124066. */
  124067. register(): void;
  124068. /**
  124069. * Rebuilds the elements related to this component in case of
  124070. * context lost for instance.
  124071. */
  124072. rebuild(): void;
  124073. /**
  124074. * Disposes the component and the associated ressources
  124075. */
  124076. dispose(): void;
  124077. private _beforeCameraUpdate;
  124078. }
  124079. }
  124080. declare module BABYLON {
  124081. /**
  124082. * Navigation plugin interface to add navigation constrained by a navigation mesh
  124083. */
  124084. export interface INavigationEnginePlugin {
  124085. /**
  124086. * plugin name
  124087. */
  124088. name: string;
  124089. /**
  124090. * Creates a navigation mesh
  124091. * @param meshes array of all the geometry used to compute the navigatio mesh
  124092. * @param parameters bunch of parameters used to filter geometry
  124093. */
  124094. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124095. /**
  124096. * Create a navigation mesh debug mesh
  124097. * @param scene is where the mesh will be added
  124098. * @returns debug display mesh
  124099. */
  124100. createDebugNavMesh(scene: Scene): Mesh;
  124101. /**
  124102. * Get a navigation mesh constrained position, closest to the parameter position
  124103. * @param position world position
  124104. * @returns the closest point to position constrained by the navigation mesh
  124105. */
  124106. getClosestPoint(position: Vector3): Vector3;
  124107. /**
  124108. * Get a navigation mesh constrained position, within a particular radius
  124109. * @param position world position
  124110. * @param maxRadius the maximum distance to the constrained world position
  124111. * @returns the closest point to position constrained by the navigation mesh
  124112. */
  124113. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124114. /**
  124115. * Compute the final position from a segment made of destination-position
  124116. * @param position world position
  124117. * @param destination world position
  124118. * @returns the resulting point along the navmesh
  124119. */
  124120. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124121. /**
  124122. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124123. * @param start world position
  124124. * @param end world position
  124125. * @returns array containing world position composing the path
  124126. */
  124127. computePath(start: Vector3, end: Vector3): Vector3[];
  124128. /**
  124129. * If this plugin is supported
  124130. * @returns true if plugin is supported
  124131. */
  124132. isSupported(): boolean;
  124133. /**
  124134. * Create a new Crowd so you can add agents
  124135. * @param maxAgents the maximum agent count in the crowd
  124136. * @param maxAgentRadius the maximum radius an agent can have
  124137. * @param scene to attach the crowd to
  124138. * @returns the crowd you can add agents to
  124139. */
  124140. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124141. /**
  124142. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124143. * The queries will try to find a solution within those bounds
  124144. * default is (1,1,1)
  124145. * @param extent x,y,z value that define the extent around the queries point of reference
  124146. */
  124147. setDefaultQueryExtent(extent: Vector3): void;
  124148. /**
  124149. * Get the Bounding box extent specified by setDefaultQueryExtent
  124150. * @returns the box extent values
  124151. */
  124152. getDefaultQueryExtent(): Vector3;
  124153. /**
  124154. * Release all resources
  124155. */
  124156. dispose(): void;
  124157. }
  124158. /**
  124159. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  124160. */
  124161. export interface ICrowd {
  124162. /**
  124163. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124164. * You can attach anything to that node. The node position is updated in the scene update tick.
  124165. * @param pos world position that will be constrained by the navigation mesh
  124166. * @param parameters agent parameters
  124167. * @param transform hooked to the agent that will be update by the scene
  124168. * @returns agent index
  124169. */
  124170. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124171. /**
  124172. * Returns the agent position in world space
  124173. * @param index agent index returned by addAgent
  124174. * @returns world space position
  124175. */
  124176. getAgentPosition(index: number): Vector3;
  124177. /**
  124178. * Gets the agent velocity in world space
  124179. * @param index agent index returned by addAgent
  124180. * @returns world space velocity
  124181. */
  124182. getAgentVelocity(index: number): Vector3;
  124183. /**
  124184. * remove a particular agent previously created
  124185. * @param index agent index returned by addAgent
  124186. */
  124187. removeAgent(index: number): void;
  124188. /**
  124189. * get the list of all agents attached to this crowd
  124190. * @returns list of agent indices
  124191. */
  124192. getAgents(): number[];
  124193. /**
  124194. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124195. * @param deltaTime in seconds
  124196. */
  124197. update(deltaTime: number): void;
  124198. /**
  124199. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124200. * @param index agent index returned by addAgent
  124201. * @param destination targeted world position
  124202. */
  124203. agentGoto(index: number, destination: Vector3): void;
  124204. /**
  124205. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124206. * The queries will try to find a solution within those bounds
  124207. * default is (1,1,1)
  124208. * @param extent x,y,z value that define the extent around the queries point of reference
  124209. */
  124210. setDefaultQueryExtent(extent: Vector3): void;
  124211. /**
  124212. * Get the Bounding box extent specified by setDefaultQueryExtent
  124213. * @returns the box extent values
  124214. */
  124215. getDefaultQueryExtent(): Vector3;
  124216. /**
  124217. * Release all resources
  124218. */
  124219. dispose(): void;
  124220. }
  124221. /**
  124222. * Configures an agent
  124223. */
  124224. export interface IAgentParameters {
  124225. /**
  124226. * Agent radius. [Limit: >= 0]
  124227. */
  124228. radius: number;
  124229. /**
  124230. * Agent height. [Limit: > 0]
  124231. */
  124232. height: number;
  124233. /**
  124234. * Maximum allowed acceleration. [Limit: >= 0]
  124235. */
  124236. maxAcceleration: number;
  124237. /**
  124238. * Maximum allowed speed. [Limit: >= 0]
  124239. */
  124240. maxSpeed: number;
  124241. /**
  124242. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  124243. */
  124244. collisionQueryRange: number;
  124245. /**
  124246. * The path visibility optimization range. [Limit: > 0]
  124247. */
  124248. pathOptimizationRange: number;
  124249. /**
  124250. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  124251. */
  124252. separationWeight: number;
  124253. }
  124254. /**
  124255. * Configures the navigation mesh creation
  124256. */
  124257. export interface INavMeshParameters {
  124258. /**
  124259. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  124260. */
  124261. cs: number;
  124262. /**
  124263. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  124264. */
  124265. ch: number;
  124266. /**
  124267. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  124268. */
  124269. walkableSlopeAngle: number;
  124270. /**
  124271. * Minimum floor to 'ceiling' height that will still allow the floor area to
  124272. * be considered walkable. [Limit: >= 3] [Units: vx]
  124273. */
  124274. walkableHeight: number;
  124275. /**
  124276. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  124277. */
  124278. walkableClimb: number;
  124279. /**
  124280. * The distance to erode/shrink the walkable area of the heightfield away from
  124281. * obstructions. [Limit: >=0] [Units: vx]
  124282. */
  124283. walkableRadius: number;
  124284. /**
  124285. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  124286. */
  124287. maxEdgeLen: number;
  124288. /**
  124289. * The maximum distance a simplfied contour's border edges should deviate
  124290. * the original raw contour. [Limit: >=0] [Units: vx]
  124291. */
  124292. maxSimplificationError: number;
  124293. /**
  124294. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  124295. */
  124296. minRegionArea: number;
  124297. /**
  124298. * Any regions with a span count smaller than this value will, if possible,
  124299. * be merged with larger regions. [Limit: >=0] [Units: vx]
  124300. */
  124301. mergeRegionArea: number;
  124302. /**
  124303. * The maximum number of vertices allowed for polygons generated during the
  124304. * contour to polygon conversion process. [Limit: >= 3]
  124305. */
  124306. maxVertsPerPoly: number;
  124307. /**
  124308. * Sets the sampling distance to use when generating the detail mesh.
  124309. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  124310. */
  124311. detailSampleDist: number;
  124312. /**
  124313. * The maximum distance the detail mesh surface should deviate from heightfield
  124314. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  124315. */
  124316. detailSampleMaxError: number;
  124317. }
  124318. }
  124319. declare module BABYLON {
  124320. /**
  124321. * RecastJS navigation plugin
  124322. */
  124323. export class RecastJSPlugin implements INavigationEnginePlugin {
  124324. /**
  124325. * Reference to the Recast library
  124326. */
  124327. bjsRECAST: any;
  124328. /**
  124329. * plugin name
  124330. */
  124331. name: string;
  124332. /**
  124333. * the first navmesh created. We might extend this to support multiple navmeshes
  124334. */
  124335. navMesh: any;
  124336. /**
  124337. * Initializes the recastJS plugin
  124338. * @param recastInjection can be used to inject your own recast reference
  124339. */
  124340. constructor(recastInjection?: any);
  124341. /**
  124342. * Creates a navigation mesh
  124343. * @param meshes array of all the geometry used to compute the navigatio mesh
  124344. * @param parameters bunch of parameters used to filter geometry
  124345. */
  124346. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124347. /**
  124348. * Create a navigation mesh debug mesh
  124349. * @param scene is where the mesh will be added
  124350. * @returns debug display mesh
  124351. */
  124352. createDebugNavMesh(scene: Scene): Mesh;
  124353. /**
  124354. * Get a navigation mesh constrained position, closest to the parameter position
  124355. * @param position world position
  124356. * @returns the closest point to position constrained by the navigation mesh
  124357. */
  124358. getClosestPoint(position: Vector3): Vector3;
  124359. /**
  124360. * Get a navigation mesh constrained position, within a particular radius
  124361. * @param position world position
  124362. * @param maxRadius the maximum distance to the constrained world position
  124363. * @returns the closest point to position constrained by the navigation mesh
  124364. */
  124365. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124366. /**
  124367. * Compute the final position from a segment made of destination-position
  124368. * @param position world position
  124369. * @param destination world position
  124370. * @returns the resulting point along the navmesh
  124371. */
  124372. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124373. /**
  124374. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124375. * @param start world position
  124376. * @param end world position
  124377. * @returns array containing world position composing the path
  124378. */
  124379. computePath(start: Vector3, end: Vector3): Vector3[];
  124380. /**
  124381. * Create a new Crowd so you can add agents
  124382. * @param maxAgents the maximum agent count in the crowd
  124383. * @param maxAgentRadius the maximum radius an agent can have
  124384. * @param scene to attach the crowd to
  124385. * @returns the crowd you can add agents to
  124386. */
  124387. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124388. /**
  124389. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124390. * The queries will try to find a solution within those bounds
  124391. * default is (1,1,1)
  124392. * @param extent x,y,z value that define the extent around the queries point of reference
  124393. */
  124394. setDefaultQueryExtent(extent: Vector3): void;
  124395. /**
  124396. * Get the Bounding box extent specified by setDefaultQueryExtent
  124397. * @returns the box extent values
  124398. */
  124399. getDefaultQueryExtent(): Vector3;
  124400. /**
  124401. * Disposes
  124402. */
  124403. dispose(): void;
  124404. /**
  124405. * If this plugin is supported
  124406. * @returns true if plugin is supported
  124407. */
  124408. isSupported(): boolean;
  124409. }
  124410. /**
  124411. * Recast detour crowd implementation
  124412. */
  124413. export class RecastJSCrowd implements ICrowd {
  124414. /**
  124415. * Recast/detour plugin
  124416. */
  124417. bjsRECASTPlugin: RecastJSPlugin;
  124418. /**
  124419. * Link to the detour crowd
  124420. */
  124421. recastCrowd: any;
  124422. /**
  124423. * One transform per agent
  124424. */
  124425. transforms: TransformNode[];
  124426. /**
  124427. * All agents created
  124428. */
  124429. agents: number[];
  124430. /**
  124431. * Link to the scene is kept to unregister the crowd from the scene
  124432. */
  124433. private _scene;
  124434. /**
  124435. * Observer for crowd updates
  124436. */
  124437. private _onBeforeAnimationsObserver;
  124438. /**
  124439. * Constructor
  124440. * @param plugin recastJS plugin
  124441. * @param maxAgents the maximum agent count in the crowd
  124442. * @param maxAgentRadius the maximum radius an agent can have
  124443. * @param scene to attach the crowd to
  124444. * @returns the crowd you can add agents to
  124445. */
  124446. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  124447. /**
  124448. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124449. * You can attach anything to that node. The node position is updated in the scene update tick.
  124450. * @param pos world position that will be constrained by the navigation mesh
  124451. * @param parameters agent parameters
  124452. * @param transform hooked to the agent that will be update by the scene
  124453. * @returns agent index
  124454. */
  124455. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124456. /**
  124457. * Returns the agent position in world space
  124458. * @param index agent index returned by addAgent
  124459. * @returns world space position
  124460. */
  124461. getAgentPosition(index: number): Vector3;
  124462. /**
  124463. * Returns the agent velocity in world space
  124464. * @param index agent index returned by addAgent
  124465. * @returns world space velocity
  124466. */
  124467. getAgentVelocity(index: number): Vector3;
  124468. /**
  124469. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124470. * @param index agent index returned by addAgent
  124471. * @param destination targeted world position
  124472. */
  124473. agentGoto(index: number, destination: Vector3): void;
  124474. /**
  124475. * remove a particular agent previously created
  124476. * @param index agent index returned by addAgent
  124477. */
  124478. removeAgent(index: number): void;
  124479. /**
  124480. * get the list of all agents attached to this crowd
  124481. * @returns list of agent indices
  124482. */
  124483. getAgents(): number[];
  124484. /**
  124485. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124486. * @param deltaTime in seconds
  124487. */
  124488. update(deltaTime: number): void;
  124489. /**
  124490. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124491. * The queries will try to find a solution within those bounds
  124492. * default is (1,1,1)
  124493. * @param extent x,y,z value that define the extent around the queries point of reference
  124494. */
  124495. setDefaultQueryExtent(extent: Vector3): void;
  124496. /**
  124497. * Get the Bounding box extent specified by setDefaultQueryExtent
  124498. * @returns the box extent values
  124499. */
  124500. getDefaultQueryExtent(): Vector3;
  124501. /**
  124502. * Release all resources
  124503. */
  124504. dispose(): void;
  124505. }
  124506. }
  124507. declare module BABYLON {
  124508. /**
  124509. * Class used to enable access to IndexedDB
  124510. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  124511. */
  124512. export class Database implements IOfflineProvider {
  124513. private _callbackManifestChecked;
  124514. private _currentSceneUrl;
  124515. private _db;
  124516. private _enableSceneOffline;
  124517. private _enableTexturesOffline;
  124518. private _manifestVersionFound;
  124519. private _mustUpdateRessources;
  124520. private _hasReachedQuota;
  124521. private _isSupported;
  124522. private _idbFactory;
  124523. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  124524. private static IsUASupportingBlobStorage;
  124525. /**
  124526. * Gets a boolean indicating if Database storate is enabled (off by default)
  124527. */
  124528. static IDBStorageEnabled: boolean;
  124529. /**
  124530. * Gets a boolean indicating if scene must be saved in the database
  124531. */
  124532. readonly enableSceneOffline: boolean;
  124533. /**
  124534. * Gets a boolean indicating if textures must be saved in the database
  124535. */
  124536. readonly enableTexturesOffline: boolean;
  124537. /**
  124538. * Creates a new Database
  124539. * @param urlToScene defines the url to load the scene
  124540. * @param callbackManifestChecked defines the callback to use when manifest is checked
  124541. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  124542. */
  124543. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  124544. private static _ParseURL;
  124545. private static _ReturnFullUrlLocation;
  124546. private _checkManifestFile;
  124547. /**
  124548. * Open the database and make it available
  124549. * @param successCallback defines the callback to call on success
  124550. * @param errorCallback defines the callback to call on error
  124551. */
  124552. open(successCallback: () => void, errorCallback: () => void): void;
  124553. /**
  124554. * Loads an image from the database
  124555. * @param url defines the url to load from
  124556. * @param image defines the target DOM image
  124557. */
  124558. loadImage(url: string, image: HTMLImageElement): void;
  124559. private _loadImageFromDBAsync;
  124560. private _saveImageIntoDBAsync;
  124561. private _checkVersionFromDB;
  124562. private _loadVersionFromDBAsync;
  124563. private _saveVersionIntoDBAsync;
  124564. /**
  124565. * Loads a file from database
  124566. * @param url defines the URL to load from
  124567. * @param sceneLoaded defines a callback to call on success
  124568. * @param progressCallBack defines a callback to call when progress changed
  124569. * @param errorCallback defines a callback to call on error
  124570. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  124571. */
  124572. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  124573. private _loadFileAsync;
  124574. private _saveFileAsync;
  124575. /**
  124576. * Validates if xhr data is correct
  124577. * @param xhr defines the request to validate
  124578. * @param dataType defines the expected data type
  124579. * @returns true if data is correct
  124580. */
  124581. private static _ValidateXHRData;
  124582. }
  124583. }
  124584. declare module BABYLON {
  124585. /** @hidden */
  124586. export var gpuUpdateParticlesPixelShader: {
  124587. name: string;
  124588. shader: string;
  124589. };
  124590. }
  124591. declare module BABYLON {
  124592. /** @hidden */
  124593. export var gpuUpdateParticlesVertexShader: {
  124594. name: string;
  124595. shader: string;
  124596. };
  124597. }
  124598. declare module BABYLON {
  124599. /** @hidden */
  124600. export var clipPlaneFragmentDeclaration2: {
  124601. name: string;
  124602. shader: string;
  124603. };
  124604. }
  124605. declare module BABYLON {
  124606. /** @hidden */
  124607. export var gpuRenderParticlesPixelShader: {
  124608. name: string;
  124609. shader: string;
  124610. };
  124611. }
  124612. declare module BABYLON {
  124613. /** @hidden */
  124614. export var clipPlaneVertexDeclaration2: {
  124615. name: string;
  124616. shader: string;
  124617. };
  124618. }
  124619. declare module BABYLON {
  124620. /** @hidden */
  124621. export var gpuRenderParticlesVertexShader: {
  124622. name: string;
  124623. shader: string;
  124624. };
  124625. }
  124626. declare module BABYLON {
  124627. /**
  124628. * This represents a GPU particle system in Babylon
  124629. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  124630. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  124631. */
  124632. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  124633. /**
  124634. * The layer mask we are rendering the particles through.
  124635. */
  124636. layerMask: number;
  124637. private _capacity;
  124638. private _activeCount;
  124639. private _currentActiveCount;
  124640. private _accumulatedCount;
  124641. private _renderEffect;
  124642. private _updateEffect;
  124643. private _buffer0;
  124644. private _buffer1;
  124645. private _spriteBuffer;
  124646. private _updateVAO;
  124647. private _renderVAO;
  124648. private _targetIndex;
  124649. private _sourceBuffer;
  124650. private _targetBuffer;
  124651. private _engine;
  124652. private _currentRenderId;
  124653. private _started;
  124654. private _stopped;
  124655. private _timeDelta;
  124656. private _randomTexture;
  124657. private _randomTexture2;
  124658. private _attributesStrideSize;
  124659. private _updateEffectOptions;
  124660. private _randomTextureSize;
  124661. private _actualFrame;
  124662. private readonly _rawTextureWidth;
  124663. /**
  124664. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  124665. */
  124666. static readonly IsSupported: boolean;
  124667. /**
  124668. * An event triggered when the system is disposed.
  124669. */
  124670. onDisposeObservable: Observable<GPUParticleSystem>;
  124671. /**
  124672. * Gets the maximum number of particles active at the same time.
  124673. * @returns The max number of active particles.
  124674. */
  124675. getCapacity(): number;
  124676. /**
  124677. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  124678. * to override the particles.
  124679. */
  124680. forceDepthWrite: boolean;
  124681. /**
  124682. * Gets or set the number of active particles
  124683. */
  124684. activeParticleCount: number;
  124685. private _preWarmDone;
  124686. /**
  124687. * Is this system ready to be used/rendered
  124688. * @return true if the system is ready
  124689. */
  124690. isReady(): boolean;
  124691. /**
  124692. * Gets if the system has been started. (Note: this will still be true after stop is called)
  124693. * @returns True if it has been started, otherwise false.
  124694. */
  124695. isStarted(): boolean;
  124696. /**
  124697. * Starts the particle system and begins to emit
  124698. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  124699. */
  124700. start(delay?: number): void;
  124701. /**
  124702. * Stops the particle system.
  124703. */
  124704. stop(): void;
  124705. /**
  124706. * Remove all active particles
  124707. */
  124708. reset(): void;
  124709. /**
  124710. * Returns the string "GPUParticleSystem"
  124711. * @returns a string containing the class name
  124712. */
  124713. getClassName(): string;
  124714. private _colorGradientsTexture;
  124715. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  124716. /**
  124717. * Adds a new color gradient
  124718. * @param gradient defines the gradient to use (between 0 and 1)
  124719. * @param color1 defines the color to affect to the specified gradient
  124720. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  124721. * @returns the current particle system
  124722. */
  124723. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  124724. /**
  124725. * Remove a specific color gradient
  124726. * @param gradient defines the gradient to remove
  124727. * @returns the current particle system
  124728. */
  124729. removeColorGradient(gradient: number): GPUParticleSystem;
  124730. private _angularSpeedGradientsTexture;
  124731. private _sizeGradientsTexture;
  124732. private _velocityGradientsTexture;
  124733. private _limitVelocityGradientsTexture;
  124734. private _dragGradientsTexture;
  124735. private _addFactorGradient;
  124736. /**
  124737. * Adds a new size gradient
  124738. * @param gradient defines the gradient to use (between 0 and 1)
  124739. * @param factor defines the size factor to affect to the specified gradient
  124740. * @returns the current particle system
  124741. */
  124742. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  124743. /**
  124744. * Remove a specific size gradient
  124745. * @param gradient defines the gradient to remove
  124746. * @returns the current particle system
  124747. */
  124748. removeSizeGradient(gradient: number): GPUParticleSystem;
  124749. /**
  124750. * Adds a new angular speed gradient
  124751. * @param gradient defines the gradient to use (between 0 and 1)
  124752. * @param factor defines the angular speed to affect to the specified gradient
  124753. * @returns the current particle system
  124754. */
  124755. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  124756. /**
  124757. * Remove a specific angular speed gradient
  124758. * @param gradient defines the gradient to remove
  124759. * @returns the current particle system
  124760. */
  124761. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  124762. /**
  124763. * Adds a new velocity gradient
  124764. * @param gradient defines the gradient to use (between 0 and 1)
  124765. * @param factor defines the velocity to affect to the specified gradient
  124766. * @returns the current particle system
  124767. */
  124768. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124769. /**
  124770. * Remove a specific velocity gradient
  124771. * @param gradient defines the gradient to remove
  124772. * @returns the current particle system
  124773. */
  124774. removeVelocityGradient(gradient: number): GPUParticleSystem;
  124775. /**
  124776. * Adds a new limit velocity gradient
  124777. * @param gradient defines the gradient to use (between 0 and 1)
  124778. * @param factor defines the limit velocity value to affect to the specified gradient
  124779. * @returns the current particle system
  124780. */
  124781. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124782. /**
  124783. * Remove a specific limit velocity gradient
  124784. * @param gradient defines the gradient to remove
  124785. * @returns the current particle system
  124786. */
  124787. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  124788. /**
  124789. * Adds a new drag gradient
  124790. * @param gradient defines the gradient to use (between 0 and 1)
  124791. * @param factor defines the drag value to affect to the specified gradient
  124792. * @returns the current particle system
  124793. */
  124794. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  124795. /**
  124796. * Remove a specific drag gradient
  124797. * @param gradient defines the gradient to remove
  124798. * @returns the current particle system
  124799. */
  124800. removeDragGradient(gradient: number): GPUParticleSystem;
  124801. /**
  124802. * Not supported by GPUParticleSystem
  124803. * @param gradient defines the gradient to use (between 0 and 1)
  124804. * @param factor defines the emit rate value to affect to the specified gradient
  124805. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124806. * @returns the current particle system
  124807. */
  124808. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124809. /**
  124810. * Not supported by GPUParticleSystem
  124811. * @param gradient defines the gradient to remove
  124812. * @returns the current particle system
  124813. */
  124814. removeEmitRateGradient(gradient: number): IParticleSystem;
  124815. /**
  124816. * Not supported by GPUParticleSystem
  124817. * @param gradient defines the gradient to use (between 0 and 1)
  124818. * @param factor defines the start size value to affect to the specified gradient
  124819. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124820. * @returns the current particle system
  124821. */
  124822. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124823. /**
  124824. * Not supported by GPUParticleSystem
  124825. * @param gradient defines the gradient to remove
  124826. * @returns the current particle system
  124827. */
  124828. removeStartSizeGradient(gradient: number): IParticleSystem;
  124829. /**
  124830. * Not supported by GPUParticleSystem
  124831. * @param gradient defines the gradient to use (between 0 and 1)
  124832. * @param min defines the color remap minimal range
  124833. * @param max defines the color remap maximal range
  124834. * @returns the current particle system
  124835. */
  124836. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124837. /**
  124838. * Not supported by GPUParticleSystem
  124839. * @param gradient defines the gradient to remove
  124840. * @returns the current particle system
  124841. */
  124842. removeColorRemapGradient(): IParticleSystem;
  124843. /**
  124844. * Not supported by GPUParticleSystem
  124845. * @param gradient defines the gradient to use (between 0 and 1)
  124846. * @param min defines the alpha remap minimal range
  124847. * @param max defines the alpha remap maximal range
  124848. * @returns the current particle system
  124849. */
  124850. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124851. /**
  124852. * Not supported by GPUParticleSystem
  124853. * @param gradient defines the gradient to remove
  124854. * @returns the current particle system
  124855. */
  124856. removeAlphaRemapGradient(): IParticleSystem;
  124857. /**
  124858. * Not supported by GPUParticleSystem
  124859. * @param gradient defines the gradient to use (between 0 and 1)
  124860. * @param color defines the color to affect to the specified gradient
  124861. * @returns the current particle system
  124862. */
  124863. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  124864. /**
  124865. * Not supported by GPUParticleSystem
  124866. * @param gradient defines the gradient to remove
  124867. * @returns the current particle system
  124868. */
  124869. removeRampGradient(): IParticleSystem;
  124870. /**
  124871. * Not supported by GPUParticleSystem
  124872. * @returns the list of ramp gradients
  124873. */
  124874. getRampGradients(): Nullable<Array<Color3Gradient>>;
  124875. /**
  124876. * Not supported by GPUParticleSystem
  124877. * Gets or sets a boolean indicating that ramp gradients must be used
  124878. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  124879. */
  124880. useRampGradients: boolean;
  124881. /**
  124882. * Not supported by GPUParticleSystem
  124883. * @param gradient defines the gradient to use (between 0 and 1)
  124884. * @param factor defines the life time factor to affect to the specified gradient
  124885. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124886. * @returns the current particle system
  124887. */
  124888. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124889. /**
  124890. * Not supported by GPUParticleSystem
  124891. * @param gradient defines the gradient to remove
  124892. * @returns the current particle system
  124893. */
  124894. removeLifeTimeGradient(gradient: number): IParticleSystem;
  124895. /**
  124896. * Instantiates a GPU particle system.
  124897. * 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.
  124898. * @param name The name of the particle system
  124899. * @param options The options used to create the system
  124900. * @param scene The scene the particle system belongs to
  124901. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  124902. */
  124903. constructor(name: string, options: Partial<{
  124904. capacity: number;
  124905. randomTextureSize: number;
  124906. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  124907. protected _reset(): void;
  124908. private _createUpdateVAO;
  124909. private _createRenderVAO;
  124910. private _initialize;
  124911. /** @hidden */
  124912. _recreateUpdateEffect(): void;
  124913. /** @hidden */
  124914. _recreateRenderEffect(): void;
  124915. /**
  124916. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  124917. * @param preWarm defines if we are in the pre-warmimg phase
  124918. */
  124919. animate(preWarm?: boolean): void;
  124920. private _createFactorGradientTexture;
  124921. private _createSizeGradientTexture;
  124922. private _createAngularSpeedGradientTexture;
  124923. private _createVelocityGradientTexture;
  124924. private _createLimitVelocityGradientTexture;
  124925. private _createDragGradientTexture;
  124926. private _createColorGradientTexture;
  124927. /**
  124928. * Renders the particle system in its current state
  124929. * @param preWarm defines if the system should only update the particles but not render them
  124930. * @returns the current number of particles
  124931. */
  124932. render(preWarm?: boolean): number;
  124933. /**
  124934. * Rebuilds the particle system
  124935. */
  124936. rebuild(): void;
  124937. private _releaseBuffers;
  124938. private _releaseVAOs;
  124939. /**
  124940. * Disposes the particle system and free the associated resources
  124941. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  124942. */
  124943. dispose(disposeTexture?: boolean): void;
  124944. /**
  124945. * Clones the particle system.
  124946. * @param name The name of the cloned object
  124947. * @param newEmitter The new emitter to use
  124948. * @returns the cloned particle system
  124949. */
  124950. clone(name: string, newEmitter: any): GPUParticleSystem;
  124951. /**
  124952. * Serializes the particle system to a JSON object.
  124953. * @returns the JSON object
  124954. */
  124955. serialize(): any;
  124956. /**
  124957. * Parses a JSON object to create a GPU particle system.
  124958. * @param parsedParticleSystem The JSON object to parse
  124959. * @param scene The scene to create the particle system in
  124960. * @param rootUrl The root url to use to load external dependencies like texture
  124961. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  124962. * @returns the parsed GPU particle system
  124963. */
  124964. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  124965. }
  124966. }
  124967. declare module BABYLON {
  124968. /**
  124969. * Represents a set of particle systems working together to create a specific effect
  124970. */
  124971. export class ParticleSystemSet implements IDisposable {
  124972. private _emitterCreationOptions;
  124973. private _emitterNode;
  124974. /**
  124975. * Gets the particle system list
  124976. */
  124977. systems: IParticleSystem[];
  124978. /**
  124979. * Gets the emitter node used with this set
  124980. */
  124981. readonly emitterNode: Nullable<TransformNode>;
  124982. /**
  124983. * Creates a new emitter mesh as a sphere
  124984. * @param options defines the options used to create the sphere
  124985. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  124986. * @param scene defines the hosting scene
  124987. */
  124988. setEmitterAsSphere(options: {
  124989. diameter: number;
  124990. segments: number;
  124991. color: Color3;
  124992. }, renderingGroupId: number, scene: Scene): void;
  124993. /**
  124994. * Starts all particle systems of the set
  124995. * @param emitter defines an optional mesh to use as emitter for the particle systems
  124996. */
  124997. start(emitter?: AbstractMesh): void;
  124998. /**
  124999. * Release all associated resources
  125000. */
  125001. dispose(): void;
  125002. /**
  125003. * Serialize the set into a JSON compatible object
  125004. * @returns a JSON compatible representation of the set
  125005. */
  125006. serialize(): any;
  125007. /**
  125008. * Parse a new ParticleSystemSet from a serialized source
  125009. * @param data defines a JSON compatible representation of the set
  125010. * @param scene defines the hosting scene
  125011. * @param gpu defines if we want GPU particles or CPU particles
  125012. * @returns a new ParticleSystemSet
  125013. */
  125014. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  125015. }
  125016. }
  125017. declare module BABYLON {
  125018. /**
  125019. * This class is made for on one-liner static method to help creating particle system set.
  125020. */
  125021. export class ParticleHelper {
  125022. /**
  125023. * Gets or sets base Assets URL
  125024. */
  125025. static BaseAssetsUrl: string;
  125026. /**
  125027. * Create a default particle system that you can tweak
  125028. * @param emitter defines the emitter to use
  125029. * @param capacity defines the system capacity (default is 500 particles)
  125030. * @param scene defines the hosting scene
  125031. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  125032. * @returns the new Particle system
  125033. */
  125034. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  125035. /**
  125036. * This is the main static method (one-liner) of this helper to create different particle systems
  125037. * @param type This string represents the type to the particle system to create
  125038. * @param scene The scene where the particle system should live
  125039. * @param gpu If the system will use gpu
  125040. * @returns the ParticleSystemSet created
  125041. */
  125042. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  125043. /**
  125044. * Static function used to export a particle system to a ParticleSystemSet variable.
  125045. * Please note that the emitter shape is not exported
  125046. * @param systems defines the particle systems to export
  125047. * @returns the created particle system set
  125048. */
  125049. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  125050. }
  125051. }
  125052. declare module BABYLON {
  125053. interface Engine {
  125054. /**
  125055. * Create an effect to use with particle systems.
  125056. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  125057. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  125058. * @param uniformsNames defines a list of attribute names
  125059. * @param samplers defines an array of string used to represent textures
  125060. * @param defines defines the string containing the defines to use to compile the shaders
  125061. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  125062. * @param onCompiled defines a function to call when the effect creation is successful
  125063. * @param onError defines a function to call when the effect creation has failed
  125064. * @returns the new Effect
  125065. */
  125066. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  125067. }
  125068. interface Mesh {
  125069. /**
  125070. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  125071. * @returns an array of IParticleSystem
  125072. */
  125073. getEmittedParticleSystems(): IParticleSystem[];
  125074. /**
  125075. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  125076. * @returns an array of IParticleSystem
  125077. */
  125078. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  125079. }
  125080. /**
  125081. * @hidden
  125082. */
  125083. export var _IDoNeedToBeInTheBuild: number;
  125084. }
  125085. declare module BABYLON {
  125086. interface Scene {
  125087. /** @hidden (Backing field) */
  125088. _physicsEngine: Nullable<IPhysicsEngine>;
  125089. /**
  125090. * Gets the current physics engine
  125091. * @returns a IPhysicsEngine or null if none attached
  125092. */
  125093. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  125094. /**
  125095. * Enables physics to the current scene
  125096. * @param gravity defines the scene's gravity for the physics engine
  125097. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  125098. * @return a boolean indicating if the physics engine was initialized
  125099. */
  125100. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  125101. /**
  125102. * Disables and disposes the physics engine associated with the scene
  125103. */
  125104. disablePhysicsEngine(): void;
  125105. /**
  125106. * Gets a boolean indicating if there is an active physics engine
  125107. * @returns a boolean indicating if there is an active physics engine
  125108. */
  125109. isPhysicsEnabled(): boolean;
  125110. /**
  125111. * Deletes a physics compound impostor
  125112. * @param compound defines the compound to delete
  125113. */
  125114. deleteCompoundImpostor(compound: any): void;
  125115. /**
  125116. * An event triggered when physic simulation is about to be run
  125117. */
  125118. onBeforePhysicsObservable: Observable<Scene>;
  125119. /**
  125120. * An event triggered when physic simulation has been done
  125121. */
  125122. onAfterPhysicsObservable: Observable<Scene>;
  125123. }
  125124. interface AbstractMesh {
  125125. /** @hidden */
  125126. _physicsImpostor: Nullable<PhysicsImpostor>;
  125127. /**
  125128. * Gets or sets impostor used for physic simulation
  125129. * @see http://doc.babylonjs.com/features/physics_engine
  125130. */
  125131. physicsImpostor: Nullable<PhysicsImpostor>;
  125132. /**
  125133. * Gets the current physics impostor
  125134. * @see http://doc.babylonjs.com/features/physics_engine
  125135. * @returns a physics impostor or null
  125136. */
  125137. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  125138. /** Apply a physic impulse to the mesh
  125139. * @param force defines the force to apply
  125140. * @param contactPoint defines where to apply the force
  125141. * @returns the current mesh
  125142. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  125143. */
  125144. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  125145. /**
  125146. * Creates a physic joint between two meshes
  125147. * @param otherMesh defines the other mesh to use
  125148. * @param pivot1 defines the pivot to use on this mesh
  125149. * @param pivot2 defines the pivot to use on the other mesh
  125150. * @param options defines additional options (can be plugin dependent)
  125151. * @returns the current mesh
  125152. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  125153. */
  125154. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  125155. /** @hidden */
  125156. _disposePhysicsObserver: Nullable<Observer<Node>>;
  125157. }
  125158. /**
  125159. * Defines the physics engine scene component responsible to manage a physics engine
  125160. */
  125161. export class PhysicsEngineSceneComponent implements ISceneComponent {
  125162. /**
  125163. * The component name helpful to identify the component in the list of scene components.
  125164. */
  125165. readonly name: string;
  125166. /**
  125167. * The scene the component belongs to.
  125168. */
  125169. scene: Scene;
  125170. /**
  125171. * Creates a new instance of the component for the given scene
  125172. * @param scene Defines the scene to register the component in
  125173. */
  125174. constructor(scene: Scene);
  125175. /**
  125176. * Registers the component in a given scene
  125177. */
  125178. register(): void;
  125179. /**
  125180. * Rebuilds the elements related to this component in case of
  125181. * context lost for instance.
  125182. */
  125183. rebuild(): void;
  125184. /**
  125185. * Disposes the component and the associated ressources
  125186. */
  125187. dispose(): void;
  125188. }
  125189. }
  125190. declare module BABYLON {
  125191. /**
  125192. * A helper for physics simulations
  125193. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125194. */
  125195. export class PhysicsHelper {
  125196. private _scene;
  125197. private _physicsEngine;
  125198. /**
  125199. * Initializes the Physics helper
  125200. * @param scene Babylon.js scene
  125201. */
  125202. constructor(scene: Scene);
  125203. /**
  125204. * Applies a radial explosion impulse
  125205. * @param origin the origin of the explosion
  125206. * @param radiusOrEventOptions the radius or the options of radial explosion
  125207. * @param strength the explosion strength
  125208. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125209. * @returns A physics radial explosion event, or null
  125210. */
  125211. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  125212. /**
  125213. * Applies a radial explosion force
  125214. * @param origin the origin of the explosion
  125215. * @param radiusOrEventOptions the radius or the options of radial explosion
  125216. * @param strength the explosion strength
  125217. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125218. * @returns A physics radial explosion event, or null
  125219. */
  125220. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  125221. /**
  125222. * Creates a gravitational field
  125223. * @param origin the origin of the explosion
  125224. * @param radiusOrEventOptions the radius or the options of radial explosion
  125225. * @param strength the explosion strength
  125226. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125227. * @returns A physics gravitational field event, or null
  125228. */
  125229. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  125230. /**
  125231. * Creates a physics updraft event
  125232. * @param origin the origin of the updraft
  125233. * @param radiusOrEventOptions the radius or the options of the updraft
  125234. * @param strength the strength of the updraft
  125235. * @param height the height of the updraft
  125236. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  125237. * @returns A physics updraft event, or null
  125238. */
  125239. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  125240. /**
  125241. * Creates a physics vortex event
  125242. * @param origin the of the vortex
  125243. * @param radiusOrEventOptions the radius or the options of the vortex
  125244. * @param strength the strength of the vortex
  125245. * @param height the height of the vortex
  125246. * @returns a Physics vortex event, or null
  125247. * A physics vortex event or null
  125248. */
  125249. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  125250. }
  125251. /**
  125252. * Represents a physics radial explosion event
  125253. */
  125254. class PhysicsRadialExplosionEvent {
  125255. private _scene;
  125256. private _options;
  125257. private _sphere;
  125258. private _dataFetched;
  125259. /**
  125260. * Initializes a radial explosioin event
  125261. * @param _scene BabylonJS scene
  125262. * @param _options The options for the vortex event
  125263. */
  125264. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  125265. /**
  125266. * Returns the data related to the radial explosion event (sphere).
  125267. * @returns The radial explosion event data
  125268. */
  125269. getData(): PhysicsRadialExplosionEventData;
  125270. /**
  125271. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  125272. * @param impostor A physics imposter
  125273. * @param origin the origin of the explosion
  125274. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  125275. */
  125276. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  125277. /**
  125278. * Triggers affecterd impostors callbacks
  125279. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  125280. */
  125281. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  125282. /**
  125283. * Disposes the sphere.
  125284. * @param force Specifies if the sphere should be disposed by force
  125285. */
  125286. dispose(force?: boolean): void;
  125287. /*** Helpers ***/
  125288. private _prepareSphere;
  125289. private _intersectsWithSphere;
  125290. }
  125291. /**
  125292. * Represents a gravitational field event
  125293. */
  125294. class PhysicsGravitationalFieldEvent {
  125295. private _physicsHelper;
  125296. private _scene;
  125297. private _origin;
  125298. private _options;
  125299. private _tickCallback;
  125300. private _sphere;
  125301. private _dataFetched;
  125302. /**
  125303. * Initializes the physics gravitational field event
  125304. * @param _physicsHelper A physics helper
  125305. * @param _scene BabylonJS scene
  125306. * @param _origin The origin position of the gravitational field event
  125307. * @param _options The options for the vortex event
  125308. */
  125309. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  125310. /**
  125311. * Returns the data related to the gravitational field event (sphere).
  125312. * @returns A gravitational field event
  125313. */
  125314. getData(): PhysicsGravitationalFieldEventData;
  125315. /**
  125316. * Enables the gravitational field.
  125317. */
  125318. enable(): void;
  125319. /**
  125320. * Disables the gravitational field.
  125321. */
  125322. disable(): void;
  125323. /**
  125324. * Disposes the sphere.
  125325. * @param force The force to dispose from the gravitational field event
  125326. */
  125327. dispose(force?: boolean): void;
  125328. private _tick;
  125329. }
  125330. /**
  125331. * Represents a physics updraft event
  125332. */
  125333. class PhysicsUpdraftEvent {
  125334. private _scene;
  125335. private _origin;
  125336. private _options;
  125337. private _physicsEngine;
  125338. private _originTop;
  125339. private _originDirection;
  125340. private _tickCallback;
  125341. private _cylinder;
  125342. private _cylinderPosition;
  125343. private _dataFetched;
  125344. /**
  125345. * Initializes the physics updraft event
  125346. * @param _scene BabylonJS scene
  125347. * @param _origin The origin position of the updraft
  125348. * @param _options The options for the updraft event
  125349. */
  125350. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  125351. /**
  125352. * Returns the data related to the updraft event (cylinder).
  125353. * @returns A physics updraft event
  125354. */
  125355. getData(): PhysicsUpdraftEventData;
  125356. /**
  125357. * Enables the updraft.
  125358. */
  125359. enable(): void;
  125360. /**
  125361. * Disables the updraft.
  125362. */
  125363. disable(): void;
  125364. /**
  125365. * Disposes the cylinder.
  125366. * @param force Specifies if the updraft should be disposed by force
  125367. */
  125368. dispose(force?: boolean): void;
  125369. private getImpostorHitData;
  125370. private _tick;
  125371. /*** Helpers ***/
  125372. private _prepareCylinder;
  125373. private _intersectsWithCylinder;
  125374. }
  125375. /**
  125376. * Represents a physics vortex event
  125377. */
  125378. class PhysicsVortexEvent {
  125379. private _scene;
  125380. private _origin;
  125381. private _options;
  125382. private _physicsEngine;
  125383. private _originTop;
  125384. private _tickCallback;
  125385. private _cylinder;
  125386. private _cylinderPosition;
  125387. private _dataFetched;
  125388. /**
  125389. * Initializes the physics vortex event
  125390. * @param _scene The BabylonJS scene
  125391. * @param _origin The origin position of the vortex
  125392. * @param _options The options for the vortex event
  125393. */
  125394. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  125395. /**
  125396. * Returns the data related to the vortex event (cylinder).
  125397. * @returns The physics vortex event data
  125398. */
  125399. getData(): PhysicsVortexEventData;
  125400. /**
  125401. * Enables the vortex.
  125402. */
  125403. enable(): void;
  125404. /**
  125405. * Disables the cortex.
  125406. */
  125407. disable(): void;
  125408. /**
  125409. * Disposes the sphere.
  125410. * @param force
  125411. */
  125412. dispose(force?: boolean): void;
  125413. private getImpostorHitData;
  125414. private _tick;
  125415. /*** Helpers ***/
  125416. private _prepareCylinder;
  125417. private _intersectsWithCylinder;
  125418. }
  125419. /**
  125420. * Options fot the radial explosion event
  125421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125422. */
  125423. export class PhysicsRadialExplosionEventOptions {
  125424. /**
  125425. * The radius of the sphere for the radial explosion.
  125426. */
  125427. radius: number;
  125428. /**
  125429. * The strenth of the explosion.
  125430. */
  125431. strength: number;
  125432. /**
  125433. * The strenght of the force in correspondence to the distance of the affected object
  125434. */
  125435. falloff: PhysicsRadialImpulseFalloff;
  125436. /**
  125437. * Sphere options for the radial explosion.
  125438. */
  125439. sphere: {
  125440. segments: number;
  125441. diameter: number;
  125442. };
  125443. /**
  125444. * Sphere options for the radial explosion.
  125445. */
  125446. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  125447. }
  125448. /**
  125449. * Options fot the updraft event
  125450. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125451. */
  125452. export class PhysicsUpdraftEventOptions {
  125453. /**
  125454. * The radius of the cylinder for the vortex
  125455. */
  125456. radius: number;
  125457. /**
  125458. * The strenth of the updraft.
  125459. */
  125460. strength: number;
  125461. /**
  125462. * The height of the cylinder for the updraft.
  125463. */
  125464. height: number;
  125465. /**
  125466. * The mode for the the updraft.
  125467. */
  125468. updraftMode: PhysicsUpdraftMode;
  125469. }
  125470. /**
  125471. * Options fot the vortex event
  125472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125473. */
  125474. export class PhysicsVortexEventOptions {
  125475. /**
  125476. * The radius of the cylinder for the vortex
  125477. */
  125478. radius: number;
  125479. /**
  125480. * The strenth of the vortex.
  125481. */
  125482. strength: number;
  125483. /**
  125484. * The height of the cylinder for the vortex.
  125485. */
  125486. height: number;
  125487. /**
  125488. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  125489. */
  125490. centripetalForceThreshold: number;
  125491. /**
  125492. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  125493. */
  125494. centripetalForceMultiplier: number;
  125495. /**
  125496. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  125497. */
  125498. centrifugalForceMultiplier: number;
  125499. /**
  125500. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  125501. */
  125502. updraftForceMultiplier: number;
  125503. }
  125504. /**
  125505. * The strenght of the force in correspondence to the distance of the affected object
  125506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125507. */
  125508. export enum PhysicsRadialImpulseFalloff {
  125509. /** Defines that impulse is constant in strength across it's whole radius */
  125510. Constant = 0,
  125511. /** Defines that impulse gets weaker if it's further from the origin */
  125512. Linear = 1
  125513. }
  125514. /**
  125515. * The strength of the force in correspondence to the distance of the affected object
  125516. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125517. */
  125518. export enum PhysicsUpdraftMode {
  125519. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  125520. Center = 0,
  125521. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  125522. Perpendicular = 1
  125523. }
  125524. /**
  125525. * Interface for a physics hit data
  125526. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125527. */
  125528. export interface PhysicsHitData {
  125529. /**
  125530. * The force applied at the contact point
  125531. */
  125532. force: Vector3;
  125533. /**
  125534. * The contact point
  125535. */
  125536. contactPoint: Vector3;
  125537. /**
  125538. * The distance from the origin to the contact point
  125539. */
  125540. distanceFromOrigin: number;
  125541. }
  125542. /**
  125543. * Interface for radial explosion event data
  125544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125545. */
  125546. export interface PhysicsRadialExplosionEventData {
  125547. /**
  125548. * A sphere used for the radial explosion event
  125549. */
  125550. sphere: Mesh;
  125551. }
  125552. /**
  125553. * Interface for gravitational field event data
  125554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125555. */
  125556. export interface PhysicsGravitationalFieldEventData {
  125557. /**
  125558. * A sphere mesh used for the gravitational field event
  125559. */
  125560. sphere: Mesh;
  125561. }
  125562. /**
  125563. * Interface for updraft event data
  125564. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125565. */
  125566. export interface PhysicsUpdraftEventData {
  125567. /**
  125568. * A cylinder used for the updraft event
  125569. */
  125570. cylinder: Mesh;
  125571. }
  125572. /**
  125573. * Interface for vortex event data
  125574. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125575. */
  125576. export interface PhysicsVortexEventData {
  125577. /**
  125578. * A cylinder used for the vortex event
  125579. */
  125580. cylinder: Mesh;
  125581. }
  125582. /**
  125583. * Interface for an affected physics impostor
  125584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125585. */
  125586. export interface PhysicsAffectedImpostorWithData {
  125587. /**
  125588. * The impostor affected by the effect
  125589. */
  125590. impostor: PhysicsImpostor;
  125591. /**
  125592. * The data about the hit/horce from the explosion
  125593. */
  125594. hitData: PhysicsHitData;
  125595. }
  125596. }
  125597. declare module BABYLON {
  125598. /** @hidden */
  125599. export var blackAndWhitePixelShader: {
  125600. name: string;
  125601. shader: string;
  125602. };
  125603. }
  125604. declare module BABYLON {
  125605. /**
  125606. * Post process used to render in black and white
  125607. */
  125608. export class BlackAndWhitePostProcess extends PostProcess {
  125609. /**
  125610. * Linear about to convert he result to black and white (default: 1)
  125611. */
  125612. degree: number;
  125613. /**
  125614. * Creates a black and white post process
  125615. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  125616. * @param name The name of the effect.
  125617. * @param options The required width/height ratio to downsize to before computing the render pass.
  125618. * @param camera The camera to apply the render pass to.
  125619. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125620. * @param engine The engine which the post process will be applied. (default: current engine)
  125621. * @param reusable If the post process can be reused on the same frame. (default: false)
  125622. */
  125623. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125624. }
  125625. }
  125626. declare module BABYLON {
  125627. /**
  125628. * This represents a set of one or more post processes in Babylon.
  125629. * A post process can be used to apply a shader to a texture after it is rendered.
  125630. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125631. */
  125632. export class PostProcessRenderEffect {
  125633. private _postProcesses;
  125634. private _getPostProcesses;
  125635. private _singleInstance;
  125636. private _cameras;
  125637. private _indicesForCamera;
  125638. /**
  125639. * Name of the effect
  125640. * @hidden
  125641. */
  125642. _name: string;
  125643. /**
  125644. * Instantiates a post process render effect.
  125645. * A post process can be used to apply a shader to a texture after it is rendered.
  125646. * @param engine The engine the effect is tied to
  125647. * @param name The name of the effect
  125648. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  125649. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  125650. */
  125651. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  125652. /**
  125653. * Checks if all the post processes in the effect are supported.
  125654. */
  125655. readonly isSupported: boolean;
  125656. /**
  125657. * Updates the current state of the effect
  125658. * @hidden
  125659. */
  125660. _update(): void;
  125661. /**
  125662. * Attaches the effect on cameras
  125663. * @param cameras The camera to attach to.
  125664. * @hidden
  125665. */
  125666. _attachCameras(cameras: Camera): void;
  125667. /**
  125668. * Attaches the effect on cameras
  125669. * @param cameras The camera to attach to.
  125670. * @hidden
  125671. */
  125672. _attachCameras(cameras: Camera[]): void;
  125673. /**
  125674. * Detaches the effect on cameras
  125675. * @param cameras The camera to detatch from.
  125676. * @hidden
  125677. */
  125678. _detachCameras(cameras: Camera): void;
  125679. /**
  125680. * Detatches the effect on cameras
  125681. * @param cameras The camera to detatch from.
  125682. * @hidden
  125683. */
  125684. _detachCameras(cameras: Camera[]): void;
  125685. /**
  125686. * Enables the effect on given cameras
  125687. * @param cameras The camera to enable.
  125688. * @hidden
  125689. */
  125690. _enable(cameras: Camera): void;
  125691. /**
  125692. * Enables the effect on given cameras
  125693. * @param cameras The camera to enable.
  125694. * @hidden
  125695. */
  125696. _enable(cameras: Nullable<Camera[]>): void;
  125697. /**
  125698. * Disables the effect on the given cameras
  125699. * @param cameras The camera to disable.
  125700. * @hidden
  125701. */
  125702. _disable(cameras: Camera): void;
  125703. /**
  125704. * Disables the effect on the given cameras
  125705. * @param cameras The camera to disable.
  125706. * @hidden
  125707. */
  125708. _disable(cameras: Nullable<Camera[]>): void;
  125709. /**
  125710. * Gets a list of the post processes contained in the effect.
  125711. * @param camera The camera to get the post processes on.
  125712. * @returns The list of the post processes in the effect.
  125713. */
  125714. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  125715. }
  125716. }
  125717. declare module BABYLON {
  125718. /** @hidden */
  125719. export var extractHighlightsPixelShader: {
  125720. name: string;
  125721. shader: string;
  125722. };
  125723. }
  125724. declare module BABYLON {
  125725. /**
  125726. * 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.
  125727. */
  125728. export class ExtractHighlightsPostProcess extends PostProcess {
  125729. /**
  125730. * The luminance threshold, pixels below this value will be set to black.
  125731. */
  125732. threshold: number;
  125733. /** @hidden */
  125734. _exposure: number;
  125735. /**
  125736. * Post process which has the input texture to be used when performing highlight extraction
  125737. * @hidden
  125738. */
  125739. _inputPostProcess: Nullable<PostProcess>;
  125740. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125741. }
  125742. }
  125743. declare module BABYLON {
  125744. /** @hidden */
  125745. export var bloomMergePixelShader: {
  125746. name: string;
  125747. shader: string;
  125748. };
  125749. }
  125750. declare module BABYLON {
  125751. /**
  125752. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  125753. */
  125754. export class BloomMergePostProcess extends PostProcess {
  125755. /** Weight of the bloom to be added to the original input. */
  125756. weight: number;
  125757. /**
  125758. * Creates a new instance of @see BloomMergePostProcess
  125759. * @param name The name of the effect.
  125760. * @param originalFromInput Post process which's input will be used for the merge.
  125761. * @param blurred Blurred highlights post process which's output will be used.
  125762. * @param weight Weight of the bloom to be added to the original input.
  125763. * @param options The required width/height ratio to downsize to before computing the render pass.
  125764. * @param camera The camera to apply the render pass to.
  125765. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125766. * @param engine The engine which the post process will be applied. (default: current engine)
  125767. * @param reusable If the post process can be reused on the same frame. (default: false)
  125768. * @param textureType Type of textures used when performing the post process. (default: 0)
  125769. * @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)
  125770. */
  125771. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  125772. /** Weight of the bloom to be added to the original input. */
  125773. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125774. }
  125775. }
  125776. declare module BABYLON {
  125777. /**
  125778. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  125779. */
  125780. export class BloomEffect extends PostProcessRenderEffect {
  125781. private bloomScale;
  125782. /**
  125783. * @hidden Internal
  125784. */
  125785. _effects: Array<PostProcess>;
  125786. /**
  125787. * @hidden Internal
  125788. */
  125789. _downscale: ExtractHighlightsPostProcess;
  125790. private _blurX;
  125791. private _blurY;
  125792. private _merge;
  125793. /**
  125794. * The luminance threshold to find bright areas of the image to bloom.
  125795. */
  125796. threshold: number;
  125797. /**
  125798. * The strength of the bloom.
  125799. */
  125800. weight: number;
  125801. /**
  125802. * Specifies the size of the bloom blur kernel, relative to the final output size
  125803. */
  125804. kernel: number;
  125805. /**
  125806. * Creates a new instance of @see BloomEffect
  125807. * @param scene The scene the effect belongs to.
  125808. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  125809. * @param bloomKernel The size of the kernel to be used when applying the blur.
  125810. * @param bloomWeight The the strength of bloom.
  125811. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  125812. * @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)
  125813. */
  125814. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  125815. /**
  125816. * Disposes each of the internal effects for a given camera.
  125817. * @param camera The camera to dispose the effect on.
  125818. */
  125819. disposeEffects(camera: Camera): void;
  125820. /**
  125821. * @hidden Internal
  125822. */
  125823. _updateEffects(): void;
  125824. /**
  125825. * Internal
  125826. * @returns if all the contained post processes are ready.
  125827. * @hidden
  125828. */
  125829. _isReady(): boolean;
  125830. }
  125831. }
  125832. declare module BABYLON {
  125833. /** @hidden */
  125834. export var chromaticAberrationPixelShader: {
  125835. name: string;
  125836. shader: string;
  125837. };
  125838. }
  125839. declare module BABYLON {
  125840. /**
  125841. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  125842. */
  125843. export class ChromaticAberrationPostProcess extends PostProcess {
  125844. /**
  125845. * The amount of seperation of rgb channels (default: 30)
  125846. */
  125847. aberrationAmount: number;
  125848. /**
  125849. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  125850. */
  125851. radialIntensity: number;
  125852. /**
  125853. * 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))
  125854. */
  125855. direction: Vector2;
  125856. /**
  125857. * 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))
  125858. */
  125859. centerPosition: Vector2;
  125860. /**
  125861. * Creates a new instance ChromaticAberrationPostProcess
  125862. * @param name The name of the effect.
  125863. * @param screenWidth The width of the screen to apply the effect on.
  125864. * @param screenHeight The height of the screen to apply the effect on.
  125865. * @param options The required width/height ratio to downsize to before computing the render pass.
  125866. * @param camera The camera to apply the render pass to.
  125867. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125868. * @param engine The engine which the post process will be applied. (default: current engine)
  125869. * @param reusable If the post process can be reused on the same frame. (default: false)
  125870. * @param textureType Type of textures used when performing the post process. (default: 0)
  125871. * @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)
  125872. */
  125873. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125874. }
  125875. }
  125876. declare module BABYLON {
  125877. /** @hidden */
  125878. export var circleOfConfusionPixelShader: {
  125879. name: string;
  125880. shader: string;
  125881. };
  125882. }
  125883. declare module BABYLON {
  125884. /**
  125885. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  125886. */
  125887. export class CircleOfConfusionPostProcess extends PostProcess {
  125888. /**
  125889. * 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.
  125890. */
  125891. lensSize: number;
  125892. /**
  125893. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125894. */
  125895. fStop: number;
  125896. /**
  125897. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125898. */
  125899. focusDistance: number;
  125900. /**
  125901. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  125902. */
  125903. focalLength: number;
  125904. private _depthTexture;
  125905. /**
  125906. * Creates a new instance CircleOfConfusionPostProcess
  125907. * @param name The name of the effect.
  125908. * @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.
  125909. * @param options The required width/height ratio to downsize to before computing the render pass.
  125910. * @param camera The camera to apply the render pass to.
  125911. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125912. * @param engine The engine which the post process will be applied. (default: current engine)
  125913. * @param reusable If the post process can be reused on the same frame. (default: false)
  125914. * @param textureType Type of textures used when performing the post process. (default: 0)
  125915. * @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)
  125916. */
  125917. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125918. /**
  125919. * 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.
  125920. */
  125921. depthTexture: RenderTargetTexture;
  125922. }
  125923. }
  125924. declare module BABYLON {
  125925. /** @hidden */
  125926. export var colorCorrectionPixelShader: {
  125927. name: string;
  125928. shader: string;
  125929. };
  125930. }
  125931. declare module BABYLON {
  125932. /**
  125933. *
  125934. * This post-process allows the modification of rendered colors by using
  125935. * a 'look-up table' (LUT). This effect is also called Color Grading.
  125936. *
  125937. * The object needs to be provided an url to a texture containing the color
  125938. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  125939. * Use an image editing software to tweak the LUT to match your needs.
  125940. *
  125941. * For an example of a color LUT, see here:
  125942. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  125943. * For explanations on color grading, see here:
  125944. * @see http://udn.epicgames.com/Three/ColorGrading.html
  125945. *
  125946. */
  125947. export class ColorCorrectionPostProcess extends PostProcess {
  125948. private _colorTableTexture;
  125949. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125950. }
  125951. }
  125952. declare module BABYLON {
  125953. /** @hidden */
  125954. export var convolutionPixelShader: {
  125955. name: string;
  125956. shader: string;
  125957. };
  125958. }
  125959. declare module BABYLON {
  125960. /**
  125961. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  125962. * input texture to perform effects such as edge detection or sharpening
  125963. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  125964. */
  125965. export class ConvolutionPostProcess extends PostProcess {
  125966. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125967. kernel: number[];
  125968. /**
  125969. * Creates a new instance ConvolutionPostProcess
  125970. * @param name The name of the effect.
  125971. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  125972. * @param options The required width/height ratio to downsize to before computing the render pass.
  125973. * @param camera The camera to apply the render pass to.
  125974. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125975. * @param engine The engine which the post process will be applied. (default: current engine)
  125976. * @param reusable If the post process can be reused on the same frame. (default: false)
  125977. * @param textureType Type of textures used when performing the post process. (default: 0)
  125978. */
  125979. constructor(name: string,
  125980. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125981. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  125982. /**
  125983. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125984. */
  125985. static EdgeDetect0Kernel: number[];
  125986. /**
  125987. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125988. */
  125989. static EdgeDetect1Kernel: number[];
  125990. /**
  125991. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125992. */
  125993. static EdgeDetect2Kernel: number[];
  125994. /**
  125995. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125996. */
  125997. static SharpenKernel: number[];
  125998. /**
  125999. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126000. */
  126001. static EmbossKernel: number[];
  126002. /**
  126003. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126004. */
  126005. static GaussianKernel: number[];
  126006. }
  126007. }
  126008. declare module BABYLON {
  126009. /**
  126010. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  126011. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  126012. * based on samples that have a large difference in distance than the center pixel.
  126013. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  126014. */
  126015. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  126016. direction: Vector2;
  126017. /**
  126018. * Creates a new instance CircleOfConfusionPostProcess
  126019. * @param name The name of the effect.
  126020. * @param scene The scene the effect belongs to.
  126021. * @param direction The direction the blur should be applied.
  126022. * @param kernel The size of the kernel used to blur.
  126023. * @param options The required width/height ratio to downsize to before computing the render pass.
  126024. * @param camera The camera to apply the render pass to.
  126025. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  126026. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  126027. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126028. * @param engine The engine which the post process will be applied. (default: current engine)
  126029. * @param reusable If the post process can be reused on the same frame. (default: false)
  126030. * @param textureType Type of textures used when performing the post process. (default: 0)
  126031. * @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)
  126032. */
  126033. 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);
  126034. }
  126035. }
  126036. declare module BABYLON {
  126037. /** @hidden */
  126038. export var depthOfFieldMergePixelShader: {
  126039. name: string;
  126040. shader: string;
  126041. };
  126042. }
  126043. declare module BABYLON {
  126044. /**
  126045. * Options to be set when merging outputs from the default pipeline.
  126046. */
  126047. export class DepthOfFieldMergePostProcessOptions {
  126048. /**
  126049. * The original image to merge on top of
  126050. */
  126051. originalFromInput: PostProcess;
  126052. /**
  126053. * Parameters to perform the merge of the depth of field effect
  126054. */
  126055. depthOfField?: {
  126056. circleOfConfusion: PostProcess;
  126057. blurSteps: Array<PostProcess>;
  126058. };
  126059. /**
  126060. * Parameters to perform the merge of bloom effect
  126061. */
  126062. bloom?: {
  126063. blurred: PostProcess;
  126064. weight: number;
  126065. };
  126066. }
  126067. /**
  126068. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  126069. */
  126070. export class DepthOfFieldMergePostProcess extends PostProcess {
  126071. private blurSteps;
  126072. /**
  126073. * Creates a new instance of DepthOfFieldMergePostProcess
  126074. * @param name The name of the effect.
  126075. * @param originalFromInput Post process which's input will be used for the merge.
  126076. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  126077. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  126078. * @param options The required width/height ratio to downsize to before computing the render pass.
  126079. * @param camera The camera to apply the render pass to.
  126080. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126081. * @param engine The engine which the post process will be applied. (default: current engine)
  126082. * @param reusable If the post process can be reused on the same frame. (default: false)
  126083. * @param textureType Type of textures used when performing the post process. (default: 0)
  126084. * @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)
  126085. */
  126086. 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);
  126087. /**
  126088. * Updates the effect with the current post process compile time values and recompiles the shader.
  126089. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  126090. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  126091. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  126092. * @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
  126093. * @param onCompiled Called when the shader has been compiled.
  126094. * @param onError Called if there is an error when compiling a shader.
  126095. */
  126096. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  126097. }
  126098. }
  126099. declare module BABYLON {
  126100. /**
  126101. * Specifies the level of max blur that should be applied when using the depth of field effect
  126102. */
  126103. export enum DepthOfFieldEffectBlurLevel {
  126104. /**
  126105. * Subtle blur
  126106. */
  126107. Low = 0,
  126108. /**
  126109. * Medium blur
  126110. */
  126111. Medium = 1,
  126112. /**
  126113. * Large blur
  126114. */
  126115. High = 2
  126116. }
  126117. /**
  126118. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  126119. */
  126120. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  126121. private _circleOfConfusion;
  126122. /**
  126123. * @hidden Internal, blurs from high to low
  126124. */
  126125. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  126126. private _depthOfFieldBlurY;
  126127. private _dofMerge;
  126128. /**
  126129. * @hidden Internal post processes in depth of field effect
  126130. */
  126131. _effects: Array<PostProcess>;
  126132. /**
  126133. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  126134. */
  126135. focalLength: number;
  126136. /**
  126137. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  126138. */
  126139. fStop: number;
  126140. /**
  126141. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  126142. */
  126143. focusDistance: number;
  126144. /**
  126145. * 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.
  126146. */
  126147. lensSize: number;
  126148. /**
  126149. * Creates a new instance DepthOfFieldEffect
  126150. * @param scene The scene the effect belongs to.
  126151. * @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.
  126152. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  126153. * @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)
  126154. */
  126155. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  126156. /**
  126157. * Get the current class name of the current effet
  126158. * @returns "DepthOfFieldEffect"
  126159. */
  126160. getClassName(): string;
  126161. /**
  126162. * 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.
  126163. */
  126164. depthTexture: RenderTargetTexture;
  126165. /**
  126166. * Disposes each of the internal effects for a given camera.
  126167. * @param camera The camera to dispose the effect on.
  126168. */
  126169. disposeEffects(camera: Camera): void;
  126170. /**
  126171. * @hidden Internal
  126172. */
  126173. _updateEffects(): void;
  126174. /**
  126175. * Internal
  126176. * @returns if all the contained post processes are ready.
  126177. * @hidden
  126178. */
  126179. _isReady(): boolean;
  126180. }
  126181. }
  126182. declare module BABYLON {
  126183. /** @hidden */
  126184. export var displayPassPixelShader: {
  126185. name: string;
  126186. shader: string;
  126187. };
  126188. }
  126189. declare module BABYLON {
  126190. /**
  126191. * DisplayPassPostProcess which produces an output the same as it's input
  126192. */
  126193. export class DisplayPassPostProcess extends PostProcess {
  126194. /**
  126195. * Creates the DisplayPassPostProcess
  126196. * @param name The name of the effect.
  126197. * @param options The required width/height ratio to downsize to before computing the render pass.
  126198. * @param camera The camera to apply the render pass to.
  126199. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126200. * @param engine The engine which the post process will be applied. (default: current engine)
  126201. * @param reusable If the post process can be reused on the same frame. (default: false)
  126202. */
  126203. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126204. }
  126205. }
  126206. declare module BABYLON {
  126207. /** @hidden */
  126208. export var filterPixelShader: {
  126209. name: string;
  126210. shader: string;
  126211. };
  126212. }
  126213. declare module BABYLON {
  126214. /**
  126215. * Applies a kernel filter to the image
  126216. */
  126217. export class FilterPostProcess extends PostProcess {
  126218. /** The matrix to be applied to the image */
  126219. kernelMatrix: Matrix;
  126220. /**
  126221. *
  126222. * @param name The name of the effect.
  126223. * @param kernelMatrix The matrix to be applied to the image
  126224. * @param options The required width/height ratio to downsize to before computing the render pass.
  126225. * @param camera The camera to apply the render pass to.
  126226. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126227. * @param engine The engine which the post process will be applied. (default: current engine)
  126228. * @param reusable If the post process can be reused on the same frame. (default: false)
  126229. */
  126230. constructor(name: string,
  126231. /** The matrix to be applied to the image */
  126232. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126233. }
  126234. }
  126235. declare module BABYLON {
  126236. /** @hidden */
  126237. export var fxaaPixelShader: {
  126238. name: string;
  126239. shader: string;
  126240. };
  126241. }
  126242. declare module BABYLON {
  126243. /** @hidden */
  126244. export var fxaaVertexShader: {
  126245. name: string;
  126246. shader: string;
  126247. };
  126248. }
  126249. declare module BABYLON {
  126250. /**
  126251. * Fxaa post process
  126252. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  126253. */
  126254. export class FxaaPostProcess extends PostProcess {
  126255. /** @hidden */
  126256. texelWidth: number;
  126257. /** @hidden */
  126258. texelHeight: number;
  126259. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126260. private _getDefines;
  126261. }
  126262. }
  126263. declare module BABYLON {
  126264. /** @hidden */
  126265. export var grainPixelShader: {
  126266. name: string;
  126267. shader: string;
  126268. };
  126269. }
  126270. declare module BABYLON {
  126271. /**
  126272. * The GrainPostProcess adds noise to the image at mid luminance levels
  126273. */
  126274. export class GrainPostProcess extends PostProcess {
  126275. /**
  126276. * The intensity of the grain added (default: 30)
  126277. */
  126278. intensity: number;
  126279. /**
  126280. * If the grain should be randomized on every frame
  126281. */
  126282. animated: boolean;
  126283. /**
  126284. * Creates a new instance of @see GrainPostProcess
  126285. * @param name The name of the effect.
  126286. * @param options The required width/height ratio to downsize to before computing the render pass.
  126287. * @param camera The camera to apply the render pass to.
  126288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126289. * @param engine The engine which the post process will be applied. (default: current engine)
  126290. * @param reusable If the post process can be reused on the same frame. (default: false)
  126291. * @param textureType Type of textures used when performing the post process. (default: 0)
  126292. * @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)
  126293. */
  126294. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126295. }
  126296. }
  126297. declare module BABYLON {
  126298. /** @hidden */
  126299. export var highlightsPixelShader: {
  126300. name: string;
  126301. shader: string;
  126302. };
  126303. }
  126304. declare module BABYLON {
  126305. /**
  126306. * Extracts highlights from the image
  126307. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126308. */
  126309. export class HighlightsPostProcess extends PostProcess {
  126310. /**
  126311. * Extracts highlights from the image
  126312. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126313. * @param name The name of the effect.
  126314. * @param options The required width/height ratio to downsize to before computing the render pass.
  126315. * @param camera The camera to apply the render pass to.
  126316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126317. * @param engine The engine which the post process will be applied. (default: current engine)
  126318. * @param reusable If the post process can be reused on the same frame. (default: false)
  126319. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  126320. */
  126321. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126322. }
  126323. }
  126324. declare module BABYLON {
  126325. /** @hidden */
  126326. export var mrtFragmentDeclaration: {
  126327. name: string;
  126328. shader: string;
  126329. };
  126330. }
  126331. declare module BABYLON {
  126332. /** @hidden */
  126333. export var geometryPixelShader: {
  126334. name: string;
  126335. shader: string;
  126336. };
  126337. }
  126338. declare module BABYLON {
  126339. /** @hidden */
  126340. export var geometryVertexShader: {
  126341. name: string;
  126342. shader: string;
  126343. };
  126344. }
  126345. declare module BABYLON {
  126346. /** @hidden */
  126347. interface ISavedTransformationMatrix {
  126348. world: Matrix;
  126349. viewProjection: Matrix;
  126350. }
  126351. /**
  126352. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  126353. */
  126354. export class GeometryBufferRenderer {
  126355. /**
  126356. * Constant used to retrieve the position texture index in the G-Buffer textures array
  126357. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  126358. */
  126359. static readonly POSITION_TEXTURE_TYPE: number;
  126360. /**
  126361. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  126362. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  126363. */
  126364. static readonly VELOCITY_TEXTURE_TYPE: number;
  126365. /**
  126366. * Dictionary used to store the previous transformation matrices of each rendered mesh
  126367. * in order to compute objects velocities when enableVelocity is set to "true"
  126368. * @hidden
  126369. */
  126370. _previousTransformationMatrices: {
  126371. [index: number]: ISavedTransformationMatrix;
  126372. };
  126373. /**
  126374. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  126375. * in order to compute objects velocities when enableVelocity is set to "true"
  126376. * @hidden
  126377. */
  126378. _previousBonesTransformationMatrices: {
  126379. [index: number]: Float32Array;
  126380. };
  126381. /**
  126382. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  126383. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  126384. */
  126385. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  126386. private _scene;
  126387. private _multiRenderTarget;
  126388. private _ratio;
  126389. private _enablePosition;
  126390. private _enableVelocity;
  126391. private _positionIndex;
  126392. private _velocityIndex;
  126393. protected _effect: Effect;
  126394. protected _cachedDefines: string;
  126395. /**
  126396. * Set the render list (meshes to be rendered) used in the G buffer.
  126397. */
  126398. renderList: Mesh[];
  126399. /**
  126400. * Gets wether or not G buffer are supported by the running hardware.
  126401. * This requires draw buffer supports
  126402. */
  126403. readonly isSupported: boolean;
  126404. /**
  126405. * Returns the index of the given texture type in the G-Buffer textures array
  126406. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  126407. * @returns the index of the given texture type in the G-Buffer textures array
  126408. */
  126409. getTextureIndex(textureType: number): number;
  126410. /**
  126411. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  126412. */
  126413. /**
  126414. * Sets whether or not objects positions are enabled for the G buffer.
  126415. */
  126416. enablePosition: boolean;
  126417. /**
  126418. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  126419. */
  126420. /**
  126421. * Sets wether or not objects velocities are enabled for the G buffer.
  126422. */
  126423. enableVelocity: boolean;
  126424. /**
  126425. * Gets the scene associated with the buffer.
  126426. */
  126427. readonly scene: Scene;
  126428. /**
  126429. * Gets the ratio used by the buffer during its creation.
  126430. * How big is the buffer related to the main canvas.
  126431. */
  126432. readonly ratio: number;
  126433. /** @hidden */
  126434. static _SceneComponentInitialization: (scene: Scene) => void;
  126435. /**
  126436. * Creates a new G Buffer for the scene
  126437. * @param scene The scene the buffer belongs to
  126438. * @param ratio How big is the buffer related to the main canvas.
  126439. */
  126440. constructor(scene: Scene, ratio?: number);
  126441. /**
  126442. * Checks wether everything is ready to render a submesh to the G buffer.
  126443. * @param subMesh the submesh to check readiness for
  126444. * @param useInstances is the mesh drawn using instance or not
  126445. * @returns true if ready otherwise false
  126446. */
  126447. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126448. /**
  126449. * Gets the current underlying G Buffer.
  126450. * @returns the buffer
  126451. */
  126452. getGBuffer(): MultiRenderTarget;
  126453. /**
  126454. * Gets the number of samples used to render the buffer (anti aliasing).
  126455. */
  126456. /**
  126457. * Sets the number of samples used to render the buffer (anti aliasing).
  126458. */
  126459. samples: number;
  126460. /**
  126461. * Disposes the renderer and frees up associated resources.
  126462. */
  126463. dispose(): void;
  126464. protected _createRenderTargets(): void;
  126465. private _copyBonesTransformationMatrices;
  126466. }
  126467. }
  126468. declare module BABYLON {
  126469. interface Scene {
  126470. /** @hidden (Backing field) */
  126471. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126472. /**
  126473. * Gets or Sets the current geometry buffer associated to the scene.
  126474. */
  126475. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126476. /**
  126477. * Enables a GeometryBufferRender and associates it with the scene
  126478. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  126479. * @returns the GeometryBufferRenderer
  126480. */
  126481. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  126482. /**
  126483. * Disables the GeometryBufferRender associated with the scene
  126484. */
  126485. disableGeometryBufferRenderer(): void;
  126486. }
  126487. /**
  126488. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  126489. * in several rendering techniques.
  126490. */
  126491. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  126492. /**
  126493. * The component name helpful to identify the component in the list of scene components.
  126494. */
  126495. readonly name: string;
  126496. /**
  126497. * The scene the component belongs to.
  126498. */
  126499. scene: Scene;
  126500. /**
  126501. * Creates a new instance of the component for the given scene
  126502. * @param scene Defines the scene to register the component in
  126503. */
  126504. constructor(scene: Scene);
  126505. /**
  126506. * Registers the component in a given scene
  126507. */
  126508. register(): void;
  126509. /**
  126510. * Rebuilds the elements related to this component in case of
  126511. * context lost for instance.
  126512. */
  126513. rebuild(): void;
  126514. /**
  126515. * Disposes the component and the associated ressources
  126516. */
  126517. dispose(): void;
  126518. private _gatherRenderTargets;
  126519. }
  126520. }
  126521. declare module BABYLON {
  126522. /** @hidden */
  126523. export var motionBlurPixelShader: {
  126524. name: string;
  126525. shader: string;
  126526. };
  126527. }
  126528. declare module BABYLON {
  126529. /**
  126530. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  126531. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  126532. * As an example, all you have to do is to create the post-process:
  126533. * var mb = new BABYLON.MotionBlurPostProcess(
  126534. * 'mb', // The name of the effect.
  126535. * scene, // The scene containing the objects to blur according to their velocity.
  126536. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  126537. * camera // The camera to apply the render pass to.
  126538. * );
  126539. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  126540. */
  126541. export class MotionBlurPostProcess extends PostProcess {
  126542. /**
  126543. * Defines how much the image is blurred by the movement. Default value is equal to 1
  126544. */
  126545. motionStrength: number;
  126546. /**
  126547. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  126548. */
  126549. /**
  126550. * Sets the number of iterations to be used for motion blur quality
  126551. */
  126552. motionBlurSamples: number;
  126553. private _motionBlurSamples;
  126554. private _geometryBufferRenderer;
  126555. /**
  126556. * Creates a new instance MotionBlurPostProcess
  126557. * @param name The name of the effect.
  126558. * @param scene The scene containing the objects to blur according to their velocity.
  126559. * @param options The required width/height ratio to downsize to before computing the render pass.
  126560. * @param camera The camera to apply the render pass to.
  126561. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126562. * @param engine The engine which the post process will be applied. (default: current engine)
  126563. * @param reusable If the post process can be reused on the same frame. (default: false)
  126564. * @param textureType Type of textures used when performing the post process. (default: 0)
  126565. * @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)
  126566. */
  126567. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126568. /**
  126569. * Excludes the given skinned mesh from computing bones velocities.
  126570. * 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.
  126571. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  126572. */
  126573. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126574. /**
  126575. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  126576. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  126577. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  126578. */
  126579. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126580. /**
  126581. * Disposes the post process.
  126582. * @param camera The camera to dispose the post process on.
  126583. */
  126584. dispose(camera?: Camera): void;
  126585. }
  126586. }
  126587. declare module BABYLON {
  126588. /** @hidden */
  126589. export var refractionPixelShader: {
  126590. name: string;
  126591. shader: string;
  126592. };
  126593. }
  126594. declare module BABYLON {
  126595. /**
  126596. * Post process which applies a refractin texture
  126597. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126598. */
  126599. export class RefractionPostProcess extends PostProcess {
  126600. /** the base color of the refraction (used to taint the rendering) */
  126601. color: Color3;
  126602. /** simulated refraction depth */
  126603. depth: number;
  126604. /** the coefficient of the base color (0 to remove base color tainting) */
  126605. colorLevel: number;
  126606. private _refTexture;
  126607. private _ownRefractionTexture;
  126608. /**
  126609. * Gets or sets the refraction texture
  126610. * Please note that you are responsible for disposing the texture if you set it manually
  126611. */
  126612. refractionTexture: Texture;
  126613. /**
  126614. * Initializes the RefractionPostProcess
  126615. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126616. * @param name The name of the effect.
  126617. * @param refractionTextureUrl Url of the refraction texture to use
  126618. * @param color the base color of the refraction (used to taint the rendering)
  126619. * @param depth simulated refraction depth
  126620. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  126621. * @param camera The camera to apply the render pass to.
  126622. * @param options The required width/height ratio to downsize to before computing the render pass.
  126623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126624. * @param engine The engine which the post process will be applied. (default: current engine)
  126625. * @param reusable If the post process can be reused on the same frame. (default: false)
  126626. */
  126627. constructor(name: string, refractionTextureUrl: string,
  126628. /** the base color of the refraction (used to taint the rendering) */
  126629. color: Color3,
  126630. /** simulated refraction depth */
  126631. depth: number,
  126632. /** the coefficient of the base color (0 to remove base color tainting) */
  126633. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126634. /**
  126635. * Disposes of the post process
  126636. * @param camera Camera to dispose post process on
  126637. */
  126638. dispose(camera: Camera): void;
  126639. }
  126640. }
  126641. declare module BABYLON {
  126642. /** @hidden */
  126643. export var sharpenPixelShader: {
  126644. name: string;
  126645. shader: string;
  126646. };
  126647. }
  126648. declare module BABYLON {
  126649. /**
  126650. * The SharpenPostProcess applies a sharpen kernel to every pixel
  126651. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  126652. */
  126653. export class SharpenPostProcess extends PostProcess {
  126654. /**
  126655. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  126656. */
  126657. colorAmount: number;
  126658. /**
  126659. * How much sharpness should be applied (default: 0.3)
  126660. */
  126661. edgeAmount: number;
  126662. /**
  126663. * Creates a new instance ConvolutionPostProcess
  126664. * @param name The name of the effect.
  126665. * @param options The required width/height ratio to downsize to before computing the render pass.
  126666. * @param camera The camera to apply the render pass to.
  126667. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126668. * @param engine The engine which the post process will be applied. (default: current engine)
  126669. * @param reusable If the post process can be reused on the same frame. (default: false)
  126670. * @param textureType Type of textures used when performing the post process. (default: 0)
  126671. * @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)
  126672. */
  126673. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126674. }
  126675. }
  126676. declare module BABYLON {
  126677. /**
  126678. * PostProcessRenderPipeline
  126679. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126680. */
  126681. export class PostProcessRenderPipeline {
  126682. private engine;
  126683. private _renderEffects;
  126684. private _renderEffectsForIsolatedPass;
  126685. /**
  126686. * List of inspectable custom properties (used by the Inspector)
  126687. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  126688. */
  126689. inspectableCustomProperties: IInspectable[];
  126690. /**
  126691. * @hidden
  126692. */
  126693. protected _cameras: Camera[];
  126694. /** @hidden */
  126695. _name: string;
  126696. /**
  126697. * Gets pipeline name
  126698. */
  126699. readonly name: string;
  126700. /**
  126701. * Initializes a PostProcessRenderPipeline
  126702. * @param engine engine to add the pipeline to
  126703. * @param name name of the pipeline
  126704. */
  126705. constructor(engine: Engine, name: string);
  126706. /**
  126707. * Gets the class name
  126708. * @returns "PostProcessRenderPipeline"
  126709. */
  126710. getClassName(): string;
  126711. /**
  126712. * If all the render effects in the pipeline are supported
  126713. */
  126714. readonly isSupported: boolean;
  126715. /**
  126716. * Adds an effect to the pipeline
  126717. * @param renderEffect the effect to add
  126718. */
  126719. addEffect(renderEffect: PostProcessRenderEffect): void;
  126720. /** @hidden */
  126721. _rebuild(): void;
  126722. /** @hidden */
  126723. _enableEffect(renderEffectName: string, cameras: Camera): void;
  126724. /** @hidden */
  126725. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  126726. /** @hidden */
  126727. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126728. /** @hidden */
  126729. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126730. /** @hidden */
  126731. _attachCameras(cameras: Camera, unique: boolean): void;
  126732. /** @hidden */
  126733. _attachCameras(cameras: Camera[], unique: boolean): void;
  126734. /** @hidden */
  126735. _detachCameras(cameras: Camera): void;
  126736. /** @hidden */
  126737. _detachCameras(cameras: Nullable<Camera[]>): void;
  126738. /** @hidden */
  126739. _update(): void;
  126740. /** @hidden */
  126741. _reset(): void;
  126742. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  126743. /**
  126744. * Disposes of the pipeline
  126745. */
  126746. dispose(): void;
  126747. }
  126748. }
  126749. declare module BABYLON {
  126750. /**
  126751. * PostProcessRenderPipelineManager class
  126752. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126753. */
  126754. export class PostProcessRenderPipelineManager {
  126755. private _renderPipelines;
  126756. /**
  126757. * Initializes a PostProcessRenderPipelineManager
  126758. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126759. */
  126760. constructor();
  126761. /**
  126762. * Gets the list of supported render pipelines
  126763. */
  126764. readonly supportedPipelines: PostProcessRenderPipeline[];
  126765. /**
  126766. * Adds a pipeline to the manager
  126767. * @param renderPipeline The pipeline to add
  126768. */
  126769. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  126770. /**
  126771. * Attaches a camera to the pipeline
  126772. * @param renderPipelineName The name of the pipeline to attach to
  126773. * @param cameras the camera to attach
  126774. * @param unique if the camera can be attached multiple times to the pipeline
  126775. */
  126776. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  126777. /**
  126778. * Detaches a camera from the pipeline
  126779. * @param renderPipelineName The name of the pipeline to detach from
  126780. * @param cameras the camera to detach
  126781. */
  126782. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  126783. /**
  126784. * Enables an effect by name on a pipeline
  126785. * @param renderPipelineName the name of the pipeline to enable the effect in
  126786. * @param renderEffectName the name of the effect to enable
  126787. * @param cameras the cameras that the effect should be enabled on
  126788. */
  126789. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126790. /**
  126791. * Disables an effect by name on a pipeline
  126792. * @param renderPipelineName the name of the pipeline to disable the effect in
  126793. * @param renderEffectName the name of the effect to disable
  126794. * @param cameras the cameras that the effect should be disabled on
  126795. */
  126796. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126797. /**
  126798. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  126799. */
  126800. update(): void;
  126801. /** @hidden */
  126802. _rebuild(): void;
  126803. /**
  126804. * Disposes of the manager and pipelines
  126805. */
  126806. dispose(): void;
  126807. }
  126808. }
  126809. declare module BABYLON {
  126810. interface Scene {
  126811. /** @hidden (Backing field) */
  126812. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126813. /**
  126814. * Gets the postprocess render pipeline manager
  126815. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126816. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126817. */
  126818. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126819. }
  126820. /**
  126821. * Defines the Render Pipeline scene component responsible to rendering pipelines
  126822. */
  126823. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  126824. /**
  126825. * The component name helpfull to identify the component in the list of scene components.
  126826. */
  126827. readonly name: string;
  126828. /**
  126829. * The scene the component belongs to.
  126830. */
  126831. scene: Scene;
  126832. /**
  126833. * Creates a new instance of the component for the given scene
  126834. * @param scene Defines the scene to register the component in
  126835. */
  126836. constructor(scene: Scene);
  126837. /**
  126838. * Registers the component in a given scene
  126839. */
  126840. register(): void;
  126841. /**
  126842. * Rebuilds the elements related to this component in case of
  126843. * context lost for instance.
  126844. */
  126845. rebuild(): void;
  126846. /**
  126847. * Disposes the component and the associated ressources
  126848. */
  126849. dispose(): void;
  126850. private _gatherRenderTargets;
  126851. }
  126852. }
  126853. declare module BABYLON {
  126854. /**
  126855. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  126856. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126857. */
  126858. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  126859. private _scene;
  126860. private _camerasToBeAttached;
  126861. /**
  126862. * ID of the sharpen post process,
  126863. */
  126864. private readonly SharpenPostProcessId;
  126865. /**
  126866. * @ignore
  126867. * ID of the image processing post process;
  126868. */
  126869. readonly ImageProcessingPostProcessId: string;
  126870. /**
  126871. * @ignore
  126872. * ID of the Fast Approximate Anti-Aliasing post process;
  126873. */
  126874. readonly FxaaPostProcessId: string;
  126875. /**
  126876. * ID of the chromatic aberration post process,
  126877. */
  126878. private readonly ChromaticAberrationPostProcessId;
  126879. /**
  126880. * ID of the grain post process
  126881. */
  126882. private readonly GrainPostProcessId;
  126883. /**
  126884. * Sharpen post process which will apply a sharpen convolution to enhance edges
  126885. */
  126886. sharpen: SharpenPostProcess;
  126887. private _sharpenEffect;
  126888. private bloom;
  126889. /**
  126890. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  126891. */
  126892. depthOfField: DepthOfFieldEffect;
  126893. /**
  126894. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  126895. */
  126896. fxaa: FxaaPostProcess;
  126897. /**
  126898. * Image post processing pass used to perform operations such as tone mapping or color grading.
  126899. */
  126900. imageProcessing: ImageProcessingPostProcess;
  126901. /**
  126902. * Chromatic aberration post process which will shift rgb colors in the image
  126903. */
  126904. chromaticAberration: ChromaticAberrationPostProcess;
  126905. private _chromaticAberrationEffect;
  126906. /**
  126907. * Grain post process which add noise to the image
  126908. */
  126909. grain: GrainPostProcess;
  126910. private _grainEffect;
  126911. /**
  126912. * Glow post process which adds a glow to emissive areas of the image
  126913. */
  126914. private _glowLayer;
  126915. /**
  126916. * Animations which can be used to tweak settings over a period of time
  126917. */
  126918. animations: Animation[];
  126919. private _imageProcessingConfigurationObserver;
  126920. private _sharpenEnabled;
  126921. private _bloomEnabled;
  126922. private _depthOfFieldEnabled;
  126923. private _depthOfFieldBlurLevel;
  126924. private _fxaaEnabled;
  126925. private _imageProcessingEnabled;
  126926. private _defaultPipelineTextureType;
  126927. private _bloomScale;
  126928. private _chromaticAberrationEnabled;
  126929. private _grainEnabled;
  126930. private _buildAllowed;
  126931. /**
  126932. * Gets active scene
  126933. */
  126934. readonly scene: Scene;
  126935. /**
  126936. * Enable or disable the sharpen process from the pipeline
  126937. */
  126938. sharpenEnabled: boolean;
  126939. private _resizeObserver;
  126940. private _hardwareScaleLevel;
  126941. private _bloomKernel;
  126942. /**
  126943. * Specifies the size of the bloom blur kernel, relative to the final output size
  126944. */
  126945. bloomKernel: number;
  126946. /**
  126947. * Specifies the weight of the bloom in the final rendering
  126948. */
  126949. private _bloomWeight;
  126950. /**
  126951. * Specifies the luma threshold for the area that will be blurred by the bloom
  126952. */
  126953. private _bloomThreshold;
  126954. private _hdr;
  126955. /**
  126956. * The strength of the bloom.
  126957. */
  126958. bloomWeight: number;
  126959. /**
  126960. * The strength of the bloom.
  126961. */
  126962. bloomThreshold: number;
  126963. /**
  126964. * The scale of the bloom, lower value will provide better performance.
  126965. */
  126966. bloomScale: number;
  126967. /**
  126968. * Enable or disable the bloom from the pipeline
  126969. */
  126970. bloomEnabled: boolean;
  126971. private _rebuildBloom;
  126972. /**
  126973. * If the depth of field is enabled.
  126974. */
  126975. depthOfFieldEnabled: boolean;
  126976. /**
  126977. * Blur level of the depth of field effect. (Higher blur will effect performance)
  126978. */
  126979. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  126980. /**
  126981. * If the anti aliasing is enabled.
  126982. */
  126983. fxaaEnabled: boolean;
  126984. private _samples;
  126985. /**
  126986. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  126987. */
  126988. samples: number;
  126989. /**
  126990. * If image processing is enabled.
  126991. */
  126992. imageProcessingEnabled: boolean;
  126993. /**
  126994. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  126995. */
  126996. glowLayerEnabled: boolean;
  126997. /**
  126998. * Gets the glow layer (or null if not defined)
  126999. */
  127000. readonly glowLayer: Nullable<GlowLayer>;
  127001. /**
  127002. * Enable or disable the chromaticAberration process from the pipeline
  127003. */
  127004. chromaticAberrationEnabled: boolean;
  127005. /**
  127006. * Enable or disable the grain process from the pipeline
  127007. */
  127008. grainEnabled: boolean;
  127009. /**
  127010. * @constructor
  127011. * @param name - The rendering pipeline name (default: "")
  127012. * @param hdr - If high dynamic range textures should be used (default: true)
  127013. * @param scene - The scene linked to this pipeline (default: the last created scene)
  127014. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  127015. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  127016. */
  127017. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  127018. /**
  127019. * Get the class name
  127020. * @returns "DefaultRenderingPipeline"
  127021. */
  127022. getClassName(): string;
  127023. /**
  127024. * Force the compilation of the entire pipeline.
  127025. */
  127026. prepare(): void;
  127027. private _hasCleared;
  127028. private _prevPostProcess;
  127029. private _prevPrevPostProcess;
  127030. private _setAutoClearAndTextureSharing;
  127031. private _depthOfFieldSceneObserver;
  127032. private _buildPipeline;
  127033. private _disposePostProcesses;
  127034. /**
  127035. * Adds a camera to the pipeline
  127036. * @param camera the camera to be added
  127037. */
  127038. addCamera(camera: Camera): void;
  127039. /**
  127040. * Removes a camera from the pipeline
  127041. * @param camera the camera to remove
  127042. */
  127043. removeCamera(camera: Camera): void;
  127044. /**
  127045. * Dispose of the pipeline and stop all post processes
  127046. */
  127047. dispose(): void;
  127048. /**
  127049. * Serialize the rendering pipeline (Used when exporting)
  127050. * @returns the serialized object
  127051. */
  127052. serialize(): any;
  127053. /**
  127054. * Parse the serialized pipeline
  127055. * @param source Source pipeline.
  127056. * @param scene The scene to load the pipeline to.
  127057. * @param rootUrl The URL of the serialized pipeline.
  127058. * @returns An instantiated pipeline from the serialized object.
  127059. */
  127060. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  127061. }
  127062. }
  127063. declare module BABYLON {
  127064. /** @hidden */
  127065. export var lensHighlightsPixelShader: {
  127066. name: string;
  127067. shader: string;
  127068. };
  127069. }
  127070. declare module BABYLON {
  127071. /** @hidden */
  127072. export var depthOfFieldPixelShader: {
  127073. name: string;
  127074. shader: string;
  127075. };
  127076. }
  127077. declare module BABYLON {
  127078. /**
  127079. * BABYLON.JS Chromatic Aberration GLSL Shader
  127080. * Author: Olivier Guyot
  127081. * Separates very slightly R, G and B colors on the edges of the screen
  127082. * Inspired by Francois Tarlier & Martins Upitis
  127083. */
  127084. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  127085. /**
  127086. * @ignore
  127087. * The chromatic aberration PostProcess id in the pipeline
  127088. */
  127089. LensChromaticAberrationEffect: string;
  127090. /**
  127091. * @ignore
  127092. * The highlights enhancing PostProcess id in the pipeline
  127093. */
  127094. HighlightsEnhancingEffect: string;
  127095. /**
  127096. * @ignore
  127097. * The depth-of-field PostProcess id in the pipeline
  127098. */
  127099. LensDepthOfFieldEffect: string;
  127100. private _scene;
  127101. private _depthTexture;
  127102. private _grainTexture;
  127103. private _chromaticAberrationPostProcess;
  127104. private _highlightsPostProcess;
  127105. private _depthOfFieldPostProcess;
  127106. private _edgeBlur;
  127107. private _grainAmount;
  127108. private _chromaticAberration;
  127109. private _distortion;
  127110. private _highlightsGain;
  127111. private _highlightsThreshold;
  127112. private _dofDistance;
  127113. private _dofAperture;
  127114. private _dofDarken;
  127115. private _dofPentagon;
  127116. private _blurNoise;
  127117. /**
  127118. * @constructor
  127119. *
  127120. * Effect parameters are as follow:
  127121. * {
  127122. * chromatic_aberration: number; // from 0 to x (1 for realism)
  127123. * edge_blur: number; // from 0 to x (1 for realism)
  127124. * distortion: number; // from 0 to x (1 for realism)
  127125. * grain_amount: number; // from 0 to 1
  127126. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  127127. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  127128. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  127129. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  127130. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  127131. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  127132. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  127133. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  127134. * }
  127135. * Note: if an effect parameter is unset, effect is disabled
  127136. *
  127137. * @param name The rendering pipeline name
  127138. * @param parameters - An object containing all parameters (see above)
  127139. * @param scene The scene linked to this pipeline
  127140. * @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)
  127141. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127142. */
  127143. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  127144. /**
  127145. * Get the class name
  127146. * @returns "LensRenderingPipeline"
  127147. */
  127148. getClassName(): string;
  127149. /**
  127150. * Gets associated scene
  127151. */
  127152. readonly scene: Scene;
  127153. /**
  127154. * Gets or sets the edge blur
  127155. */
  127156. edgeBlur: number;
  127157. /**
  127158. * Gets or sets the grain amount
  127159. */
  127160. grainAmount: number;
  127161. /**
  127162. * Gets or sets the chromatic aberration amount
  127163. */
  127164. chromaticAberration: number;
  127165. /**
  127166. * Gets or sets the depth of field aperture
  127167. */
  127168. dofAperture: number;
  127169. /**
  127170. * Gets or sets the edge distortion
  127171. */
  127172. edgeDistortion: number;
  127173. /**
  127174. * Gets or sets the depth of field distortion
  127175. */
  127176. dofDistortion: number;
  127177. /**
  127178. * Gets or sets the darken out of focus amount
  127179. */
  127180. darkenOutOfFocus: number;
  127181. /**
  127182. * Gets or sets a boolean indicating if blur noise is enabled
  127183. */
  127184. blurNoise: boolean;
  127185. /**
  127186. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  127187. */
  127188. pentagonBokeh: boolean;
  127189. /**
  127190. * Gets or sets the highlight grain amount
  127191. */
  127192. highlightsGain: number;
  127193. /**
  127194. * Gets or sets the highlight threshold
  127195. */
  127196. highlightsThreshold: number;
  127197. /**
  127198. * Sets the amount of blur at the edges
  127199. * @param amount blur amount
  127200. */
  127201. setEdgeBlur(amount: number): void;
  127202. /**
  127203. * Sets edge blur to 0
  127204. */
  127205. disableEdgeBlur(): void;
  127206. /**
  127207. * Sets the amout of grain
  127208. * @param amount Amount of grain
  127209. */
  127210. setGrainAmount(amount: number): void;
  127211. /**
  127212. * Set grain amount to 0
  127213. */
  127214. disableGrain(): void;
  127215. /**
  127216. * Sets the chromatic aberration amount
  127217. * @param amount amount of chromatic aberration
  127218. */
  127219. setChromaticAberration(amount: number): void;
  127220. /**
  127221. * Sets chromatic aberration amount to 0
  127222. */
  127223. disableChromaticAberration(): void;
  127224. /**
  127225. * Sets the EdgeDistortion amount
  127226. * @param amount amount of EdgeDistortion
  127227. */
  127228. setEdgeDistortion(amount: number): void;
  127229. /**
  127230. * Sets edge distortion to 0
  127231. */
  127232. disableEdgeDistortion(): void;
  127233. /**
  127234. * Sets the FocusDistance amount
  127235. * @param amount amount of FocusDistance
  127236. */
  127237. setFocusDistance(amount: number): void;
  127238. /**
  127239. * Disables depth of field
  127240. */
  127241. disableDepthOfField(): void;
  127242. /**
  127243. * Sets the Aperture amount
  127244. * @param amount amount of Aperture
  127245. */
  127246. setAperture(amount: number): void;
  127247. /**
  127248. * Sets the DarkenOutOfFocus amount
  127249. * @param amount amount of DarkenOutOfFocus
  127250. */
  127251. setDarkenOutOfFocus(amount: number): void;
  127252. private _pentagonBokehIsEnabled;
  127253. /**
  127254. * Creates a pentagon bokeh effect
  127255. */
  127256. enablePentagonBokeh(): void;
  127257. /**
  127258. * Disables the pentagon bokeh effect
  127259. */
  127260. disablePentagonBokeh(): void;
  127261. /**
  127262. * Enables noise blur
  127263. */
  127264. enableNoiseBlur(): void;
  127265. /**
  127266. * Disables noise blur
  127267. */
  127268. disableNoiseBlur(): void;
  127269. /**
  127270. * Sets the HighlightsGain amount
  127271. * @param amount amount of HighlightsGain
  127272. */
  127273. setHighlightsGain(amount: number): void;
  127274. /**
  127275. * Sets the HighlightsThreshold amount
  127276. * @param amount amount of HighlightsThreshold
  127277. */
  127278. setHighlightsThreshold(amount: number): void;
  127279. /**
  127280. * Disables highlights
  127281. */
  127282. disableHighlights(): void;
  127283. /**
  127284. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  127285. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  127286. */
  127287. dispose(disableDepthRender?: boolean): void;
  127288. private _createChromaticAberrationPostProcess;
  127289. private _createHighlightsPostProcess;
  127290. private _createDepthOfFieldPostProcess;
  127291. private _createGrainTexture;
  127292. }
  127293. }
  127294. declare module BABYLON {
  127295. /** @hidden */
  127296. export var ssao2PixelShader: {
  127297. name: string;
  127298. shader: string;
  127299. };
  127300. }
  127301. declare module BABYLON {
  127302. /** @hidden */
  127303. export var ssaoCombinePixelShader: {
  127304. name: string;
  127305. shader: string;
  127306. };
  127307. }
  127308. declare module BABYLON {
  127309. /**
  127310. * Render pipeline to produce ssao effect
  127311. */
  127312. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  127313. /**
  127314. * @ignore
  127315. * The PassPostProcess id in the pipeline that contains the original scene color
  127316. */
  127317. SSAOOriginalSceneColorEffect: string;
  127318. /**
  127319. * @ignore
  127320. * The SSAO PostProcess id in the pipeline
  127321. */
  127322. SSAORenderEffect: string;
  127323. /**
  127324. * @ignore
  127325. * The horizontal blur PostProcess id in the pipeline
  127326. */
  127327. SSAOBlurHRenderEffect: string;
  127328. /**
  127329. * @ignore
  127330. * The vertical blur PostProcess id in the pipeline
  127331. */
  127332. SSAOBlurVRenderEffect: string;
  127333. /**
  127334. * @ignore
  127335. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127336. */
  127337. SSAOCombineRenderEffect: string;
  127338. /**
  127339. * The output strength of the SSAO post-process. Default value is 1.0.
  127340. */
  127341. totalStrength: number;
  127342. /**
  127343. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  127344. */
  127345. maxZ: number;
  127346. /**
  127347. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  127348. */
  127349. minZAspect: number;
  127350. private _samples;
  127351. /**
  127352. * Number of samples used for the SSAO calculations. Default value is 8
  127353. */
  127354. samples: number;
  127355. private _textureSamples;
  127356. /**
  127357. * Number of samples to use for antialiasing
  127358. */
  127359. textureSamples: number;
  127360. /**
  127361. * Ratio object used for SSAO ratio and blur ratio
  127362. */
  127363. private _ratio;
  127364. /**
  127365. * Dynamically generated sphere sampler.
  127366. */
  127367. private _sampleSphere;
  127368. /**
  127369. * Blur filter offsets
  127370. */
  127371. private _samplerOffsets;
  127372. private _expensiveBlur;
  127373. /**
  127374. * If bilateral blur should be used
  127375. */
  127376. expensiveBlur: boolean;
  127377. /**
  127378. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  127379. */
  127380. radius: number;
  127381. /**
  127382. * The base color of the SSAO post-process
  127383. * The final result is "base + ssao" between [0, 1]
  127384. */
  127385. base: number;
  127386. /**
  127387. * Support test.
  127388. */
  127389. static readonly IsSupported: boolean;
  127390. private _scene;
  127391. private _depthTexture;
  127392. private _normalTexture;
  127393. private _randomTexture;
  127394. private _originalColorPostProcess;
  127395. private _ssaoPostProcess;
  127396. private _blurHPostProcess;
  127397. private _blurVPostProcess;
  127398. private _ssaoCombinePostProcess;
  127399. private _firstUpdate;
  127400. /**
  127401. * Gets active scene
  127402. */
  127403. readonly scene: Scene;
  127404. /**
  127405. * @constructor
  127406. * @param name The rendering pipeline name
  127407. * @param scene The scene linked to this pipeline
  127408. * @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 }
  127409. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127410. */
  127411. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127412. /**
  127413. * Get the class name
  127414. * @returns "SSAO2RenderingPipeline"
  127415. */
  127416. getClassName(): string;
  127417. /**
  127418. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127419. */
  127420. dispose(disableGeometryBufferRenderer?: boolean): void;
  127421. private _createBlurPostProcess;
  127422. /** @hidden */
  127423. _rebuild(): void;
  127424. private _bits;
  127425. private _radicalInverse_VdC;
  127426. private _hammersley;
  127427. private _hemisphereSample_uniform;
  127428. private _generateHemisphere;
  127429. private _createSSAOPostProcess;
  127430. private _createSSAOCombinePostProcess;
  127431. private _createRandomTexture;
  127432. /**
  127433. * Serialize the rendering pipeline (Used when exporting)
  127434. * @returns the serialized object
  127435. */
  127436. serialize(): any;
  127437. /**
  127438. * Parse the serialized pipeline
  127439. * @param source Source pipeline.
  127440. * @param scene The scene to load the pipeline to.
  127441. * @param rootUrl The URL of the serialized pipeline.
  127442. * @returns An instantiated pipeline from the serialized object.
  127443. */
  127444. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  127445. }
  127446. }
  127447. declare module BABYLON {
  127448. /** @hidden */
  127449. export var ssaoPixelShader: {
  127450. name: string;
  127451. shader: string;
  127452. };
  127453. }
  127454. declare module BABYLON {
  127455. /**
  127456. * Render pipeline to produce ssao effect
  127457. */
  127458. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  127459. /**
  127460. * @ignore
  127461. * The PassPostProcess id in the pipeline that contains the original scene color
  127462. */
  127463. SSAOOriginalSceneColorEffect: string;
  127464. /**
  127465. * @ignore
  127466. * The SSAO PostProcess id in the pipeline
  127467. */
  127468. SSAORenderEffect: string;
  127469. /**
  127470. * @ignore
  127471. * The horizontal blur PostProcess id in the pipeline
  127472. */
  127473. SSAOBlurHRenderEffect: string;
  127474. /**
  127475. * @ignore
  127476. * The vertical blur PostProcess id in the pipeline
  127477. */
  127478. SSAOBlurVRenderEffect: string;
  127479. /**
  127480. * @ignore
  127481. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127482. */
  127483. SSAOCombineRenderEffect: string;
  127484. /**
  127485. * The output strength of the SSAO post-process. Default value is 1.0.
  127486. */
  127487. totalStrength: number;
  127488. /**
  127489. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  127490. */
  127491. radius: number;
  127492. /**
  127493. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  127494. * Must not be equal to fallOff and superior to fallOff.
  127495. * Default value is 0.0075
  127496. */
  127497. area: number;
  127498. /**
  127499. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  127500. * Must not be equal to area and inferior to area.
  127501. * Default value is 0.000001
  127502. */
  127503. fallOff: number;
  127504. /**
  127505. * The base color of the SSAO post-process
  127506. * The final result is "base + ssao" between [0, 1]
  127507. */
  127508. base: number;
  127509. private _scene;
  127510. private _depthTexture;
  127511. private _randomTexture;
  127512. private _originalColorPostProcess;
  127513. private _ssaoPostProcess;
  127514. private _blurHPostProcess;
  127515. private _blurVPostProcess;
  127516. private _ssaoCombinePostProcess;
  127517. private _firstUpdate;
  127518. /**
  127519. * Gets active scene
  127520. */
  127521. readonly scene: Scene;
  127522. /**
  127523. * @constructor
  127524. * @param name - The rendering pipeline name
  127525. * @param scene - The scene linked to this pipeline
  127526. * @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 }
  127527. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  127528. */
  127529. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127530. /**
  127531. * Get the class name
  127532. * @returns "SSAORenderingPipeline"
  127533. */
  127534. getClassName(): string;
  127535. /**
  127536. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127537. */
  127538. dispose(disableDepthRender?: boolean): void;
  127539. private _createBlurPostProcess;
  127540. /** @hidden */
  127541. _rebuild(): void;
  127542. private _createSSAOPostProcess;
  127543. private _createSSAOCombinePostProcess;
  127544. private _createRandomTexture;
  127545. }
  127546. }
  127547. declare module BABYLON {
  127548. /** @hidden */
  127549. export var standardPixelShader: {
  127550. name: string;
  127551. shader: string;
  127552. };
  127553. }
  127554. declare module BABYLON {
  127555. /**
  127556. * Standard rendering pipeline
  127557. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127558. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  127559. */
  127560. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  127561. /**
  127562. * Public members
  127563. */
  127564. /**
  127565. * Post-process which contains the original scene color before the pipeline applies all the effects
  127566. */
  127567. originalPostProcess: Nullable<PostProcess>;
  127568. /**
  127569. * Post-process used to down scale an image x4
  127570. */
  127571. downSampleX4PostProcess: Nullable<PostProcess>;
  127572. /**
  127573. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  127574. */
  127575. brightPassPostProcess: Nullable<PostProcess>;
  127576. /**
  127577. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  127578. */
  127579. blurHPostProcesses: PostProcess[];
  127580. /**
  127581. * Post-process array storing all the vertical blur post-processes used by the pipeline
  127582. */
  127583. blurVPostProcesses: PostProcess[];
  127584. /**
  127585. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  127586. */
  127587. textureAdderPostProcess: Nullable<PostProcess>;
  127588. /**
  127589. * Post-process used to create volumetric lighting effect
  127590. */
  127591. volumetricLightPostProcess: Nullable<PostProcess>;
  127592. /**
  127593. * Post-process used to smooth the previous volumetric light post-process on the X axis
  127594. */
  127595. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  127596. /**
  127597. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  127598. */
  127599. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  127600. /**
  127601. * Post-process used to merge the volumetric light effect and the real scene color
  127602. */
  127603. volumetricLightMergePostProces: Nullable<PostProcess>;
  127604. /**
  127605. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  127606. */
  127607. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  127608. /**
  127609. * Base post-process used to calculate the average luminance of the final image for HDR
  127610. */
  127611. luminancePostProcess: Nullable<PostProcess>;
  127612. /**
  127613. * Post-processes used to create down sample post-processes in order to get
  127614. * the average luminance of the final image for HDR
  127615. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  127616. */
  127617. luminanceDownSamplePostProcesses: PostProcess[];
  127618. /**
  127619. * Post-process used to create a HDR effect (light adaptation)
  127620. */
  127621. hdrPostProcess: Nullable<PostProcess>;
  127622. /**
  127623. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  127624. */
  127625. textureAdderFinalPostProcess: Nullable<PostProcess>;
  127626. /**
  127627. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  127628. */
  127629. lensFlareFinalPostProcess: Nullable<PostProcess>;
  127630. /**
  127631. * Post-process used to merge the final HDR post-process and the real scene color
  127632. */
  127633. hdrFinalPostProcess: Nullable<PostProcess>;
  127634. /**
  127635. * Post-process used to create a lens flare effect
  127636. */
  127637. lensFlarePostProcess: Nullable<PostProcess>;
  127638. /**
  127639. * Post-process that merges the result of the lens flare post-process and the real scene color
  127640. */
  127641. lensFlareComposePostProcess: Nullable<PostProcess>;
  127642. /**
  127643. * Post-process used to create a motion blur effect
  127644. */
  127645. motionBlurPostProcess: Nullable<PostProcess>;
  127646. /**
  127647. * Post-process used to create a depth of field effect
  127648. */
  127649. depthOfFieldPostProcess: Nullable<PostProcess>;
  127650. /**
  127651. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  127652. */
  127653. fxaaPostProcess: Nullable<FxaaPostProcess>;
  127654. /**
  127655. * Represents the brightness threshold in order to configure the illuminated surfaces
  127656. */
  127657. brightThreshold: number;
  127658. /**
  127659. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  127660. */
  127661. blurWidth: number;
  127662. /**
  127663. * Sets if the blur for highlighted surfaces must be only horizontal
  127664. */
  127665. horizontalBlur: boolean;
  127666. /**
  127667. * Gets the overall exposure used by the pipeline
  127668. */
  127669. /**
  127670. * Sets the overall exposure used by the pipeline
  127671. */
  127672. exposure: number;
  127673. /**
  127674. * Texture used typically to simulate "dirty" on camera lens
  127675. */
  127676. lensTexture: Nullable<Texture>;
  127677. /**
  127678. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  127679. */
  127680. volumetricLightCoefficient: number;
  127681. /**
  127682. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  127683. */
  127684. volumetricLightPower: number;
  127685. /**
  127686. * Used the set the blur intensity to smooth the volumetric lights
  127687. */
  127688. volumetricLightBlurScale: number;
  127689. /**
  127690. * Light (spot or directional) used to generate the volumetric lights rays
  127691. * The source light must have a shadow generate so the pipeline can get its
  127692. * depth map
  127693. */
  127694. sourceLight: Nullable<SpotLight | DirectionalLight>;
  127695. /**
  127696. * For eye adaptation, represents the minimum luminance the eye can see
  127697. */
  127698. hdrMinimumLuminance: number;
  127699. /**
  127700. * For eye adaptation, represents the decrease luminance speed
  127701. */
  127702. hdrDecreaseRate: number;
  127703. /**
  127704. * For eye adaptation, represents the increase luminance speed
  127705. */
  127706. hdrIncreaseRate: number;
  127707. /**
  127708. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127709. */
  127710. /**
  127711. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127712. */
  127713. hdrAutoExposure: boolean;
  127714. /**
  127715. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  127716. */
  127717. lensColorTexture: Nullable<Texture>;
  127718. /**
  127719. * The overall strengh for the lens flare effect
  127720. */
  127721. lensFlareStrength: number;
  127722. /**
  127723. * Dispersion coefficient for lens flare ghosts
  127724. */
  127725. lensFlareGhostDispersal: number;
  127726. /**
  127727. * Main lens flare halo width
  127728. */
  127729. lensFlareHaloWidth: number;
  127730. /**
  127731. * Based on the lens distortion effect, defines how much the lens flare result
  127732. * is distorted
  127733. */
  127734. lensFlareDistortionStrength: number;
  127735. /**
  127736. * Configures the blur intensity used for for lens flare (halo)
  127737. */
  127738. lensFlareBlurWidth: number;
  127739. /**
  127740. * Lens star texture must be used to simulate rays on the flares and is available
  127741. * in the documentation
  127742. */
  127743. lensStarTexture: Nullable<Texture>;
  127744. /**
  127745. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  127746. * flare effect by taking account of the dirt texture
  127747. */
  127748. lensFlareDirtTexture: Nullable<Texture>;
  127749. /**
  127750. * Represents the focal length for the depth of field effect
  127751. */
  127752. depthOfFieldDistance: number;
  127753. /**
  127754. * Represents the blur intensity for the blurred part of the depth of field effect
  127755. */
  127756. depthOfFieldBlurWidth: number;
  127757. /**
  127758. * Gets how much the image is blurred by the movement while using the motion blur post-process
  127759. */
  127760. /**
  127761. * Sets how much the image is blurred by the movement while using the motion blur post-process
  127762. */
  127763. motionStrength: number;
  127764. /**
  127765. * Gets wether or not the motion blur post-process is object based or screen based.
  127766. */
  127767. /**
  127768. * Sets wether or not the motion blur post-process should be object based or screen based
  127769. */
  127770. objectBasedMotionBlur: boolean;
  127771. /**
  127772. * List of animations for the pipeline (IAnimatable implementation)
  127773. */
  127774. animations: Animation[];
  127775. /**
  127776. * Private members
  127777. */
  127778. private _scene;
  127779. private _currentDepthOfFieldSource;
  127780. private _basePostProcess;
  127781. private _fixedExposure;
  127782. private _currentExposure;
  127783. private _hdrAutoExposure;
  127784. private _hdrCurrentLuminance;
  127785. private _motionStrength;
  127786. private _isObjectBasedMotionBlur;
  127787. private _floatTextureType;
  127788. private _camerasToBeAttached;
  127789. private _ratio;
  127790. private _bloomEnabled;
  127791. private _depthOfFieldEnabled;
  127792. private _vlsEnabled;
  127793. private _lensFlareEnabled;
  127794. private _hdrEnabled;
  127795. private _motionBlurEnabled;
  127796. private _fxaaEnabled;
  127797. private _motionBlurSamples;
  127798. private _volumetricLightStepsCount;
  127799. private _samples;
  127800. /**
  127801. * @ignore
  127802. * Specifies if the bloom pipeline is enabled
  127803. */
  127804. BloomEnabled: boolean;
  127805. /**
  127806. * @ignore
  127807. * Specifies if the depth of field pipeline is enabed
  127808. */
  127809. DepthOfFieldEnabled: boolean;
  127810. /**
  127811. * @ignore
  127812. * Specifies if the lens flare pipeline is enabed
  127813. */
  127814. LensFlareEnabled: boolean;
  127815. /**
  127816. * @ignore
  127817. * Specifies if the HDR pipeline is enabled
  127818. */
  127819. HDREnabled: boolean;
  127820. /**
  127821. * @ignore
  127822. * Specifies if the volumetric lights scattering effect is enabled
  127823. */
  127824. VLSEnabled: boolean;
  127825. /**
  127826. * @ignore
  127827. * Specifies if the motion blur effect is enabled
  127828. */
  127829. MotionBlurEnabled: boolean;
  127830. /**
  127831. * Specifies if anti-aliasing is enabled
  127832. */
  127833. fxaaEnabled: boolean;
  127834. /**
  127835. * Specifies the number of steps used to calculate the volumetric lights
  127836. * Typically in interval [50, 200]
  127837. */
  127838. volumetricLightStepsCount: number;
  127839. /**
  127840. * Specifies the number of samples used for the motion blur effect
  127841. * Typically in interval [16, 64]
  127842. */
  127843. motionBlurSamples: number;
  127844. /**
  127845. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  127846. */
  127847. samples: number;
  127848. /**
  127849. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127850. * @constructor
  127851. * @param name The rendering pipeline name
  127852. * @param scene The scene linked to this pipeline
  127853. * @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)
  127854. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  127855. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127856. */
  127857. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  127858. private _buildPipeline;
  127859. private _createDownSampleX4PostProcess;
  127860. private _createBrightPassPostProcess;
  127861. private _createBlurPostProcesses;
  127862. private _createTextureAdderPostProcess;
  127863. private _createVolumetricLightPostProcess;
  127864. private _createLuminancePostProcesses;
  127865. private _createHdrPostProcess;
  127866. private _createLensFlarePostProcess;
  127867. private _createDepthOfFieldPostProcess;
  127868. private _createMotionBlurPostProcess;
  127869. private _getDepthTexture;
  127870. private _disposePostProcesses;
  127871. /**
  127872. * Dispose of the pipeline and stop all post processes
  127873. */
  127874. dispose(): void;
  127875. /**
  127876. * Serialize the rendering pipeline (Used when exporting)
  127877. * @returns the serialized object
  127878. */
  127879. serialize(): any;
  127880. /**
  127881. * Parse the serialized pipeline
  127882. * @param source Source pipeline.
  127883. * @param scene The scene to load the pipeline to.
  127884. * @param rootUrl The URL of the serialized pipeline.
  127885. * @returns An instantiated pipeline from the serialized object.
  127886. */
  127887. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  127888. /**
  127889. * Luminance steps
  127890. */
  127891. static LuminanceSteps: number;
  127892. }
  127893. }
  127894. declare module BABYLON {
  127895. /** @hidden */
  127896. export var tonemapPixelShader: {
  127897. name: string;
  127898. shader: string;
  127899. };
  127900. }
  127901. declare module BABYLON {
  127902. /** Defines operator used for tonemapping */
  127903. export enum TonemappingOperator {
  127904. /** Hable */
  127905. Hable = 0,
  127906. /** Reinhard */
  127907. Reinhard = 1,
  127908. /** HejiDawson */
  127909. HejiDawson = 2,
  127910. /** Photographic */
  127911. Photographic = 3
  127912. }
  127913. /**
  127914. * Defines a post process to apply tone mapping
  127915. */
  127916. export class TonemapPostProcess extends PostProcess {
  127917. private _operator;
  127918. /** Defines the required exposure adjustement */
  127919. exposureAdjustment: number;
  127920. /**
  127921. * Creates a new TonemapPostProcess
  127922. * @param name defines the name of the postprocess
  127923. * @param _operator defines the operator to use
  127924. * @param exposureAdjustment defines the required exposure adjustement
  127925. * @param camera defines the camera to use (can be null)
  127926. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  127927. * @param engine defines the hosting engine (can be ignore if camera is set)
  127928. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  127929. */
  127930. constructor(name: string, _operator: TonemappingOperator,
  127931. /** Defines the required exposure adjustement */
  127932. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  127933. }
  127934. }
  127935. declare module BABYLON {
  127936. /** @hidden */
  127937. export var depthVertexShader: {
  127938. name: string;
  127939. shader: string;
  127940. };
  127941. }
  127942. declare module BABYLON {
  127943. /** @hidden */
  127944. export var volumetricLightScatteringPixelShader: {
  127945. name: string;
  127946. shader: string;
  127947. };
  127948. }
  127949. declare module BABYLON {
  127950. /** @hidden */
  127951. export var volumetricLightScatteringPassVertexShader: {
  127952. name: string;
  127953. shader: string;
  127954. };
  127955. }
  127956. declare module BABYLON {
  127957. /** @hidden */
  127958. export var volumetricLightScatteringPassPixelShader: {
  127959. name: string;
  127960. shader: string;
  127961. };
  127962. }
  127963. declare module BABYLON {
  127964. /**
  127965. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  127966. */
  127967. export class VolumetricLightScatteringPostProcess extends PostProcess {
  127968. private _volumetricLightScatteringPass;
  127969. private _volumetricLightScatteringRTT;
  127970. private _viewPort;
  127971. private _screenCoordinates;
  127972. private _cachedDefines;
  127973. /**
  127974. * If not undefined, the mesh position is computed from the attached node position
  127975. */
  127976. attachedNode: {
  127977. position: Vector3;
  127978. };
  127979. /**
  127980. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  127981. */
  127982. customMeshPosition: Vector3;
  127983. /**
  127984. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  127985. */
  127986. useCustomMeshPosition: boolean;
  127987. /**
  127988. * If the post-process should inverse the light scattering direction
  127989. */
  127990. invert: boolean;
  127991. /**
  127992. * The internal mesh used by the post-process
  127993. */
  127994. mesh: Mesh;
  127995. /**
  127996. * @hidden
  127997. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  127998. */
  127999. useDiffuseColor: boolean;
  128000. /**
  128001. * Array containing the excluded meshes not rendered in the internal pass
  128002. */
  128003. excludedMeshes: AbstractMesh[];
  128004. /**
  128005. * Controls the overall intensity of the post-process
  128006. */
  128007. exposure: number;
  128008. /**
  128009. * Dissipates each sample's contribution in range [0, 1]
  128010. */
  128011. decay: number;
  128012. /**
  128013. * Controls the overall intensity of each sample
  128014. */
  128015. weight: number;
  128016. /**
  128017. * Controls the density of each sample
  128018. */
  128019. density: number;
  128020. /**
  128021. * @constructor
  128022. * @param name The post-process name
  128023. * @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)
  128024. * @param camera The camera that the post-process will be attached to
  128025. * @param mesh The mesh used to create the light scattering
  128026. * @param samples The post-process quality, default 100
  128027. * @param samplingModeThe post-process filtering mode
  128028. * @param engine The babylon engine
  128029. * @param reusable If the post-process is reusable
  128030. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  128031. */
  128032. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  128033. /**
  128034. * Returns the string "VolumetricLightScatteringPostProcess"
  128035. * @returns "VolumetricLightScatteringPostProcess"
  128036. */
  128037. getClassName(): string;
  128038. private _isReady;
  128039. /**
  128040. * Sets the new light position for light scattering effect
  128041. * @param position The new custom light position
  128042. */
  128043. setCustomMeshPosition(position: Vector3): void;
  128044. /**
  128045. * Returns the light position for light scattering effect
  128046. * @return Vector3 The custom light position
  128047. */
  128048. getCustomMeshPosition(): Vector3;
  128049. /**
  128050. * Disposes the internal assets and detaches the post-process from the camera
  128051. */
  128052. dispose(camera: Camera): void;
  128053. /**
  128054. * Returns the render target texture used by the post-process
  128055. * @return the render target texture used by the post-process
  128056. */
  128057. getPass(): RenderTargetTexture;
  128058. private _meshExcluded;
  128059. private _createPass;
  128060. private _updateMeshScreenCoordinates;
  128061. /**
  128062. * Creates a default mesh for the Volumeric Light Scattering post-process
  128063. * @param name The mesh name
  128064. * @param scene The scene where to create the mesh
  128065. * @return the default mesh
  128066. */
  128067. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  128068. }
  128069. }
  128070. declare module BABYLON {
  128071. interface Scene {
  128072. /** @hidden (Backing field) */
  128073. _boundingBoxRenderer: BoundingBoxRenderer;
  128074. /** @hidden (Backing field) */
  128075. _forceShowBoundingBoxes: boolean;
  128076. /**
  128077. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  128078. */
  128079. forceShowBoundingBoxes: boolean;
  128080. /**
  128081. * Gets the bounding box renderer associated with the scene
  128082. * @returns a BoundingBoxRenderer
  128083. */
  128084. getBoundingBoxRenderer(): BoundingBoxRenderer;
  128085. }
  128086. interface AbstractMesh {
  128087. /** @hidden (Backing field) */
  128088. _showBoundingBox: boolean;
  128089. /**
  128090. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  128091. */
  128092. showBoundingBox: boolean;
  128093. }
  128094. /**
  128095. * Component responsible of rendering the bounding box of the meshes in a scene.
  128096. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  128097. */
  128098. export class BoundingBoxRenderer implements ISceneComponent {
  128099. /**
  128100. * The component name helpfull to identify the component in the list of scene components.
  128101. */
  128102. readonly name: string;
  128103. /**
  128104. * The scene the component belongs to.
  128105. */
  128106. scene: Scene;
  128107. /**
  128108. * Color of the bounding box lines placed in front of an object
  128109. */
  128110. frontColor: Color3;
  128111. /**
  128112. * Color of the bounding box lines placed behind an object
  128113. */
  128114. backColor: Color3;
  128115. /**
  128116. * Defines if the renderer should show the back lines or not
  128117. */
  128118. showBackLines: boolean;
  128119. /**
  128120. * @hidden
  128121. */
  128122. renderList: SmartArray<BoundingBox>;
  128123. private _colorShader;
  128124. private _vertexBuffers;
  128125. private _indexBuffer;
  128126. private _fillIndexBuffer;
  128127. private _fillIndexData;
  128128. /**
  128129. * Instantiates a new bounding box renderer in a scene.
  128130. * @param scene the scene the renderer renders in
  128131. */
  128132. constructor(scene: Scene);
  128133. /**
  128134. * Registers the component in a given scene
  128135. */
  128136. register(): void;
  128137. private _evaluateSubMesh;
  128138. private _activeMesh;
  128139. private _prepareRessources;
  128140. private _createIndexBuffer;
  128141. /**
  128142. * Rebuilds the elements related to this component in case of
  128143. * context lost for instance.
  128144. */
  128145. rebuild(): void;
  128146. /**
  128147. * @hidden
  128148. */
  128149. reset(): void;
  128150. /**
  128151. * Render the bounding boxes of a specific rendering group
  128152. * @param renderingGroupId defines the rendering group to render
  128153. */
  128154. render(renderingGroupId: number): void;
  128155. /**
  128156. * In case of occlusion queries, we can render the occlusion bounding box through this method
  128157. * @param mesh Define the mesh to render the occlusion bounding box for
  128158. */
  128159. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  128160. /**
  128161. * Dispose and release the resources attached to this renderer.
  128162. */
  128163. dispose(): void;
  128164. }
  128165. }
  128166. declare module BABYLON {
  128167. /** @hidden */
  128168. export var depthPixelShader: {
  128169. name: string;
  128170. shader: string;
  128171. };
  128172. }
  128173. declare module BABYLON {
  128174. /**
  128175. * This represents a depth renderer in Babylon.
  128176. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  128177. */
  128178. export class DepthRenderer {
  128179. private _scene;
  128180. private _depthMap;
  128181. private _effect;
  128182. private readonly _storeNonLinearDepth;
  128183. private readonly _clearColor;
  128184. /** Get if the depth renderer is using packed depth or not */
  128185. readonly isPacked: boolean;
  128186. private _cachedDefines;
  128187. private _camera;
  128188. /**
  128189. * Specifiess that the depth renderer will only be used within
  128190. * the camera it is created for.
  128191. * This can help forcing its rendering during the camera processing.
  128192. */
  128193. useOnlyInActiveCamera: boolean;
  128194. /** @hidden */
  128195. static _SceneComponentInitialization: (scene: Scene) => void;
  128196. /**
  128197. * Instantiates a depth renderer
  128198. * @param scene The scene the renderer belongs to
  128199. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  128200. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  128201. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128202. */
  128203. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  128204. /**
  128205. * Creates the depth rendering effect and checks if the effect is ready.
  128206. * @param subMesh The submesh to be used to render the depth map of
  128207. * @param useInstances If multiple world instances should be used
  128208. * @returns if the depth renderer is ready to render the depth map
  128209. */
  128210. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128211. /**
  128212. * Gets the texture which the depth map will be written to.
  128213. * @returns The depth map texture
  128214. */
  128215. getDepthMap(): RenderTargetTexture;
  128216. /**
  128217. * Disposes of the depth renderer.
  128218. */
  128219. dispose(): void;
  128220. }
  128221. }
  128222. declare module BABYLON {
  128223. interface Scene {
  128224. /** @hidden (Backing field) */
  128225. _depthRenderer: {
  128226. [id: string]: DepthRenderer;
  128227. };
  128228. /**
  128229. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  128230. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  128231. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128232. * @returns the created depth renderer
  128233. */
  128234. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  128235. /**
  128236. * Disables a depth renderer for a given camera
  128237. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  128238. */
  128239. disableDepthRenderer(camera?: Nullable<Camera>): void;
  128240. }
  128241. /**
  128242. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  128243. * in several rendering techniques.
  128244. */
  128245. export class DepthRendererSceneComponent implements ISceneComponent {
  128246. /**
  128247. * The component name helpfull to identify the component in the list of scene components.
  128248. */
  128249. readonly name: string;
  128250. /**
  128251. * The scene the component belongs to.
  128252. */
  128253. scene: Scene;
  128254. /**
  128255. * Creates a new instance of the component for the given scene
  128256. * @param scene Defines the scene to register the component in
  128257. */
  128258. constructor(scene: Scene);
  128259. /**
  128260. * Registers the component in a given scene
  128261. */
  128262. register(): void;
  128263. /**
  128264. * Rebuilds the elements related to this component in case of
  128265. * context lost for instance.
  128266. */
  128267. rebuild(): void;
  128268. /**
  128269. * Disposes the component and the associated ressources
  128270. */
  128271. dispose(): void;
  128272. private _gatherRenderTargets;
  128273. private _gatherActiveCameraRenderTargets;
  128274. }
  128275. }
  128276. declare module BABYLON {
  128277. /** @hidden */
  128278. export var outlinePixelShader: {
  128279. name: string;
  128280. shader: string;
  128281. };
  128282. }
  128283. declare module BABYLON {
  128284. /** @hidden */
  128285. export var outlineVertexShader: {
  128286. name: string;
  128287. shader: string;
  128288. };
  128289. }
  128290. declare module BABYLON {
  128291. interface Scene {
  128292. /** @hidden */
  128293. _outlineRenderer: OutlineRenderer;
  128294. /**
  128295. * Gets the outline renderer associated with the scene
  128296. * @returns a OutlineRenderer
  128297. */
  128298. getOutlineRenderer(): OutlineRenderer;
  128299. }
  128300. interface AbstractMesh {
  128301. /** @hidden (Backing field) */
  128302. _renderOutline: boolean;
  128303. /**
  128304. * Gets or sets a boolean indicating if the outline must be rendered as well
  128305. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  128306. */
  128307. renderOutline: boolean;
  128308. /** @hidden (Backing field) */
  128309. _renderOverlay: boolean;
  128310. /**
  128311. * Gets or sets a boolean indicating if the overlay must be rendered as well
  128312. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  128313. */
  128314. renderOverlay: boolean;
  128315. }
  128316. /**
  128317. * This class is responsible to draw bothe outline/overlay of meshes.
  128318. * It should not be used directly but through the available method on mesh.
  128319. */
  128320. export class OutlineRenderer implements ISceneComponent {
  128321. /**
  128322. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  128323. */
  128324. private static _StencilReference;
  128325. /**
  128326. * The name of the component. Each component must have a unique name.
  128327. */
  128328. name: string;
  128329. /**
  128330. * The scene the component belongs to.
  128331. */
  128332. scene: Scene;
  128333. /**
  128334. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  128335. */
  128336. zOffset: number;
  128337. private _engine;
  128338. private _effect;
  128339. private _cachedDefines;
  128340. private _savedDepthWrite;
  128341. /**
  128342. * Instantiates a new outline renderer. (There could be only one per scene).
  128343. * @param scene Defines the scene it belongs to
  128344. */
  128345. constructor(scene: Scene);
  128346. /**
  128347. * Register the component to one instance of a scene.
  128348. */
  128349. register(): void;
  128350. /**
  128351. * Rebuilds the elements related to this component in case of
  128352. * context lost for instance.
  128353. */
  128354. rebuild(): void;
  128355. /**
  128356. * Disposes the component and the associated ressources.
  128357. */
  128358. dispose(): void;
  128359. /**
  128360. * Renders the outline in the canvas.
  128361. * @param subMesh Defines the sumesh to render
  128362. * @param batch Defines the batch of meshes in case of instances
  128363. * @param useOverlay Defines if the rendering is for the overlay or the outline
  128364. */
  128365. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  128366. /**
  128367. * Returns whether or not the outline renderer is ready for a given submesh.
  128368. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  128369. * @param subMesh Defines the submesh to check readyness for
  128370. * @param useInstances Defines wheter wee are trying to render instances or not
  128371. * @returns true if ready otherwise false
  128372. */
  128373. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128374. private _beforeRenderingMesh;
  128375. private _afterRenderingMesh;
  128376. }
  128377. }
  128378. declare module BABYLON {
  128379. /**
  128380. * Class used to manage multiple sprites of different sizes on the same spritesheet
  128381. * @see http://doc.babylonjs.com/babylon101/sprites
  128382. */
  128383. export class SpritePackedManager extends SpriteManager {
  128384. /** defines the packed manager's name */
  128385. name: string;
  128386. /**
  128387. * Creates a new sprite manager from a packed sprite sheet
  128388. * @param name defines the manager's name
  128389. * @param imgUrl defines the sprite sheet url
  128390. * @param capacity defines the maximum allowed number of sprites
  128391. * @param scene defines the hosting scene
  128392. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  128393. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  128394. * @param samplingMode defines the smapling mode to use with spritesheet
  128395. * @param fromPacked set to true; do not alter
  128396. */
  128397. constructor(
  128398. /** defines the packed manager's name */
  128399. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  128400. }
  128401. }
  128402. declare module BABYLON {
  128403. /**
  128404. * Defines the list of states available for a task inside a AssetsManager
  128405. */
  128406. export enum AssetTaskState {
  128407. /**
  128408. * Initialization
  128409. */
  128410. INIT = 0,
  128411. /**
  128412. * Running
  128413. */
  128414. RUNNING = 1,
  128415. /**
  128416. * Done
  128417. */
  128418. DONE = 2,
  128419. /**
  128420. * Error
  128421. */
  128422. ERROR = 3
  128423. }
  128424. /**
  128425. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  128426. */
  128427. export abstract class AbstractAssetTask {
  128428. /**
  128429. * Task name
  128430. */ name: string;
  128431. /**
  128432. * Callback called when the task is successful
  128433. */
  128434. onSuccess: (task: any) => void;
  128435. /**
  128436. * Callback called when the task is not successful
  128437. */
  128438. onError: (task: any, message?: string, exception?: any) => void;
  128439. /**
  128440. * Creates a new AssetsManager
  128441. * @param name defines the name of the task
  128442. */
  128443. constructor(
  128444. /**
  128445. * Task name
  128446. */ name: string);
  128447. private _isCompleted;
  128448. private _taskState;
  128449. private _errorObject;
  128450. /**
  128451. * Get if the task is completed
  128452. */
  128453. readonly isCompleted: boolean;
  128454. /**
  128455. * Gets the current state of the task
  128456. */
  128457. readonly taskState: AssetTaskState;
  128458. /**
  128459. * Gets the current error object (if task is in error)
  128460. */
  128461. readonly errorObject: {
  128462. message?: string;
  128463. exception?: any;
  128464. };
  128465. /**
  128466. * Internal only
  128467. * @hidden
  128468. */
  128469. _setErrorObject(message?: string, exception?: any): void;
  128470. /**
  128471. * Execute the current task
  128472. * @param scene defines the scene where you want your assets to be loaded
  128473. * @param onSuccess is a callback called when the task is successfully executed
  128474. * @param onError is a callback called if an error occurs
  128475. */
  128476. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128477. /**
  128478. * Execute the current task
  128479. * @param scene defines the scene where you want your assets to be loaded
  128480. * @param onSuccess is a callback called when the task is successfully executed
  128481. * @param onError is a callback called if an error occurs
  128482. */
  128483. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128484. /**
  128485. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  128486. * This can be used with failed tasks that have the reason for failure fixed.
  128487. */
  128488. reset(): void;
  128489. private onErrorCallback;
  128490. private onDoneCallback;
  128491. }
  128492. /**
  128493. * Define the interface used by progress events raised during assets loading
  128494. */
  128495. export interface IAssetsProgressEvent {
  128496. /**
  128497. * Defines the number of remaining tasks to process
  128498. */
  128499. remainingCount: number;
  128500. /**
  128501. * Defines the total number of tasks
  128502. */
  128503. totalCount: number;
  128504. /**
  128505. * Defines the task that was just processed
  128506. */
  128507. task: AbstractAssetTask;
  128508. }
  128509. /**
  128510. * Class used to share progress information about assets loading
  128511. */
  128512. export class AssetsProgressEvent implements IAssetsProgressEvent {
  128513. /**
  128514. * Defines the number of remaining tasks to process
  128515. */
  128516. remainingCount: number;
  128517. /**
  128518. * Defines the total number of tasks
  128519. */
  128520. totalCount: number;
  128521. /**
  128522. * Defines the task that was just processed
  128523. */
  128524. task: AbstractAssetTask;
  128525. /**
  128526. * Creates a AssetsProgressEvent
  128527. * @param remainingCount defines the number of remaining tasks to process
  128528. * @param totalCount defines the total number of tasks
  128529. * @param task defines the task that was just processed
  128530. */
  128531. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  128532. }
  128533. /**
  128534. * Define a task used by AssetsManager to load meshes
  128535. */
  128536. export class MeshAssetTask extends AbstractAssetTask {
  128537. /**
  128538. * Defines the name of the task
  128539. */
  128540. name: string;
  128541. /**
  128542. * Defines the list of mesh's names you want to load
  128543. */
  128544. meshesNames: any;
  128545. /**
  128546. * Defines the root url to use as a base to load your meshes and associated resources
  128547. */
  128548. rootUrl: string;
  128549. /**
  128550. * Defines the filename of the scene to load from
  128551. */
  128552. sceneFilename: string;
  128553. /**
  128554. * Gets the list of loaded meshes
  128555. */
  128556. loadedMeshes: Array<AbstractMesh>;
  128557. /**
  128558. * Gets the list of loaded particle systems
  128559. */
  128560. loadedParticleSystems: Array<IParticleSystem>;
  128561. /**
  128562. * Gets the list of loaded skeletons
  128563. */
  128564. loadedSkeletons: Array<Skeleton>;
  128565. /**
  128566. * Gets the list of loaded animation groups
  128567. */
  128568. loadedAnimationGroups: Array<AnimationGroup>;
  128569. /**
  128570. * Callback called when the task is successful
  128571. */
  128572. onSuccess: (task: MeshAssetTask) => void;
  128573. /**
  128574. * Callback called when the task is successful
  128575. */
  128576. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  128577. /**
  128578. * Creates a new MeshAssetTask
  128579. * @param name defines the name of the task
  128580. * @param meshesNames defines the list of mesh's names you want to load
  128581. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  128582. * @param sceneFilename defines the filename of the scene to load from
  128583. */
  128584. constructor(
  128585. /**
  128586. * Defines the name of the task
  128587. */
  128588. name: string,
  128589. /**
  128590. * Defines the list of mesh's names you want to load
  128591. */
  128592. meshesNames: any,
  128593. /**
  128594. * Defines the root url to use as a base to load your meshes and associated resources
  128595. */
  128596. rootUrl: string,
  128597. /**
  128598. * Defines the filename of the scene to load from
  128599. */
  128600. sceneFilename: string);
  128601. /**
  128602. * Execute the current task
  128603. * @param scene defines the scene where you want your assets to be loaded
  128604. * @param onSuccess is a callback called when the task is successfully executed
  128605. * @param onError is a callback called if an error occurs
  128606. */
  128607. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128608. }
  128609. /**
  128610. * Define a task used by AssetsManager to load text content
  128611. */
  128612. export class TextFileAssetTask extends AbstractAssetTask {
  128613. /**
  128614. * Defines the name of the task
  128615. */
  128616. name: string;
  128617. /**
  128618. * Defines the location of the file to load
  128619. */
  128620. url: string;
  128621. /**
  128622. * Gets the loaded text string
  128623. */
  128624. text: string;
  128625. /**
  128626. * Callback called when the task is successful
  128627. */
  128628. onSuccess: (task: TextFileAssetTask) => void;
  128629. /**
  128630. * Callback called when the task is successful
  128631. */
  128632. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  128633. /**
  128634. * Creates a new TextFileAssetTask object
  128635. * @param name defines the name of the task
  128636. * @param url defines the location of the file to load
  128637. */
  128638. constructor(
  128639. /**
  128640. * Defines the name of the task
  128641. */
  128642. name: string,
  128643. /**
  128644. * Defines the location of the file to load
  128645. */
  128646. url: string);
  128647. /**
  128648. * Execute the current task
  128649. * @param scene defines the scene where you want your assets to be loaded
  128650. * @param onSuccess is a callback called when the task is successfully executed
  128651. * @param onError is a callback called if an error occurs
  128652. */
  128653. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128654. }
  128655. /**
  128656. * Define a task used by AssetsManager to load binary data
  128657. */
  128658. export class BinaryFileAssetTask extends AbstractAssetTask {
  128659. /**
  128660. * Defines the name of the task
  128661. */
  128662. name: string;
  128663. /**
  128664. * Defines the location of the file to load
  128665. */
  128666. url: string;
  128667. /**
  128668. * Gets the lodaded data (as an array buffer)
  128669. */
  128670. data: ArrayBuffer;
  128671. /**
  128672. * Callback called when the task is successful
  128673. */
  128674. onSuccess: (task: BinaryFileAssetTask) => void;
  128675. /**
  128676. * Callback called when the task is successful
  128677. */
  128678. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  128679. /**
  128680. * Creates a new BinaryFileAssetTask object
  128681. * @param name defines the name of the new task
  128682. * @param url defines the location of the file to load
  128683. */
  128684. constructor(
  128685. /**
  128686. * Defines the name of the task
  128687. */
  128688. name: string,
  128689. /**
  128690. * Defines the location of the file to load
  128691. */
  128692. url: string);
  128693. /**
  128694. * Execute the current task
  128695. * @param scene defines the scene where you want your assets to be loaded
  128696. * @param onSuccess is a callback called when the task is successfully executed
  128697. * @param onError is a callback called if an error occurs
  128698. */
  128699. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128700. }
  128701. /**
  128702. * Define a task used by AssetsManager to load images
  128703. */
  128704. export class ImageAssetTask extends AbstractAssetTask {
  128705. /**
  128706. * Defines the name of the task
  128707. */
  128708. name: string;
  128709. /**
  128710. * Defines the location of the image to load
  128711. */
  128712. url: string;
  128713. /**
  128714. * Gets the loaded images
  128715. */
  128716. image: HTMLImageElement;
  128717. /**
  128718. * Callback called when the task is successful
  128719. */
  128720. onSuccess: (task: ImageAssetTask) => void;
  128721. /**
  128722. * Callback called when the task is successful
  128723. */
  128724. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  128725. /**
  128726. * Creates a new ImageAssetTask
  128727. * @param name defines the name of the task
  128728. * @param url defines the location of the image to load
  128729. */
  128730. constructor(
  128731. /**
  128732. * Defines the name of the task
  128733. */
  128734. name: string,
  128735. /**
  128736. * Defines the location of the image to load
  128737. */
  128738. url: string);
  128739. /**
  128740. * Execute the current task
  128741. * @param scene defines the scene where you want your assets to be loaded
  128742. * @param onSuccess is a callback called when the task is successfully executed
  128743. * @param onError is a callback called if an error occurs
  128744. */
  128745. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128746. }
  128747. /**
  128748. * Defines the interface used by texture loading tasks
  128749. */
  128750. export interface ITextureAssetTask<TEX extends BaseTexture> {
  128751. /**
  128752. * Gets the loaded texture
  128753. */
  128754. texture: TEX;
  128755. }
  128756. /**
  128757. * Define a task used by AssetsManager to load 2D textures
  128758. */
  128759. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  128760. /**
  128761. * Defines the name of the task
  128762. */
  128763. name: string;
  128764. /**
  128765. * Defines the location of the file to load
  128766. */
  128767. url: string;
  128768. /**
  128769. * Defines if mipmap should not be generated (default is false)
  128770. */
  128771. noMipmap?: boolean | undefined;
  128772. /**
  128773. * Defines if texture must be inverted on Y axis (default is false)
  128774. */
  128775. invertY?: boolean | undefined;
  128776. /**
  128777. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128778. */
  128779. samplingMode: number;
  128780. /**
  128781. * Gets the loaded texture
  128782. */
  128783. texture: Texture;
  128784. /**
  128785. * Callback called when the task is successful
  128786. */
  128787. onSuccess: (task: TextureAssetTask) => void;
  128788. /**
  128789. * Callback called when the task is successful
  128790. */
  128791. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  128792. /**
  128793. * Creates a new TextureAssetTask object
  128794. * @param name defines the name of the task
  128795. * @param url defines the location of the file to load
  128796. * @param noMipmap defines if mipmap should not be generated (default is false)
  128797. * @param invertY defines if texture must be inverted on Y axis (default is false)
  128798. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128799. */
  128800. constructor(
  128801. /**
  128802. * Defines the name of the task
  128803. */
  128804. name: string,
  128805. /**
  128806. * Defines the location of the file to load
  128807. */
  128808. url: string,
  128809. /**
  128810. * Defines if mipmap should not be generated (default is false)
  128811. */
  128812. noMipmap?: boolean | undefined,
  128813. /**
  128814. * Defines if texture must be inverted on Y axis (default is false)
  128815. */
  128816. invertY?: boolean | undefined,
  128817. /**
  128818. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128819. */
  128820. samplingMode?: number);
  128821. /**
  128822. * Execute the current task
  128823. * @param scene defines the scene where you want your assets to be loaded
  128824. * @param onSuccess is a callback called when the task is successfully executed
  128825. * @param onError is a callback called if an error occurs
  128826. */
  128827. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128828. }
  128829. /**
  128830. * Define a task used by AssetsManager to load cube textures
  128831. */
  128832. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  128833. /**
  128834. * Defines the name of the task
  128835. */
  128836. name: string;
  128837. /**
  128838. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128839. */
  128840. url: string;
  128841. /**
  128842. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128843. */
  128844. extensions?: string[] | undefined;
  128845. /**
  128846. * Defines if mipmaps should not be generated (default is false)
  128847. */
  128848. noMipmap?: boolean | undefined;
  128849. /**
  128850. * Defines the explicit list of files (undefined by default)
  128851. */
  128852. files?: string[] | undefined;
  128853. /**
  128854. * Gets the loaded texture
  128855. */
  128856. texture: CubeTexture;
  128857. /**
  128858. * Callback called when the task is successful
  128859. */
  128860. onSuccess: (task: CubeTextureAssetTask) => void;
  128861. /**
  128862. * Callback called when the task is successful
  128863. */
  128864. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  128865. /**
  128866. * Creates a new CubeTextureAssetTask
  128867. * @param name defines the name of the task
  128868. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128869. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128870. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128871. * @param files defines the explicit list of files (undefined by default)
  128872. */
  128873. constructor(
  128874. /**
  128875. * Defines the name of the task
  128876. */
  128877. name: string,
  128878. /**
  128879. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128880. */
  128881. url: string,
  128882. /**
  128883. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128884. */
  128885. extensions?: string[] | undefined,
  128886. /**
  128887. * Defines if mipmaps should not be generated (default is false)
  128888. */
  128889. noMipmap?: boolean | undefined,
  128890. /**
  128891. * Defines the explicit list of files (undefined by default)
  128892. */
  128893. files?: string[] | undefined);
  128894. /**
  128895. * Execute the current task
  128896. * @param scene defines the scene where you want your assets to be loaded
  128897. * @param onSuccess is a callback called when the task is successfully executed
  128898. * @param onError is a callback called if an error occurs
  128899. */
  128900. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128901. }
  128902. /**
  128903. * Define a task used by AssetsManager to load HDR cube textures
  128904. */
  128905. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  128906. /**
  128907. * Defines the name of the task
  128908. */
  128909. name: string;
  128910. /**
  128911. * Defines the location of the file to load
  128912. */
  128913. url: string;
  128914. /**
  128915. * Defines the desired size (the more it increases the longer the generation will be)
  128916. */
  128917. size: number;
  128918. /**
  128919. * Defines if mipmaps should not be generated (default is false)
  128920. */
  128921. noMipmap: boolean;
  128922. /**
  128923. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128924. */
  128925. generateHarmonics: boolean;
  128926. /**
  128927. * 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)
  128928. */
  128929. gammaSpace: boolean;
  128930. /**
  128931. * Internal Use Only
  128932. */
  128933. reserved: boolean;
  128934. /**
  128935. * Gets the loaded texture
  128936. */
  128937. texture: HDRCubeTexture;
  128938. /**
  128939. * Callback called when the task is successful
  128940. */
  128941. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  128942. /**
  128943. * Callback called when the task is successful
  128944. */
  128945. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  128946. /**
  128947. * Creates a new HDRCubeTextureAssetTask object
  128948. * @param name defines the name of the task
  128949. * @param url defines the location of the file to load
  128950. * @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.
  128951. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128952. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128953. * @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)
  128954. * @param reserved Internal use only
  128955. */
  128956. constructor(
  128957. /**
  128958. * Defines the name of the task
  128959. */
  128960. name: string,
  128961. /**
  128962. * Defines the location of the file to load
  128963. */
  128964. url: string,
  128965. /**
  128966. * Defines the desired size (the more it increases the longer the generation will be)
  128967. */
  128968. size: number,
  128969. /**
  128970. * Defines if mipmaps should not be generated (default is false)
  128971. */
  128972. noMipmap?: boolean,
  128973. /**
  128974. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128975. */
  128976. generateHarmonics?: boolean,
  128977. /**
  128978. * 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)
  128979. */
  128980. gammaSpace?: boolean,
  128981. /**
  128982. * Internal Use Only
  128983. */
  128984. reserved?: boolean);
  128985. /**
  128986. * Execute the current task
  128987. * @param scene defines the scene where you want your assets to be loaded
  128988. * @param onSuccess is a callback called when the task is successfully executed
  128989. * @param onError is a callback called if an error occurs
  128990. */
  128991. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128992. }
  128993. /**
  128994. * Define a task used by AssetsManager to load Equirectangular cube textures
  128995. */
  128996. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  128997. /**
  128998. * Defines the name of the task
  128999. */
  129000. name: string;
  129001. /**
  129002. * Defines the location of the file to load
  129003. */
  129004. url: string;
  129005. /**
  129006. * Defines the desired size (the more it increases the longer the generation will be)
  129007. */
  129008. size: number;
  129009. /**
  129010. * Defines if mipmaps should not be generated (default is false)
  129011. */
  129012. noMipmap: boolean;
  129013. /**
  129014. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  129015. * but the standard material would require them in Gamma space) (default is true)
  129016. */
  129017. gammaSpace: boolean;
  129018. /**
  129019. * Gets the loaded texture
  129020. */
  129021. texture: EquiRectangularCubeTexture;
  129022. /**
  129023. * Callback called when the task is successful
  129024. */
  129025. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  129026. /**
  129027. * Callback called when the task is successful
  129028. */
  129029. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  129030. /**
  129031. * Creates a new EquiRectangularCubeTextureAssetTask object
  129032. * @param name defines the name of the task
  129033. * @param url defines the location of the file to load
  129034. * @param size defines the desired size (the more it increases the longer the generation will be)
  129035. * If the size is omitted this implies you are using a preprocessed cubemap.
  129036. * @param noMipmap defines if mipmaps should not be generated (default is false)
  129037. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  129038. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  129039. * (default is true)
  129040. */
  129041. constructor(
  129042. /**
  129043. * Defines the name of the task
  129044. */
  129045. name: string,
  129046. /**
  129047. * Defines the location of the file to load
  129048. */
  129049. url: string,
  129050. /**
  129051. * Defines the desired size (the more it increases the longer the generation will be)
  129052. */
  129053. size: number,
  129054. /**
  129055. * Defines if mipmaps should not be generated (default is false)
  129056. */
  129057. noMipmap?: boolean,
  129058. /**
  129059. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  129060. * but the standard material would require them in Gamma space) (default is true)
  129061. */
  129062. gammaSpace?: boolean);
  129063. /**
  129064. * Execute the current task
  129065. * @param scene defines the scene where you want your assets to be loaded
  129066. * @param onSuccess is a callback called when the task is successfully executed
  129067. * @param onError is a callback called if an error occurs
  129068. */
  129069. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129070. }
  129071. /**
  129072. * This class can be used to easily import assets into a scene
  129073. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  129074. */
  129075. export class AssetsManager {
  129076. private _scene;
  129077. private _isLoading;
  129078. protected _tasks: AbstractAssetTask[];
  129079. protected _waitingTasksCount: number;
  129080. protected _totalTasksCount: number;
  129081. /**
  129082. * Callback called when all tasks are processed
  129083. */
  129084. onFinish: (tasks: AbstractAssetTask[]) => void;
  129085. /**
  129086. * Callback called when a task is successful
  129087. */
  129088. onTaskSuccess: (task: AbstractAssetTask) => void;
  129089. /**
  129090. * Callback called when a task had an error
  129091. */
  129092. onTaskError: (task: AbstractAssetTask) => void;
  129093. /**
  129094. * Callback called when a task is done (whatever the result is)
  129095. */
  129096. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  129097. /**
  129098. * Observable called when all tasks are processed
  129099. */
  129100. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  129101. /**
  129102. * Observable called when a task had an error
  129103. */
  129104. onTaskErrorObservable: Observable<AbstractAssetTask>;
  129105. /**
  129106. * Observable called when all tasks were executed
  129107. */
  129108. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  129109. /**
  129110. * Observable called when a task is done (whatever the result is)
  129111. */
  129112. onProgressObservable: Observable<IAssetsProgressEvent>;
  129113. /**
  129114. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  129115. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  129116. */
  129117. useDefaultLoadingScreen: boolean;
  129118. /**
  129119. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  129120. * when all assets have been downloaded.
  129121. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  129122. */
  129123. autoHideLoadingUI: boolean;
  129124. /**
  129125. * Creates a new AssetsManager
  129126. * @param scene defines the scene to work on
  129127. */
  129128. constructor(scene: Scene);
  129129. /**
  129130. * Add a MeshAssetTask to the list of active tasks
  129131. * @param taskName defines the name of the new task
  129132. * @param meshesNames defines the name of meshes to load
  129133. * @param rootUrl defines the root url to use to locate files
  129134. * @param sceneFilename defines the filename of the scene file
  129135. * @returns a new MeshAssetTask object
  129136. */
  129137. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  129138. /**
  129139. * Add a TextFileAssetTask to the list of active tasks
  129140. * @param taskName defines the name of the new task
  129141. * @param url defines the url of the file to load
  129142. * @returns a new TextFileAssetTask object
  129143. */
  129144. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  129145. /**
  129146. * Add a BinaryFileAssetTask to the list of active tasks
  129147. * @param taskName defines the name of the new task
  129148. * @param url defines the url of the file to load
  129149. * @returns a new BinaryFileAssetTask object
  129150. */
  129151. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  129152. /**
  129153. * Add a ImageAssetTask to the list of active tasks
  129154. * @param taskName defines the name of the new task
  129155. * @param url defines the url of the file to load
  129156. * @returns a new ImageAssetTask object
  129157. */
  129158. addImageTask(taskName: string, url: string): ImageAssetTask;
  129159. /**
  129160. * Add a TextureAssetTask to the list of active tasks
  129161. * @param taskName defines the name of the new task
  129162. * @param url defines the url of the file to load
  129163. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129164. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  129165. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129166. * @returns a new TextureAssetTask object
  129167. */
  129168. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  129169. /**
  129170. * Add a CubeTextureAssetTask to the list of active tasks
  129171. * @param taskName defines the name of the new task
  129172. * @param url defines the url of the file to load
  129173. * @param extensions defines the extension to use to load the cube map (can be null)
  129174. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129175. * @param files defines the list of files to load (can be null)
  129176. * @returns a new CubeTextureAssetTask object
  129177. */
  129178. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  129179. /**
  129180. *
  129181. * Add a HDRCubeTextureAssetTask to the list of active tasks
  129182. * @param taskName defines the name of the new task
  129183. * @param url defines the url of the file to load
  129184. * @param size defines the size you want for the cubemap (can be null)
  129185. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129186. * @param generateHarmonics defines if you want to automatically generate (true by default)
  129187. * @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)
  129188. * @param reserved Internal use only
  129189. * @returns a new HDRCubeTextureAssetTask object
  129190. */
  129191. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  129192. /**
  129193. *
  129194. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  129195. * @param taskName defines the name of the new task
  129196. * @param url defines the url of the file to load
  129197. * @param size defines the size you want for the cubemap (can be null)
  129198. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129199. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129200. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129201. * @returns a new EquiRectangularCubeTextureAssetTask object
  129202. */
  129203. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  129204. /**
  129205. * Remove a task from the assets manager.
  129206. * @param task the task to remove
  129207. */
  129208. removeTask(task: AbstractAssetTask): void;
  129209. private _decreaseWaitingTasksCount;
  129210. private _runTask;
  129211. /**
  129212. * Reset the AssetsManager and remove all tasks
  129213. * @return the current instance of the AssetsManager
  129214. */
  129215. reset(): AssetsManager;
  129216. /**
  129217. * Start the loading process
  129218. * @return the current instance of the AssetsManager
  129219. */
  129220. load(): AssetsManager;
  129221. /**
  129222. * Start the loading process as an async operation
  129223. * @return a promise returning the list of failed tasks
  129224. */
  129225. loadAsync(): Promise<void>;
  129226. }
  129227. }
  129228. declare module BABYLON {
  129229. /**
  129230. * Wrapper class for promise with external resolve and reject.
  129231. */
  129232. export class Deferred<T> {
  129233. /**
  129234. * The promise associated with this deferred object.
  129235. */
  129236. readonly promise: Promise<T>;
  129237. private _resolve;
  129238. private _reject;
  129239. /**
  129240. * The resolve method of the promise associated with this deferred object.
  129241. */
  129242. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  129243. /**
  129244. * The reject method of the promise associated with this deferred object.
  129245. */
  129246. readonly reject: (reason?: any) => void;
  129247. /**
  129248. * Constructor for this deferred object.
  129249. */
  129250. constructor();
  129251. }
  129252. }
  129253. declare module BABYLON {
  129254. /**
  129255. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  129256. */
  129257. export class MeshExploder {
  129258. private _centerMesh;
  129259. private _meshes;
  129260. private _meshesOrigins;
  129261. private _toCenterVectors;
  129262. private _scaledDirection;
  129263. private _newPosition;
  129264. private _centerPosition;
  129265. /**
  129266. * Explodes meshes from a center mesh.
  129267. * @param meshes The meshes to explode.
  129268. * @param centerMesh The mesh to be center of explosion.
  129269. */
  129270. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  129271. private _setCenterMesh;
  129272. /**
  129273. * Get class name
  129274. * @returns "MeshExploder"
  129275. */
  129276. getClassName(): string;
  129277. /**
  129278. * "Exploded meshes"
  129279. * @returns Array of meshes with the centerMesh at index 0.
  129280. */
  129281. getMeshes(): Array<Mesh>;
  129282. /**
  129283. * Explodes meshes giving a specific direction
  129284. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  129285. */
  129286. explode(direction?: number): void;
  129287. }
  129288. }
  129289. declare module BABYLON {
  129290. /**
  129291. * Class used to help managing file picking and drag'n'drop
  129292. */
  129293. export class FilesInput {
  129294. /**
  129295. * List of files ready to be loaded
  129296. */
  129297. static readonly FilesToLoad: {
  129298. [key: string]: File;
  129299. };
  129300. /**
  129301. * Callback called when a file is processed
  129302. */
  129303. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  129304. private _engine;
  129305. private _currentScene;
  129306. private _sceneLoadedCallback;
  129307. private _progressCallback;
  129308. private _additionalRenderLoopLogicCallback;
  129309. private _textureLoadingCallback;
  129310. private _startingProcessingFilesCallback;
  129311. private _onReloadCallback;
  129312. private _errorCallback;
  129313. private _elementToMonitor;
  129314. private _sceneFileToLoad;
  129315. private _filesToLoad;
  129316. /**
  129317. * Creates a new FilesInput
  129318. * @param engine defines the rendering engine
  129319. * @param scene defines the hosting scene
  129320. * @param sceneLoadedCallback callback called when scene is loaded
  129321. * @param progressCallback callback called to track progress
  129322. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  129323. * @param textureLoadingCallback callback called when a texture is loading
  129324. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  129325. * @param onReloadCallback callback called when a reload is requested
  129326. * @param errorCallback callback call if an error occurs
  129327. */
  129328. 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);
  129329. private _dragEnterHandler;
  129330. private _dragOverHandler;
  129331. private _dropHandler;
  129332. /**
  129333. * Calls this function to listen to drag'n'drop events on a specific DOM element
  129334. * @param elementToMonitor defines the DOM element to track
  129335. */
  129336. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  129337. /**
  129338. * Release all associated resources
  129339. */
  129340. dispose(): void;
  129341. private renderFunction;
  129342. private drag;
  129343. private drop;
  129344. private _traverseFolder;
  129345. private _processFiles;
  129346. /**
  129347. * Load files from a drop event
  129348. * @param event defines the drop event to use as source
  129349. */
  129350. loadFiles(event: any): void;
  129351. private _processReload;
  129352. /**
  129353. * Reload the current scene from the loaded files
  129354. */
  129355. reload(): void;
  129356. }
  129357. }
  129358. declare module BABYLON {
  129359. /**
  129360. * Defines the root class used to create scene optimization to use with SceneOptimizer
  129361. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129362. */
  129363. export class SceneOptimization {
  129364. /**
  129365. * Defines the priority of this optimization (0 by default which means first in the list)
  129366. */
  129367. priority: number;
  129368. /**
  129369. * Gets a string describing the action executed by the current optimization
  129370. * @returns description string
  129371. */
  129372. getDescription(): string;
  129373. /**
  129374. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129375. * @param scene defines the current scene where to apply this optimization
  129376. * @param optimizer defines the current optimizer
  129377. * @returns true if everything that can be done was applied
  129378. */
  129379. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129380. /**
  129381. * Creates the SceneOptimization object
  129382. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129383. * @param desc defines the description associated with the optimization
  129384. */
  129385. constructor(
  129386. /**
  129387. * Defines the priority of this optimization (0 by default which means first in the list)
  129388. */
  129389. priority?: number);
  129390. }
  129391. /**
  129392. * Defines an optimization used to reduce the size of render target textures
  129393. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129394. */
  129395. export class TextureOptimization extends SceneOptimization {
  129396. /**
  129397. * Defines the priority of this optimization (0 by default which means first in the list)
  129398. */
  129399. priority: number;
  129400. /**
  129401. * 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
  129402. */
  129403. maximumSize: number;
  129404. /**
  129405. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129406. */
  129407. step: number;
  129408. /**
  129409. * Gets a string describing the action executed by the current optimization
  129410. * @returns description string
  129411. */
  129412. getDescription(): string;
  129413. /**
  129414. * Creates the TextureOptimization object
  129415. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129416. * @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
  129417. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129418. */
  129419. constructor(
  129420. /**
  129421. * Defines the priority of this optimization (0 by default which means first in the list)
  129422. */
  129423. priority?: number,
  129424. /**
  129425. * 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
  129426. */
  129427. maximumSize?: number,
  129428. /**
  129429. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129430. */
  129431. step?: number);
  129432. /**
  129433. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129434. * @param scene defines the current scene where to apply this optimization
  129435. * @param optimizer defines the current optimizer
  129436. * @returns true if everything that can be done was applied
  129437. */
  129438. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129439. }
  129440. /**
  129441. * Defines an optimization used to increase or decrease the rendering resolution
  129442. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129443. */
  129444. export class HardwareScalingOptimization extends SceneOptimization {
  129445. /**
  129446. * Defines the priority of this optimization (0 by default which means first in the list)
  129447. */
  129448. priority: number;
  129449. /**
  129450. * Defines the maximum scale to use (2 by default)
  129451. */
  129452. maximumScale: number;
  129453. /**
  129454. * Defines the step to use between two passes (0.5 by default)
  129455. */
  129456. step: number;
  129457. private _currentScale;
  129458. private _directionOffset;
  129459. /**
  129460. * Gets a string describing the action executed by the current optimization
  129461. * @return description string
  129462. */
  129463. getDescription(): string;
  129464. /**
  129465. * Creates the HardwareScalingOptimization object
  129466. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129467. * @param maximumScale defines the maximum scale to use (2 by default)
  129468. * @param step defines the step to use between two passes (0.5 by default)
  129469. */
  129470. constructor(
  129471. /**
  129472. * Defines the priority of this optimization (0 by default which means first in the list)
  129473. */
  129474. priority?: number,
  129475. /**
  129476. * Defines the maximum scale to use (2 by default)
  129477. */
  129478. maximumScale?: number,
  129479. /**
  129480. * Defines the step to use between two passes (0.5 by default)
  129481. */
  129482. step?: number);
  129483. /**
  129484. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129485. * @param scene defines the current scene where to apply this optimization
  129486. * @param optimizer defines the current optimizer
  129487. * @returns true if everything that can be done was applied
  129488. */
  129489. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129490. }
  129491. /**
  129492. * Defines an optimization used to remove shadows
  129493. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129494. */
  129495. export class ShadowsOptimization extends SceneOptimization {
  129496. /**
  129497. * Gets a string describing the action executed by the current optimization
  129498. * @return description string
  129499. */
  129500. getDescription(): string;
  129501. /**
  129502. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129503. * @param scene defines the current scene where to apply this optimization
  129504. * @param optimizer defines the current optimizer
  129505. * @returns true if everything that can be done was applied
  129506. */
  129507. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129508. }
  129509. /**
  129510. * Defines an optimization used to turn post-processes off
  129511. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129512. */
  129513. export class PostProcessesOptimization extends SceneOptimization {
  129514. /**
  129515. * Gets a string describing the action executed by the current optimization
  129516. * @return description string
  129517. */
  129518. getDescription(): string;
  129519. /**
  129520. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129521. * @param scene defines the current scene where to apply this optimization
  129522. * @param optimizer defines the current optimizer
  129523. * @returns true if everything that can be done was applied
  129524. */
  129525. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129526. }
  129527. /**
  129528. * Defines an optimization used to turn lens flares off
  129529. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129530. */
  129531. export class LensFlaresOptimization extends SceneOptimization {
  129532. /**
  129533. * Gets a string describing the action executed by the current optimization
  129534. * @return description string
  129535. */
  129536. getDescription(): string;
  129537. /**
  129538. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129539. * @param scene defines the current scene where to apply this optimization
  129540. * @param optimizer defines the current optimizer
  129541. * @returns true if everything that can be done was applied
  129542. */
  129543. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129544. }
  129545. /**
  129546. * Defines an optimization based on user defined callback.
  129547. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129548. */
  129549. export class CustomOptimization extends SceneOptimization {
  129550. /**
  129551. * Callback called to apply the custom optimization.
  129552. */
  129553. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  129554. /**
  129555. * Callback called to get custom description
  129556. */
  129557. onGetDescription: () => string;
  129558. /**
  129559. * Gets a string describing the action executed by the current optimization
  129560. * @returns description string
  129561. */
  129562. getDescription(): string;
  129563. /**
  129564. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129565. * @param scene defines the current scene where to apply this optimization
  129566. * @param optimizer defines the current optimizer
  129567. * @returns true if everything that can be done was applied
  129568. */
  129569. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129570. }
  129571. /**
  129572. * Defines an optimization used to turn particles off
  129573. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129574. */
  129575. export class ParticlesOptimization extends SceneOptimization {
  129576. /**
  129577. * Gets a string describing the action executed by the current optimization
  129578. * @return description string
  129579. */
  129580. getDescription(): string;
  129581. /**
  129582. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129583. * @param scene defines the current scene where to apply this optimization
  129584. * @param optimizer defines the current optimizer
  129585. * @returns true if everything that can be done was applied
  129586. */
  129587. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129588. }
  129589. /**
  129590. * Defines an optimization used to turn render targets off
  129591. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129592. */
  129593. export class RenderTargetsOptimization extends SceneOptimization {
  129594. /**
  129595. * Gets a string describing the action executed by the current optimization
  129596. * @return description string
  129597. */
  129598. getDescription(): string;
  129599. /**
  129600. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129601. * @param scene defines the current scene where to apply this optimization
  129602. * @param optimizer defines the current optimizer
  129603. * @returns true if everything that can be done was applied
  129604. */
  129605. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129606. }
  129607. /**
  129608. * Defines an optimization used to merge meshes with compatible materials
  129609. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129610. */
  129611. export class MergeMeshesOptimization extends SceneOptimization {
  129612. private static _UpdateSelectionTree;
  129613. /**
  129614. * Gets or sets a boolean which defines if optimization octree has to be updated
  129615. */
  129616. /**
  129617. * Gets or sets a boolean which defines if optimization octree has to be updated
  129618. */
  129619. static UpdateSelectionTree: boolean;
  129620. /**
  129621. * Gets a string describing the action executed by the current optimization
  129622. * @return description string
  129623. */
  129624. getDescription(): string;
  129625. private _canBeMerged;
  129626. /**
  129627. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129628. * @param scene defines the current scene where to apply this optimization
  129629. * @param optimizer defines the current optimizer
  129630. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  129631. * @returns true if everything that can be done was applied
  129632. */
  129633. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  129634. }
  129635. /**
  129636. * Defines a list of options used by SceneOptimizer
  129637. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129638. */
  129639. export class SceneOptimizerOptions {
  129640. /**
  129641. * Defines the target frame rate to reach (60 by default)
  129642. */
  129643. targetFrameRate: number;
  129644. /**
  129645. * Defines the interval between two checkes (2000ms by default)
  129646. */
  129647. trackerDuration: number;
  129648. /**
  129649. * Gets the list of optimizations to apply
  129650. */
  129651. optimizations: SceneOptimization[];
  129652. /**
  129653. * Creates a new list of options used by SceneOptimizer
  129654. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  129655. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  129656. */
  129657. constructor(
  129658. /**
  129659. * Defines the target frame rate to reach (60 by default)
  129660. */
  129661. targetFrameRate?: number,
  129662. /**
  129663. * Defines the interval between two checkes (2000ms by default)
  129664. */
  129665. trackerDuration?: number);
  129666. /**
  129667. * Add a new optimization
  129668. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  129669. * @returns the current SceneOptimizerOptions
  129670. */
  129671. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  129672. /**
  129673. * Add a new custom optimization
  129674. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  129675. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  129676. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129677. * @returns the current SceneOptimizerOptions
  129678. */
  129679. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  129680. /**
  129681. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  129682. * @param targetFrameRate defines the target frame rate (60 by default)
  129683. * @returns a SceneOptimizerOptions object
  129684. */
  129685. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129686. /**
  129687. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  129688. * @param targetFrameRate defines the target frame rate (60 by default)
  129689. * @returns a SceneOptimizerOptions object
  129690. */
  129691. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129692. /**
  129693. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  129694. * @param targetFrameRate defines the target frame rate (60 by default)
  129695. * @returns a SceneOptimizerOptions object
  129696. */
  129697. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129698. }
  129699. /**
  129700. * Class used to run optimizations in order to reach a target frame rate
  129701. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129702. */
  129703. export class SceneOptimizer implements IDisposable {
  129704. private _isRunning;
  129705. private _options;
  129706. private _scene;
  129707. private _currentPriorityLevel;
  129708. private _targetFrameRate;
  129709. private _trackerDuration;
  129710. private _currentFrameRate;
  129711. private _sceneDisposeObserver;
  129712. private _improvementMode;
  129713. /**
  129714. * Defines an observable called when the optimizer reaches the target frame rate
  129715. */
  129716. onSuccessObservable: Observable<SceneOptimizer>;
  129717. /**
  129718. * Defines an observable called when the optimizer enables an optimization
  129719. */
  129720. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  129721. /**
  129722. * Defines an observable called when the optimizer is not able to reach the target frame rate
  129723. */
  129724. onFailureObservable: Observable<SceneOptimizer>;
  129725. /**
  129726. * Gets a boolean indicating if the optimizer is in improvement mode
  129727. */
  129728. readonly isInImprovementMode: boolean;
  129729. /**
  129730. * Gets the current priority level (0 at start)
  129731. */
  129732. readonly currentPriorityLevel: number;
  129733. /**
  129734. * Gets the current frame rate checked by the SceneOptimizer
  129735. */
  129736. readonly currentFrameRate: number;
  129737. /**
  129738. * Gets or sets the current target frame rate (60 by default)
  129739. */
  129740. /**
  129741. * Gets or sets the current target frame rate (60 by default)
  129742. */
  129743. targetFrameRate: number;
  129744. /**
  129745. * Gets or sets the current interval between two checks (every 2000ms by default)
  129746. */
  129747. /**
  129748. * Gets or sets the current interval between two checks (every 2000ms by default)
  129749. */
  129750. trackerDuration: number;
  129751. /**
  129752. * Gets the list of active optimizations
  129753. */
  129754. readonly optimizations: SceneOptimization[];
  129755. /**
  129756. * Creates a new SceneOptimizer
  129757. * @param scene defines the scene to work on
  129758. * @param options defines the options to use with the SceneOptimizer
  129759. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  129760. * @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)
  129761. */
  129762. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  129763. /**
  129764. * Stops the current optimizer
  129765. */
  129766. stop(): void;
  129767. /**
  129768. * Reset the optimizer to initial step (current priority level = 0)
  129769. */
  129770. reset(): void;
  129771. /**
  129772. * Start the optimizer. By default it will try to reach a specific framerate
  129773. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  129774. */
  129775. start(): void;
  129776. private _checkCurrentState;
  129777. /**
  129778. * Release all resources
  129779. */
  129780. dispose(): void;
  129781. /**
  129782. * Helper function to create a SceneOptimizer with one single line of code
  129783. * @param scene defines the scene to work on
  129784. * @param options defines the options to use with the SceneOptimizer
  129785. * @param onSuccess defines a callback to call on success
  129786. * @param onFailure defines a callback to call on failure
  129787. * @returns the new SceneOptimizer object
  129788. */
  129789. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  129790. }
  129791. }
  129792. declare module BABYLON {
  129793. /**
  129794. * Class used to serialize a scene into a string
  129795. */
  129796. export class SceneSerializer {
  129797. /**
  129798. * Clear cache used by a previous serialization
  129799. */
  129800. static ClearCache(): void;
  129801. /**
  129802. * Serialize a scene into a JSON compatible object
  129803. * @param scene defines the scene to serialize
  129804. * @returns a JSON compatible object
  129805. */
  129806. static Serialize(scene: Scene): any;
  129807. /**
  129808. * Serialize a mesh into a JSON compatible object
  129809. * @param toSerialize defines the mesh to serialize
  129810. * @param withParents defines if parents must be serialized as well
  129811. * @param withChildren defines if children must be serialized as well
  129812. * @returns a JSON compatible object
  129813. */
  129814. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  129815. }
  129816. }
  129817. declare module BABYLON {
  129818. /**
  129819. * Class used to host texture specific utilities
  129820. */
  129821. export class TextureTools {
  129822. /**
  129823. * Uses the GPU to create a copy texture rescaled at a given size
  129824. * @param texture Texture to copy from
  129825. * @param width defines the desired width
  129826. * @param height defines the desired height
  129827. * @param useBilinearMode defines if bilinear mode has to be used
  129828. * @return the generated texture
  129829. */
  129830. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  129831. }
  129832. }
  129833. declare module BABYLON {
  129834. /**
  129835. * This represents the different options available for the video capture.
  129836. */
  129837. export interface VideoRecorderOptions {
  129838. /** Defines the mime type of the video. */
  129839. mimeType: string;
  129840. /** Defines the FPS the video should be recorded at. */
  129841. fps: number;
  129842. /** Defines the chunk size for the recording data. */
  129843. recordChunckSize: number;
  129844. /** The audio tracks to attach to the recording. */
  129845. audioTracks?: MediaStreamTrack[];
  129846. }
  129847. /**
  129848. * This can help with recording videos from BabylonJS.
  129849. * This is based on the available WebRTC functionalities of the browser.
  129850. *
  129851. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  129852. */
  129853. export class VideoRecorder {
  129854. private static readonly _defaultOptions;
  129855. /**
  129856. * Returns whether or not the VideoRecorder is available in your browser.
  129857. * @param engine Defines the Babylon Engine.
  129858. * @returns true if supported otherwise false.
  129859. */
  129860. static IsSupported(engine: Engine): boolean;
  129861. private readonly _options;
  129862. private _canvas;
  129863. private _mediaRecorder;
  129864. private _recordedChunks;
  129865. private _fileName;
  129866. private _resolve;
  129867. private _reject;
  129868. /**
  129869. * True when a recording is already in progress.
  129870. */
  129871. readonly isRecording: boolean;
  129872. /**
  129873. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  129874. * @param engine Defines the BabylonJS Engine you wish to record.
  129875. * @param options Defines options that can be used to customize the capture.
  129876. */
  129877. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  129878. /**
  129879. * Stops the current recording before the default capture timeout passed in the startRecording function.
  129880. */
  129881. stopRecording(): void;
  129882. /**
  129883. * Starts recording the canvas for a max duration specified in parameters.
  129884. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  129885. * If null no automatic download will start and you can rely on the promise to get the data back.
  129886. * @param maxDuration Defines the maximum recording time in seconds.
  129887. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  129888. * @return A promise callback at the end of the recording with the video data in Blob.
  129889. */
  129890. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  129891. /**
  129892. * Releases internal resources used during the recording.
  129893. */
  129894. dispose(): void;
  129895. private _handleDataAvailable;
  129896. private _handleError;
  129897. private _handleStop;
  129898. }
  129899. }
  129900. declare module BABYLON {
  129901. /**
  129902. * Class containing a set of static utilities functions for screenshots
  129903. */
  129904. export class ScreenshotTools {
  129905. /**
  129906. * Captures a screenshot of the current rendering
  129907. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129908. * @param engine defines the rendering engine
  129909. * @param camera defines the source camera
  129910. * @param size This parameter can be set to a single number or to an object with the
  129911. * following (optional) properties: precision, width, height. If a single number is passed,
  129912. * it will be used for both width and height. If an object is passed, the screenshot size
  129913. * will be derived from the parameters. The precision property is a multiplier allowing
  129914. * rendering at a higher or lower resolution
  129915. * @param successCallback defines the callback receives a single parameter which contains the
  129916. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129917. * src parameter of an <img> to display it
  129918. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129919. * Check your browser for supported MIME types
  129920. */
  129921. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  129922. /**
  129923. * Captures a screenshot of the current rendering
  129924. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129925. * @param engine defines the rendering engine
  129926. * @param camera defines the source camera
  129927. * @param size This parameter can be set to a single number or to an object with the
  129928. * following (optional) properties: precision, width, height. If a single number is passed,
  129929. * it will be used for both width and height. If an object is passed, the screenshot size
  129930. * will be derived from the parameters. The precision property is a multiplier allowing
  129931. * rendering at a higher or lower resolution
  129932. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129933. * Check your browser for supported MIME types
  129934. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129935. * to the src parameter of an <img> to display it
  129936. */
  129937. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  129938. /**
  129939. * Generates an image screenshot from the specified camera.
  129940. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129941. * @param engine The engine to use for rendering
  129942. * @param camera The camera to use for rendering
  129943. * @param size This parameter can be set to a single number or to an object with the
  129944. * following (optional) properties: precision, width, height. If a single number is passed,
  129945. * it will be used for both width and height. If an object is passed, the screenshot size
  129946. * will be derived from the parameters. The precision property is a multiplier allowing
  129947. * rendering at a higher or lower resolution
  129948. * @param successCallback The callback receives a single parameter which contains the
  129949. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129950. * src parameter of an <img> to display it
  129951. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129952. * Check your browser for supported MIME types
  129953. * @param samples Texture samples (default: 1)
  129954. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129955. * @param fileName A name for for the downloaded file.
  129956. */
  129957. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  129958. /**
  129959. * Generates an image screenshot from the specified camera.
  129960. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129961. * @param engine The engine to use for rendering
  129962. * @param camera The camera to use for rendering
  129963. * @param size This parameter can be set to a single number or to an object with the
  129964. * following (optional) properties: precision, width, height. If a single number is passed,
  129965. * it will be used for both width and height. If an object is passed, the screenshot size
  129966. * will be derived from the parameters. The precision property is a multiplier allowing
  129967. * rendering at a higher or lower resolution
  129968. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129969. * Check your browser for supported MIME types
  129970. * @param samples Texture samples (default: 1)
  129971. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129972. * @param fileName A name for for the downloaded file.
  129973. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129974. * to the src parameter of an <img> to display it
  129975. */
  129976. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  129977. /**
  129978. * Gets height and width for screenshot size
  129979. * @private
  129980. */
  129981. private static _getScreenshotSize;
  129982. }
  129983. }
  129984. declare module BABYLON {
  129985. /**
  129986. * A cursor which tracks a point on a path
  129987. */
  129988. export class PathCursor {
  129989. private path;
  129990. /**
  129991. * Stores path cursor callbacks for when an onchange event is triggered
  129992. */
  129993. private _onchange;
  129994. /**
  129995. * The value of the path cursor
  129996. */
  129997. value: number;
  129998. /**
  129999. * The animation array of the path cursor
  130000. */
  130001. animations: Animation[];
  130002. /**
  130003. * Initializes the path cursor
  130004. * @param path The path to track
  130005. */
  130006. constructor(path: Path2);
  130007. /**
  130008. * Gets the cursor point on the path
  130009. * @returns A point on the path cursor at the cursor location
  130010. */
  130011. getPoint(): Vector3;
  130012. /**
  130013. * Moves the cursor ahead by the step amount
  130014. * @param step The amount to move the cursor forward
  130015. * @returns This path cursor
  130016. */
  130017. moveAhead(step?: number): PathCursor;
  130018. /**
  130019. * Moves the cursor behind by the step amount
  130020. * @param step The amount to move the cursor back
  130021. * @returns This path cursor
  130022. */
  130023. moveBack(step?: number): PathCursor;
  130024. /**
  130025. * Moves the cursor by the step amount
  130026. * If the step amount is greater than one, an exception is thrown
  130027. * @param step The amount to move the cursor
  130028. * @returns This path cursor
  130029. */
  130030. move(step: number): PathCursor;
  130031. /**
  130032. * Ensures that the value is limited between zero and one
  130033. * @returns This path cursor
  130034. */
  130035. private ensureLimits;
  130036. /**
  130037. * Runs onchange callbacks on change (used by the animation engine)
  130038. * @returns This path cursor
  130039. */
  130040. private raiseOnChange;
  130041. /**
  130042. * Executes a function on change
  130043. * @param f A path cursor onchange callback
  130044. * @returns This path cursor
  130045. */
  130046. onchange(f: (cursor: PathCursor) => void): PathCursor;
  130047. }
  130048. }
  130049. declare module BABYLON {
  130050. /** @hidden */
  130051. export var blurPixelShader: {
  130052. name: string;
  130053. shader: string;
  130054. };
  130055. }
  130056. declare module BABYLON {
  130057. /** @hidden */
  130058. export var pointCloudVertexDeclaration: {
  130059. name: string;
  130060. shader: string;
  130061. };
  130062. }
  130063. // Mixins
  130064. interface Window {
  130065. mozIndexedDB: IDBFactory;
  130066. webkitIndexedDB: IDBFactory;
  130067. msIndexedDB: IDBFactory;
  130068. webkitURL: typeof URL;
  130069. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  130070. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  130071. WebGLRenderingContext: WebGLRenderingContext;
  130072. MSGesture: MSGesture;
  130073. CANNON: any;
  130074. AudioContext: AudioContext;
  130075. webkitAudioContext: AudioContext;
  130076. PointerEvent: any;
  130077. Math: Math;
  130078. Uint8Array: Uint8ArrayConstructor;
  130079. Float32Array: Float32ArrayConstructor;
  130080. mozURL: typeof URL;
  130081. msURL: typeof URL;
  130082. VRFrameData: any; // WebVR, from specs 1.1
  130083. DracoDecoderModule: any;
  130084. setImmediate(handler: (...args: any[]) => void): number;
  130085. }
  130086. interface HTMLCanvasElement {
  130087. requestPointerLock(): void;
  130088. msRequestPointerLock?(): void;
  130089. mozRequestPointerLock?(): void;
  130090. webkitRequestPointerLock?(): void;
  130091. /** Track wether a record is in progress */
  130092. isRecording: boolean;
  130093. /** Capture Stream method defined by some browsers */
  130094. captureStream(fps?: number): MediaStream;
  130095. }
  130096. interface CanvasRenderingContext2D {
  130097. msImageSmoothingEnabled: boolean;
  130098. }
  130099. interface MouseEvent {
  130100. mozMovementX: number;
  130101. mozMovementY: number;
  130102. webkitMovementX: number;
  130103. webkitMovementY: number;
  130104. msMovementX: number;
  130105. msMovementY: number;
  130106. }
  130107. interface Navigator {
  130108. mozGetVRDevices: (any: any) => any;
  130109. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130110. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130111. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130112. webkitGetGamepads(): Gamepad[];
  130113. msGetGamepads(): Gamepad[];
  130114. webkitGamepads(): Gamepad[];
  130115. }
  130116. interface HTMLVideoElement {
  130117. mozSrcObject: any;
  130118. }
  130119. interface Math {
  130120. fround(x: number): number;
  130121. imul(a: number, b: number): number;
  130122. }
  130123. interface WebGLRenderingContext {
  130124. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  130125. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  130126. vertexAttribDivisor(index: number, divisor: number): void;
  130127. createVertexArray(): any;
  130128. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  130129. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  130130. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  130131. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  130132. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  130133. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  130134. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  130135. // Queries
  130136. createQuery(): WebGLQuery;
  130137. deleteQuery(query: WebGLQuery): void;
  130138. beginQuery(target: number, query: WebGLQuery): void;
  130139. endQuery(target: number): void;
  130140. getQueryParameter(query: WebGLQuery, pname: number): any;
  130141. getQuery(target: number, pname: number): any;
  130142. MAX_SAMPLES: number;
  130143. RGBA8: number;
  130144. READ_FRAMEBUFFER: number;
  130145. DRAW_FRAMEBUFFER: number;
  130146. UNIFORM_BUFFER: number;
  130147. HALF_FLOAT_OES: number;
  130148. RGBA16F: number;
  130149. RGBA32F: number;
  130150. R32F: number;
  130151. RG32F: number;
  130152. RGB32F: number;
  130153. R16F: number;
  130154. RG16F: number;
  130155. RGB16F: number;
  130156. RED: number;
  130157. RG: number;
  130158. R8: number;
  130159. RG8: number;
  130160. UNSIGNED_INT_24_8: number;
  130161. DEPTH24_STENCIL8: number;
  130162. MIN: number;
  130163. MAX: number;
  130164. /* Multiple Render Targets */
  130165. drawBuffers(buffers: number[]): void;
  130166. readBuffer(src: number): void;
  130167. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  130168. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  130169. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  130170. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  130171. // Occlusion Query
  130172. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  130173. ANY_SAMPLES_PASSED: number;
  130174. QUERY_RESULT_AVAILABLE: number;
  130175. QUERY_RESULT: number;
  130176. }
  130177. interface WebGLProgram {
  130178. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  130179. }
  130180. interface EXT_disjoint_timer_query {
  130181. QUERY_COUNTER_BITS_EXT: number;
  130182. TIME_ELAPSED_EXT: number;
  130183. TIMESTAMP_EXT: number;
  130184. GPU_DISJOINT_EXT: number;
  130185. QUERY_RESULT_EXT: number;
  130186. QUERY_RESULT_AVAILABLE_EXT: number;
  130187. queryCounterEXT(query: WebGLQuery, target: number): void;
  130188. createQueryEXT(): WebGLQuery;
  130189. beginQueryEXT(target: number, query: WebGLQuery): void;
  130190. endQueryEXT(target: number): void;
  130191. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  130192. deleteQueryEXT(query: WebGLQuery): void;
  130193. }
  130194. interface WebGLUniformLocation {
  130195. _currentState: any;
  130196. }
  130197. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  130198. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  130199. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  130200. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  130201. interface WebGLRenderingContext {
  130202. readonly RASTERIZER_DISCARD: number;
  130203. readonly DEPTH_COMPONENT24: number;
  130204. readonly TEXTURE_3D: number;
  130205. readonly TEXTURE_2D_ARRAY: number;
  130206. readonly TEXTURE_COMPARE_FUNC: number;
  130207. readonly TEXTURE_COMPARE_MODE: number;
  130208. readonly COMPARE_REF_TO_TEXTURE: number;
  130209. readonly TEXTURE_WRAP_R: number;
  130210. readonly HALF_FLOAT: number;
  130211. readonly RGB8: number;
  130212. readonly RED_INTEGER: number;
  130213. readonly RG_INTEGER: number;
  130214. readonly RGB_INTEGER: number;
  130215. readonly RGBA_INTEGER: number;
  130216. readonly R8_SNORM: number;
  130217. readonly RG8_SNORM: number;
  130218. readonly RGB8_SNORM: number;
  130219. readonly RGBA8_SNORM: number;
  130220. readonly R8I: number;
  130221. readonly RG8I: number;
  130222. readonly RGB8I: number;
  130223. readonly RGBA8I: number;
  130224. readonly R8UI: number;
  130225. readonly RG8UI: number;
  130226. readonly RGB8UI: number;
  130227. readonly RGBA8UI: number;
  130228. readonly R16I: number;
  130229. readonly RG16I: number;
  130230. readonly RGB16I: number;
  130231. readonly RGBA16I: number;
  130232. readonly R16UI: number;
  130233. readonly RG16UI: number;
  130234. readonly RGB16UI: number;
  130235. readonly RGBA16UI: number;
  130236. readonly R32I: number;
  130237. readonly RG32I: number;
  130238. readonly RGB32I: number;
  130239. readonly RGBA32I: number;
  130240. readonly R32UI: number;
  130241. readonly RG32UI: number;
  130242. readonly RGB32UI: number;
  130243. readonly RGBA32UI: number;
  130244. readonly RGB10_A2UI: number;
  130245. readonly R11F_G11F_B10F: number;
  130246. readonly RGB9_E5: number;
  130247. readonly RGB10_A2: number;
  130248. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  130249. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  130250. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  130251. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  130252. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  130253. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  130254. 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;
  130255. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  130256. readonly TRANSFORM_FEEDBACK: number;
  130257. readonly INTERLEAVED_ATTRIBS: number;
  130258. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  130259. createTransformFeedback(): WebGLTransformFeedback;
  130260. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  130261. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  130262. beginTransformFeedback(primitiveMode: number): void;
  130263. endTransformFeedback(): void;
  130264. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  130265. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130266. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130267. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130268. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  130269. }
  130270. interface ImageBitmap {
  130271. readonly width: number;
  130272. readonly height: number;
  130273. close(): void;
  130274. }
  130275. interface WebGLQuery extends WebGLObject {
  130276. }
  130277. declare var WebGLQuery: {
  130278. prototype: WebGLQuery;
  130279. new(): WebGLQuery;
  130280. };
  130281. interface WebGLSampler extends WebGLObject {
  130282. }
  130283. declare var WebGLSampler: {
  130284. prototype: WebGLSampler;
  130285. new(): WebGLSampler;
  130286. };
  130287. interface WebGLSync extends WebGLObject {
  130288. }
  130289. declare var WebGLSync: {
  130290. prototype: WebGLSync;
  130291. new(): WebGLSync;
  130292. };
  130293. interface WebGLTransformFeedback extends WebGLObject {
  130294. }
  130295. declare var WebGLTransformFeedback: {
  130296. prototype: WebGLTransformFeedback;
  130297. new(): WebGLTransformFeedback;
  130298. };
  130299. interface WebGLVertexArrayObject extends WebGLObject {
  130300. }
  130301. declare var WebGLVertexArrayObject: {
  130302. prototype: WebGLVertexArrayObject;
  130303. new(): WebGLVertexArrayObject;
  130304. };
  130305. // Type definitions for WebVR API
  130306. // Project: https://w3c.github.io/webvr/
  130307. // Definitions by: six a <https://github.com/lostfictions>
  130308. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  130309. interface VRDisplay extends EventTarget {
  130310. /**
  130311. * Dictionary of capabilities describing the VRDisplay.
  130312. */
  130313. readonly capabilities: VRDisplayCapabilities;
  130314. /**
  130315. * z-depth defining the far plane of the eye view frustum
  130316. * enables mapping of values in the render target depth
  130317. * attachment to scene coordinates. Initially set to 10000.0.
  130318. */
  130319. depthFar: number;
  130320. /**
  130321. * z-depth defining the near plane of the eye view frustum
  130322. * enables mapping of values in the render target depth
  130323. * attachment to scene coordinates. Initially set to 0.01.
  130324. */
  130325. depthNear: number;
  130326. /**
  130327. * An identifier for this distinct VRDisplay. Used as an
  130328. * association point in the Gamepad API.
  130329. */
  130330. readonly displayId: number;
  130331. /**
  130332. * A display name, a user-readable name identifying it.
  130333. */
  130334. readonly displayName: string;
  130335. readonly isConnected: boolean;
  130336. readonly isPresenting: boolean;
  130337. /**
  130338. * If this VRDisplay supports room-scale experiences, the optional
  130339. * stage attribute contains details on the room-scale parameters.
  130340. */
  130341. readonly stageParameters: VRStageParameters | null;
  130342. /**
  130343. * Passing the value returned by `requestAnimationFrame` to
  130344. * `cancelAnimationFrame` will unregister the callback.
  130345. * @param handle Define the hanle of the request to cancel
  130346. */
  130347. cancelAnimationFrame(handle: number): void;
  130348. /**
  130349. * Stops presenting to the VRDisplay.
  130350. * @returns a promise to know when it stopped
  130351. */
  130352. exitPresent(): Promise<void>;
  130353. /**
  130354. * Return the current VREyeParameters for the given eye.
  130355. * @param whichEye Define the eye we want the parameter for
  130356. * @returns the eye parameters
  130357. */
  130358. getEyeParameters(whichEye: string): VREyeParameters;
  130359. /**
  130360. * Populates the passed VRFrameData with the information required to render
  130361. * the current frame.
  130362. * @param frameData Define the data structure to populate
  130363. * @returns true if ok otherwise false
  130364. */
  130365. getFrameData(frameData: VRFrameData): boolean;
  130366. /**
  130367. * Get the layers currently being presented.
  130368. * @returns the list of VR layers
  130369. */
  130370. getLayers(): VRLayer[];
  130371. /**
  130372. * Return a VRPose containing the future predicted pose of the VRDisplay
  130373. * when the current frame will be presented. The value returned will not
  130374. * change until JavaScript has returned control to the browser.
  130375. *
  130376. * The VRPose will contain the position, orientation, velocity,
  130377. * and acceleration of each of these properties.
  130378. * @returns the pose object
  130379. */
  130380. getPose(): VRPose;
  130381. /**
  130382. * Return the current instantaneous pose of the VRDisplay, with no
  130383. * prediction applied.
  130384. * @returns the current instantaneous pose
  130385. */
  130386. getImmediatePose(): VRPose;
  130387. /**
  130388. * The callback passed to `requestAnimationFrame` will be called
  130389. * any time a new frame should be rendered. When the VRDisplay is
  130390. * presenting the callback will be called at the native refresh
  130391. * rate of the HMD. When not presenting this function acts
  130392. * identically to how window.requestAnimationFrame acts. Content should
  130393. * make no assumptions of frame rate or vsync behavior as the HMD runs
  130394. * asynchronously from other displays and at differing refresh rates.
  130395. * @param callback Define the eaction to run next frame
  130396. * @returns the request handle it
  130397. */
  130398. requestAnimationFrame(callback: FrameRequestCallback): number;
  130399. /**
  130400. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  130401. * Repeat calls while already presenting will update the VRLayers being displayed.
  130402. * @param layers Define the list of layer to present
  130403. * @returns a promise to know when the request has been fulfilled
  130404. */
  130405. requestPresent(layers: VRLayer[]): Promise<void>;
  130406. /**
  130407. * Reset the pose for this display, treating its current position and
  130408. * orientation as the "origin/zero" values. VRPose.position,
  130409. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  130410. * updated when calling resetPose(). This should be called in only
  130411. * sitting-space experiences.
  130412. */
  130413. resetPose(): void;
  130414. /**
  130415. * The VRLayer provided to the VRDisplay will be captured and presented
  130416. * in the HMD. Calling this function has the same effect on the source
  130417. * canvas as any other operation that uses its source image, and canvases
  130418. * created without preserveDrawingBuffer set to true will be cleared.
  130419. * @param pose Define the pose to submit
  130420. */
  130421. submitFrame(pose?: VRPose): void;
  130422. }
  130423. declare var VRDisplay: {
  130424. prototype: VRDisplay;
  130425. new(): VRDisplay;
  130426. };
  130427. interface VRLayer {
  130428. leftBounds?: number[] | Float32Array | null;
  130429. rightBounds?: number[] | Float32Array | null;
  130430. source?: HTMLCanvasElement | null;
  130431. }
  130432. interface VRDisplayCapabilities {
  130433. readonly canPresent: boolean;
  130434. readonly hasExternalDisplay: boolean;
  130435. readonly hasOrientation: boolean;
  130436. readonly hasPosition: boolean;
  130437. readonly maxLayers: number;
  130438. }
  130439. interface VREyeParameters {
  130440. /** @deprecated */
  130441. readonly fieldOfView: VRFieldOfView;
  130442. readonly offset: Float32Array;
  130443. readonly renderHeight: number;
  130444. readonly renderWidth: number;
  130445. }
  130446. interface VRFieldOfView {
  130447. readonly downDegrees: number;
  130448. readonly leftDegrees: number;
  130449. readonly rightDegrees: number;
  130450. readonly upDegrees: number;
  130451. }
  130452. interface VRFrameData {
  130453. readonly leftProjectionMatrix: Float32Array;
  130454. readonly leftViewMatrix: Float32Array;
  130455. readonly pose: VRPose;
  130456. readonly rightProjectionMatrix: Float32Array;
  130457. readonly rightViewMatrix: Float32Array;
  130458. readonly timestamp: number;
  130459. }
  130460. interface VRPose {
  130461. readonly angularAcceleration: Float32Array | null;
  130462. readonly angularVelocity: Float32Array | null;
  130463. readonly linearAcceleration: Float32Array | null;
  130464. readonly linearVelocity: Float32Array | null;
  130465. readonly orientation: Float32Array | null;
  130466. readonly position: Float32Array | null;
  130467. readonly timestamp: number;
  130468. }
  130469. interface VRStageParameters {
  130470. sittingToStandingTransform?: Float32Array;
  130471. sizeX?: number;
  130472. sizeY?: number;
  130473. }
  130474. interface Navigator {
  130475. getVRDisplays(): Promise<VRDisplay[]>;
  130476. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  130477. }
  130478. interface Window {
  130479. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  130480. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  130481. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  130482. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130483. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130484. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  130485. }
  130486. interface Gamepad {
  130487. readonly displayId: number;
  130488. }
  130489. type XRSessionMode =
  130490. | "inline"
  130491. | "immersive-vr"
  130492. | "immersive-ar";
  130493. type XRReferenceSpaceType =
  130494. | "viewer"
  130495. | "local"
  130496. | "local-floor"
  130497. | "bounded-floor"
  130498. | "unbounded";
  130499. type XREnvironmentBlendMode =
  130500. | "opaque"
  130501. | "additive"
  130502. | "alpha-blend";
  130503. type XRVisibilityState =
  130504. | "visible"
  130505. | "visible-blurred"
  130506. | "hidden";
  130507. type XRHandedness =
  130508. | "none"
  130509. | "left"
  130510. | "right";
  130511. type XRTargetRayMode =
  130512. | "gaze"
  130513. | "tracked-pointer"
  130514. | "screen";
  130515. type XREye =
  130516. | "none"
  130517. | "left"
  130518. | "right";
  130519. interface XRSpace extends EventTarget {
  130520. }
  130521. interface XRRenderState {
  130522. depthNear?: number;
  130523. depthFar?: number;
  130524. inlineVerticalFieldOfView?: number;
  130525. baseLayer?: XRWebGLLayer;
  130526. }
  130527. interface XRInputSource {
  130528. handedness: XRHandedness;
  130529. targetRayMode: XRTargetRayMode;
  130530. targetRaySpace: XRSpace;
  130531. gripSpace: XRSpace | undefined;
  130532. gamepad: Gamepad | undefined;
  130533. profiles: Array<string>;
  130534. }
  130535. interface XRSession {
  130536. addEventListener: Function;
  130537. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  130538. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  130539. requestAnimationFrame: Function;
  130540. end(): Promise<void>;
  130541. renderState: XRRenderState;
  130542. inputSources: Array<XRInputSource>;
  130543. }
  130544. interface XRReferenceSpace extends XRSpace {
  130545. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  130546. onreset: any;
  130547. }
  130548. interface XRFrame {
  130549. session: XRSession;
  130550. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  130551. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  130552. }
  130553. interface XRViewerPose extends XRPose {
  130554. views: Array<XRView>;
  130555. }
  130556. interface XRPose {
  130557. transform: XRRigidTransform;
  130558. emulatedPosition: boolean;
  130559. }
  130560. declare var XRWebGLLayer: {
  130561. prototype: XRWebGLLayer;
  130562. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  130563. };
  130564. interface XRWebGLLayer {
  130565. framebuffer: WebGLFramebuffer;
  130566. framebufferWidth: number;
  130567. framebufferHeight: number;
  130568. getViewport: Function;
  130569. }
  130570. interface XRRigidTransform {
  130571. position: DOMPointReadOnly;
  130572. orientation: DOMPointReadOnly;
  130573. matrix: Float32Array;
  130574. inverse: XRRigidTransform;
  130575. }
  130576. interface XRView {
  130577. eye: XREye;
  130578. projectionMatrix: Float32Array;
  130579. transform: XRRigidTransform;
  130580. }
  130581. interface XRInputSourceChangeEvent {
  130582. session: XRSession;
  130583. removed: Array<XRInputSource>;
  130584. added: Array<XRInputSource>;
  130585. }